diff mbox

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

Message ID 20180604211106.4442-1-programmingkidx@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Programmingkid June 4, 2018, 9:11 p.m. UTC
The assembler in most versions of Mac OS X is pretty old and does not support
the xgetbv instruction. To go around this problem the raw encoding of the
instruction is used instead.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
 tcg/i386/tcg-target.inc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

no-reply@patchew.org June 4, 2018, 9:15 p.m. UTC | #1
Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180604211106.4442-1-programmingkidx@gmail.com
Subject: [Qemu-devel] [PATCH] tcg-target.inc.c: Use byte form of xgetbv instruction

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 t [tag update]            patchew/20180531205046.153256-1-eblake@redhat.com -> patchew/20180531205046.153256-1-eblake@redhat.com
 * [new tag]               patchew/20180604211106.4442-1-programmingkidx@gmail.com -> patchew/20180604211106.4442-1-programmingkidx@gmail.com
Switched to a new branch 'test'
8ee6e3972e tcg-target.inc.c: Use byte form of xgetbv instruction

=== OUTPUT BEGIN ===
Checking PATCH 1/1: tcg-target.inc.c: Use byte form of xgetbv instruction...
ERROR: trailing whitespace
#23: FILE: tcg/i386/tcg-target.inc.c:3505:
+             * The xgetbv instruction is not available to older versions of the $

ERROR: spaces required around that ':' (ctx:VxW)
#26: FILE: tcg/i386/tcg-target.inc.c:3508:
+            asm (".byte 0x0f, 0x01, 0xd0": "=a" (xcrl), "=d" (xcrh) : "c" (0));
                                          ^

total: 2 errors, 0 warnings, 12 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
diff mbox

Patch

diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index 5357909..82e004a 100644
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -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;