Skip to content

Commit 2c13ac7

Browse files
lifeixwenlingz
authored andcommitted
hv: vmcs: minor fix about APICv feature setting
1) Shouldn't try to set APIC-register virtualization if the physical doesn't support APICV advanced mode. 2) Remove all APICv features VMCS setting when LAPIC is passed through to guest. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent 4fc2009 commit 2c13ac7

File tree

1 file changed

+6
-4
lines changed
  • hypervisor/arch/x86/guest

1 file changed

+6
-4
lines changed

hypervisor/arch/x86/guest/vmcs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu)
316316

317317
/*Disable VM_EXIT for CR3 access*/
318318
value32 &= ~(VMX_PROCBASED_CTLS_CR3_LOAD | VMX_PROCBASED_CTLS_CR3_STORE);
319+
value32 &= ~(VMX_PROCBASED_CTLS_CR8_LOAD | VMX_PROCBASED_CTLS_CR8_STORE);
319320

320321
/*
321322
* Disable VM_EXIT for invlpg execution.
@@ -330,9 +331,8 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu)
330331
* guest (optional)
331332
*/
332333
value32 = check_vmx_ctrl(MSR_IA32_VMX_PROCBASED_CTLS2,
333-
VMX_PROCBASED_CTLS2_VAPIC | VMX_PROCBASED_CTLS2_EPT |
334-
VMX_PROCBASED_CTLS2_RDTSCP | VMX_PROCBASED_CTLS2_UNRESTRICT |
335-
VMX_PROCBASED_CTLS2_VAPIC_REGS);
334+
VMX_PROCBASED_CTLS2_VAPIC | VMX_PROCBASED_CTLS2_EPT |
335+
VMX_PROCBASED_CTLS2_RDTSCP | VMX_PROCBASED_CTLS2_UNRESTRICT);
336336

337337
if (vcpu->arch.vpid != 0U) {
338338
value32 |= VMX_PROCBASED_CTLS2_VPID;
@@ -342,6 +342,7 @@ static void init_exec_ctrl(struct acrn_vcpu *vcpu)
342342

343343
if (is_apicv_advanced_feature_supported()) {
344344
value32 |= VMX_PROCBASED_CTLS2_VIRQ;
345+
value32 |= VMX_PROCBASED_CTLS2_VAPIC_REGS;
345346
} else {
346347
/*
347348
* This field exists only on processors that support
@@ -601,9 +602,10 @@ void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu)
601602
exec_vmwrite32(VMX_TPR_THRESHOLD, 0U);
602603

603604
value32 = exec_vmread32(VMX_PROC_VM_EXEC_CONTROLS2);
604-
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC_REGS;
605+
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC;
605606
if (is_apicv_advanced_feature_supported()) {
606607
value32 &= ~VMX_PROCBASED_CTLS2_VIRQ;
608+
value32 &= ~VMX_PROCBASED_CTLS2_VAPIC_REGS;
607609
}
608610
exec_vmwrite32(VMX_PROC_VM_EXEC_CONTROLS2, value32);
609611

0 commit comments

Comments
 (0)