[PATCH] swiotlb: add a SWIOTLB_ANY flag to lift restricted low memory for encryption

Jun Miao posted 1 patch 9 months, 1 week ago
arch/x86/kernel/pci-dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] swiotlb: add a SWIOTLB_ANY flag to lift restricted low memory for encryption
Posted by Jun Miao 9 months, 1 week ago
TDX guest wants to allocate a swiotlb buffer that is not restricted
to low memory for the trusted hypervisor scheme. So that allow to pick
a location everywhere for hypervisors with guest memory encryption in
swiotlb_memblock_alloc() interface by adding a new flag.

Signed-off-by: Jun Miao <jun.miao@intel.com>
---
 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.43.0
RE: [PATCH] swiotlb: add a SWIOTLB_ANY flag to lift restricted low memory for encryption
Posted by Miao, Jun 9 months ago
Hi maintainers and Big shot,
I would like to further explain my original intention:
The purpose is to solve the problem found by customers when inserting 8 NVMe disks - There will be a swiotlb buffer full warning. 
When CONFIG_SWIOTLB_DYNAMIC is turned on, it is impossible to allocate more than 2G swiotlb buffer to meet the actual high throughput usage requirements. 

Warm regards
Jun Miao
>
>TDX guest wants to allocate a swiotlb buffer that is not restricted to low memory
>for the trusted hypervisor scheme. So that allow to pick a location everywhere for
>hypervisors with guest memory encryption in
>swiotlb_memblock_alloc() interface by adding a new flag.
>
>Signed-off-by: Jun Miao <jun.miao@intel.com>
>---
> 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.43.0