Date: Tue, 3 Jul 2012 20:01:24 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 213866 for review Message-ID: <201207032001.q63K1OJP056230@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@213866?ac=10 Change 213866 by jhb@jhb_ralph on 2012/07/03 20:00:43 Let the assembler see xsave/xrstor/xsaveopt/xgetbv/xsetbv instructions if NEW_AS is defined. (I'm have some patches to add those to binutils.) Affected files ... .. //depot/projects/smpng/sys/modules/x86dis/x86dis.c#3 edit Differences ... ==== //depot/projects/smpng/sys/modules/x86dis/x86dis.c#3 (text+ko) ==== @@ -1,5 +1,7 @@ #include <sys/types.h> +//#define NEW_AS + static __inline void xrstor(char *addr, uint64_t mask) { @@ -7,9 +9,13 @@ low = mask; hi = mask >> 32; +#ifdef NEW_AS + __asm __volatile("xrstor %0" : : "m" (addr), "a" (low), "d" (hi)); +#else /* xrstor (%rdi) */ __asm __volatile(".byte 0x0f,0xae,0x2f" : : "a" (low), "d" (hi), "D" (addr)); +#endif } static __inline void @@ -19,9 +25,14 @@ low = mask; hi = mask >> 32; +#ifdef NEW_AS + __asm __volatile("xsave %0" : "=m" (addr) : "a" (low), "d" (hi) : + "memory"); +#else /* xsave (%rdi) */ __asm __volatile(".byte 0x0f,0xae,0x27" : : "a" (low), "d" (hi), "D" (addr) : "memory"); +#endif } static __inline void @@ -31,9 +42,14 @@ low = mask; hi = mask >> 32; +#ifdef NEW_AS + __asm __volatile("xsaveopt %0" : "=m" (addr) : "a" (low), "d" (hi) : + "memory"); +#else /* xsaveopt (%rdi) */ __asm __volatile(".byte 0x0f,0xae,0x37" : : "a" (low), "d" (hi), "D" (addr) : "memory"); +#endif } static __inline uint64_t @@ -41,8 +57,12 @@ { uint32_t low, high; +#ifdef NEW_AS + __asm __volatile("xgetbv" : "=a" (low), "=d" (high) : "c" (reg)); +#else __asm __volatile(".byte 0x0f,0x01,0xd0" : "=a" (low), "=d" (high) : "c" (reg)); +#endif return (low | ((uint64_t)high << 32)); } @@ -53,8 +73,12 @@ low = val; hi = val >> 32; +#ifdef NEW_AS + __asm __volatile("xsetbv" : : "c" (reg), "a" (low), "d" (hi)); +#else __asm __volatile(".byte 0x0f,0x01,0xd1" : : "c" (reg), "a" (low), "d" (hi)); +#endif } static __inline uint64_t
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207032001.q63K1OJP056230>
