Skip to content

Commit 05c4fe8

Browse files
ssuthiku-amdbonzini
authored andcommitted
KVM: SVM: Refresh AVIC configuration when changing APIC mode
AMD AVIC can support xAPIC and x2APIC virtualization, which requires changing x2APIC bit VMCB and MSR intercepton for x2APIC MSRs. Therefore, call avic_refresh_apicv_exec_ctrl() to refresh configuration accordingly. Reviewed-by: Maxim Levitsky <[email protected]> Signed-off-by: Suravee Suthikulpanit <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8fc9c7a commit 05c4fe8

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,18 @@ void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
675675
avic_handle_ldr_update(vcpu);
676676
}
677677

678+
void avic_set_virtual_apic_mode(struct kvm_vcpu *vcpu)
679+
{
680+
if (!lapic_in_kernel(vcpu) || avic_mode == AVIC_MODE_NONE)
681+
return;
682+
683+
if (kvm_get_apic_mode(vcpu) == LAPIC_MODE_INVALID) {
684+
WARN_ONCE(true, "Invalid local APIC state (vcpu_id=%d)", vcpu->vcpu_id);
685+
return;
686+
}
687+
avic_refresh_apicv_exec_ctrl(vcpu);
688+
}
689+
678690
static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
679691
{
680692
int ret = 0;

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,6 +4793,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
47934793
.enable_nmi_window = svm_enable_nmi_window,
47944794
.enable_irq_window = svm_enable_irq_window,
47954795
.update_cr8_intercept = svm_update_cr8_intercept,
4796+
.set_virtual_apic_mode = avic_set_virtual_apic_mode,
47964797
.refresh_apicv_exec_ctrl = avic_refresh_apicv_exec_ctrl,
47974798
.check_apicv_inhibit_reasons = avic_check_apicv_inhibit_reasons,
47984799
.apicv_post_state_restore = avic_apicv_post_state_restore,

arch/x86/kvm/svm/svm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ void avic_vcpu_blocking(struct kvm_vcpu *vcpu);
634634
void avic_vcpu_unblocking(struct kvm_vcpu *vcpu);
635635
void avic_ring_doorbell(struct kvm_vcpu *vcpu);
636636
unsigned long avic_vcpu_get_apicv_inhibit_reasons(struct kvm_vcpu *vcpu);
637+
void avic_set_virtual_apic_mode(struct kvm_vcpu *vcpu);
638+
637639

638640
/* sev.c */
639641

0 commit comments

Comments
 (0)