Browse Source

[build] Prevent use of MMX and SSE registers

The existence of MMX and SSE is required by the System V x86_64 ABI
and so is assumed by gcc, but these registers are not preserved by our
own interrupt handlers and are unlikely to be preserved by other
context switch handlers in a boot firmware environment.

Explicitly prevent gcc from using MMX or SSE registers to avoid
potential problems due to silent register corruption.

We must remove the %xmm0-%xmm5 clobbers from the x86_64 version of
hv_call() since otherwise gcc will complain about unknown register
names.  Theoretically, we should probably add code to explicitly
preserve the %xmm0-%xmm5 registers across a hypercall, in order to
guarantee to external code that these registers remain unchanged.  In
practice this is difficult since SSE registers are disabled by
default: for background information see commits 71560d1 ("[librm]
Preserve FPU, MMX and SSE state across calls to virt_call()") and
dd9a14d ("[librm] Conditionalize the workaround for the Tivoli VMM's
SSE garbling").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
1df3b53051
2 changed files with 5 additions and 2 deletions
  1. 4
    0
      src/arch/x86_64/Makefile
  2. 1
    2
      src/arch/x86_64/include/bits/hyperv.h

+ 4
- 0
src/arch/x86_64/Makefile View File

@@ -13,6 +13,10 @@ CFLAGS		+= -m64
13 13
 ASFLAGS		+= --64
14 14
 LDFLAGS		+= -m elf_x86_64
15 15
 
16
+# Prevent use of MMX and SSE registers
17
+#
18
+CFLAGS		+= -mno-mmx -mno-sse
19
+
16 20
 # EFI requires -fshort-wchar, and nothing else currently uses wchar_t
17 21
 #
18 22
 CFLAGS		+= -fshort-wchar

+ 1
- 2
src/arch/x86_64/include/bits/hyperv.h View File

@@ -44,8 +44,7 @@ hv_call ( struct hv_hypervisor *hv, unsigned int code, const void *in,
44 44
 			       : "=a" ( result ), "+r" ( rcx ), "+r" ( rdx ),
45 45
 				 "+r" ( r8 )
46 46
 			       : "m" ( hypercall )
47
-			       : "r9", "r10", "r11", "xmm0", "xmm1", "xmm2",
48
-				 "xmm3", "xmm4", "xmm5" );
47
+			       : "r9", "r10", "r11" );
49 48
 	return result;
50 49
 }
51 50
 

Loading…
Cancel
Save