]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commit
x86/EFI: meet further spec requirements for runtime calls
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 12:52:53 +0000 (13:52 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 12:52:53 +0000 (13:52 +0100)
commitf6b7fedc896250028cb81dafe9a3f6773aaf1da2
tree8671346967cd1389a4f0120c51f2160069d65d29
parent27e14d346ed6ff1c3a3cfc479507e62d133e92a9
x86/EFI: meet further spec requirements for runtime calls

So far we didn't guarantee 16-byte alignment of the stack: While (so
far) we don't tell the compiler to use smaller alignment, we also don't
guarantee 16-byte alignment when establishing stack pointers for new
vCPU-s. Runtime service functions using SSE instructions may end with
#GP(0) without that.

Note that making use of -mpreferred-stack-boundary=3, as mentioned in
the comment, wouldn't help to reduce the needed alignment: The compiler
would then be free to align the stack of the function with the aligned
object, but would be permitted to place an odd number of 8-byte objects
there, resulting in the callee to still run on an unaligned stack.

(The only working alternative to the approach chosen here would be to
use -mincoming-stack-boundary=3, but that would affect all functions in
runtime.c, not just the ones actually making runtime services calls.
And it would still require the manual alignment logic here to be used
with gcc 5.2 and earlier - not permitting that command line option -,
just that then the alignment amount would become conditional.)

Hence enforce the needed alignment by making efi_rs_enter() return a
suitably aligned structure, which the caller then necessarily has to
store in a suitably aligned local variable, the address of which then
gets passed to efi_rs_leave(). Also (to limit exposure) move the
function declarations to where they belong: They're local to runtime.c,
and shared only with compat.c (by the latter including the former).

Furthermore we should avoid #MF to be raised on the FLDCW we do.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/common/efi/efi.h
xen/common/efi/runtime.c