Skip to contentSkip to conversation

tcg-target.inc.c: Use byte form of xgetbv instruction

PATCH Applied John Arbuckle 2 participants 2 messages Jun 4, 2018 – Jun 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tcg-target.inc.c: Use byte form of xgetbv instruction

---
v2 changes:
- Fixed a spacing issue in the asm() function.

 tcg/i386/tcg-target.inc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tcg/i386/tcg-target.inc.c +5 -1
index 5357909fff..09141fa8e0 100644
@@ -3501,7 +3501,11 @@ static void tcg_target_init(TCGContext *s)
            sure of not hitting invalid opcode.  */
         if (c & bit_OSXSAVE) {
             unsigned xcrl, xcrh;
-            asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));
+            /*
+             * The xgetbv instruction is not available to older versions of the
+             * assembler, so we encode the instruction manually.
+             */
+            asm(".byte 0x0f, 0x01, 0xd0" : "=a" (xcrl), "=d" (xcrh) : "c" (0));
             if ((xcrl & 6) == 6) {
                 have_avx1 = (c & bit_AVX) != 0;
                 have_avx2 = (b7 & bit_AVX2) != 0;
Signature · 1 line
2.14.3 (Apple Git-98)