Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iommu/amd: Add support for nest parent domain allocation

To support nested translation, the nest parent domain is allocated with
IOMMU_HWPT_ALLOC_NEST_PARENT flag, and stores information of the v1 page
table for stage 2 (i.e. GPA->SPA).

Also, only support nest parent domain on AMD system, which can support
the Guest CR3 Table (GCR3TRPMode) feature. This feature is required in
order to program DTE[GCR3 Table Root Pointer] with the GPA.

Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Suravee Suthikulpanit and committed by
Joerg Roedel
b43a29de b2bb0573

+23 -3
+23 -3
drivers/iommu/amd/iommu.c
··· 2769 2769 return &domain->domain; 2770 2770 } 2771 2771 2772 + static inline bool is_nest_parent_supported(u32 flags) 2773 + { 2774 + /* Only allow nest parent when these features are supported */ 2775 + return check_feature(FEATURE_GT) && 2776 + check_feature(FEATURE_GIOSUP) && 2777 + check_feature2(FEATURE_GCR3TRPMODE); 2778 + } 2779 + 2772 2780 static struct iommu_domain * 2773 2781 amd_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags, 2774 2782 const struct iommu_user_data *user_data) ··· 2784 2776 { 2785 2777 struct amd_iommu *iommu = get_amd_iommu_from_dev(dev); 2786 2778 const u32 supported_flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING | 2787 - IOMMU_HWPT_ALLOC_PASID; 2779 + IOMMU_HWPT_ALLOC_PASID | 2780 + IOMMU_HWPT_ALLOC_NEST_PARENT; 2788 2781 2789 2782 if ((flags & ~supported_flags) || user_data) 2790 2783 return ERR_PTR(-EOPNOTSUPP); 2791 2784 2792 2785 switch (flags & supported_flags) { 2793 2786 case IOMMU_HWPT_ALLOC_DIRTY_TRACKING: 2794 - /* Allocate domain with v1 page table for dirty tracking */ 2795 - if (!amd_iommu_hd_support(iommu)) 2787 + case IOMMU_HWPT_ALLOC_NEST_PARENT: 2788 + case IOMMU_HWPT_ALLOC_DIRTY_TRACKING | IOMMU_HWPT_ALLOC_NEST_PARENT: 2789 + /* 2790 + * Allocate domain with v1 page table for dirty tracking 2791 + * and/or Nest parent. 2792 + */ 2793 + if ((flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING) && 2794 + !amd_iommu_hd_support(iommu)) 2796 2795 break; 2796 + 2797 + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && 2798 + !is_nest_parent_supported(flags)) 2799 + break; 2800 + 2797 2801 return amd_iommu_domain_alloc_paging_v1(dev, flags); 2798 2802 case IOMMU_HWPT_ALLOC_PASID: 2799 2803 /* Allocate domain with v2 page table if IOMMU supports PASID. */