Message ID | 20220301105311.885699-9-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/12] dma-direct: use is_swiotlb_active in dma_direct_map_page | expand |
On 01/03/2022 10:53, Christoph Hellwig wrote: > diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c > index 2ac0ef9c2fb76..7ab7002758396 100644 > --- a/arch/x86/kernel/pci-dma.c > +++ b/arch/x86/kernel/pci-dma.c > @@ -53,6 +53,13 @@ static void __init pci_swiotlb_detect(void) > if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) > x86_swiotlb_enable = true; > > + /* > + * Guest with guest memory encryption must always do I/O through a > + * bounce buffer as the hypervisor can't access arbitrary VM memory. This isn't really "must". The guest is perfectly capable of sharing memory with the hypervisor. It's just that for now, bounce buffering is allegedly faster, and the simple way of getting it working. ~Andrew
On Tue, Mar 01, 2022 at 11:39:29AM +0000, Andrew Cooper wrote: > This isn't really "must". The guest is perfectly capable of sharing > memory with the hypervisor. > > It's just that for now, bounce buffering is allegedly faster, and the > simple way of getting it working. Yeah, I guess you щould just share/unshare on demand. But given that this isn't implemented it is a must in the current kernel. But if you want a different wording suggest one and I'll put it in.
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 5a99f993e6392..568274917f1cd 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -336,14 +336,6 @@ static void __init ms_hyperv_init_platform(void) swiotlb_unencrypted_base = ms_hyperv.shared_gpa_boundary; #endif } - -#ifdef CONFIG_SWIOTLB - /* - * Enable swiotlb force mode in Isolation VM to - * use swiotlb bounce buffer for dma transaction. - */ - swiotlb_force = SWIOTLB_FORCE; -#endif } if (hv_max_functions_eax >= HYPERV_CPUID_NESTED_FEATURES) { diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index 2ac0ef9c2fb76..7ab7002758396 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -53,6 +53,13 @@ static void __init pci_swiotlb_detect(void) if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) x86_swiotlb_enable = true; + /* + * Guest with guest memory encryption must always do I/O through a + * bounce buffer as the hypervisor can't access arbitrary VM memory. + */ + if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) + swiotlb_force = SWIOTLB_FORCE; + if (swiotlb_force == SWIOTLB_FORCE) x86_swiotlb_enable = true; } diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c index 2b2d018ea3450..a72942d569cf9 100644 --- a/arch/x86/mm/mem_encrypt_amd.c +++ b/arch/x86/mm/mem_encrypt_amd.c @@ -191,9 +191,6 @@ void __init sme_early_init(void) /* Update the protection map with memory encryption mask */ for (i = 0; i < ARRAY_SIZE(protection_map); i++) protection_map[i] = pgprot_encrypted(protection_map[i]); - - if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) - swiotlb_force = SWIOTLB_FORCE; } void __init sev_setup_arch(void)
Move enabling SWIOTLB_FORCE for guest memory encryption into common code. Signed-off-by: Christoph Hellwig <hch@lst.de> --- arch/x86/kernel/cpu/mshyperv.c | 8 -------- arch/x86/kernel/pci-dma.c | 7 +++++++ arch/x86/mm/mem_encrypt_amd.c | 3 --- 3 files changed, 7 insertions(+), 11 deletions(-)