From: guenther Date: Thu, 29 Feb 2024 16:10:52 +0000 (+0000) Subject: Intel vmm restores just the base of the GDTR and IDTR ith fixed, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d28c6fef18b4e9c1f2db9a660b4ada06707996c1;p=openbsd Intel vmm restores just the base of the GDTR and IDTR ith fixed, high limits, beyond what we actually expect. We already restored the IDTR from scratch, but the restore of the GDTR (limit) was removed in r1.10. Put that back in a simpler way, simplify the IDTR restore and delete the save/restore of the LDTR because that one really is handled as we want by vmm. ok dv@ mlarkin@ --- diff --git a/sys/arch/amd64/amd64/vmm_machdep.c b/sys/arch/amd64/amd64/vmm_machdep.c index 943797dde8b..e3abe2f72da 100644 --- a/sys/arch/amd64/amd64/vmm_machdep.c +++ b/sys/arch/amd64/amd64/vmm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm_machdep.c,v 1.19 2024/02/25 22:33:09 guenther Exp $ */ +/* $OpenBSD: vmm_machdep.c,v 1.20 2024/02/29 16:10:52 guenther Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -3958,9 +3958,8 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp) struct schedstate_percpu *spc; struct vmx_invvpid_descriptor vid; uint64_t eii, procbased, int_st; - uint16_t irq, ldt_sel; + uint16_t irq; u_long s; - struct region_descriptor idtr; rw_assert_wrlock(&vcpu->vc_lock); @@ -4180,9 +4179,6 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp) break; } - sidt(&idtr); - sldt(&ldt_sel); - TRACEPOINT(vmm, guest_enter, vcpu, vrp); /* @@ -4210,8 +4206,14 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp) wrpkru(0, PGK_VALUE); } - lidt(&idtr); - lldt(ldt_sel); + /* + * VM exit restores the GDT and IDT bases, but gives + * them high limits. Reload with the correct limits here. + * 'gdt' is set above first time through and reset there + * whenever this thread switches CPU. + */ + bare_lgdt(&gdt); + cpu_init_idt(); /* * On exit, interrupts are disabled, and we are running with