lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230110143137.54517-3-suravee.suthikulpanit@amd.com>
Date:   Tue, 10 Jan 2023 08:31:35 -0600
From:   Suravee Suthikulpanit <suravee.suthikulpanit@....com>
To:     <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>
CC:     <joro@...tes.org>, <robin.murphy@....com>, <ashish.kalra@....com>,
        <thomas.lendacky@....com>, <vasant.hegde@....com>,
        <jon.grimm@....com>,
        Suravee Suthikulpanit <suravee.suthikulpanit@....com>
Subject: [PATCH 2/4] iommu/amd: Introduce structure amd_iommu_svm_ops.is_snp_guest()

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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ