Messages in this thread Patch in this message | | | From | Suravee Suthikulpanit <> | Subject | [PATCH 2/4] iommu/amd: Introduce structure amd_iommu_svm_ops.is_snp_guest() | Date | Tue, 10 Jan 2023 08:31:35 -0600 |
| |
The structure can be used to provide call-back functions, which are called by the AMD IOMMU driver when it needs to handle certain operations.
SVM driver can define handler for each operation in the struct amd_iommu_svm_ops and register the structure using the amd_iommu_register_svm_ops() function.
Initially, it contains a function pointer is_snp_guest(), which is used to check whether SNP is active for a KVM guest.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com> --- drivers/iommu/amd/iommu.c | 10 ++++++++++ include/linux/amd-iommu.h | 6 ++++++ 2 files changed, 16 insertions(+)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 681ab1fdb7d5..a03723930f70 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -754,6 +754,16 @@ static void iommu_poll_ppr_log(struct amd_iommu *iommu) } } +static const struct amd_iommu_svm_ops *amd_iommu_svm_ops; + +int amd_iommu_register_svm_ops(const struct amd_iommu_svm_ops *ops) +{ + amd_iommu_svm_ops = ops; + + return 0; +} +EXPORT_SYMBOL(amd_iommu_register_svm_ops); + #ifdef CONFIG_IRQ_REMAP static int (*iommu_ga_log_notifier)(u32); diff --git a/include/linux/amd-iommu.h b/include/linux/amd-iommu.h index 953e6f12fa1c..d4837af75550 100644 --- a/include/linux/amd-iommu.h +++ b/include/linux/amd-iommu.h @@ -11,6 +11,7 @@ #include <linux/types.h> struct amd_iommu; +struct kvm; /* * This is mainly used to communicate information back-and-forth @@ -26,6 +27,10 @@ struct amd_iommu_pi_data { void *ir_data; }; +struct amd_iommu_svm_ops { + bool (*is_snp_guest)(struct kvm *kvm); +}; + #ifdef CONFIG_AMD_IOMMU struct task_struct; @@ -205,6 +210,7 @@ int amd_iommu_pc_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, int amd_iommu_pc_get_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, u64 *value); struct amd_iommu *get_amd_iommu(unsigned int idx); +int amd_iommu_register_svm_ops(const struct amd_iommu_svm_ops *ops); #ifdef CONFIG_AMD_MEM_ENCRYPT int amd_iommu_snp_enable(void); -- 2.32.0
| |