Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Aug 2021 13:02:25 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 034eea1ee5dd - stable/13 - vmm: Make iommu ops tables const
Message-ID:  <202108161302.17GD2PHn092800@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=034eea1ee5dd25c6a3ff2ce544a990fdd04458fb

commit 034eea1ee5dd25c6a3ff2ce544a990fdd04458fb
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-08-09 17:28:27 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-08-16 13:01:20 +0000

    vmm: Make iommu ops tables const
    
    While here, use designated initializers and rename some AMD iommu method
    implementations to match the corresponding op names.  No functional
    change intended.
    
    Reviewed by:    grehan
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 41335c6b7f636f9ca59d0afba5728cf90020d6b1)
---
 sys/amd64/vmm/amd/amdvi_hw.c | 28 ++++++++++++++--------------
 sys/amd64/vmm/intel/vtd.c    | 24 ++++++++++++------------
 sys/amd64/vmm/io/iommu.c     |  2 +-
 sys/amd64/vmm/io/iommu.h     |  4 ++--
 4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/sys/amd64/vmm/amd/amdvi_hw.c b/sys/amd64/vmm/amd/amdvi_hw.c
index e488c5fd5f6a..57386b6bea88 100644
--- a/sys/amd64/vmm/amd/amdvi_hw.c
+++ b/sys/amd64/vmm/amd/amdvi_hw.c
@@ -1181,7 +1181,7 @@ amdvi_create_mapping(void *arg, vm_paddr_t gpa, vm_paddr_t hpa,
 }
 
 static uint64_t
-amdvi_destroy_mapping(void *arg, vm_paddr_t gpa, uint64_t len)
+amdvi_remove_mapping(void *arg, vm_paddr_t gpa, uint64_t len)
 {
 	struct amdvi_domain *domain;
 
@@ -1360,7 +1360,7 @@ amdvi_disable(void)
 }
 
 static void
-amdvi_inv_tlb(void *arg)
+amdvi_invalidate_tlb(void *arg)
 {
 	struct amdvi_domain *domain;
 
@@ -1369,16 +1369,16 @@ amdvi_inv_tlb(void *arg)
 	amdvi_do_inv_domain(domain->id, false);
 }
 
-struct iommu_ops iommu_ops_amd = {
-	amdvi_init,
-	amdvi_cleanup,
-	amdvi_enable,
-	amdvi_disable,
-	amdvi_create_domain,
-	amdvi_destroy_domain,
-	amdvi_create_mapping,
-	amdvi_destroy_mapping,
-	amdvi_add_device,
-	amdvi_remove_device,
-	amdvi_inv_tlb
+const struct iommu_ops iommu_ops_amd = {
+	.init = amdvi_init,
+	.cleanup = amdvi_cleanup,
+	.enable = amdvi_enable,
+	.disable = amdvi_disable,
+	.create_domain = amdvi_create_domain,
+	.destroy_domain = amdvi_destroy_domain,
+	.create_mapping = amdvi_create_mapping,
+	.remove_mapping = amdvi_remove_mapping,
+	.add_device = amdvi_add_device,
+	.remove_device = amdvi_remove_device,
+	.invalidate_tlb = amdvi_invalidate_tlb
 };
diff --git a/sys/amd64/vmm/intel/vtd.c b/sys/amd64/vmm/intel/vtd.c
index f47e2b56bdce..8f06dc823364 100644
--- a/sys/amd64/vmm/intel/vtd.c
+++ b/sys/amd64/vmm/intel/vtd.c
@@ -761,16 +761,16 @@ vtd_destroy_domain(void *arg)
 	free(dom, M_VTD);
 }
 
-struct iommu_ops iommu_ops_intel = {
-	vtd_init,
-	vtd_cleanup,
-	vtd_enable,
-	vtd_disable,
-	vtd_create_domain,
-	vtd_destroy_domain,
-	vtd_create_mapping,
-	vtd_remove_mapping,
-	vtd_add_device,
-	vtd_remove_device,
-	vtd_invalidate_tlb,
+const struct iommu_ops iommu_ops_intel = {
+	.init = vtd_init,
+	.cleanup = vtd_cleanup,
+	.enable = vtd_enable,
+	.disable = vtd_disable,
+	.create_domain = vtd_create_domain,
+	.destroy_domain = vtd_destroy_domain,
+	.create_mapping = vtd_create_mapping,
+	.remove_mapping = vtd_remove_mapping,
+	.add_device = vtd_add_device,
+	.remove_device = vtd_remove_device,
+	.invalidate_tlb = vtd_invalidate_tlb,
 };
diff --git a/sys/amd64/vmm/io/iommu.c b/sys/amd64/vmm/io/iommu.c
index 3fe4d299a497..6a589f153815 100644
--- a/sys/amd64/vmm/io/iommu.c
+++ b/sys/amd64/vmm/io/iommu.c
@@ -59,7 +59,7 @@ static int iommu_enable = 1;
 SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, enable, CTLFLAG_RDTUN, &iommu_enable, 0,
     "Enable use of I/O MMU (required for PCI passthrough).");
 
-static struct iommu_ops *ops;
+static const struct iommu_ops *ops;
 static void *host_domain;
 static eventhandler_tag add_tag, delete_tag;
 
diff --git a/sys/amd64/vmm/io/iommu.h b/sys/amd64/vmm/io/iommu.h
index f8003a5d4552..090415b57505 100644
--- a/sys/amd64/vmm/io/iommu.h
+++ b/sys/amd64/vmm/io/iommu.h
@@ -60,8 +60,8 @@ struct iommu_ops {
 	iommu_invalidate_tlb_t	invalidate_tlb;
 };
 
-extern struct iommu_ops iommu_ops_intel;
-extern struct iommu_ops iommu_ops_amd;
+extern const struct iommu_ops iommu_ops_intel;
+extern const struct iommu_ops iommu_ops_amd;
 
 void	iommu_cleanup(void);
 void	*iommu_host_domain(void);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108161302.17GD2PHn092800>