devvmx: skip tsc offset writing if CPU doesn't support it
This commit is contained in:
parent
c7dcc82b0b
commit
4f310b8f51
1 changed files with 8 additions and 4 deletions
|
@ -267,6 +267,7 @@ struct Vmx {
|
||||||
char errstr[ERRMAX];
|
char errstr[ERRMAX];
|
||||||
Ureg ureg;
|
Ureg ureg;
|
||||||
uvlong tscoffset;
|
uvlong tscoffset;
|
||||||
|
u32int procbctls;
|
||||||
uintptr cr2;
|
uintptr cr2;
|
||||||
uintptr xcr0;
|
uintptr xcr0;
|
||||||
uintptr dr[8]; /* DR7 is also kept in VMCS */
|
uintptr dr[8]; /* DR7 is also kept in VMCS */
|
||||||
|
@ -962,6 +963,7 @@ vmcsinit(Vmx *vmx)
|
||||||
x |= PROCB_USECTLS2;
|
x |= PROCB_USECTLS2;
|
||||||
x &= msr >> 32;
|
x &= msr >> 32;
|
||||||
vmcswrite(PROCB_CTLS, x);
|
vmcswrite(PROCB_CTLS, x);
|
||||||
|
vmx->procbctls = x;
|
||||||
|
|
||||||
if(rdmsr(VMX_PROCB_CTLS2_MSR, &msr) < 0) error("rdmsr(VMX_PROCB_CTLS2_MSR failed");
|
if(rdmsr(VMX_PROCB_CTLS2_MSR, &msr) < 0) error("rdmsr(VMX_PROCB_CTLS2_MSR failed");
|
||||||
x = PROCB_EPT | PROCB_VPID | PROCB_UNRESTR;
|
x = PROCB_EPT | PROCB_VPID | PROCB_UNRESTR;
|
||||||
|
@ -1062,9 +1064,11 @@ vmcsinit(Vmx *vmx)
|
||||||
vmcswrite(VMEXIT_MSRSTADDR, PADDR(vmx->msrguest));
|
vmcswrite(VMEXIT_MSRSTADDR, PADDR(vmx->msrguest));
|
||||||
vmcswrite(VMEXIT_MSRLDADDR, PADDR(vmx->msrhost));
|
vmcswrite(VMEXIT_MSRLDADDR, PADDR(vmx->msrhost));
|
||||||
vmcswrite(MSR_BITMAP, PADDR(vmx->msrbits));
|
vmcswrite(MSR_BITMAP, PADDR(vmx->msrbits));
|
||||||
|
|
||||||
cycles(&vmx->tscoffset);
|
if(vmx->procbctls & PROCB_TSCOFFSET){
|
||||||
vmcswrite(VMCS_TSC_OFFSET, vmx->tscoffset);
|
cycles(&vmx->tscoffset);
|
||||||
|
vmcswrite(VMCS_TSC_OFFSET, vmx->tscoffset);
|
||||||
|
}
|
||||||
|
|
||||||
if(sizeof(uintptr) == 8){
|
if(sizeof(uintptr) == 8){
|
||||||
vmxaddmsr(vmx, Star, 0);
|
vmxaddmsr(vmx, Star, 0);
|
||||||
|
@ -1682,7 +1686,7 @@ vmxproc(void *vmxp)
|
||||||
}
|
}
|
||||||
rc = vmlaunch(&vmx->ureg, vmx->launched);
|
rc = vmlaunch(&vmx->ureg, vmx->launched);
|
||||||
cycles(&end);
|
cycles(&end);
|
||||||
useend = 1;
|
useend = vmx->procbctls & PROCB_TSCOFFSET;
|
||||||
vmx->cr2 = getcr2();
|
vmx->cr2 = getcr2();
|
||||||
if(m->xcr0 != 0 && vmx->xcr0 != m->xcr0)
|
if(m->xcr0 != 0 && vmx->xcr0 != m->xcr0)
|
||||||
putxcr0(m->xcr0);
|
putxcr0(m->xcr0);
|
||||||
|
|
Loading…
Reference in a new issue