2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <palacios/vmm_types.h>
24 #define MAKE_1OP_8FLAGS_INST(iname) static inline void iname##8(addr_t * dst, addr_t * flags) { \
25 uchar_t tmp_dst = *dst; \
27 /* Some of the flags values are not copied out in a pushf, we save them here */ \
28 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
38 : "=q"(tmp_dst),"=q"(*flags) \
39 : "q"(*flags), "0"(tmp_dst) \
42 *flags |= flags_rsvd; \
46 #define MAKE_1OP_16FLAGS_INST(iname) static inline void iname##16(addr_t * dst, addr_t * flags) { \
47 ushort_t tmp_dst = *dst; \
49 /* Some of the flags values are not copied out in a pushf, we save them here */ \
50 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
60 : "=q"(tmp_dst),"=q"(*flags) \
61 : "q"(*flags), "0"(tmp_dst) \
64 *flags |= flags_rsvd; \
68 #define MAKE_1OP_32FLAGS_INST(iname) static inline void iname##32(addr_t * dst, addr_t * flags) { \
69 uint_t tmp_dst = *dst; \
71 /* Some of the flags values are not copied out in a pushf, we save them here */ \
72 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
82 : "=q"(tmp_dst),"=q"(*flags) \
83 : "q"(*flags), "0"(tmp_dst) \
86 *flags |= flags_rsvd; \
90 #define MAKE_1OP_64FLAGS_INST(iname) static inline void iname##64(addr_t * dst, addr_t * flags) { \
91 ullong_t tmp_dst = *dst; \
93 /* Some of the flags values are not copied out in a pushf, we save them here */ \
94 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
104 : "=q"(tmp_dst),"=q"(*flags) \
105 : "q"(*flags), "0"(tmp_dst) \
108 *flags |= flags_rsvd; \
114 #define MAKE_1OP_8_INST(iname) static inline void iname##8(addr_t * dst) { \
115 uchar_t tmp_dst = *dst; \
125 #define MAKE_1OP_16_INST(iname) static inline void iname##16(addr_t * dst) { \
126 ushort_t tmp_dst = *dst; \
136 #define MAKE_1OP_32_INST(iname) static inline void iname##32(addr_t * dst) { \
137 uint_t tmp_dst = *dst; \
147 #define MAKE_1OP_64_INST(iname) static inline void iname##64(addr_t * dst) { \
148 ullong_t tmp_dst = *dst; \
159 #define MAKE_2OP_64FLAGS_INST(iname) static inline void iname##64(addr_t * dst, addr_t * src, addr_t * flags) { \
160 uint64_t tmp_dst = *dst, tmp_src = *src; \
161 addr_t tmp_flags = *flags; \
163 /* Some of the flags values are not copied out in a pushf, we save them here */ \
164 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
170 #iname"q %2, %0\r\n" \
174 : "=q"(tmp_dst),"=q"(tmp_flags) \
175 : "q"(tmp_src),"q"(tmp_flags), "0"(tmp_dst) \
179 *flags = tmp_flags; \
180 *flags |= flags_rsvd; \
187 #define MAKE_2OP_32FLAGS_INST(iname) static inline void iname##32(addr_t * dst, addr_t * src, addr_t * flags) { \
188 uint32_t tmp_dst = *dst, tmp_src = *src; \
190 /* Some of the flags values are not copied out in a pushf, we save them here */ \
191 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
201 : "=q"(tmp_dst),"=q"(*flags) \
202 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
205 *flags |= flags_rsvd; \
210 #define MAKE_2OP_16FLAGS_INST(iname) static inline void iname##16(addr_t * dst, addr_t * src, addr_t * flags) { \
211 ushort_t tmp_dst = *dst, tmp_src = *src; \
213 /* Some of the flags values are not copied out in a pushf, we save them here */ \
214 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
224 : "=q"(tmp_dst),"=q"(*flags) \
225 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
228 *flags |= flags_rsvd; \
232 #define MAKE_2OP_8FLAGS_INST(iname) static inline void iname##8(addr_t * dst, addr_t * src, addr_t * flags) { \
233 uchar_t tmp_dst = *dst, tmp_src = *src; \
235 /* Some of the flags values are not copied out in a pushf, we save them here */ \
236 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
246 : "=q"(tmp_dst),"=q"(*flags) \
247 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
250 *flags |= flags_rsvd; \
257 #define MAKE_2OP_32STR_INST(iname) static inline void iname##32(addr_t * dst, \
259 addr_t * ecx, addr_t * flags) { \
260 /* Some of the flags values are not copied out in a pushf, we save them here */ \
261 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
273 : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \
276 /* : "=D"(*dst),"=S"(*src),"=c"(*ecx),"=q"(*flags)*/ \
277 *flags |= flags_rsvd; \
280 #define MAKE_2OP_16STR_INST(iname) static inline void iname##16(addr_t * dst, \
282 addr_t * ecx, addr_t * flags) { \
283 /* Some of the flags values are not copied out in a pushf, we save them here */ \
284 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
296 : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \
298 *flags |= flags_rsvd; \
303 #define MAKE_2OP_8STR_INST(iname) static inline void iname##8(addr_t * dst, \
305 addr_t * ecx, addr_t * flags) { \
306 /* Some of the flags values are not copied out in a pushf, we save them here */ \
307 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
319 : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags) \
321 *flags |= flags_rsvd; \
327 #define MAKE_2OP_32_INST(iname) static inline void iname##32(addr_t * dst, addr_t * src) { \
328 uint32_t tmp_dst = *dst, tmp_src = *src; \
333 : "q"(tmp_src), "0"(tmp_dst) \
338 #define MAKE_2OP_16_INST(iname) static inline void iname##16(addr_t * dst, addr_t * src) { \
339 ushort_t tmp_dst = *dst, tmp_src = *src; \
344 : "q"(tmp_src), "0"(tmp_dst) \
349 #define MAKE_2OP_8_INST(iname) static inline void iname##8(addr_t * dst, addr_t * src) { \
350 uchar_t tmp_dst = *dst, tmp_src = *src; \
355 : "q"(tmp_src), "0"(tmp_dst) \
366 MAKE_2OP_8FLAGS_INST(adc);
367 MAKE_2OP_8FLAGS_INST(add);
368 MAKE_2OP_8FLAGS_INST(and);
369 MAKE_2OP_8FLAGS_INST(or);
370 MAKE_2OP_8FLAGS_INST(xor);
371 MAKE_2OP_8FLAGS_INST(sub);
374 MAKE_1OP_8FLAGS_INST(inc);
375 MAKE_1OP_8FLAGS_INST(dec);
376 MAKE_1OP_8FLAGS_INST(neg);
377 MAKE_1OP_8FLAGS_INST(setb);
378 MAKE_1OP_8FLAGS_INST(setbe);
379 MAKE_1OP_8FLAGS_INST(setl);
380 MAKE_1OP_8FLAGS_INST(setle);
381 MAKE_1OP_8FLAGS_INST(setnb);
382 MAKE_1OP_8FLAGS_INST(setnbe);
383 MAKE_1OP_8FLAGS_INST(setnl);
384 MAKE_1OP_8FLAGS_INST(setnle);
385 MAKE_1OP_8FLAGS_INST(setno);
386 MAKE_1OP_8FLAGS_INST(setnp);
387 MAKE_1OP_8FLAGS_INST(setns);
388 MAKE_1OP_8FLAGS_INST(setnz);
389 MAKE_1OP_8FLAGS_INST(seto);
390 MAKE_1OP_8FLAGS_INST(setp);
391 MAKE_1OP_8FLAGS_INST(sets);
392 MAKE_1OP_8FLAGS_INST(setz);
395 MAKE_1OP_8_INST(not);
397 MAKE_2OP_8_INST(mov);
398 MAKE_2OP_8_INST(xchg);
402 MAKE_2OP_16FLAGS_INST(adc);
403 MAKE_2OP_16FLAGS_INST(add);
404 MAKE_2OP_16FLAGS_INST(and);
405 MAKE_2OP_16FLAGS_INST(or);
406 MAKE_2OP_16FLAGS_INST(xor);
407 MAKE_2OP_16FLAGS_INST(sub);
410 MAKE_1OP_16FLAGS_INST(inc);
411 MAKE_1OP_16FLAGS_INST(dec);
412 MAKE_1OP_16FLAGS_INST(neg);
414 MAKE_1OP_16_INST(not);
416 MAKE_2OP_16_INST(mov);
417 MAKE_2OP_16_INST(xchg);
423 MAKE_2OP_32FLAGS_INST(adc);
424 MAKE_2OP_32FLAGS_INST(add);
425 MAKE_2OP_32FLAGS_INST(and);
426 MAKE_2OP_32FLAGS_INST(or);
427 MAKE_2OP_32FLAGS_INST(xor);
428 MAKE_2OP_32FLAGS_INST(sub);
431 MAKE_1OP_32FLAGS_INST(inc);
432 MAKE_1OP_32FLAGS_INST(dec);
433 MAKE_1OP_32FLAGS_INST(neg);
435 MAKE_1OP_32_INST(not);
437 MAKE_2OP_32_INST(mov);
438 MAKE_2OP_32_INST(xchg);
440 MAKE_2OP_8STR_INST(movs);
441 MAKE_2OP_16STR_INST(movs);
442 MAKE_2OP_32STR_INST(movs);