Commit d2272ec7 authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Joerg Roedel

iommu/amd: Move pt_root to struct amd_io_pgtable

To better organize the data structure since it contains IO page table
related information.
Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20201215073705.123786-4-suravee.suthikulpanit@amd.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent c9b258c6
...@@ -105,7 +105,7 @@ static inline void *iommu_phys_to_virt(unsigned long paddr) ...@@ -105,7 +105,7 @@ static inline void *iommu_phys_to_virt(unsigned long paddr)
static inline static inline
void amd_iommu_domain_set_pt_root(struct protection_domain *domain, u64 root) void amd_iommu_domain_set_pt_root(struct protection_domain *domain, u64 root)
{ {
atomic64_set(&domain->pt_root, root); atomic64_set(&domain->iop.pt_root, root);
} }
static inline static inline
......
...@@ -498,6 +498,7 @@ struct amd_io_pgtable { ...@@ -498,6 +498,7 @@ struct amd_io_pgtable {
struct io_pgtable iop; struct io_pgtable iop;
int mode; int mode;
u64 *root; u64 *root;
atomic64_t pt_root; /* pgtable root and pgtable mode */
}; };
/* /*
...@@ -511,7 +512,6 @@ struct protection_domain { ...@@ -511,7 +512,6 @@ struct protection_domain {
struct amd_io_pgtable iop; struct amd_io_pgtable iop;
spinlock_t lock; /* mostly used to lock the page table*/ spinlock_t lock; /* mostly used to lock the page table*/
u16 id; /* the domain id written to the device table */ u16 id; /* the domain id written to the device table */
atomic64_t pt_root; /* pgtable root and pgtable mode */
int glx; /* Number of levels for GCR3 table */ int glx; /* Number of levels for GCR3 table */
u64 *gcr3_tbl; /* Guest CR3 table */ u64 *gcr3_tbl; /* Guest CR3 table */
unsigned long flags; /* flags to find out type of domain */ unsigned long flags; /* flags to find out type of domain */
......
...@@ -144,7 +144,7 @@ static struct protection_domain *to_pdomain(struct iommu_domain *dom) ...@@ -144,7 +144,7 @@ static struct protection_domain *to_pdomain(struct iommu_domain *dom)
static void amd_iommu_domain_get_pgtable(struct protection_domain *domain, static void amd_iommu_domain_get_pgtable(struct protection_domain *domain,
struct domain_pgtable *pgtable) struct domain_pgtable *pgtable)
{ {
u64 pt_root = atomic64_read(&domain->pt_root); u64 pt_root = atomic64_read(&domain->iop.pt_root);
pgtable->root = (u64 *)(pt_root & PAGE_MASK); pgtable->root = (u64 *)(pt_root & PAGE_MASK);
pgtable->mode = pt_root & 7; /* lowest 3 bits encode pgtable mode */ pgtable->mode = pt_root & 7; /* lowest 3 bits encode pgtable mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment