Re: [PATCH v2 09/12] iommu/amd: Add support for nest parent domain allocation

From: Suthikulpanit, Suravee

Date: Wed Oct 08 2025 - 10:16:36 EST




On 10/2/2025 1:00 PM, Nicolin Chen wrote:
On Wed, Oct 01, 2025 at 06:09:51AM +0000, Suravee Suthikulpanit wrote:
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.

Signed-off-by: Suravee Suthikulpanit<suravee.suthikulpanit@xxxxxxx>
+static inline bool is_nest_parent_supported(u32 flags)
+{
+ /* Only allow nest parent when these features are supported */
+ if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) &&
+ (!check_feature(FEATURE_GT) ||
+ !check_feature(FEATURE_GIOSUP) ||
+ !check_feature2(FEATURE_GCR3TRPMODE)))
+ return false;
+
+ return true;
If the "flags" doesn't have IOMMU_HWPT_ALLOC_NEST_PARENT while one
of the features is missing, this would return true, indicating the
HW supports nesting parent, which will be logically wrong although
it does validate the nest parent flag.

Following the existing coding style, I think this could be just:

static inline bool is_nest_parent_supported(void)
{
/* Only allow nest parent when these features are supported */
return check_feature(FEATURE_GT) && check_feature(FEATURE_GIOSUP) &&
check_feature2(FEATURE_GCR3TRPMODE);
}

Ahh, I missed this part.

Thanks,
Suravee