ref: ed040d676ad95858211ec8b5f43e8713692fdeb2
parent: eaffaab79030463fff1587ea595ea104204737ed
author: aiju <devnull@localhost>
date: Sun Jun 18 18:13:20 EDT 2017
devvmx: fix CR0/CR4 readout; also don't exit on PAUSE instruction
--- a/sys/src/9/pc/devvmx.c
+++ b/sys/src/9/pc/devvmx.c
@@ -349,7 +349,7 @@
guest = vmcsread(GUEST_CR0);
mask = vmcsread(GUEST_CR0MASK);
shadow = vmcsread(GUEST_CR0SHADOW);
- return seprint(p, e, "%#.*ullx", sizeof(uintptr) * 2, guest & mask | shadow & ~mask);
+ return seprint(p, e, "%#.*ullx", sizeof(uintptr) * 2, guest & ~mask | shadow & mask);
}
static char *
@@ -360,7 +360,7 @@
guest = vmcsread(GUEST_CR4);
mask = vmcsread(GUEST_CR4MASK);
shadow = vmcsread(GUEST_CR4SHADOW);
- return seprint(p, e, "%#.*ullx", sizeof(uintptr) * 2, guest & mask | shadow & ~mask);
+ return seprint(p, e, "%#.*ullx", sizeof(uintptr) * 2, guest & ~mask | shadow & mask);
}
static int
@@ -757,7 +757,7 @@
if(rdmsr(VMX_PROCB_CTLS_MSR, &msr) < 0) error("rdmsr(VMX_PROCB_CTLS_MSR failed");
x = (u32int)procb_ctls | 1<<1 | 7<<4 | 1<<8 | 1<<13 | 1<<14 | 1<<26; /* currently reserved default1 bits */
x |= PROCB_EXITHLT | PROCB_EXITMWAIT;
- x |= PROCB_EXITMOVDR | PROCB_EXITIO | PROCB_EXITMONITOR | PROCB_EXITPAUSE;
+ x |= PROCB_EXITMOVDR | PROCB_EXITIO | PROCB_EXITMONITOR;
x |= PROCB_USECTLS2;
x &= msr >> 32;
vmcswrite(PROCB_CTLS, x);
@@ -993,15 +993,20 @@
p0 = va_arg(va, char *);
e = va_arg(va, char *);
p = p0;
- for(r = guestregs; r < guestregs + nelem(guestregs); r++){
- if(r->offset >= 0)
- val = vmcsread(r->offset);
- else
- val = *(uintptr*)((uchar*)&vmx + ~r->offset);
- s = r->size;
- if(s == 0) s = sizeof(uintptr);
- p = seprint(p, e, "%s %#.*llux\n", r->name, s * 2, val);
- }
+ for(r = guestregs; r < guestregs + nelem(guestregs); r++)
+ if(r->read != nil){
+ p = seprint(p, e, "%s ", r->name);
+ p = r->read(p, e);
+ p = strecpy(p, e, "\n");
+ }else{
+ if(r->offset >= 0)
+ val = vmcsread(r->offset);
+ else
+ val = *(uintptr*)((uchar*)&vmx + ~r->offset);
+ s = r->size;
+ if(s == 0) s = sizeof(uintptr);
+ p = seprint(p, e, "%s %#.*llux\n", r->name, s * 2, val);
+ }
return p - p0;
}