freebsd-dev/sys/amd64/vmm
Neel Natu ad54f37429 Fix a long standing bug in VMXCTX_GUEST_RESTORE().
There was an assumption by the "callers" of this macro that on "return" the
%rsp will be pointing to the 'vmxctx'. The macro was not doing this and thus
when trying to restore host state on an error from "vmlaunch" or "vmresume"
we were treating the memory locations on the host stack as 'struct vmxctx'.
This led to all sorts of weird bugs like double faults or invalid instruction
faults.

This bug is exposed by the -O2 option used to compile the kernel module. With
the -O2 flag the compiler will optimize the following piece of code:

	int loopstart = 1;
	...
	if (loopstart) {
		loopstart = 0;
		vmx_launch();
	} else
		vmx_resume();

into this:

	vmx_launch();

Since vmx_launch() and vmx_resume() are declared to be __dead2 functions the
compiler is free to do this. The compiler has no way to know that the
functions return indirectly through vmx_setjmp(). This optimization in turn
leads us to trigger the bug in VMXCTX_GUEST_RESTORE().

With this change we can boot a 8.1 guest on a 9.0 host.

Reported by: jhb@
2011-05-20 03:23:09 +00:00
..
amd
intel Fix a long standing bug in VMXCTX_GUEST_RESTORE(). 2011-05-20 03:23:09 +00:00
io
vmm_dev.c
vmm_ipi.c
vmm_ipi.h
vmm_ktr.h
vmm_lapic.c
vmm_lapic.h
vmm_mem.c
vmm_mem.h
vmm_msr.c
vmm_msr.h
vmm_stat.c
vmm_stat.h
vmm_support.S
vmm_util.c
vmm_util.h
vmm.c
x86.c Changes to allow the GENERIC+bhye kernel built from this branch to 2011-05-19 21:53:25 +00:00
x86.h Changes to allow the GENERIC+bhye kernel built from this branch to 2011-05-19 21:53:25 +00:00