[kvm-unit-tests PATCH v2] x86: prevent GCC from using sse* instructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



GCC 8 emitted MOVDQU when compiling vmx.elf, but we do not enable
CR4.OSFXSR in that test, so the instruction throws #UD.
This patch forbids sse instructions, instead of enabling CR4.OSFXSR, as
I think it's better to keep the environment minimal.

Paolo suggested a way to keep sse around the function that uses it,
allowing us to disable all sse instructions.

Signed-off-by: Radim Krčmář <rkrcmar@xxxxxxxxxx>
---
v2: add -mno-sse [Paolo]
---
 x86/Makefile.x86_64 | 2 +-
 x86/emulator.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64
index 623fc5b37726..af2f1dd8ce55 100644
--- a/x86/Makefile.x86_64
+++ b/x86/Makefile.x86_64
@@ -1,7 +1,7 @@
 cstart.o = $(TEST_DIR)/cstart64.o
 bits = 64
 ldarch = elf64-x86-64
-COMMON_CFLAGS += -mno-red-zone
+COMMON_CFLAGS += -mno-red-zone -mno-sse -mno-sse2
 
 cflatobjs += lib/x86/setjmp64.o
 cflatobjs += lib/x86/intel-iommu.o
diff --git a/x86/emulator.c b/x86/emulator.c
index e6f27cccd031..c74237fb1b23 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -652,7 +652,7 @@ static bool sseeq(sse_union *v1, sse_union *v2)
     return ok;
 }
 
-static void test_sse(sse_union *mem)
+static __attribute__((target("sse"))) void test_sse(sse_union *mem)
 {
     sse_union v;
 
-- 
2.16.2




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux