]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iommu/amd: KVM: SVM: Use pi_desc_addr to derive ga_root_ptr
authorSean Christopherson <seanjc@google.com>
Wed, 11 Jun 2025 22:45:24 +0000 (15:45 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:24 +0000 (09:50 -0700)
Use vcpu_data.pi_desc_addr instead of amd_iommu_pi_data.base to get the
GA root pointer.  KVM is the only source of amd_iommu_pi_data.base, and
KVM's one and only path for writing amd_iommu_pi_data.base computes the
exact same value for vcpu_data.pi_desc_addr and amd_iommu_pi_data.base,
and fills amd_iommu_pi_data.base if and only if vcpu_data.pi_desc_addr is
valid, i.e. amd_iommu_pi_data.base is fully redundant.

Cc: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Tested-by: Sairaj Kodilkar <sarunkod@amd.com>
Link: https://lore.kernel.org/r/20250611224604.313496-23-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/avic.c
drivers/iommu/amd/iommu.c
include/linux/amd-iommu.h

index 375a29022000ec1d8a5351e26886a23c43279db0..d95742faae110d94c7bb332012c65a0508a150ff 100644 (file)
@@ -894,8 +894,11 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
 
                        enable_remapped_mode = false;
 
-                       /* Try to enable guest_mode in IRTE */
-                       pi.base = avic_get_backing_page_address(svm);
+                       /*
+                        * Try to enable guest_mode in IRTE.  Note, the address
+                        * of the vCPU's AVIC backing page is passed to the
+                        * IOMMU via vcpu_info->pi_desc_addr.
+                        */
                        pi.ga_tag = AVIC_GATAG(to_kvm_svm(kvm)->avic_vm_id,
                                                     svm->vcpu.vcpu_id);
                        pi.is_guest_mode = true;
index ed96050d4933b7055bdda051ffd0518257222542..bdfb57af7111c9cb0e37053b369857a5c8b89541 100644 (file)
@@ -3888,7 +3888,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
        pi_data->ir_data = ir_data;
 
        if (pi_data->is_guest_mode) {
-               ir_data->ga_root_ptr = (pi_data->base >> 12);
+               ir_data->ga_root_ptr = (vcpu_pi_info->pi_desc_addr >> 12);
                ir_data->ga_vector = vcpu_pi_info->vector;
                ir_data->ga_tag = pi_data->ga_tag;
                ret = amd_iommu_activate_guest_mode(ir_data);
index 1f9b13d803c5d559705c2a6ad42110721cc68f96..deeefc92a5cf52b9f6f20897ae78c16af0ba72bf 100644 (file)
@@ -19,8 +19,6 @@ struct amd_iommu;
  */
 struct amd_iommu_pi_data {
        u32 ga_tag;
-       u64 base;
-
        bool is_guest_mode;
        struct vcpu_data *vcpu_data;
        void *ir_data;