[Qemu-devel] [PATCH v2] tcg-target.inc.c: Use byte form of xgetbv instruction

John Arbuckle posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180604215102.11002-1-programmingkidx@gmail.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
Test s390x passed
tcg/i386/tcg-target.inc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH v2] tcg-target.inc.c: Use byte form of xgetbv instruction
Posted by John Arbuckle 5 years, 10 months ago
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
v2 changes:
- Fixed a spacing issue in the asm() function.

 tcg/i386/tcg-target.inc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index 5357909fff..09141fa8e0 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;
-- 
2.14.3 (Apple Git-98)


Re: [Qemu-devel] [PATCH v2] tcg-target.inc.c: Use byte form of xgetbv instruction
Posted by Richard Henderson 5 years, 10 months ago
On 06/04/2018 02:51 PM, John Arbuckle wrote:
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
> v2 changes:
> - Fixed a spacing issue in the asm() function.

Applied, thanks.


r~