mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
kvm: x86: svm: Add support to (de)activate posted interrupts
Introduce interface for (de)activate posted interrupts, and implement SVM hooks to toggle AMD IOMMU guest virtual APIC mode. Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
24bbf74c0c
commit
8937d76239
1 changed files with 36 additions and 1 deletions
|
@ -5155,17 +5155,52 @@ static void svm_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int svm_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
unsigned long flags;
|
||||||
|
struct amd_svm_iommu_ir *ir;
|
||||||
|
struct vcpu_svm *svm = to_svm(vcpu);
|
||||||
|
|
||||||
|
if (!kvm_arch_has_assigned_device(vcpu->kvm))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here, we go through the per-vcpu ir_list to update all existing
|
||||||
|
* interrupt remapping table entry targeting this vcpu.
|
||||||
|
*/
|
||||||
|
spin_lock_irqsave(&svm->ir_list_lock, flags);
|
||||||
|
|
||||||
|
if (list_empty(&svm->ir_list))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
list_for_each_entry(ir, &svm->ir_list, node) {
|
||||||
|
if (activate)
|
||||||
|
ret = amd_iommu_activate_guest_mode(ir->data);
|
||||||
|
else
|
||||||
|
ret = amd_iommu_deactivate_guest_mode(ir->data);
|
||||||
|
if (ret)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
spin_unlock_irqrestore(&svm->ir_list_lock, flags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Note: Currently only used by Hyper-V. */
|
/* Note: Currently only used by Hyper-V. */
|
||||||
static void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
|
static void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
struct vcpu_svm *svm = to_svm(vcpu);
|
struct vcpu_svm *svm = to_svm(vcpu);
|
||||||
struct vmcb *vmcb = svm->vmcb;
|
struct vmcb *vmcb = svm->vmcb;
|
||||||
|
bool activated = kvm_vcpu_apicv_active(vcpu);
|
||||||
|
|
||||||
if (kvm_vcpu_apicv_active(vcpu))
|
if (activated)
|
||||||
vmcb->control.int_ctl |= AVIC_ENABLE_MASK;
|
vmcb->control.int_ctl |= AVIC_ENABLE_MASK;
|
||||||
else
|
else
|
||||||
vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK;
|
vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK;
|
||||||
mark_dirty(vmcb, VMCB_AVIC);
|
mark_dirty(vmcb, VMCB_AVIC);
|
||||||
|
|
||||||
|
svm_set_pi_irte_mode(vcpu, activated);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
|
static void svm_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)
|
||||||
|
|
Loading…
Add table
Reference in a new issue