1 #include <palacios/vmm_types.h>
5 #define MAKE_1OP_8FLAGS_INST(iname) static inline void iname##8(addr_t * dst, addr_t * flags) { \
6 uchar_t tmp_dst = *dst; \
8 /* Some of the flags values are not copied out in a pushf, we save them here */ \
9 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
19 : "=q"(tmp_dst),"=q"(*flags) \
20 : "q"(*flags), "0"(tmp_dst) \
23 *flags |= flags_rsvd; \
27 #define MAKE_1OP_16FLAGS_INST(iname) static inline void iname##16(addr_t * dst, addr_t * flags) { \
28 ushort_t tmp_dst = *dst; \
30 /* Some of the flags values are not copied out in a pushf, we save them here */ \
31 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
41 : "=q"(tmp_dst),"=q"(*flags) \
42 : "q"(*flags), "0"(tmp_dst) \
45 *flags |= flags_rsvd; \
49 #define MAKE_1OP_32FLAGS_INST(iname) static inline void iname##32(addr_t * dst, addr_t * flags) { \
50 uint_t tmp_dst = *dst; \
52 /* Some of the flags values are not copied out in a pushf, we save them here */ \
53 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
63 : "=q"(tmp_dst),"=q"(*flags) \
64 : "q"(*flags), "0"(tmp_dst) \
67 *flags |= flags_rsvd; \
71 #define MAKE_1OP_64FLAGS_INST(iname) static inline void iname##64(addr_t * dst, addr_t * flags) { \
72 ullong_t tmp_dst = *dst; \
74 /* Some of the flags values are not copied out in a pushf, we save them here */ \
75 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
85 : "=q"(tmp_dst),"=q"(*flags) \
86 : "q"(*flags), "0"(tmp_dst) \
89 *flags |= flags_rsvd; \
95 #define MAKE_1OP_8_INST(iname) static inline void iname##8(addr_t * dst) { \
96 uchar_t tmp_dst = *dst; \
106 #define MAKE_1OP_16_INST(iname) static inline void iname##16(addr_t * dst) { \
107 ushort_t tmp_dst = *dst; \
117 #define MAKE_1OP_32_INST(iname) static inline void iname##32(addr_t * dst) { \
118 uint_t tmp_dst = *dst; \
128 #define MAKE_1OP_64_INST(iname) static inline void iname##64(addr_t * dst) { \
129 ullong_t tmp_dst = *dst; \
140 #define MAKE_2OP_64FLAGS_INST(iname) static inline void iname##64(addr_t * dst, addr_t * src, addr_t * flags) { \
141 uint64_t tmp_dst = *dst, tmp_src = *src; \
142 addr_t tmp_flags = *flags; \
144 /* Some of the flags values are not copied out in a pushf, we save them here */ \
145 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
151 #iname"q %2, %0\r\n" \
155 : "=q"(tmp_dst),"=q"(tmp_flags) \
156 : "q"(tmp_src),"q"(tmp_flags), "0"(tmp_dst) \
160 *flags = tmp_flags; \
161 *flags |= flags_rsvd; \
168 #define MAKE_2OP_32FLAGS_INST(iname) static inline void iname##32(addr_t * dst, addr_t * src, addr_t * flags) { \
169 uint32_t tmp_dst = *dst, tmp_src = *src; \
171 /* Some of the flags values are not copied out in a pushf, we save them here */ \
172 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
182 : "=q"(tmp_dst),"=q"(*flags) \
183 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
186 *flags |= flags_rsvd; \
191 #define MAKE_2OP_16FLAGS_INST(iname) static inline void iname##16(addr_t * dst, addr_t * src, addr_t * flags) { \
192 ushort_t tmp_dst = *dst, tmp_src = *src; \
194 /* Some of the flags values are not copied out in a pushf, we save them here */ \
195 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
205 : "=q"(tmp_dst),"=q"(*flags) \
206 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
209 *flags |= flags_rsvd; \
213 #define MAKE_2OP_8FLAGS_INST(iname) static inline void iname##8(addr_t * dst, addr_t * src, addr_t * flags) { \
214 uchar_t tmp_dst = *dst, tmp_src = *src; \
216 /* Some of the flags values are not copied out in a pushf, we save them here */ \
217 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
227 : "=q"(tmp_dst),"=q"(*flags) \
228 : "q"(tmp_src),"q"(*flags), "0"(tmp_dst) \
231 *flags |= flags_rsvd; \
238 #define MAKE_2OP_32STR_INST(iname) static inline void iname##32(addr_t * dst, \
240 addr_t * ecx, addr_t * flags) { \
241 /* Some of the flags values are not copied out in a pushf, we save them here */ \
242 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
254 : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \
257 /* : "=D"(*dst),"=S"(*src),"=c"(*ecx),"=q"(*flags)*/ \
258 *flags |= flags_rsvd; \
261 #define MAKE_2OP_16STR_INST(iname) static inline void iname##16(addr_t * dst, \
263 addr_t * ecx, addr_t * flags) { \
264 /* Some of the flags values are not copied out in a pushf, we save them here */ \
265 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
277 : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \
279 *flags |= flags_rsvd; \
284 #define MAKE_2OP_8STR_INST(iname) static inline void iname##8(addr_t * dst, \
286 addr_t * ecx, addr_t * flags) { \
287 /* Some of the flags values are not copied out in a pushf, we save them here */ \
288 addr_t flags_rsvd = *flags & ~0xfffe7fff; \
300 : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags) \
302 *flags |= flags_rsvd; \
308 #define MAKE_2OP_32_INST(iname) static inline void iname##32(addr_t * dst, addr_t * src) { \
309 uint32_t tmp_dst = *dst, tmp_src = *src; \
314 : "q"(tmp_src), "0"(tmp_dst) \
319 #define MAKE_2OP_16_INST(iname) static inline void iname##16(addr_t * dst, addr_t * src) { \
320 ushort_t tmp_dst = *dst, tmp_src = *src; \
325 : "q"(tmp_src), "0"(tmp_dst) \
330 #define MAKE_2OP_8_INST(iname) static inline void iname##8(addr_t * dst, addr_t * src) { \
331 uchar_t tmp_dst = *dst, tmp_src = *src; \
336 : "q"(tmp_src), "0"(tmp_dst) \
347 MAKE_2OP_8FLAGS_INST(adc);
348 MAKE_2OP_8FLAGS_INST(add);
349 MAKE_2OP_8FLAGS_INST(and);
350 MAKE_2OP_8FLAGS_INST(or);
351 MAKE_2OP_8FLAGS_INST(xor);
352 MAKE_2OP_8FLAGS_INST(sub);
355 MAKE_1OP_8FLAGS_INST(inc);
356 MAKE_1OP_8FLAGS_INST(dec);
357 MAKE_1OP_8FLAGS_INST(neg);
358 MAKE_1OP_8FLAGS_INST(setb);
359 MAKE_1OP_8FLAGS_INST(setbe);
360 MAKE_1OP_8FLAGS_INST(setl);
361 MAKE_1OP_8FLAGS_INST(setle);
362 MAKE_1OP_8FLAGS_INST(setnb);
363 MAKE_1OP_8FLAGS_INST(setnbe);
364 MAKE_1OP_8FLAGS_INST(setnl);
365 MAKE_1OP_8FLAGS_INST(setnle);
366 MAKE_1OP_8FLAGS_INST(setno);
367 MAKE_1OP_8FLAGS_INST(setnp);
368 MAKE_1OP_8FLAGS_INST(setns);
369 MAKE_1OP_8FLAGS_INST(setnz);
370 MAKE_1OP_8FLAGS_INST(seto);
371 MAKE_1OP_8FLAGS_INST(setp);
372 MAKE_1OP_8FLAGS_INST(sets);
373 MAKE_1OP_8FLAGS_INST(setz);
376 MAKE_1OP_8_INST(not);
378 MAKE_2OP_8_INST(mov);
379 MAKE_2OP_8_INST(xchg);
383 MAKE_2OP_16FLAGS_INST(adc);
384 MAKE_2OP_16FLAGS_INST(add);
385 MAKE_2OP_16FLAGS_INST(and);
386 MAKE_2OP_16FLAGS_INST(or);
387 MAKE_2OP_16FLAGS_INST(xor);
388 MAKE_2OP_16FLAGS_INST(sub);
391 MAKE_1OP_16FLAGS_INST(inc);
392 MAKE_1OP_16FLAGS_INST(dec);
393 MAKE_1OP_16FLAGS_INST(neg);
395 MAKE_1OP_16_INST(not);
397 MAKE_2OP_16_INST(mov);
398 MAKE_2OP_16_INST(xchg);
404 MAKE_2OP_32FLAGS_INST(adc);
405 MAKE_2OP_32FLAGS_INST(add);
406 MAKE_2OP_32FLAGS_INST(and);
407 MAKE_2OP_32FLAGS_INST(or);
408 MAKE_2OP_32FLAGS_INST(xor);
409 MAKE_2OP_32FLAGS_INST(sub);
412 MAKE_1OP_32FLAGS_INST(inc);
413 MAKE_1OP_32FLAGS_INST(dec);
414 MAKE_1OP_32FLAGS_INST(neg);
416 MAKE_1OP_32_INST(not);
418 MAKE_2OP_32_INST(mov);
419 MAKE_2OP_32_INST(xchg);
421 MAKE_2OP_8STR_INST(movs);
422 MAKE_2OP_16STR_INST(movs);
423 MAKE_2OP_32STR_INST(movs);