]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Prevent use of MMX and SSE registers
authorMichael Brown <mcb30@ipxe.org>
Tue, 20 Mar 2018 19:34:46 +0000 (21:34 +0200)
committerMichael Brown <mcb30@ipxe.org>
Tue, 20 Mar 2018 20:01:08 +0000 (22:01 +0200)
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>
src/arch/x86_64/Makefile
src/arch/x86_64/include/bits/hyperv.h

index 246905cdb6fd9638aee022f349fbdcd96f87d0d1..b3064b7526fd7ca5b16606b7eda086e184bcd4fe 100644 (file)
@@ -13,6 +13,10 @@ CFLAGS               += -m64
 ASFLAGS                += --64
 LDFLAGS                += -m elf_x86_64
 
+# Prevent use of MMX and SSE registers
+#
+CFLAGS         += -mno-mmx -mno-sse
+
 # EFI requires -fshort-wchar, and nothing else currently uses wchar_t
 #
 CFLAGS         += -fshort-wchar
index 975b1eee0f7e81583846d7b1c9c9aa086ad8e7da..fa8bb3f93f5327811221bba8230c13025992d827 100644 (file)
@@ -44,8 +44,7 @@ hv_call ( struct hv_hypervisor *hv, unsigned int code, const void *in,
                               : "=a" ( result ), "+r" ( rcx ), "+r" ( rdx ),
                                 "+r" ( r8 )
                               : "m" ( hypercall )
-                              : "r9", "r10", "r11", "xmm0", "xmm1", "xmm2",
-                                "xmm3", "xmm4", "xmm5" );
+                              : "r9", "r10", "r11" );
        return result;
 }