[PATCH v3] x86/pci-dma: add a SWIOTLB_ANY flag to lift the low mem limitation

Jun Miao posted 1 patch 1 month, 2 weeks ago
arch/x86/kernel/pci-dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v3] x86/pci-dma: add a SWIOTLB_ANY flag to lift the low mem limitation
Posted by Jun Miao 1 month, 2 weeks ago
Intel TDX guest wants to allocate a swiotlb buffer that is not restricted to
low memory for the trusted hypervisor scheme.  Adding a new flag will be used
in swiotlb_memblock_alloc() to allow allocation of SWIOTLB memory beyond low 
memory restriction.

Power SVM already supports this, but X86 still faces the same limitation.
Commit: 8ba2ed1be9 (swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction)

Reviewed-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
Tested-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
Signed-off-by: Jun Miao <jun.miao@intel.com>
---

V1 -> V2:
1.Updated commit message and description.
2.Add Reviewed and Tested.

V1 Latest Feedback : https://lists.openwall.net/linux-kernel/2026/02/11/483

v2 -> v3:
We can alloc 4GB with the dynamic swiotlb, rather than 1GB.
1G is not correct. So change the commit log.

---
 arch/x86/kernel/pci-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 6267363e0189..73b9320c4a7d 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -61,7 +61,7 @@ static void __init pci_swiotlb_detect(void)
 	 */
 	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
 		x86_swiotlb_enable = true;
-		x86_swiotlb_flags |= SWIOTLB_FORCE;
+		x86_swiotlb_flags |= SWIOTLB_ANY | SWIOTLB_FORCE;
 	}
 }
 #else
-- 
2.47.1
Re: [PATCH v3] x86/pci-dma: add a SWIOTLB_ANY flag to lift the low mem limitation
Posted by Marek Szyprowski 1 month, 2 weeks ago
On 12.02.2026 10:37, Jun Miao wrote:
> Intel TDX guest wants to allocate a swiotlb buffer that is not restricted to
> low memory for the trusted hypervisor scheme.  Adding a new flag will be used
> in swiotlb_memblock_alloc() to allow allocation of SWIOTLB memory beyond low
> memory restriction.
>
> Power SVM already supports this, but X86 still faces the same limitation.
> Commit: 8ba2ed1be9 (swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction)
>
> Reviewed-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
> Tested-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
> Signed-off-by: Jun Miao <jun.miao@intel.com>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>
> V1 -> V2:
> 1.Updated commit message and description.
> 2.Add Reviewed and Tested.
>
> V1 Latest Feedback : https://protect2.fireeye.com/v1/url?k=f35668f3-92dd7dc5-f357e3bc-74fe485cbff1-e6ff63e2f942f6a7&q=1&e=66eee4e1-a18d-47f9-ad21-f3dfab1d6f09&u=https%3A%2F%2Flists.openwall.net%2Flinux-kernel%2F2026%2F02%2F11%2F483
>
> v2 -> v3:
> We can alloc 4GB with the dynamic swiotlb, rather than 1GB.
> 1G is not correct. So change the commit log.
>
> ---
>   arch/x86/kernel/pci-dma.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
> index 6267363e0189..73b9320c4a7d 100644
> --- a/arch/x86/kernel/pci-dma.c
> +++ b/arch/x86/kernel/pci-dma.c
> @@ -61,7 +61,7 @@ static void __init pci_swiotlb_detect(void)
>   	 */
>   	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
>   		x86_swiotlb_enable = true;
> -		x86_swiotlb_flags |= SWIOTLB_FORCE;
> +		x86_swiotlb_flags |= SWIOTLB_ANY | SWIOTLB_FORCE;
>   	}
>   }
>   #else

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland
RE: [PATCH v3] x86/pci-dma: add a SWIOTLB_ANY flag to lift the low mem limitation
Posted by Miao, Jun 2 weeks, 1 day ago
Hi Marek 
Thanks a lot for the ACK on the swiotlb. 
It is very important to confirm the functionality. I really appreciate your review @ Marek

Maybe x86 maintainers would also like to hear your thoughts on this, especially since architectures like powerpc already have support for this. 
Any additional feedback or suggestions on X86 might have would be greatly appreciated.

Best regards,
Jun Miao

>On 12.02.2026 10:37, Jun Miao wrote:
>> Intel TDX guest wants to allocate a swiotlb buffer that is not
>> restricted to low memory for the trusted hypervisor scheme.  Adding a
>> new flag will be used in swiotlb_memblock_alloc() to allow allocation
>> of SWIOTLB memory beyond low memory restriction.
>>
>> Power SVM already supports this, but X86 still faces the same limitation.
>> Commit: 8ba2ed1be9 (swiotlb: add a SWIOTLB_ANY flag to lift the low
>> memory restriction)
>>
>> Reviewed-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
>> Tested-by: Aakarsh Jain <aakarsh.jain@oss.qualcomm.com>
>> Signed-off-by: Jun Miao <jun.miao@intel.com>
>
>Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
>> ---
>>
>> V1 -> V2:
>> 1.Updated commit message and description.
>> 2.Add Reviewed and Tested.
>>
>> V1 Latest Feedback :
>> https://protect2.fireeye.com/v1/url?k=f35668f3-92dd7dc5-f357e3bc-74fe4
>> 85cbff1-e6ff63e2f942f6a7&q=1&e=66eee4e1-a18d-47f9-ad21-
>f3dfab1d6f09&u=
>> https%3A%2F%2Flists.openwall.net%2Flinux-
>kernel%2F2026%2F02%2F11%2F483
>>
>> v2 -> v3:
>> We can alloc 4GB with the dynamic swiotlb, rather than 1GB.
>> 1G is not correct. So change the commit log.
>>
>> ---
>>   arch/x86/kernel/pci-dma.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
>> index 6267363e0189..73b9320c4a7d 100644
>> --- a/arch/x86/kernel/pci-dma.c
>> +++ b/arch/x86/kernel/pci-dma.c
>> @@ -61,7 +61,7 @@ static void __init pci_swiotlb_detect(void)
>>   	 */
>>   	if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
>>   		x86_swiotlb_enable = true;
>> -		x86_swiotlb_flags |= SWIOTLB_FORCE;
>> +		x86_swiotlb_flags |= SWIOTLB_ANY | SWIOTLB_FORCE;
>>   	}
>>   }
>>   #else
>
>Best regards
>--
>Marek Szyprowski, PhD
>Samsung R&D Institute Poland