Skip to content

Commit 04f261a

Browse files
LuBaolujgunthorpe
authored andcommitted
iommu/vt-d: Extend dmar_domain to support nested domain
The nested domain fields are exclusive to those that used for a DMA remapping domain. Use union to avoid memory waste. Link: https://lore.kernel.org/r/20231026044216.64964-3-yi.l.liu@intel.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 82b6661 commit 04f261a

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

drivers/iommu/intel/iommu.h

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <asm/cacheflush.h>
2727
#include <asm/iommu.h>
28+
#include <uapi/linux/iommufd.h>
2829

2930
/*
3031
* VT-d hardware uses 4KiB page size regardless of host page size.
@@ -605,15 +606,38 @@ struct dmar_domain {
605606
struct list_head devices; /* all devices' list */
606607
struct list_head dev_pasids; /* all attached pasids */
607608

608-
struct dma_pte *pgd; /* virtual address */
609-
int gaw; /* max guest address width */
610-
611-
/* adjusted guest address width, 0 is level 2 30-bit */
612-
int agaw;
613609
int iommu_superpage;/* Level of superpages supported:
614610
0 == 4KiB (no superpages), 1 == 2MiB,
615611
2 == 1GiB, 3 == 512GiB, 4 == 1TiB */
616-
u64 max_addr; /* maximum mapped address */
612+
union {
613+
/* DMA remapping domain */
614+
struct {
615+
/* virtual address */
616+
struct dma_pte *pgd;
617+
/* max guest address width */
618+
int gaw;
619+
/*
620+
* adjusted guest address width:
621+
* 0: level 2 30-bit
622+
* 1: level 3 39-bit
623+
* 2: level 4 48-bit
624+
* 3: level 5 57-bit
625+
*/
626+
int agaw;
627+
/* maximum mapped address */
628+
u64 max_addr;
629+
};
630+
631+
/* Nested user domain */
632+
struct {
633+
/* parent page table which the user domain is nested on */
634+
struct dmar_domain *s2_domain;
635+
/* user page table pointer (in GPA) */
636+
unsigned long s1_pgtbl;
637+
/* page table attributes */
638+
struct iommu_hwpt_vtd_s1 s1_cfg;
639+
};
640+
};
617641

618642
struct iommu_domain domain; /* generic domain data structure for
619643
iommu core */

0 commit comments

Comments
 (0)