Skip to content

Commit c4cdbaf

Browse files
committed
iommu/amd: KVM: SVM: Use pi_desc_addr to derive ga_root_ptr
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>
1 parent 52d826c commit c4cdbaf

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,11 @@ int avic_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
894894

895895
enable_remapped_mode = false;
896896

897-
/* Try to enable guest_mode in IRTE */
898-
pi.base = avic_get_backing_page_address(svm);
897+
/*
898+
* Try to enable guest_mode in IRTE. Note, the address
899+
* of the vCPU's AVIC backing page is passed to the
900+
* IOMMU via vcpu_info->pi_desc_addr.
901+
*/
899902
pi.ga_tag = AVIC_GATAG(to_kvm_svm(kvm)->avic_vm_id,
900903
svm->vcpu.vcpu_id);
901904
pi.is_guest_mode = true;

drivers/iommu/amd/iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3888,7 +3888,7 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
38883888
pi_data->ir_data = ir_data;
38893889

38903890
if (pi_data->is_guest_mode) {
3891-
ir_data->ga_root_ptr = (pi_data->base >> 12);
3891+
ir_data->ga_root_ptr = (vcpu_pi_info->pi_desc_addr >> 12);
38923892
ir_data->ga_vector = vcpu_pi_info->vector;
38933893
ir_data->ga_tag = pi_data->ga_tag;
38943894
ret = amd_iommu_activate_guest_mode(ir_data);

include/linux/amd-iommu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ struct amd_iommu;
1919
*/
2020
struct amd_iommu_pi_data {
2121
u32 ga_tag;
22-
u64 base;
23-
2422
bool is_guest_mode;
2523
struct vcpu_data *vcpu_data;
2624
void *ir_data;

0 commit comments

Comments
 (0)