Skip to content

Commit be8ca17

Browse files
ssuthiku-amdbonzini
authored andcommitted
KVM: x86: Introducing kvm_x86_ops.apicv_post_state_restore
Adding kvm_x86_ops hooks to allow APICv to do post state restore. This is required to support VM save and restore feature. Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 18f40c5 commit be8ca17

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ struct kvm_x86_ops {
10041004

10051005
int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq,
10061006
uint32_t guest_irq, bool set);
1007+
void (*apicv_post_state_restore)(struct kvm_vcpu *vcpu);
10071008
};
10081009

10091010
struct kvm_arch_async_pf {

arch/x86/kvm/lapic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,8 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu,
19611961
1 : count_vectors(apic->regs + APIC_ISR);
19621962
apic->highest_isr_cache = -1;
19631963
if (vcpu->arch.apicv_active) {
1964+
if (kvm_x86_ops->apicv_post_state_restore)
1965+
kvm_x86_ops->apicv_post_state_restore(vcpu);
19641966
kvm_x86_ops->hwapic_irr_update(vcpu,
19651967
apic_find_highest_irr(apic));
19661968
kvm_x86_ops->hwapic_isr_update(vcpu->kvm,

arch/x86/kvm/svm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4834,6 +4834,15 @@ static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
48344834
{
48354835
}
48364836

4837+
static inline void avic_post_state_restore(struct kvm_vcpu *vcpu)
4838+
{
4839+
if (avic_handle_apic_id_update(vcpu) != 0)
4840+
return;
4841+
if (avic_handle_dfr_update(vcpu) != 0)
4842+
return;
4843+
avic_handle_ldr_update(vcpu);
4844+
}
4845+
48374846
static struct kvm_x86_ops svm_x86_ops = {
48384847
.cpu_has_kvm_support = has_svm,
48394848
.disabled_by_bios = is_disabled,
@@ -4914,6 +4923,7 @@ static struct kvm_x86_ops svm_x86_ops = {
49144923
.sync_pir_to_irr = svm_sync_pir_to_irr,
49154924
.hwapic_irr_update = svm_hwapic_irr_update,
49164925
.hwapic_isr_update = svm_hwapic_isr_update,
4926+
.apicv_post_state_restore = avic_post_state_restore,
49174927

49184928
.set_tss_addr = svm_set_tss_addr,
49194929
.get_tdp_level = get_npt_level,

0 commit comments

Comments
 (0)