Browse Source

[librm] Conditionalize the workaround for the Tivoli VMM's SSE garbling

Commit 71560d1 ("[librm] Preserve FPU, MMX and SSE state across calls
to virt_call()") added FXSAVE and FXRSTOR instructions to iPXE.  In
KVM virtual machines, these instructions execute fine as long as the
host CPU supports the "unrestricted_guest" feature (that is, it can
virtualize big real mode natively).  On older host CPUs however, KVM
has to emulate big real mode, and it currently doesn't implement
FXSAVE emulation.

Upstream QEMU rebuilt iPXE at commit 0418631 ("[thunderx] Fix
compilation with older versions of gcc") which is a descendant of
commit 71560d1 (see above).

This was done in QEMU commit ffdc5a2 ("ipxe: update submodule from
4e03af8ec to 041863191").  The resultant binaries were bundled with
the QEMU v2.7.0 release; see QEMU commit c52125a ("ipxe: update
prebuilt binaries").

This distributed the iPXE workaround for the Tivoli VMM bug to a
number of KVM users with old host CPUs, causing KVM emulation failures
(guest crashes) for them while netbooting.

Make the FXSAVE and FXRSTOR instructions conditional on a new feature
test macro called TIVOLI_VMM_WORKAROUND.  Define the macro by default.

There is prior art for an assembly file including config/general.h:
see arch/x86/prefix/romprefix.S.  Also, TIVOLI_VMM_WORKAROUND seems to
be a good fit for the "Obscure configuration options" section in
config/general.h.

Cc: Bandan Das <bsd@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Greg <rollenwiese@yahoo.com>
Cc: Michael Brown <mcb30@ipxe.org>
Cc: Michael Prokop <launchpad@michael-prokop.at>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Pickford <arch@netremedies.ca>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Ref: https://bugs.archlinux.org/task/50778
Ref: https://bugs.launchpad.net/qemu/+bug/1623276
Ref: https://bugzilla.proxmox.com/show_bug.cgi?id=1182
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1356762
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Laszlo Ersek 8 years ago
parent
commit
dd9a14de35
2 changed files with 14 additions and 3 deletions
  1. 11
    3
      src/arch/x86/transitions/librm.S
  2. 3
    0
      src/config/general.h

+ 11
- 3
src/arch/x86/transitions/librm.S View File

7
 
7
 
8
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
8
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
9
 
9
 
10
+/* Drag in general configuration */
11
+#include <config/general.h>
12
+
10
 /* Drag in local definitions */
13
 /* Drag in local definitions */
11
 #include "librm.h"
14
 #include "librm.h"
12
 
15
 
207
 VC_TMP_CR4:		.space	4
210
 VC_TMP_CR4:		.space	4
208
 VC_TMP_EMER:		.space	8
211
 VC_TMP_EMER:		.space	8
209
 .endif
212
 .endif
213
+#ifdef TIVOLI_VMM_WORKAROUND
210
 VC_TMP_FXSAVE:		.space	512
214
 VC_TMP_FXSAVE:		.space	512
215
+#endif
211
 VC_TMP_END:
216
 VC_TMP_END:
212
 	.previous
217
 	.previous
213
 
218
 
1000
 
1005
 
1001
 	/* Claim ownership of temporary static buffer */
1006
 	/* Claim ownership of temporary static buffer */
1002
 	cli
1007
 	cli
1008
+	movw	%cs:rm_ds, %ds
1003
 
1009
 
1010
+#ifdef TIVOLI_VMM_WORKAROUND
1004
 	/* Preserve FPU, MMX and SSE state in temporary static buffer */
1011
 	/* Preserve FPU, MMX and SSE state in temporary static buffer */
1005
-	movw	%cs:rm_ds, %ds
1006
 	fxsave	( rm_tmpbuf + VC_TMP_FXSAVE )
1012
 	fxsave	( rm_tmpbuf + VC_TMP_FXSAVE )
1007
-
1013
+#endif
1008
 	/* Preserve GDT and IDT in temporary static buffer */
1014
 	/* Preserve GDT and IDT in temporary static buffer */
1009
 	sidt	( rm_tmpbuf + VC_TMP_IDT )
1015
 	sidt	( rm_tmpbuf + VC_TMP_IDT )
1010
 	sgdt	( rm_tmpbuf + VC_TMP_GDT )
1016
 	sgdt	( rm_tmpbuf + VC_TMP_GDT )
1070
 	movl	$MSR_EFER, %ecx
1076
 	movl	$MSR_EFER, %ecx
1071
 	wrmsr
1077
 	wrmsr
1072
 .endif
1078
 .endif
1079
+
1080
+#ifdef TIVOLI_VMM_WORKAROUND
1073
 	/* Restore FPU, MMX and SSE state from temporary static buffer */
1081
 	/* Restore FPU, MMX and SSE state from temporary static buffer */
1074
 	fxrstor	( rm_tmpbuf + VC_TMP_FXSAVE )
1082
 	fxrstor	( rm_tmpbuf + VC_TMP_FXSAVE )
1075
-
1083
+#endif
1076
 	/* Restore registers and flags and return */
1084
 	/* Restore registers and flags and return */
1077
 	popl	%eax /* skip %cs and %ss */
1085
 	popl	%eax /* skip %cs and %ss */
1078
 	popw	%ds
1086
 	popw	%ds

+ 3
- 0
src/config/general.h View File

190
 #undef	GDBUDP			/* Remote GDB debugging over UDP
190
 #undef	GDBUDP			/* Remote GDB debugging over UDP
191
 				 * (both may be set) */
191
 				 * (both may be set) */
192
 //#define EFI_DOWNGRADE_UX	/* Downgrade UEFI user experience */
192
 //#define EFI_DOWNGRADE_UX	/* Downgrade UEFI user experience */
193
+#define	TIVOLI_VMM_WORKAROUND	/* Work around the Tivoli VMM's garbling of SSE
194
+				 * registers when iPXE traps to it due to
195
+				 * privileged instructions */
193
 
196
 
194
 #include <config/named.h>
197
 #include <config/named.h>
195
 #include NAMED_CONFIG(general.h)
198
 #include NAMED_CONFIG(general.h)

Loading…
Cancel
Save