VMM: Fix MSR emulation (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 28 Apr 2016 19:39:21 +0000 (15:39 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 2 May 2016 21:11:15 +0000 (17:11 -0400)
commitb2e48a950ca2223a1d072775eb479d26f8458b36
tree13ee22b075bc445f675d2dffee6c116c6ac3c764
parentc47d812e856902f0ba88e270ff993067959c76e9
VMM: Fix MSR emulation (XCC)

emsr_ok() was busted.

First, it was swapping rax and rdx.  The functions take rdx first, but
rdmsr takes rax first.  This was the proximate cause of a bug where if you
ran a guest pcore that did Linux initialization on the same pcore that had
a previous VM do the same, then the kernel would GPF on wrmsr 0x1c9 <-
0x300000003.  Good times.

The rdmsr() macro also wasn't zeroing the upper part of rax.  So we'd have
old stuff floating around.  That would be okay if you only ever use it with
u32s, but since it's a macro, we didn't know that from its signature.
Great.

Finally, we were passing the upper 32 of rax through to write_msr or-ed
with rdx.  That's not supposed to happen either.

Reinstall your kernel header if you care.  Though that crappy macro
shouldn't be in a kernel header...

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/ros/vmx.h
kern/arch/x86/vmm/vmm.c