iommu/amd: Add Secure ATS support
Subsystems (2)
Vasant Hegde
maintainerPATCH 1/1 iommu/amd: Add Secure ATS support
AMD IOMMU supports processing ATS requests as Secure ATS requests when IOTLB is supported and enabled (See section "2.11 Secure ATS Supports" in AMD IOMMU spec [1] for more detail).
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA. When receiving Translated DMA from a device the IOMMU performs in-line GPA to SPA translation. This ensures that any malicious devices or vulnerable IOTLB implementations do not have access to the full SPA space even if they can generate Translated DMA with arbitrary addresses. This provides security against untrusted devices.
Introduce new command line parameter (amd_iommu=sats) to enable Secure ATS. This can be used to provide security against untrusted device ATS. Also enable Secure ATS when SNP is enabled.
[1] https://www.amd.com/en/support/tech-docs/amd-io-virtualization-technology-iommu-specification
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/init.c | 17 +++++++++++++++++ drivers/iommu/amd/iommu.c | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-)
drivers/iommu/amd/amd_iommu.h +1 -0
@@ -43,6 +43,7 @@ extern int amd_iommu_guest_ir;extern enum protection_domain_mode amd_iommu_pgtable;extern int amd_iommu_gpt_level;extern unsigned long amd_iommu_pgsize_bitmap; +extern bool amd_iommu_sats;/* Protection domain ops */ void amd_iommu_init_identity_domain (void );
drivers/iommu/amd/amd_iommu_types.h +2 -0
@@ -99,6 +99,7 @@#define FEATURE_GATS GENMASK_ULL(13, 12)#define FEATURE_GLX GENMASK_ULL(15, 14)#define FEATURE_GAM_VAPIC BIT_ULL(21) +#define FEATURE_SATSSUP BIT_ULL(31)#define FEATURE_PASMAX GENMASK_ULL(36, 32)#define FEATURE_GIOSUP BIT_ULL(48)#define FEATURE_HASUP BIT_ULL(49)
@@ -417,6 +418,7 @@#define DTE_FLAG_IOTLB BIT_ULL(32)#define DTE_FLAG_MASK (0x3ffULL << 32)#define DEV_DOMID_MASK 0xffffULL +#define DTE_FLAG_SATS BIT_ULL(42)#define DTE_GCR3_14_12 GENMASK_ULL(60, 58)#define DTE_GCR3_30_15 GENMASK_ULL(31, 16)
drivers/iommu/amd/init.c +17 -0
@@ -156,6 +156,9 @@ enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1;/* Guest page table level */ int amd_iommu_gpt_level =PAGE_MODE_4_LEVEL ; +/* Secure ATS support */ +bool amd_iommu_sats; +int amd_iommu_guest_ir =AMD_IOMMU_GUEST_IR_VAPIC ;static int amd_iommu_xt_mode =IRQ_REMAP_XAPIC_MODE ;
@@ -3093,6 +3096,15 @@ static int __init early_amd_iommu_init(void) } } +/* Secure ATS supported when DTE[mode] != 0 */ +if (amd_iommu_sats) { +if (!check_feature (FEATURE_SATSSUP ) || + (amd_iommu_pgtable !=PD_MODE_V1 )) { +pr_info ("Secure ATS is not supported" ); + amd_iommu_sats = false; + } + } +/* Disable any previously enabled IOMMUs */ if (!is_kdump_kernel () || amd_iommu_disabled)disable_iommus ();
@@ -3231,6 +3243,9 @@ static __init void iommu_snp_enable(void) goto disable_snp; } +if (check_feature (FEATURE_SATSSUP )) + amd_iommu_sats = true; +pr_info ("IOMMU SNP support enabled.\n" );return ;
@@ -3526,6 +3541,8 @@ static int __init parse_amd_iommu_options(char *str) }else if (strncmp (str,"v2_pgsizes_only" ,15 ) ==0 ) {pr_info ("Restricting V1 page-sizes to 4KiB/2MiB/1GiB" ); amd_iommu_pgsize_bitmap =AMD_IOMMU_PGSIZES_V2 ; + }else if (strncmp (str,"sats" ,4 ) ==0 ) { + amd_iommu_sats = true; }else {pr_notice ("Unknown option - '%s'\n" , str); }
drivers/iommu/amd/iommu.c +10 -1
@@ -2064,9 +2064,18 @@ static void set_dte_entry(struct amd_iommu *iommu,if (domain->dirty_tracking) new.data[0 ] |=DTE_FLAG_HAD ; -if (dev_data->ats_enabled) +if (dev_data->ats_enabled) { new.data[1 ] |=DTE_FLAG_IOTLB ; +/* Secure ATS is supported when DTE[mode] != 0 */ +if (amd_iommu_sats && domain->iop.mode !=PAGE_MODE_NONE ) + new.data[1 ] |=DTE_FLAG_SATS ; +else if (amd_iommu_sats) { +pr_devel ("Secure ATS not enabled for dev 0x%x as " +"DTE[mode]=0\n" , dev_data->devid); + } + } + old_domid =READ_ONCE (dte->data[1 ]) &DEV_DOMID_MASK ; new.data[1 ] |= domid;
Signature · 1 line
2.31.1
Quoted 3 lines · Vasant Hegde
AMD IOMMU supports processing ATS requests as Secure ATS requests when IOTLB is supported and enabled (See section "2.11 Secure ATS Supports" in AMD IOMMU spec [1] for more detail).
glad to see it. I'm also working on Secure ATS for VT-d. Intel Secure ATS has an extra table named HPT (Host Permission Table) chapter 4.2.4 in revision 5.0 spec. IOMMU uses this table to check the address in the translated transactions to ensure the device has access permission.
We plan to support the HPT on S2 when nested translation is configured. But we may let the userspace VMM to decide if it wants SATS on specific device. The reason is that some devices might be considered as trusted. e.g. integrated devices.
My thought is to add a flag in iommufd_hw_capabilities to report the capability, and add a flag in iommufd_hwpt_alloc_flags to let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)
Quoted 1 line
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Signature · 2 lines
Regards, Yi Liu
Robin Murphy
reviewerQuoted 21 lines · Yi Liu
Quoted 3 lines · Vasant Hegde
AMD IOMMU supports processing ATS requests as Secure ATS requests when IOTLB is supported and enabled (See section "2.11 Secure ATS Supports" in AMD IOMMU spec [1] for more detail).
glad to see it. I'm also working on Secure ATS for VT-d. Intel Secure ATS has an extra table named HPT (Host Permission Table) chapter 4.2.4 in revision 5.0 spec. IOMMU uses this table to check the address in the translated transactions to ensure the device has access permission.
We plan to support the HPT on S2 when nested translation is configured. But we may let the userspace VMM to decide if it wants SATS on specific device. The reason is that some devices might be considered as trusted. e.g. integrated devices.
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)
Quoted 4 lines
Quoted 1 line
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
Thanks,
Robin.
Quoted 22 lines · Robin Murphy
Quoted 21 lines · Yi Liu
Quoted 3 lines · Vasant Hegde
AMD IOMMU supports processing ATS requests as Secure ATS requests when IOTLB is supported and enabled (See section "2.11 Secure ATS Supports" in AMD IOMMU spec [1] for more detail).
glad to see it. I'm also working on Secure ATS for VT-d. Intel Secure ATS has an extra table named HPT (Host Permission Table) chapter 4.2.4 in revision 5.0 spec. IOMMU uses this table to check the address in the translated transactions to ensure the device has access permission.
We plan to support the HPT on S2 when nested translation is configured. But we may let the userspace VMM to decide if it wants SATS on specific device. The reason is that some devices might be considered as trusted. e.g. integrated devices.
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
I think so. HPT is a 4-level table which uses different bits of the PA as index of each level. What in my mind so far is associating the HPT with paging domains and managing the HPT per the map/unamp pages to paging domain. Maybe we can have more discussions when my RFC is out. Should be soon.
Signature · 2 lines
Regards, Yi Liu
Quoted 9 lines · Robin Murphy
Quoted 9 lines
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)Quoted 2 lines
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
Quoted 6 lines
Quoted 2 lines
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
Yes, lets not have another driver-only command line parameter but somthing global managed by the core code.
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)
2) IOMMU converts a S1 IOVA into a TA as a S2 IOVA address and the IOMMU runs it through the S2 to validate it. (ARM calls this split-stage). Requires nesting
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
4) TA is an full physical address and the IOMMU validates the full physical using some kind of permission structure (ARM calls this Device Permission Table)
What are the three HWs doing?
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
What is Intel doing?
A domain alloc flag to put the domain into #3 mode seems like a good start to me. The core code can decide to activate the flag for the default domain. Suggest starting from pci->untrusted.
Also, #3 requires PCI topology support, the ACS flags need to be set to route all TA's to the host. The core code should check and validate this before turning it on.
I think #2 can be requested through the vSTE on ARM?
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
Jason
Quoted 18 lines · Jason Gunthorpe
Quoted 9 lines · Robin Murphy
Quoted 9 lines
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)Quoted 2 lines
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
Quoted 6 lines
Quoted 2 lines
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
Quoted 7 lines
Yes, lets not have another driver-only command line parameter but somthing global managed by the core code.
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)
do you mean "do nothing"?
Quoted 11 lines
2) IOMMU converts a S1 IOVA into a TA as a S2 IOVA address and the IOMMU runs it through the S2 to validate it. (ARM calls this split-stage). Requires nesting
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
4) TA is an full physical address and the IOMMU validates the full physical using some kind of permission structure (ARM calls this Device Permission Table)
Quoted 8 lines
What are the three HWs doing?
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
What is Intel doing?
Intel does #4. It has a Host Permission Table which validates the physical address.
4.2.4 Host Permission Table
The Host Permission Table (HPT) allows software to control access to the physical address space when one or more devices uses translated requests. System software may create one or more domains which permit memory accesses from only those ATS-devices that are accepted as part of the domain’s Trusted Computing Base (TCB). HPT is only supported when operating in scalable mode. The HPT is a 4-level structure described in Table 11 and an example HPT Walk in Figure 4-2. Each table entry corresponding to a valid page size can reference one or more valid pages using the Page Permission (PPi) fields as well as providing a pointer to the subsequent paging structure.
Quoted 7 lines
A domain alloc flag to put the domain into #3 mode seems like a good start to me. The core code can decide to activate the flag for the default domain. Suggest starting from
pci->untrusted.Also, #3 requires PCI topology support, the ACS flags need to be set to route all TA's to the host. The core code should check and validate this before turning it on.
yes. I think both #2 and #3 need to enforce it. The TA device got is not really a PA in the two modes.
Quoted 4 lines
I think #2 can be requested through the vSTE on ARM?
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
The DPT and the HPT validates physical addresses. So such tables need to be programmed when a physical address is mapped in I/O page table. So the choice may be associating it with paging domain (e.g. the S2 domain that converts GPA to PA). If so, a domain alloc flag is also a good start.
Signature · 2 lines
Regards, Yi Liu
Quoted 5 lines · Yi Liu
Quoted 3 lines
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)do you mean "do nothing"?
Yes
Quoted 7 lines
Quoted 2 lines
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
The DPT and the HPT validates physical addresses. So such tables need to be programmed when a physical address is mapped in I/O page table. So the choice may be associating it with paging domain (e.g. the S2 domain that converts GPA to PA). If so, a domain alloc flag is also a good start.
Hmm, so you imagine doing it as a side structure under the map operation.. Maybe, that will complicate my effort to unify the page tables somewhat, but maybe not too badly.
Jason
Quoted 12 lines · Jason Gunthorpe
Quoted 5 lines · Yi Liu
Quoted 3 lines
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)do you mean "do nothing"?
Yes
Quoted 3 lines
Quoted 2 lines
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
Quoted 7 lines
Quoted 4 lines
The DPT and the HPT validates physical addresses. So such tables need to be programmed when a physical address is mapped in I/O page table. So the choice may be associating it with paging domain (e.g. the S2 domain that converts GPA to PA). If so, a domain alloc flag is also a good start.
Hmm, so you imagine doing it as a side structure under the map operation.. Maybe,
yes.
Quoted 2 lines
that will complicate my effort to unify the page
tables somewhat, but maybe not too badly.
I'm not on purpose about this part :)
Signature · 2 lines
Regards, Yi Liu
Quoted 8 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:13 AMQuoted 4 lines · Yi Liu
Quoted 2 lines
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
The DPT and the HPT validates physical addresses. So such tables need to
Quoted 9 lines
be
Quoted 3 lines
programmed when a physical address is mapped in I/O page table. So the choice may be associating it with paging domain (e.g. the S2 domain that converts GPA to PA). If so, a domain alloc flag is also a good start.
Hmm, so you imagine doing it as a side structure under the map operation.. Maybe, that will complicate my effort to unify the page tables somewhat, but maybe not too badly.
might be OK. suppose some hooks in the map/unmap path allowing the driver to register for updating the permission table.
Quoted 26 lines
From: Jason Gunthorpe <[email protected]>
Sent: Tuesday, February 25, 2025 10:55 PMQuoted 2 lines · Robin Murphy
Quoted 2 lines
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommudriver
Quoted 8 lines
Quoted 8 lines
know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)
Quoted 2 lines
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation
configuration.
Quoted 5 lines
Quoted 1 line
is it? I guess admin may want some flexibility to opt-in it. :)
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
Yes, lets not have another driver-only command line parameter but somthing global managed by the core code.
Quoted 7 lines
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)2) IOMMU converts a S1 IOVA into a TA as a S2 IOVA address and the IOMMU runs it through the S2 to validate it. (ARM calls this split-stage). Requires nesting
and this won't support CXL.cache which works on physical address.
Quoted 8 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
4) TA is an full physical address and the IOMMU validates the full physical using some kind of permission structure (ARM calls this Device Permission Table)
Quoted 6 lines
What are the three HWs doing?
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
my reading of AMD spec was #2. also backed by Vasant's words:
"
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA. When receiving Translated DMA from a device the IOMMU performs in-line GPA to SPA translation.
"
Quoted 2 lines
What is Intel doing?
Intel is doing #4. The permission structure is called Host Permission Table.
Quoted 5 lines
A domain alloc flag to put the domain into #3 mode seems like a good start to me. The core code can decide to activate the flag for the default domain. Suggest starting from
pci->untrusted.
Quoted 9 lines
Also, #3 requires PCI topology support, the ACS flags need to be set to route all TA's to the host. The core code should check and validate this before turning it on.
I think #2 can be requested through the vSTE on ARM?
Not sure how to setup #4? The core code also needs to detect coherent systems (ie CXL/etc) and refuse to do anything other than #1/#4..
If above understanding is true, my preference is to support a sats flag in domain alloc (nested_parent only and PCI/CXL.io only, as the start). For AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
It provides a nice minimal start for all 3 platforms.
Later we can enable more domain/device types for #4 and beyond iommufd if necessary.
Thanks
Kevin
Quoted 5 lines · Kevin
Quoted 4 lines
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
Quoted 7 lines
my reading of AMD spec was #2. also backed by Vasant's words:
"
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA. When receiving Translated DMA from a device the IOMMU performs in-line GPA to SPA translation.
"
Maybe it is both 2 and 3 if the GCR3 PASID 0 is setup to not translate but do identity?
Quoted 5 lines
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start). For AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
I think they need to be different flags
Jason
Quoted 13 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 9 lines · Kevin
Quoted 4 lines
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
my reading of AMD spec was #2. also backed by Vasant's words:
"
With Secure ATS, for ATS requests IOMMU return GPA to device instead of
Quoted 7 lines
SPA.
Quoted 3 lines
When receiving Translated DMA from a device the IOMMU performs in-line GPA to SPA translation.
"Maybe it is both 2 and 3 if the GCR3 PASID 0 is setup to not translate but do identity?
yes but conceptually it's still more a #2 thing from host p.o.v. The host still sees a nested configuration no matter how the guest configures each GCR3 entry.
Quoted 7 lines
Quoted 6 lines
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start). For AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
Quoted 6 lines
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
If necessary the driver could report certain restrictions about sats to the user via GET_HW_INFO.
Quoted 6 lines · Kevin
Quoted 2 lines
Maybe it is both 2 and 3 if the GCR3 PASID 0 is setup to not translate but do identity?
yes but conceptually it's still more a #2 thing from host p.o.v. The host still sees a nested configuration no matter how the guest configures each GCR3 entry.
AMD doesn't even support nesting now, so if this patch works it means it is scenario #2.
Quoted 5 lines
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
We already discussed that #4 works with CXL and #2/#3 don't. They also tolerate different PCI topology settings. The core code needs to know what it is getting into and in the case of ARM it needs to instruct the driver which of the two options to use.
#2/#3 seems to be prefered when possible because it uses less memory, has less invalidation overhead, and apparently about the same performance according to the SMMU spec.
So I think two flags is the right starting point..
Jason
Quoted 17 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 14 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 5 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start). For AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
It's also checked against the device type e.x. CXL.cache.
- Then when enabling ats for a given domain type and device, follow the policy set by administrator: ats disabled, ats enabled as today, ats enabled with hw enforced security;
- Optionally iommufd may support a domain alloc flag for ats, which alone is a performance or functional dependency (by PRI), hence better to let the user opt. If opted, again follow the admin policy whether it's allowed and requires sats.
Is this way reasonable?
Quoted 9 lines · Kevin
Quoted 5 lines
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
So you don't want iommufd users to be able to opt out of it? That makes sense to me
Jason
Vasant Hegde
maintainerHi Kevin,
Quoted 31 lines · Kevin
Quoted 17 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 14 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 5 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start). For AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
Quoted 5 lines
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
When you say "sats knob", you mean sysfs interface?
Quoted 7 lines
It's also checked against the device type e.x. CXL.cache.
- Then when enabling ats for a given domain type and device, follow the policy set by administrator: ats disabled, ats enabled as today, ats enabled with hw enforced security;
Quoted 7 lines
- Optionally iommufd may support a domain alloc flag for ats, which alone is a performance or functional dependency (by PRI), hence better to let the user opt. If opted, again follow the admin policy whether it's allowed and requires sats.
Is this way reasonable?
What I am really thinking is :
- If HW has a enforcement required (like AMD SNP case where Secure ATS is
must), enable secure ATS. But do we need some way to inform core layer? If yes, may be have an domain ops similar to def_domain_type() ?
- For untrusted devices, by default enforce Secure ATS (may be a domain flag)
- Have a command line option, so that if administrator wants to enforce secure
ATS for all devices, he can do that.
-Vasant
Quoted 39 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
Quoted 7 lines
Quoted 5 lines
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
When you say "sats knob", you mean sysfs interface?
yes
Quoted 13 lines
Quoted 13 lines
It's also checked against the device type e.x. CXL.cache.
- Then when enabling ats for a given domain type and device, follow the policy set by administrator: ats disabled, ats enabled as today, ats enabled with hw enforced security;
- Optionally iommufd may support a domain alloc flag for ats, which alone is a performance or functional dependency (by PRI), hence better to let the user opt. If opted, again follow the admin policy whether it's allowed and requires sats.
Quoted 6 lines
Quoted 2 lines
Is this way reasonable?
What I am really thinking is :
- If HW has a enforcement required (like AMD SNP case where Secure ATS is
must), enable secure ATS. But do we need some way to inform core layer?
It's not conflicting. When enabling a trusted device the driver can detect whether sats has been opted in by admin for the device. If not fail the request. If yes, turn on secure ATS as part of enforcement and return -EBUSY if the admin attempts to disable it in-fly.
Quoted 2 lines
If yes,
may be have an domain ops similar todef_domain_type()?
the domain for trusted I/O will have a special flag.
Quoted 3 lines
- For untrusted devices, by default enforce Secure ATS (may be a domain
flag)
or the admin may prefer to disabling ats.
Quoted 5 lines
- Have a command line option, so that if administrator wants to enforce
secure
ATS for all devices, he can do that.
whether to enable sats depends on various factors:
- is the device trusted?
- does the overhead of enabling sats break the perf requirement of the existing ats scenario?
- different security policy based on domain types, e.g. only requiring sats for iommufd but not default DMA API domain
- ...
A global cmdline option for all devices/domains is hard to meet those requirements.
Quoted 45 lines · Kevin
Quoted 45 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
Quoted 3 lines
Quoted 1 line
When you say "sats knob", you mean sysfs interface?
yes
in case this is the direction. This might be a per iommu_group knob. do we want a default value per some info that can be probed by kernel? or we just fully rely on admin to program it?
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerHi Yi,
Quoted 46 lines · Yi Liu
Quoted 45 lines · Kevin
Quoted 45 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
When you say "sats knob", you mean sysfs interface?
yes
in case this is the direction. This might be a per
iommu_groupknob. do wewant a default value per some info that can be probed by kernel?
I prefer kernel probe/setting default values so that we can enforce HW restrictions (like SNP, untrusted device etc) and then....
Quoted 1 line
or we just fully rely on admin to program it?
have a admin option to make choice (I prefer global enforcement option). As Kevin mentioned for fine grained control, we can have per group know as well. (may be we can hook it to /sys/kernel/iommu_groups/<x>/<ats knob> ?
-Vasant
Quoted 54 lines · Vasant Hegde
Hi Yi,
Quoted 50 lines · Yi Liu
Quoted 48 lines · Kevin
Quoted 39 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
Quoted 7 lines
Quoted 5 lines
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
When you say "sats knob", you mean sysfs interface?
yes
Quoted 7 lines
Quoted 4 lines
in case this is the direction. This might be a per
iommu_groupknob. do wewant a default value per some info that can be probed by kernel?
I prefer kernel probe/setting default values so that we can enforce HW restrictions (like SNP, untrusted device etc) and then....
I got untrusted device. How is SNP probed? Is there any bit for it?
Quoted 6 lines
Quoted 2 lines
or we just fully rely on admin to program it?
have a admin option to make choice (I prefer global enforcement option). As Kevin mentioned for fine grained control, we can have per group know as well. (may be we can hook it to /sys/kernel/iommu_groups/<x>/<ats knob> ?
yeah, this suit my thought. ATS only exists when iommu is enabled. Hence Secure ATS. iommu_group is the granular where iommu can isolate devices. So per iommu group knob sounds reasonable.
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerHi Yi,
Quoted 59 lines · Yi Liu
Quoted 58 lines · Vasant Hegde
Hi Yi,
Quoted 52 lines · Yi Liu
Quoted 46 lines · Kevin
Quoted 46 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 28 lines
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
I think they need to be different flags
Quoted 7 lines
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats
when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
Quoted 3 lines
Quoted 1 line
When you say "sats knob", you mean sysfs interface?
yes
in case this is the direction. This might be a per
iommu_groupknob. do we
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
want a default value per some info that can be probed by kernel?
I prefer kernel probe/setting default values so that we can enforce HW restrictions (like SNP, untrusted device etc) and then....
I got untrusted device. How is SNP probed? Is there any bit for it?
Yes. There is a IOMMU feature bit. see iommu_snp_enable().
-Vasant
Quoted 63 lines · Vasant Hegde
Hi Yi,
Quoted 59 lines · Yi Liu
Quoted 58 lines · Vasant Hegde
Hi Yi,
Quoted 52 lines · Yi Liu
Quoted 46 lines · Kevin
Quoted 46 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 28 lines
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
I think they need to be different flags
Quoted 7 lines
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats
when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
Quoted 3 lines
Quoted 1 line
When you say "sats knob", you mean sysfs interface?
yes
in case this is the direction. This might be a per
iommu_groupknob. do we
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
want a default value per some info that can be probed by kernel?
I prefer kernel probe/setting default values so that we can enforce HW restrictions (like SNP, untrusted device etc) and then....
I got untrusted device. How is SNP probed? Is there any bit for it?
Yes. There is a IOMMU feature bit. see
iommu_snp_enable().
sure.
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the probe_device() op. What about AMD and ARM?
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Any ideas?
Signature · 2 lines
Regards, Yi Liu
Quoted 10 lines
From: Liu, Yi L <[email protected]>
Sent: Sunday, March 2, 2025 4:11 PMI'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?
I was envisioning it as a policy knob, which can be updated only when the device is not attached to any domain. There is a default value per device, based on hw capability and platform enforcement like SNP.
Then when attaching the device to a new domain, turn on ats/sats according to the policy.
Quoted 11 lines · Kevin
Quoted 10 lines
From: Liu, Yi L <[email protected]>
Sent: Sunday, March 2, 2025 4:11 PMI'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?
Quoted 2 lines
I was envisioning it as a policy knob, which can be updated only when the device is not attached to any domain.
If the device is probed, there seems always a domain attached for probed device. e.g. default_domain. Only when bound to some drivers like vfio, there is a blocked_domain attached.
Quoted 2 lines
There is a default value per
device, based on hw capability and platform enforcement like SNP.
or maybe topology as well. if a device is plugged in a slot, it might be considered as not trusted.
Quoted 2 lines
Then when attaching the device to a new domain, turn on ats/sats according to the policy.
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerHi Yi, Kevin, Jason,
Quoted 71 lines · Yi Liu
Quoted 70 lines · Vasant Hegde
Hi Yi,
Quoted 65 lines · Yi Liu
Quoted 55 lines · Vasant Hegde
Hi Yi,
Quoted 51 lines · Yi Liu
Quoted 49 lines · Kevin
Quoted 40 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 23 lines
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
I think they need to be different flags
Quoted 7 lines
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats
when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
Quoted 7 lines
Quoted 5 lines
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
When you say "sats knob", you mean sysfs interface?
yes
Quoted 7 lines
Quoted 4 lines
in case this is the direction. This might be a per
iommu_groupknob. do wewant a default value per some info that can be probed by kernel?
I prefer kernel probe/setting default values so that we can enforce HW restrictions (like SNP, untrusted device etc) and then....
I got untrusted device. How is SNP probed? Is there any bit for it?
Quoted 7 lines
Quoted 1 line
Yes. There is a IOMMU feature bit. see
iommu_snp_enable().sure.
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while> the
hw does not support SATS, it seems reasonable to disable ATS for
Quoted 3 lines
such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?
Currently AMD driver enables device ATS and configures IOMMU DTE (per device setup) during attach_device() path. There was a discussion to move device ATS enablement to probe() path. We will move it to probe() path soon.
Quoted 6 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Right. Lets see if below flow covers all the requirement
- Define new flags
IOMMU_HWPT_FLAGS_SATS / IOMMU_HWPT_FLAGS_ATS
- Enhance 'struct iommu_device' to include ATS flags (NO ATS, ATS, SECURE ATS)
iommu_device->ats_flag
- During probe() driver will update this field (similar to max_pasids)
If (IOMMU needs Secure ATS always)
iommu_device->ats_flag = IOMMU_HWPT_FLAGS_SATS
else if (device supports ATS and IOMMU supports Secure ATS)
iommu_device->ats_flag = IOMMU_HWPT_FLAGS_SATS | IOMMU_HWPT_FLAGS_ATS
else if (device supports ATS and IOMMU supports ATS)
iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS
else
iommu_device->ats_flag = <NO FLAGS> (May be have one more flagIOMMU_HWPT_FLAGS_NO_ATS) ?
- Based on default setting, kernel command line option and probe() data, core
layer can adjust ATS capability. i. e.
- If we have kernel command line (say iommu.ats=<x>), use that data for all
ATS capable device.
- If not, apply default
untrusted device -> force secure ATS or no ats
If HW needs Secure ATS always , enable Secure ATS
For all other cases use ATS
- For domain_alloc_paging_flags(), send appropriate ATS flags
Q : We need to find a way to send this info to identity domain?
- sysfs knob : core layer knows supported ATS flags. We can expose them via
sysfs. Then as Kevin mentioned, we can make sure changes happens only when device in unbind to domain.
Does this flow works fine?
-Vasant
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 3, 2025 7:42 PMCurrently AMD driver enables device ATS and configures IOMMU DTE (per device
setup) duringattach_device()path. There was a discussion to move device ATS
enablement toprobe()path. We will move it toprobe()path soon.
Based on discussion in this thread I'd expect doing it during attach is the long-term direction.
Quoted 9 lines
Quoted 8 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Quoted 3 lines
Right. Lets see if below flow covers all the requirement
- Define new flags
IOMMU_HWPT_FLAGS_SATS/IOMMU_HWPT_FLAGS_ATS
SATS policy should be managed by the sys admin, while ATS feature itself can be opted by the user.
Quoted 4 lines
- Enhance 'struct
iommu_device' to include ATS flags (NO ATS, ATS, SECURE
ATS)iommu_device->ats_flag
as commented by Jason this needs to differentiate domain types, either due to hw lacking of support for certain types or the admin imposes different security levels across different types.
Quoted 7 lines
- During
probe()driver will update this field (similar tomax_pasids) If (IOMMU needs Secure ATS always)iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS
else if (device supports ATS and IOMMU supports Secure ATS)
iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS|IOMMU_HWPT_FLAGS_ATS
Quoted 5 lines
else if (device supports ATS and IOMMU supports ATS) iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS else iommu_device->ats_flag = <NO FLAGS> (May be have one more flag
IOMMU_HWPT_FLAGS_NO_ATS) ?
Here the device->ats_flag should be more an ats_policy thing? At probe time it's assigned with a default policy according to device type, platform requirement, etc. and later exposed via sysfs for admin opt.
Actual ats enabling/enforcement is done at attach time, according to ats_policy.
Quoted 12 lines
- Based on default setting, kernel command line option and
probe()data,
core
layer can adjust ATS capability. i. e.
- If we have kernel command line (say iommu.ats=<x>), use that data for
all
ATS capable device.
- If not, apply default
untrusted device -> force secure ATS or no ats
If HW needs Secure ATS always , enable Secure ATS
For all other cases use ATS
this is an interesting one, i.e. whether we still want a global iommu option to enable sats for all applicable devices/domains. the pros is that it is simple and allows underlying driver to add sats support before a more flexible sysfs interface is ready. the downside is that it's unclear which device/domain types are affected by sats on different platforms w/o digging into the hw detail...
Vasant Hegde
maintainerKevin,
Quoted 11 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 3, 2025 7:42 PMCurrently AMD driver enables device ATS and configures IOMMU DTE (per device
setup) duringattach_device()path. There was a discussion to move device ATS
enablement toprobe()path. We will move it toprobe()path soon.Based on discussion in this thread I'd expect doing it during attach is the long-term direction.
AMD does actual enablement of ATS per device (via DTE setting) in attach device path. So I see this as default requirement. Of course some of policy enforcement we can implement later.
May be we should document full flow in detail and make sure it takes care of all HW requirements. Then decide when to do each part.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Quoted 6 lines
Quoted 3 lines
Right. Lets see if below flow covers all the requirement
- Define new flags
IOMMU_HWPT_FLAGS_SATS/IOMMU_HWPT_FLAGS_ATSSATS policy should be managed by the sys admin, while ATS feature itself can be opted by the user.
"user" you mean like iommufd during domain allocation?
Quoted 9 lines
Quoted 5 lines
- Enhance 'struct
iommu_device' to include ATS flags (NO ATS, ATS, SECURE
ATS)iommu_device->ats_flagas commented by Jason this needs to differentiate domain types, either due to hw lacking of support for certain types or the admin imposes different security levels across different types.
Right.
Quoted 14 lines
Quoted 8 lines
- During
probe()driver will update this field (similar tomax_pasids) If (IOMMU needs Secure ATS always)iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS
else if (device supports ATS and IOMMU supports Secure ATS)
iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS|IOMMU_HWPT_FLAGS_ATSQuoted 5 lines
else if (device supports ATS and IOMMU supports ATS) iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS else iommu_device->ats_flag = <NO FLAGS> (May be have one more flag
IOMMU_HWPT_FLAGS_NO_ATS) ?
Quoted 4 lines
Here the
device->ats_flagshould be more anats_policything? At probe time it's assigned with a default policy according to device type, platform requirement, etc. and later exposed via sysfs for admin opt.
Right. We can call it as ats_policy (expected/desired mode by HW driver). So now core knows HW requirement. Also default and global policy enforcement (via kernel command line).
During domain allocation, we can enforce required domain specific policy.
Quoted 3 lines
Actual ats enabling/enforcement is done at attach time, according to
ats_policy.
Then during attach_dev() we pass those flags as argument?
Quoted 14 lines
Quoted 13 lines
- Based on default setting, kernel command line option and
probe()data,
core
layer can adjust ATS capability. i. e.
- If we have kernel command line (say iommu.ats=<x>), use that data for
all
ATS capable device.
- If not, apply default
untrusted device -> force secure ATS or no ats
If HW needs Secure ATS always , enable Secure ATS
For all other cases use ATS
Quoted 6 lines
this is an interesting one, i.e. whether we still want a global iommu option to enable sats for all applicable devices/domains. the pros is that it is simple and allows underlying driver to add sats support before a more flexible sysfs interface is ready. the downside is that it's unclear which device/domain types are affected by sats on different platforms w/o digging into the hw detail...
I preferred global option (that's why this patch added amd_iommu=sats) because as you said its simple, can be enforced at global level. Also w/ sysfs interface we have to update for each device/group indivisual. Another drawback is, w/ sysfs first we have to unbind the driver (which may not be possible always), modify ATS setting, then bind driver again.
In Summary, I visualize it three level:
- Default policy implemented in kernel
- Global policy enforcement by admin via kernel command line
- Per group/device level enforcement via sysfs
Do we need something for iommufd/vfio? Where user can tell desired mode while allocating HWPT domains?
-Vasant
Quoted 7 lines
From: Vasant Hegde <[email protected]>
Sent: Tuesday, March 11, 2025 1:07 AMQuoted 3 lines · Kevin
Quoted 3 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 3, 2025 7:42 PM
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Right. Lets see if below flow covers all the requirement
- Define new flags
IOMMU_HWPT_FLAGS_SATS/IOMMU_HWPT_FLAGS_ATSSATS policy should be managed by the sys admin, while ATS feature itself can be opted by the user.
"user" you mean like iommufd during domain allocation?
yes
Quoted 18 lines
Quoted 13 lines
Quoted 7 lines
- During
probe()driver will update this field (similar tomax_pasids) If (IOMMU needs Secure ATS always)iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS
else if (device supports ATS and IOMMU supports Secure ATS)
iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS|IOMMU_HWPT_FLAGS_ATSQuoted 5 lines
else if (device supports ATS and IOMMU supports ATS) iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS else iommu_device->ats_flag = <NO FLAGS> (May be have one more flag
IOMMU_HWPT_FLAGS_NO_ATS) ?Quoted 4 lines
Here the
device->ats_flagshould be more anats_policything? At probe time it's assigned with a default policy according to device type, platform requirement, etc. and later exposed via sysfs for admin opt.
Quoted 6 lines
Right. We can call it as
ats_policy(expected/desired mode by HW driver). So now core knows HW requirement. Also default and global policy enforcement
(via kernel command line).During domain allocation, we can enforce required domain specific policy.
yes
Quoted 7 lines
Quoted 5 lines
Actual ats enabling/enforcement is done at attach time, according to
ats_policy.Then during
attach_dev()we pass those flags as argument?
the policy is already stored in iommu_device so no need to pass.
and the domain also includes the ats flag at allocation time.
Then looks no need to pass additional flags at attach?
Quoted 30 lines
Quoted 8 lines
Quoted 8 lines
- Based on default setting, kernel command line option and
probe()data,
core
layer can adjust ATS capability. i. e.
- If we have kernel command line (say iommu.ats=<x>), use that datafor
Quoted 7 lines
Quoted 6 lines
all
ATS capable device.
- If not, apply default
untrusted device -> force secure ATS or no ats If HW needs Secure ATS always , enable Secure ATS For all other cases use ATSQuoted 6 lines
this is an interesting one, i.e. whether we still want a global iommu option to enable sats for all applicable devices/domains. the pros is that it is simple and allows underlying driver to add sats support before a more flexible sysfs interface is ready. the downside is that it's unclear which device/domain types are affected by sats on different platforms w/o digging into the hw detail...
I preferred global option (that's why this patch added amd_iommu=sats) because
as you said its simple, can be enforced at global level. Also w/ sysfs interface we have to update for each device/group indivisual. Another drawback is, w/ sysfs first we have to unbind the driver (which may not be possible always), modify ATS setting, then bind driver again.
Quoted 4 lines
In Summary, I visualize it three level:
- Default policy implemented in kernel
- Global policy enforcement by admin via kernel command line
- Per group/device level enforcement via sysfs
that sounds like a path forward
Quoted 5 lines
Do we need something for iommufd/vfio? Where user can tell desired mode while
allocating HWPT domains?
we should not allow the user to change the ats mode/policy. Just the option whether a hwpt needs ats, i.e. from functionality p.o.v.
Then whether this request can be satisfied subjects from the ats policy/mode set by the administrator.
Vasant Hegde
maintainerKevin,
Quoted 51 lines · Kevin
Quoted 7 lines
From: Vasant Hegde <[email protected]>
Sent: Tuesday, March 11, 2025 1:07 AMQuoted 3 lines · Kevin
Quoted 3 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 3, 2025 7:42 PMQuoted 8 lines
Quoted 6 lines
Quoted 3 lines
Right. Lets see if below flow covers all the requirement
- Define new flags
IOMMU_HWPT_FLAGS_SATS/IOMMU_HWPT_FLAGS_ATSSATS policy should be managed by the sys admin, while ATS feature itself can be opted by the user.
"user" you mean like iommufd during domain allocation?
yes
Quoted 18 lines
Quoted 13 lines
Quoted 7 lines
- During
probe()driver will update this field (similar tomax_pasids) If (IOMMU needs Secure ATS always)iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS
else if (device supports ATS and IOMMU supports Secure ATS)
iommu_device->ats_flag=IOMMU_HWPT_FLAGS_SATS|IOMMU_HWPT_FLAGS_ATSQuoted 5 lines
else if (device supports ATS and IOMMU supports ATS) iommu_device->ats_flag = IOMMU_HWPT_FLAGS_ATS else iommu_device->ats_flag = <NO FLAGS> (May be have one more flag
IOMMU_HWPT_FLAGS_NO_ATS) ?Quoted 4 lines
Here the
device->ats_flagshould be more anats_policything? At probe time it's assigned with a default policy according to device type, platform requirement, etc. and later exposed via sysfs for admin opt.Quoted 6 lines
Right. We can call it as
ats_policy(expected/desired mode by HW driver). So now core knows HW requirement. Also default and global policy enforcement
(via kernel command line).During domain allocation, we can enforce required domain specific policy.
yes
Quoted 6 lines
Quoted 5 lines
Actual ats enabling/enforcement is done at attach time, according to
ats_policy.
Quoted 7 lines
Quoted 1 line
Then during
attach_dev()we pass those flags as argument?the policy is already stored in
iommu_deviceso no need to pass.and the domain also includes the ats flag at allocation time.
Then looks no need to pass additional flags at attach?
So when user request to change from ATS to secure ATS via sysfs :
we tweak iommu_dev / domain and call attach_dev() ?
Quoted 31 lines
Quoted 31 lines
Quoted 9 lines
Quoted 9 lines
- Based on default setting, kernel command line option and
probe()data,
core
layer can adjust ATS capability. i. e.
- If we have kernel command line (say iommu.ats=<x>), use that datafor
Quoted 7 lines
Quoted 6 lines
all
ATS capable device.
- If not, apply default
untrusted device -> force secure ATS or no ats If HW needs Secure ATS always , enable Secure ATS For all other cases use ATSQuoted 6 lines
this is an interesting one, i.e. whether we still want a global iommu option to enable sats for all applicable devices/domains. the pros is that it is simple and allows underlying driver to add sats support before a more flexible sysfs interface is ready. the downside is that it's unclear which device/domain types are affected by sats on different platforms w/o digging into the hw detail...
I preferred global option (that's why this patch added amd_iommu=sats) because
as you said its simple, can be enforced at global level. Also w/ sysfs interface we have to update for each device/group indivisual. Another drawback is, w/ sysfs first we have to unbind the driver (which may not be possible always), modify ATS setting, then bind driver again.
Quoted 6 lines
Quoted 4 lines
In Summary, I visualize it three level:
- Default policy implemented in kernel
- Global policy enforcement by admin via kernel command line
- Per group/device level enforcement via sysfsthat sounds like a path forward
Sure.
Quoted 7 lines
Quoted 6 lines
Do we need something for iommufd/vfio? Where user can tell desired mode while
allocating HWPT domains?
Quoted 5 lines
we should not allow the user to change the ats mode/policy. Just the option whether a hwpt needs ats, i.e. from functionality p.o.v.
Then whether this request can be satisfied subjects from the ats policy/mode set by the administrator.
Ok. Let me write down the details and then we can fine tune it.
-Vasant
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 17, 2025 4:57 PMQuoted 6 lines
Quoted 5 lines
Quoted 3 lines
Actual ats enabling/enforcement is done at attach time, according to
ats_policy.Then during
attach_dev()we pass those flags as argument?
Quoted 9 lines
Quoted 5 lines
the policy is already stored in
iommu_deviceso no need to pass.and the domain also includes the ats flag at allocation time.
Then looks no need to pass additional flags at attach?
So when user request to change from ATS to secure ATS via sysfs :
we tweakiommu_dev/ domain and callattach_dev()?
No. Attach is still initiated by iommufd and this is just an attribute affecting the behavior of attach.
If the device is already attached then return -EBUSY in sysfs write.
otherwise update the attribute which will take effect at next attach.
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
never
always
paging-only
secure-always
secure-paging-only
?
Jason
Quoted 21 lines · Jason Gunthorpe
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
Quoted 7 lines
never
always
paging-only
secure-always
secure-paging-only?
My two cents' worth.
We could separate ATS security and enablement. ATS security is a security policy that should be opt-in by the user through something like sysfs nodes. We can follow what we have done for the default domain
type: identity domain (non-secure) and paging domain (secure with some extra performance overhead). Users can specify the static default domain type and tweak it in a per-iommu_group manner through sysfs nodes.
For ATS security, we can probably define two levels:
- Relaxed ATS: ATS could be enabled as long as the IOMMU supports the ATS service and the device supports ATC. This matches what most IOMMU drivers currently do.
- Secure ATS: ATS could only be enabled if the platform provides enumerable capabilities that can disallow arbitrary translated DMA requests. We need to let the user know that once ATS security is set to this level, some features like host SVA won't be supported currently.
For ATS enablement, I believe we have already reached some agreement that ATS enablement is in an on-demand manner. ATS is enabled when the first domain that requires ATS is attached and disabled when the last domain is detached. That matches what we are doing for PRI.
When a domain attachment triggers ATS to be on, there might be some cases:
- ATS does not impact functionality. For example, ATS could be enabled for the DMA domain for better performance. In this case, it's a successful case if the device supports ATS but the platform can't provide the secure ATS that is demanded by the user's ATS security level. ATS will not be enabled but attach returns success.
- ATS impacts functionality. For example, the domain requires PRI. In this case, it's a failure case when the device does not support ATS or the ATS security is insufficient.
- ATS compatibility should also be checked in domain attach path. If ATS policy between attaching domain and the device does not match, an -EINVAL should be returned to inform the caller that "domain is not compatible, suggest to allocate a dedicated domain for this device".
Thanks,
baolu
Quoted 4 lines · Baolu Lu
For ATS enablement, I believe we have already reached some agreement that ATS enablement is in an on-demand manner. ATS is enabled when the first domain that requires ATS is attached and disabled when the last domain is detached. That matches what we are doing for PRI.
It is not quite so simple, we need ATS in some virtualization cases for VFIO even though it is not "using" ATS for PRI.
Today the iommu drivers always enable ATS for paging domains if ATS is supported. This is what I'm wondering if it should be made optional
Quoted 9 lines
When a domain attachment triggers ATS to be on, there might be some cases:
- ATS does not impact functionality. For example, ATS could be enabled for the DMA domain for better performance. In this case, it's a successful case if the device supports ATS but the platform can't provide the secure ATS that is demanded by the user's ATS security level. ATS will not be enabled but attach returns success.
Quoted 8 lines
- ATS impacts functionality. For example, the domain requires PRI. In this case, it's a failure case when the device does not support ATS or the ATS security is insufficient.
- ATS compatibility should also be checked in domain attach path. If ATS policy between attaching domain and the device does not match, an
-EINVALshould be returned to inform the caller that "domain is not compatible, suggest to allocate a dedicated domain for this device".
But this philosophy makes sense
Jason
Quoted 11 lines
From: Jason Gunthorpe <[email protected]>
Sent: Tuesday, March 4, 2025 10:18 PMQuoted 4 lines · Baolu Lu
For ATS enablement, I believe we have already reached some agreement that ATS enablement is in an on-demand manner. ATS is enabled when the first domain that requires ATS is attached and disabled when the last domain is detached. That matches what we are doing for PRI.
It is not quite so simple, we need ATS in some virtualization cases for VFIO even though it is not "using" ATS for PRI.
As discussed before we probably want the user to opt for ATS via a hwpt flag.
Quoted 3 lines
Today the iommu drivers always enable ATS for paging domains if ATS is supported. This is what I'm wondering if it should be made optional
that'd make sense.
Quoted 14 lines
Quoted 14 lines
When a domain attachment triggers ATS to be on, there might be some cases:
- ATS does not impact functionality. For example, ATS could be enabled for the DMA domain for better performance. In this case, it's a successful case if the device supports ATS but the platform can't provide the secure ATS that is demanded by the user's ATS security level. ATS will not be enabled but attach returns success.
- ATS impacts functionality. For example, the domain requires PRI. In this case, it's a failure case when the device does not support ATS or the ATS security is insufficient.
Quoted 7 lines
Quoted 4 lines
- ATS compatibility should also be checked in domain attach path. If ATS policy between attaching domain and the device does not match, an
-EINVALshould be returned to inform the caller that "domain is not compatible, suggest to allocate a dedicated domain for this device".But this philosophy makes sense
+1
Quoted 7 lines · Jason Gunthorpe
Quoted 4 lines · Baolu Lu
For ATS enablement, I believe we have already reached some agreement that ATS enablement is in an on-demand manner. ATS is enabled when the first domain that requires ATS is attached and disabled when the last domain is detached. That matches what we are doing for PRI.
It is not quite so simple, we need ATS in some virtualization cases for VFIO even though it is not "using" ATS for PRI.
In such cases, perhaps we could allocate a domain-allocation flag for this purpose. Userspace would opt-in to this flag when allocating the iommufd hwpt.
Quoted 3 lines
Today the iommu drivers always enable ATS for paging domains if ATS is supported. This is what I'm wondering if it should be made optional
The domain-allocation flag also applies here. The iommu core manages the policy and determines whether to pass the ATS-required flag to the domain allocation callback of the iommu drivers. The iommu core's sysfs interface will include a node to modify the allocation policy.
Thanks,
baolu
Quoted 8 lines · Jason Gunthorpe
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?
sorry, a revise. Existing intel iommu driver enables ATS in the time of domain attach. While Baolu has the below series [1] to move it to probe_device().
[1] https://lore.kernel.org/linux-iommu/[email protected]/
Quoted 4 lines
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
will it affect Baolu's above refactoring [1]? :(
Quoted 6 lines
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Quoted 6 lines
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
never
always
paging-only
this can be considered policy to the existing ATS. curious, why paging domain is special here?
Quoted 2 lines
secure-always
secure-paging-only
and this is the policy of secure ATS.
A general question. Can admin op the knob if the device has been attached to any domain?
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerHi,
Quoted 40 lines · Yi Liu
Quoted 8 lines · Jason Gunthorpe
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?sorry, a revise. Existing intel iommu driver enables ATS in the time of domain attach. While Baolu has the below series [1] to move it to
probe_device().[1] https://lore.kernel.org/linux-iommu/20250224051627.2956304-5-
[email protected]/Quoted 4 lines
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
will it affect Baolu's above refactoring [1]? :(
Quoted 6 lines
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
Quoted 6 lines
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
never
always
paging-onlythis can be considered policy to the existing ATS. curious, why paging domain is special here?
Quoted 7 lines
Quoted 2 lines
secure-always
secure-paging-onlyand this is the policy of secure ATS.
A general question. Can admin op the knob if the device has been attached to any domain?
I'd say, it should be similar to "change domain" interface we have today.
-Vasant
Quoted 6 lines · Yi Liu
Quoted 4 lines
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
will it affect Baolu's above refactoring [1]? :(
I think no, but when we get some conclusion how ATS should work I'd expect all IOMMU drivers to align
Quoted 6 lines
Quoted 3 lines
never
always
paging-onlythis can be considered policy to the existing ATS. curious, why paging domain is special here?
Using ATS with an IDENTITY translation is not a performance win, so you'd probably want to turn it off in that case.
Jason
Quoted 19 lines
From: Jason Gunthorpe <[email protected]>
Sent: Tuesday, March 4, 2025 10:21 PMQuoted 6 lines · Yi Liu
Quoted 4 lines
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
will it affect Baolu's above refactoring [1]? :(
I think no, but when we get some conclusion how ATS should work I'd expect all IOMMU drivers to align
Quoted 4 lines
Quoted 3 lines
never
always
paging-only
Quoted 6 lines
Quoted 2 lines
this can be considered policy to the existing ATS. curious, why paging domain is special here?
Using ATS with an IDENTITY translation is not a performance win, so you'd probably want to turn it off in that case.
Probably we may also need separate policy between unmanaged and dma types. In some scenarios the user may care more about potential ATS attacks from userspace drivers but not kernel drivers. In that case disabling secure ats for kernel drivers would avoid unnecessary cost of address audit.
Quoted 5 lines · Kevin
Probably we may also need separate policy between unmanaged and dma types. In some scenarios the user may care more about potential ATS attacks from userspace drivers but not kernel drivers. In that case disabling secure ats for kernel drivers would avoid unnecessary cost of address audit.
That would be some specific iommufd/vfio policy IMHO
But really, if the device is being used by iommufd or not is well known by the admin, they could set the general ATS to secure prior to binding vfio and just be done with it. No need for more automation?
Jason
Quoted 11 lines
From: Jason Gunthorpe <[email protected]>
Sent: Thursday, March 6, 2025 1:22 AMQuoted 5 lines · Kevin
Probably we may also need separate policy between unmanaged and dma types. In some scenarios the user may care more about potential ATS attacks from userspace drivers but not kernel drivers. In that case disabling secure ats for kernel drivers would avoid unnecessary cost of address audit.
Quoted 6 lines
That would be some specific iommufd/vfio policy IMHO
But really, if the device is being used by iommufd or not is well known by the admin, they could set the general ATS to secure prior to binding vfio and just be done with it. No need for more automation?
Make sense.
Quoted 16 lines · Jason Gunthorpe
Quoted 6 lines · Yi Liu
Quoted 4 lines
ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
will it affect Baolu's above refactoring [1]? :(
I think no, but when we get some conclusion how ATS should work I'd expect all IOMMU drivers to align
Quoted 4 lines
Quoted 3 lines
never
always
paging-only
Quoted 5 lines
Quoted 2 lines
this can be considered policy to the existing ATS. curious, why paging domain is special here?
Using ATS with an IDENTITY translation is not a performance win, so you'd probably want to turn it off in that case.
got it. I see no value as well. :)
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerJason,
Quoted 14 lines · Jason Gunthorpe
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
Quoted 8 lines
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
Yes. If we are dong knob then we should support normal ATS as well.
Quoted 6 lines
never
always
paging-only
secure-always
secure-paging-only
Why not just expose supported modes (No ATS, ATS, Secure ATS) per group and allow admin to select within supported modes? We may have to add more logic in sysfs store/show code path. But user will know what is supported and what they can pick.
Also sysfs knob needs new domain ops to communicate changes to indivisual driver. Like in store path
- validate the input
- make sure driver is unbond so that its safe to modify the
- New ops to communicate to indivisual driver
something like ops->set_ats_mode(dev, mode)
-Vasant
Quoted 10 lines · Vasant Hegde
Quoted 5 lines
never
always
paging-only
secure-always
secure-paging-onlyWhy not just expose supported modes (No ATS, ATS, Secure ATS) per group and allow admin to select within supported modes? We may have to add more logic in sysfs store/show code path. But user will know what is supported and what they can pick.
A sysfs type thing is what I'm thinking
Just trying to understand what options we should be providing to userspace..
I am sensitive that we'd like to disble ATS for identity modes in many common cases and we get that implicitly today.
Quoted 6 lines
Also sysfs knob needs new domain ops to communicate changes to indivisual driver. Like in store path
- validate the input
- make sure driver is unbond so that its safe to modify the
- New ops to communicate to indivisual driversomething like ops->set_ats_mode(dev, mode)
Yeah this needs to be considered.. I wonder if a flags input to attach is the right way to go.
That would be convenient for how SMMUv3 is structued now as it can just switch modes hitlessly with its existing logic. I think all drivers should have a similar design.
Jason
Vasant Hegde
maintainerJason,
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Vasant Hegde
Quoted 5 lines
never
always
paging-only
secure-always
secure-paging-onlyWhy not just expose supported modes (No ATS, ATS, Secure ATS) per group and allow admin to select within supported modes? We may have to add more logic in sysfs store/show code path. But user will know what is supported and what they can pick.
Quoted 7 lines
A sysfs type thing is what I'm thinking
Just trying to understand what options we should be providing to userspace..
I am sensitive that we'd like to disble ATS for identity modes in many common cases and we get that implicitly today.
In default boot, we can keep existing behavior right?
May be add more logic to sysfs show/store path? Meaning calculate per device group supported options and expose only those. And in store path validate against supported options?
Quoted 10 lines
Quoted 7 lines
Also sysfs knob needs new domain ops to communicate changes to indivisual driver. Like in store path
- validate the input
- make sure driver is unbond so that its safe to modify the
- New ops to communicate to indivisual driversomething like ops->set_ats_mode(dev, mode)Yeah this needs to be considered.. I wonder if a flags input to attach is the right way to go.
You mean add flag to ops->attach_dev() ? That should work fine.
I said new ops because that would make updating existing domain/DTE becomes easy.
-Vasant
Quoted 6 lines
That would be convenient for how SMMUv3 is structued now as it can just switch modes hitlessly with its existing logic. I think all drivers should have a similar design.
Jason
Quoted 27 lines · Jason Gunthorpe
Quoted 10 lines · Vasant Hegde
Quoted 5 lines
never
always
paging-only
secure-always
secure-paging-onlyWhy not just expose supported modes (No ATS, ATS, Secure ATS) per group and allow admin to select within supported modes? We may have to add more logic in sysfs store/show code path. But user will know what is supported and what they can pick.
A sysfs type thing is what I'm thinking
Just trying to understand what options we should be providing to userspace..
I am sensitive that we'd like to disble ATS for identity modes in many common cases and we get that implicitly today.
Quoted 6 lines
Also sysfs knob needs new domain ops to communicate changes to indivisual driver. Like in store path
- validate the input
- make sure driver is unbond so that its safe to modify the
- New ops to communicate to indivisual driversomething like ops->set_ats_mode(dev, mode)
Quoted 2 lines
Yeah this needs to be considered.. I wonder if a flags input to attach is the right way to go.
Do we expect this flag to setup the SATS in the underlying iommu driver? If yes, I doubt if it is proper. My reason as below:
he reason is more for the #4 case you summarized in earlier mails of this thread. Such HWs need to map the PA in the DPT/HPT table when a given PA is mapped to IOVA. We may just hook the DPT/HPT map/unmap to the map/unmap of a paging domain. Hence it's better to determine if the DPT/HPT is desired per allocation. Otherwise it may requires upper layer to replay the mapping. e.g. iommufd replay the mappings stored in IOAS->iopt
" 4) TA is an full physical address and the IOMMU validates the full
physical using some kind of permission structure (ARM calls this Device Permission Table)
"
Quoted 4 lines
That would be convenient for how SMMUv3 is structued now as it can just switch modes hitlessly with its existing logic. I think all drivers should have a similar design.
I think this is more like we have done for the set_dev_pasid op. Now it supports replacing domain. But as I replied in above, add a flag in the attach op might not be a good idea.
Signature · 2 lines
Regards, Yi Liu
Quoted 4 lines · Yi Liu
" 4) TA is an full physical address and the IOMMU validates the full
physical using some kind of permission structure (ARM calls this Device Permission Table)
"
I think selecting the two kinds of secure ATS would be done with various flags and the DPT verions of it would only be selectable at allocation time..
Quoted 7 lines
Quoted 3 lines
That would be convenient for how SMMUv3 is structued now as it can just switch modes hitlessly with its existing logic. I think all drivers should have a similar design.
I think this is more like we have done for the
set_dev_pasidop. Now it supports replacing domain. But as I replied in above, add a flag in the attach op might not be a good idea.
Yes, you can't switch between DPT and non DPT modes hitlessly like this as those would need new domain allocations.
But it could hitlessly switch between secure mode enabled/disabled or ATS enabled/disabled without changing the active
struct iommu_domain *.
Jason
Quoted 41 lines · Vasant Hegde
Jason,
Quoted 14 lines · Jason Gunthorpe
Quoted 7 lines · Yi Liu
I'm also thinking about the impact of such a knob. How should we define this knob. Should we allow it to disable/enable ATS? Especially in runtime. e.g. if the device is identified to be ATS untrusted by the admin, while the hw does not support SATS, it seems reasonable to disable ATS for such device. This might change the driver behavior on ATS enabling. Intel iommu driver enables ATS as long as it's available in the
probe_device()op. What about AMD and ARM?ARM enables ATS when a PAGING translation is set on the RID or any PASID is used. Otherwise it is off, eg for RID = IDENTITY
This seems like a reasonable thing to do to me..
Quoted 8 lines
Quoted 5 lines
On the other hand, we may just define the knob as sats required or not. This is just a knob to let kernel know if the iommu driver needs to enable sats or not. While leave the ATS enabling policy unchanged. This means we need to probe the sats capability of iommu hw before creating the knob in sysfs.
If we add some ATS control knob then maybe it should be able to disable/enable normal ATS as well?
Yes. If we are dong knob then we should support normal ATS as well.
Quoted 6 lines
never
always
paging-only
secure-always
secure-paging-onlyWhy not just expose supported modes (No ATS, ATS, Secure ATS) per group and allow admin to select within supported modes? We may have to add more logic in sysfs store/show code path. But user will know what is supported and what they can pick.
Quoted 6 lines
Also sysfs knob needs new domain ops to communicate changes to indivisual driver. Like in store path
- validate the input
- make sure driver is unbond so that its safe to modify the
- New ops to communicate to indivisual driversomething like ops->set_ats_mode(dev, mode)
Perhaps marking it in the core level is enough. Any domain that is going to be used for this device should respect it. e.g. if admin change it to be requiring SATS, then the default_domain should be reallocated with a flag to indicate it.
Signature · 2 lines
Regards, Yi Liu
Vasant Hegde
maintainerHi Keven,
Quoted 45 lines · Kevin
Quoted 45 lines
From: Vasant Hegde <[email protected]>
Sent: Thursday, February 27, 2025 11:28 PMHi Kevin,
Quoted 9 lines · Kevin
Quoted 9 lines
From: Tian, Kevin
Sent: Wednesday, February 26, 2025 10:51 AMQuoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Wednesday, February 26, 2025 9:18 AMQuoted 2 lines · Kevin
If above understanding is true, my preference is to support a sats flag in domain alloc (
nested_parentonly and PCI/CXL.io only, as the start).For
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
AMD it turns on the sats bit in the DTE. for Intel/ARM the permission structure is created and updated according to the map/unmap calls on the parent S2.
They are functionally different things, and have different requirements on the PCI topologies supported (eg CXL.cache vs no CXL.cache)
Quoted 9 lines
Quoted 2 lines
I think they need to be different flags
Not exactly. They are functionally different but serving the same purpose to the user. From user p.o.v. it's sufficient to have a general flag for sats when allocating a domain. The underlying driver decides whether such flag is supported based on the domain type and the associated device, just like checks on other existing flags.
Chatted with Yi offline. Having untrusted user control a security feature doesn't make much sense. Probably what we really require is:
- IOMMU core exposes a separate sats knob per probed device, allowing the administrator to manage the sats policy which could be no ats, unsecure ats and secure ats (might be further set per domain type in case the hw doesn't support sats for all types or the driver doesn't support all hw-supported types in one batch).
Quoted 3 lines
Quoted 1 line
When you say "sats knob", you mean sysfs interface?
yes
That means root user can change it during runtime? And we have to expose supported combination per group (like noats, ats, secure ATS). Also runtime we have to update DTE (and intel case create new domain?) if we switch from ats to secure ATS.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
It's also checked against the device type e.x. CXL.cache.
- Then when enabling ats for a given domain type and device, follow the policy set by administrator: ats disabled, ats enabled as today, ats enabled with hw enforced security;
- Optionally iommufd may support a domain alloc flag for ats, which alone is a performance or functional dependency (by PRI), hence better to let the user opt. If opted, again follow the admin policy whether it's allowed and requires sats.
Is this way reasonable?
Quoted 8 lines
Quoted 3 lines
What I am really thinking is :
- If HW has a enforcement required (like AMD SNP case where Secure ATS is
must), enable secure ATS. But do we need some way to inform core layer?It's not conflicting. When enabling a trusted device the driver can detect whether sats has been opted in by admin for the device. If not fail the request. If yes, turn on secure ATS as part of enforcement and return
-EBUSYif the admin attempts to disable it in-fly.
Sorry. I am not sure if I get everything. When you say "admin" are you referring to system admin to make choice?
Quoted 5 lines
Quoted 3 lines
If yes,
may be have an domain ops similar todef_domain_type()?the domain for trusted I/O will have a special flag.
Right. we can pass special flag to domain allocation. But how does core layer know's about HW requirement?
Quoted 6 lines
Quoted 4 lines
- For untrusted devices, by default enforce Secure ATS (may be a domain
flag)or the admin may prefer to disabling ats.
Right.
Quoted 7 lines
Quoted 6 lines
- Have a command line option, so that if administrator wants to enforce
secure
ATS for all devices, he can do that.
Quoted 7 lines
whether to enable sats depends on various factors:
- is the device trusted?
- does the overhead of enabling sats break the perf requirement of the existing ats scenario?
- different security policy based on domain types, e.g. only requiring sats for iommufd but not default DMA API domain
Also HW restriction (Booted AMD system with SNP enabled).
Quoted 4 lines
- ...
A global cmdline option for all devices/domains is hard to meet those requirements.
We will have default policy and based on global option we can do enforcement. So that user wants global level enforcement he can do it.
-Vasant
Quoted 3 lines · Vasant Hegde
- If HW has a enforcement required (like AMD SNP case where Secure ATS is
must), enable secure ATS. But do we need some way to inform core layer? If yes, may be have an domain ops similar todef_domain_type()?
Yeah I think that is probably the best option, some kind of callback to the drive to check if a platform forced secure ATS is neccessary.
I assume if you need forced secure ATS then you also are disabling IDENTITY and disabling PASID?
Jason
Quoted 8 lines
From: Jason Gunthorpe <[email protected]>
Sent: Friday, February 28, 2025 10:57 PMQuoted 1 line · Vasant Hegde
- If HW has a enforcement required (like AMD SNP case where Secure ATS
is
Quoted 1 line
must), enable secure ATS. But do we need some way to inform core layer?
Quoted 9 lines
If yes,
Quoted 1 line
may be have an domain ops similar to
def_domain_type()?Yeah I think that is probably the best option, some kind of callback to the drive to check if a platform forced secure ATS is neccessary.
I assume if you need forced secure ATS then you also are disabling IDENTITY and disabling PASID?
Out of curiosity here. The host is untrusted in SNP case. What would happen if untrusted host disables secure ATS after SNP is enabled? Is the bit locked down once SNP is enabled?
Vasant Hegde
maintainerHi Kevin,
Quoted 14 lines · Kevin
Quoted 14 lines
From: Jason Gunthorpe <[email protected]>
Sent: Friday, February 28, 2025 10:57 PMQuoted 1 line · Vasant Hegde
- If HW has a enforcement required (like AMD SNP case where Secure ATS
is
Quoted 1 line
must), enable secure ATS. But do we need some way to inform core layer?
If yes,
Quoted 1 line
may be have an domain ops similar to
def_domain_type()?Yeah I think that is probably the best option, some kind of callback to the drive to check if a platform forced secure ATS is neccessary.
Quoted 6 lines
Quoted 3 lines
I assume if you need forced secure ATS then you also are disabling IDENTITY and disabling PASID?
Out of curiosity here. The host is untrusted in SNP case. What would happen if untrusted host disables secure ATS after SNP is enabled?
Once SNP is enabled, if host disabled Secure ATS for device , but keeps ATS ON, then IOMMU will log ILLEGAL DTE Entry.
-Vasant
Quoted 1 line
Is the bit locked down once SNP is enabled?
Quoted 23 lines
From: Vasant Hegde <[email protected]>
Sent: Monday, March 10, 2025 10:14 PMQuoted 6 lines · Kevin
Quoted 6 lines
From: Jason Gunthorpe <[email protected]>
Sent: Friday, February 28, 2025 10:57 PMQuoted 1 line · Vasant Hegde
- If HW has a enforcement required (like AMD SNP case where Secure
ATS
Quoted 12 lines
Quoted 11 lines
is
Quoted 1 line
must), enable secure ATS. But do we need some way to inform core layer?
If yes,
Quoted 1 line
may be have an domain ops similar to
def_domain_type()?Yeah I think that is probably the best option, some kind of callback to the drive to check if a platform forced secure ATS is neccessary.
I assume if you need forced secure ATS then you also are disabling IDENTITY and disabling PASID?
Quoted 7 lines
Quoted 2 lines
Out of curiosity here. The host is untrusted in SNP case. What would happen if untrusted host disables secure ATS after SNP is enabled?
Once SNP is enabled, if host disabled Secure ATS for device , but keeps ATS ON,
then IOMMU will log ILLEGAL DTE Entry.
Make sense.
Vasant Hegde
maintainerJason,
Quoted 11 lines · Jason Gunthorpe
Quoted 3 lines · Vasant Hegde
- If HW has a enforcement required (like AMD SNP case where Secure ATS is
must), enable secure ATS. But do we need some way to inform core layer? If yes, may be have an domain ops similar todef_domain_type()?Yeah I think that is probably the best option, some kind of callback to the drive to check if a platform forced secure ATS is neccessary.
I assume if you need forced secure ATS then you also are disabling IDENTITY and disabling PASID?
Right. Currently SNP is enabled only when IOMMU is in Host (v1) page table mode.
-Vasant
Vasant Hegde
maintainerHi Jason,
Quoted 14 lines · Jason Gunthorpe
Quoted 12 lines · Robin Murphy
Quoted 11 lines
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)Quoted 2 lines
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
Quoted 6 lines
Quoted 3 lines
Heh, and in SMMUv3 we have both options, with split-stage ATS for nested translation, and our Device Permission Table for full ATS, so it seems like there should be room for some kind of generalised capability.
Yes, lets not have another driver-only command line parameter but somthing global managed by the core code.
I was not aware that intel/ARM has similar feature. So introduced AMD specific option. Since everyone has similar feature, if it can be done in core layer and satisfy the requirement then yes we should do that.
Quoted 11 lines
What are the options here?
1) Translated Address (TA) is a full physical address and IOMMU does do anything (today)2) IOMMU converts a S1 IOVA into a TA as a S2 IOVA address and the IOMMU runs it through the S2 to validate it. (ARM calls this split-stage). Requires nesting
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
But in nested case, its slightly different. It would have finished guest page table walk and sends GPA to device. when DMA request comes it walks final page table (GPA -> SPA) again.
Quoted 4 lines
4) TA is an full physical address and the IOMMU validates the full physical using some kind of permission structure (ARM calls this Device Permission Table)
I this this is similar to RMP validation on AMD.
Quoted 7 lines
What are the three HWs doing?
I see #2 and #4 clearly in the SMM spec. Is #3 a special case of #2 (a STE with a S2 and S1DSS bypass)?
I think AMD is doing #3 from the docs.
yep.
Quoted 6 lines
What is Intel doing?
A domain alloc flag to put the domain into #3 mode seems like a good start to me. The core code can decide to activate the flag for the default domain. Suggest starting from
pci->untrusted.
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS
- Currently when SNP (Secure Nested Paging) is enabled, we have to enable
Secure ATS. So driver has to enforce.
Also what if user wants to enforce secure ATS for all devices? have kernel command line option?
-Vasant
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
But...
Quoted 3 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS
... here it says SVA/SATS are incompatible. Any more background?
Quoted 9 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Quoted 8 lines
Here 'signal non-present' implies to support PRI.
But...
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Yeah, +1. I don't know of use cases for #2/#3 without PRI. Why do you want it?
Jason
Quoted 11 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
Quoted 7 lines
But...
Quoted 3 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Wouldn't this case be SVA with non-secure ATS and still use PRI?
"In normal non-secure processing of PCIe ATS requests, the IOMMU performs a full address transla- tion and returns an SPA to the requesting device to be stored in that device's IOTLB."
Vasant Hegde
maintainerKevin, Jason,
Quoted 11 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
Quoted 7 lines
But...
Quoted 3 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
To support SVA (PASID/PRI), we have to configure domain with AMD Guest (v2) Page table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We can support secure ATS, but ATS response will contain the SPA.
-Vasant
Quoted 24 lines · Vasant Hegde
Kevin, Jason,
Quoted 11 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
Quoted 7 lines
But...
Quoted 3 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
Quoted 7 lines
To support SVA (PASID/PRI), we have to configure domain with AMD Guest (v2) Page table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We can support secure ATS, but ATS response will contain the SPA.
I see, that makes sense. The TA is not tagged with a PASID on the wire so no iommu can support the #2 form with PASID.
Jason
Quoted 32 lines
From: Jason Gunthorpe <[email protected]>
Sent: Friday, February 28, 2025 8:04 AMQuoted 17 lines · Vasant Hegde
Kevin, Jason,
Quoted 14 lines · Kevin
Quoted 8 lines
From: Vasant Hegde <[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 3 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
But...
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
To support SVA (PASID/PRI), we have to configure domain with AMD Guest
(v2) Page
Quoted 2 lines
table and host page table will not be set (DTE[Mode]=0).
Quoted 9 lines
Quoted 3 lines
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We
can
Quoted 1 line
support secure ATS, but ATS response will contain the SPA.
I see, that makes sense. The TA is not tagged with a PASID on the wire so no iommu can support the #2 form with PASID.
PCISIG has a ECN allowing translated request to include PASID. Just not sure any device has supported it.
Quoted 16 lines · Vasant Hegde
Quoted 5 lines · Kevin
Quoted 5 lines
From: Vasant Hegde<[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 2 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Quoted 8 lines
Quoted 1 line
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
But...
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
Quoted 7 lines
To support SVA (PASID/PRI), we have to configure domain with AMD Guest (v2) Page table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We can support secure ATS, but ATS response will contain the SPA.
So, the hardware is configured to work in secure ATS mode, but the ATS is not actually secure here, right? AMD's secure ATS relies on checking GPA to SPA translation; however, GPA is always equal to SPA in the SVA case.
Am I understanding this correctly?
Thanks,
baolu
Quoted 28 lines
From: Baolu Lu <[email protected]>
Sent: Friday, February 28, 2025 9:48 AMQuoted 9 lines · Vasant Hegde
Quoted 8 lines · Kevin
Quoted 6 lines
From: Vasant Hegde<[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 2 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
Quoted 8 lines
Quoted 5 lines
But...
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
To support SVA (PASID/PRI), we have to configure domain with AMD Guest
(v2) Page
Quoted 5 lines
table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We
can
Quoted 9 lines
Quoted 1 line
support secure ATS, but ATS response will contain the SPA.
So, the hardware is configured to work in secure ATS mode, but the ATS is not actually secure here, right? AMD's secure ATS relies on checking GPA to SPA translation; however, GPA is always equal to SPA in the SVA case.
Am I understanding this correctly?
Looks so.
To support secure ATS, the IOMMU needs a structure to manage the permission per the translated address (TA).
For #2 it reuses the S2 page table for permission track hence requires nesting and TA = S2 IOVA. It cannot support bare metal SVA given S2 is absent.
AMD is clearly this flavor. also supported by ARM.
For #3 it reuses the full translation (s1, s2, or nested) with TA = untranslated IOVA. This supposes to work with all existing ATS scenarios. Probably good for prototype development but no real value given it loses all perf benefit from ATS or even worse perf compared to no ats due to double walking.
Both #2/#3 have PCI topology restrictions e.g. CXL.
ARM probably supports #3 as a special case of #2.
For #4, it introduces a separate permission structure per real physical address, hence TA = physical address. It's supposed to work for all ATS scenarios and CXL, with some burden e.g. sync with IO page table plus more invalidations, etc.
Intel/ARM supports it.
Vasant Hegde
maintainerKevin,
Quoted 55 lines · Kevin
Quoted 28 lines
From: Baolu Lu <[email protected]>
Sent: Friday, February 28, 2025 9:48 AMQuoted 9 lines · Vasant Hegde
Quoted 8 lines · Kevin
Quoted 6 lines
From: Vasant Hegde<[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 2 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
Quoted 8 lines
Quoted 5 lines
But...
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
To support SVA (PASID/PRI), we have to configure domain with AMD Guest
(v2) Page
Quoted 5 lines
table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We
can
Quoted 9 lines
Quoted 1 line
support secure ATS, but ATS response will contain the SPA.
So, the hardware is configured to work in secure ATS mode, but the ATS is not actually secure here, right? AMD's secure ATS relies on checking GPA to SPA translation; however, GPA is always equal to SPA in the SVA case.
Am I understanding this correctly?
Looks so.
To support secure ATS, the IOMMU needs a structure to manage the permission per the translated address (TA).
For #2 it reuses the S2 page table for permission track hence requires nesting and TA = S2 IOVA. It cannot support bare metal SVA given S2 is absent.
AMD is clearly this flavor. also supported by ARM.
For #3 it reuses the full translation (s1, s2, or nested) with TA = untranslated IOVA. This supposes to work with all existing ATS scenarios. Probably good for prototype development but no real value given it loses all perf benefit from ATS or even worse perf compared to no ats due to double walking.
Quoted 8 lines
Both #2/#3 have PCI topology restrictions e.g. CXL.
ARM probably supports #3 as a special case of #2.
For #4, it introduces a separate permission structure per real physical address, hence TA = physical address. It's supposed to work for all ATS scenarios and CXL, with some burden e.g. sync with IO page table plus more invalidations, etc.
Nice Summary. #2 / #4 is practically useful scenario's.
-Vasant
Quoted 3 lines · Kevin
scenarios. Probably good for prototype development but no real value given it loses all perf benefit from ATS or even worse perf compared to no ats due to double walking.
ARM's docs noted they expect about the same IO performance between #3 and #4 methods. Both are walking tables to validate the TA. The main value of ATS here is not for performance but it supports a non-present result.
So I thik given the choice we should prefer #3 over #4.
You must switch to #4 for CXL/etc/etc.
Jason
Quoted 5 lines
From: Jason Gunthorpe <[email protected]>
Sent: Friday, February 28, 2025 10:53 PMOn Fri, Feb 28, 2025 at 06:15:32AM +0000, Tian, Kevin wrote:
Quoted 8 lines
Quoted 3 lines
scenarios. Probably good for prototype development but no real value given it loses all perf benefit from ATS or even worse perf compared to no ats due to double walking.
ARM's docs noted they expect about the same IO performance between #3 and #4 methods. Both are walking tables to validate the TA. The main value of ATS here is not for performance but it supports a non-present result.
Both are walking tables but the costs are not exactly same.
In concept #4 allows a more efficient table format to achieve a good tradeoff between performance and security - perf lower than unsecure ATS but higher than #3, with security enforced.
e.g. for VT-d the permission structure is a compacted format with each 64 bit PTE covering 16 pages, i.e. only 4 perm bits per page. So it's far less walks compared to walking a full nested I/O page tables, plus a dedicated cache.
Vasant Hegde
maintainerBaolu,
Quoted 25 lines · Baolu Lu
Quoted 16 lines · Vasant Hegde
Quoted 5 lines · Kevin
Quoted 5 lines
From: Vasant Hegde<[email protected]>
Sent: Wednesday, February 26, 2025 12:47 PMQuoted 2 lines
3) TA is an IOVA and the IOMMU runs it through the full translation to validate it. ATS is just used to signal non-present
Quoted 8 lines
Quoted 1 line
Yes. AMD does this when Host page table is configured.
Here 'signal non-present' implies to support PRI.
But...
Quoted 2 lines
We need to consider various scenarios. For AMD:
- Currently on baremetal, we cannot enable SVA and Secure ATS... here it says SVA/SATS are incompatible. Any more background?
Sorry. I should have explained it better.
Quoted 7 lines
To support SVA (PASID/PRI), we have to configure domain with AMD Guest (v2) Page table and host page table will not be set (DTE[Mode]=0).
GVA -> GPA contains translation and GPA = SPA.
On ATS request it will send GPA back to device (which is actually a SPA). We can support secure ATS, but ATS response will contain the SPA.
Quoted 6 lines
So, the hardware is configured to work in secure ATS mode, but the ATS is not actually secure here, right? AMD's secure ATS relies on checking GPA to SPA translation; however, GPA is always equal to SPA in the SVA case.
Am I understanding this correctly?
Right. This is how it works currently.
-Vasant
Vasant Hegde
maintainerHi Yi,
Quoted 10 lines · Yi Liu
Quoted 3 lines · Vasant Hegde
AMD IOMMU supports processing ATS requests as Secure ATS requests when IOTLB is supported and enabled (See section "2.11 Secure ATS Supports" in AMD IOMMU spec [1] for more detail).
glad to see it. I'm also working on Secure ATS for VT-d. Intel Secure ATS has an extra table named HPT (Host Permission Table) chapter 4.2.4 in revision 5.0 spec. IOMMU uses this table to check the address in the translated transactions to ensure the device has access permission.
Quoted 4 lines
We plan to support the HPT on S2 when nested translation is configured. But we may let the userspace VMM to decide if it wants SATS on specific device. The reason is that some devices might be considered as trusted. e.g. integrated devices.
Yeah. That's another option (ATS for trusted SoC devices and secure ATS for other devices).
Quoted 11 lines
My thought is to add a flag in
iommufd_hw_capabilitiesto report the capability, and add a flag iniommufd_hwpt_alloc_flagsto let iommu driver know if HPT is needed when allocating S2 domain. Userspace attaches the un-trusted devices to the domains with HPT. While trusted devices can be attached to 'normal' S2 domains. Will to send it out soon.:)Quoted 1 line
With Secure ATS, for ATS requests IOMMU return GPA to device instead of SPA.
I suppose AMD Secure ATS only works under nested translation configuration. is it? I guess admin may want some flexibility to opt-in it. :)
AMD Secure ATS works under 3 scenarios :
- Baremetal case w/ AMD Host (V1) page table (this include VFIO passthrough)
- HW Nested setup where both page table is configured
In above two setup, its opt-in feature
- SNP (Secure Nested Paging) is ON
Secure ATS is mandatory.
-Vasant