Skip to content

Commit 1ed2d21

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/amd: Remove the amd_iommu_domain_set_pt_root() and related
Looks like many refactorings here have left this confused. There is only one storage of the root/mode, it is in the iop struct. increase_address_space() calls amd_iommu_domain_set_pgtable() with values that it already stored in iop a few lines above. amd_iommu_domain_clr_pt_root() is zero'ing memory we are about to free. It used to protect against a double free of root, but that is gone now. Remove amd_iommu_domain_set_pgtable(), amd_iommu_domain_set_pt_root(), amd_iommu_domain_clr_pt_root() as they are all pointless. Reviewed-by: Vasant Hegde <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 322d889 commit 1ed2d21

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

drivers/iommu/amd/amd_iommu.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,6 @@ static inline void *iommu_phys_to_virt(unsigned long paddr)
134134
return phys_to_virt(__sme_clr(paddr));
135135
}
136136

137-
static inline
138-
void amd_iommu_domain_set_pt_root(struct protection_domain *domain, u64 root)
139-
{
140-
domain->iop.root = (u64 *)(root & PAGE_MASK);
141-
domain->iop.mode = root & 7; /* lowest 3 bits encode pgtable mode */
142-
}
143-
144-
static inline
145-
void amd_iommu_domain_clr_pt_root(struct protection_domain *domain)
146-
{
147-
amd_iommu_domain_set_pt_root(domain, 0);
148-
}
149-
150137
static inline int get_pci_sbdf_id(struct pci_dev *pdev)
151138
{
152139
int seg = pci_domain_nr(pdev->bus);

drivers/iommu/amd/io_pgtable.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,6 @@ static void free_sub_pt(u64 *root, int mode, struct list_head *freelist)
132132
}
133133
}
134134

135-
void amd_iommu_domain_set_pgtable(struct protection_domain *domain,
136-
u64 *root, int mode)
137-
{
138-
u64 pt_root;
139-
140-
/* lowest 3 bits encode pgtable mode */
141-
pt_root = mode & 7;
142-
pt_root |= (u64)root;
143-
144-
amd_iommu_domain_set_pt_root(domain, pt_root);
145-
}
146-
147135
/*
148136
* This function is used to add another level to an IO page table. Adding
149137
* another level increases the size of the address space by 9 bits to a size up
@@ -176,12 +164,6 @@ static bool increase_address_space(struct protection_domain *domain,
176164
domain->iop.mode += 1;
177165
amd_iommu_update_and_flush_device_table(domain);
178166

179-
/*
180-
* Device Table needs to be updated and flushed before the new root can
181-
* be published.
182-
*/
183-
amd_iommu_domain_set_pgtable(domain, pte, domain->iop.mode);
184-
185167
pte = NULL;
186168
ret = true;
187169

@@ -560,23 +542,17 @@ static int iommu_v1_read_and_clear_dirty(struct io_pgtable_ops *ops,
560542
static void v1_free_pgtable(struct io_pgtable *iop)
561543
{
562544
struct amd_io_pgtable *pgtable = container_of(iop, struct amd_io_pgtable, iop);
563-
struct protection_domain *dom;
564545
LIST_HEAD(freelist);
565546

566547
if (pgtable->mode == PAGE_MODE_NONE)
567548
return;
568549

569-
dom = container_of(pgtable, struct protection_domain, iop);
570-
571550
/* Page-table is not visible to IOMMU anymore, so free it */
572551
BUG_ON(pgtable->mode < PAGE_MODE_NONE ||
573552
pgtable->mode > PAGE_MODE_6_LEVEL);
574553

575554
free_sub_pt(pgtable->root, pgtable->mode, &freelist);
576555
iommu_put_pages_list(&freelist);
577-
578-
/* Update data structure */
579-
amd_iommu_domain_clr_pt_root(dom);
580556
}
581557

582558
static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)

0 commit comments

Comments
 (0)