Re: [PATCH V4 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-06 Thread Tianyu Lan
On 12/5/2021 6:31 PM, Juergen Gross wrote: On 05.12.21 09:48, Tianyu Lan wrote: On 12/5/2021 4:34 PM, Juergen Gross wrote: On 05.12.21 09:18, Tianyu Lan wrote: From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable

Re: [PATCH V4 1/5] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-12-06 Thread Tianyu Lan
On 12/6/2021 10:09 PM, Christoph Hellwig wrote: Please spell swiotlb with a lower case s. Otherwise this look good Acked-by: Christoph Hellwig Feel free to carry this in whatever tree is suitable for the rest of the patches. Sure. Thanks for your ack and will update "swiotlb" in the next

Re: [PATCH V4 2/5] x86/hyper-v: Add hyperv Isolation VM check in the cc_platform_has()

2021-12-06 Thread Tianyu Lan
Hi Christoph: Thanks for your review. On 12/6/2021 10:06 PM, Christoph Hellwig wrote: On Sun, Dec 05, 2021 at 03:18:10AM -0500, Tianyu Lan wrote: +static bool hyperv_cc_platform_has(enum cc_attr attr) +{ +#ifdef CONFIG_HYPERV + return attr == CC_ATTR_GUEST_MEM_ENCRYPT; +#else

Re: [PATCH V4 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-05 Thread Tianyu Lan
On 12/5/2021 4:34 PM, Juergen Gross wrote: On 05.12.21 09:18, Tianyu Lan wrote: From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM

[PATCH V4 5/5] hv_netvsc: Add Isolation VM support for netvsc driver

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH V4 4/5] scsi: storvsc: Add Isolation VM support for storvsc driver

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(scsi_dma_map/unmap

[PATCH V4 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH V4 1/5] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH V4 0/5] x86/Hyper-V: Add Hyper-V Isolation VM support(Second part)

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

[PATCH V4 2/5] x86/hyper-v: Add hyperv Isolation VM check in the cc_platform_has()

2021-12-05 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides Isolation VM which has memory encrypt support. Add hyperv_cc_platform_has() and return true for check of GUEST_MEM_ENCRYPT attribute. Signed-off-by: Tianyu Lan --- Change since v3: * Change code style of checking GUEST_MEM attribute

Re: [PATCH V3 5/5] hv_netvsc: Add Isolation VM support for netvsc driver

2021-12-03 Thread Tianyu Lan
On 12/4/2021 2:59 AM, Michael Kelley (LINUX) wrote: + +/* + * hv_map_memory - map memory to extra space in the AMD SEV-SNP Isolation VM. + */ +void *hv_map_memory(void *addr, unsigned long size) +{ + unsigned long *pfns = kcalloc(size / HV_HYP_PAGE_SIZE, This should be just PAGE_SIZE, as

Re: [PATCH V3 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-03 Thread Tianyu Lan
On 12/4/2021 3:17 AM, Michael Kelley (LINUX) wrote: +static void __init hyperv_iommu_swiotlb_init(void) +{ + unsigned long hyperv_io_tlb_size; + void *hyperv_io_tlb_start; + + /* +* Allocate Hyper-V swiotlb bounce buffer at early place +* to reserve large

Re: [PATCH V3 1/5] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-12-03 Thread Tianyu Lan
On 12/4/2021 4:06 AM, Tom Lendacky wrote: Hi Tom:    Thanks for your test. Could you help to test the following patch and check whether it can fix the issue. The patch is mangled. Is the only difference where set_memory_decrypted() is called? I de-mangled the patch. No more stack

Re: [PATCH V3 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-03 Thread Tianyu Lan
On 12/2/2021 10:43 PM, Wei Liu wrote: On Wed, Dec 01, 2021 at 11:02:54AM -0500, Tianyu Lan wrote: [...] diff --git a/arch/x86/xen/pci-swiotlb-xen.c b/arch/x86/xen/pci-swiotlb-xen.c index 46df59aeaa06..30fd0600b008 100644 --- a/arch/x86/xen/pci-swiotlb-xen.c +++ b/arch/x86/xen/pci-swiotlb-xen.c

Re: [PATCH V3 2/5] x86/hyper-v: Add hyperv Isolation VM check in the cc_platform_has()

2021-12-03 Thread Tianyu Lan
On 12/2/2021 10:39 PM, Wei Liu wrote: +static bool hyperv_cc_platform_has(enum cc_attr attr) +{ +#ifdef CONFIG_HYPERV + if (attr == CC_ATTR_GUEST_MEM_ENCRYPT) + return true; + else + return false; This can be simplified as return attr ==

Re: [PATCH V3 1/5] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-12-03 Thread Tianyu Lan
On 12/2/2021 10:42 PM, Tom Lendacky wrote: On 12/1/21 10:02 AM, Tianyu Lan wrote: From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID

[PATCH V3 4/5] scsi: storvsc: Add Isolation VM support for storvsc driver

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(scsi_dma_map/unmap

[PATCH V3 5/5] hv_netvsc: Add Isolation VM support for netvsc driver

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH V3 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH V3 1/5] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH V3 2/5] x86/hyper-v: Add hyperv Isolation VM check in the cc_platform_has()

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides Isolation VM which has memory encrypt support. Add hyperv_cc_platform_has() and return true for check of GUEST_MEM_ENCRYPT attribute. Signed-off-by: Tianyu Lan --- arch/x86/kernel/cc_platform.c | 15 +++ 1 file changed, 15 insertions(+) diff

[PATCH V3 0/5] x86/Hyper-V: Add Hyper-V Isolation VM support(Second part)

2021-12-01 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

Re: [PATCH 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-26 Thread Tianyu Lan
On 11/26/2021 3:40 PM, Christoph Hellwig wrote: On Wed, Nov 17, 2021 at 10:00:08PM +0800, Tianyu Lan wrote: On 11/17/2021 6:01 PM, Christoph Hellwig wrote: This doesn't really have much to do with normal DMA mapping, so why does this direct through the dma ops? According to the previous

Re: [PATCH V2 1/6] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-11-24 Thread Tianyu Lan
Hi Michael: Thanks for your review. On 11/24/2021 1:15 AM, Michael Kelley (LINUX) wrote: @@ -172,7 +200,14 @@ void __init swiotlb_update_mem_attributes(void) vaddr = phys_to_virt(mem->start); bytes = PAGE_ALIGN(mem->nslabs << IO_TLB_SHIFT);

[PATCH V2 5/6] net: netvsc: Add Isolation VM support for netvsc driver

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH V2 6/6] scsi: storvsc: Add Isolation VM support for storvsc driver

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(scsi_dma_map/unmap

[PATCH V2 4/6] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH V2 3/6] x86/hyper-v: Add hyperv Isolation VM check in the cc_platform_has()

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides Isolation VM which has memory encrypt support. Add hyperv_cc_platform_has() and return true for check of GUEST_MEM_ENCRYPT attribute. Signed-off-by: Tianyu Lan --- arch/x86/kernel/cc_platform.c | 15 +++ 1 file changed, 15 insertions(+) diff

[PATCH V2 1/6] Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH V2 2/6] dma-mapping: Add vmap/vunmap_noncontiguous() callback in dma ops

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan Hyper-V netvsc driver needs to allocate noncontiguous DMA memory and remap it into unencrypted address space before sharing with host. Add vmap/vunmap_noncontiguous() callback and handle the remap in the Hyper-V dma ops callback. Signed-off-by: Tianyu Lan --- include/linux

[PATCH V2 0/6] x86/Hyper-V: Add Hyper-V Isolation VM support(Second part)

2021-11-23 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

Re: [PATCH 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-19 Thread Tianyu Lan
On 11/17/2021 10:00 PM, Tianyu Lan wrote: On 11/17/2021 6:01 PM, Christoph Hellwig wrote: This doesn't really have much to do with normal DMA mapping, so why does this direct through the dma ops? According to the previous discussion, dma_alloc_noncontigous() and dma_vmap_noncontiguous() may

Re: [PATCH 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-17 Thread Tianyu Lan
On 11/17/2021 6:01 PM, Christoph Hellwig wrote: This doesn't really have much to do with normal DMA mapping, so why does this direct through the dma ops? According to the previous discussion, dma_alloc_noncontigous() and dma_vmap_noncontiguous() may be used to handle the noncontigous memory

Re: [PATCH 1/5] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-11-17 Thread Tianyu Lan
Hi Christoph: Thanks for your review. On 11/17/2021 5:59 PM, Christoph Hellwig wrote: The subject is wrong, nothing x86-specific here. Please use "swiotlb: " as the prefix OK. Will update. Thanks. + * @vaddr: The vaddr of the swiotlb memory pool. The swiotlb + *

Re: [PATCH 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-17 Thread Tianyu Lan
On 11/17/2021 3:12 AM, Borislav Petkov wrote: What you should do, instead, is add an isol. VM specific hv_cc_platform_has() just like amd_cc_platform_has() and handle the cc_attrs there for your platform, like return false for CC_ATTR_GUEST_MEM_ENCRYPT and then you won't need to add that hv_*

[PATCH 5/5] scsi: storvsc: Add Isolation VM support for storvsc driver

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(scsi_dma_map/unmap

[PATCH 4/5] net: netvsc: Add Isolation VM support for netvsc driver

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH 3/5] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH 1/5] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH 2/5] dma-mapping: Add vmap/vunmap_noncontiguous() callback in dma ops

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan Hyper-V netvsc driver needs to allocate noncontiguous DMA memory and remap it into unencrypted address space before sharing with host. Add vmap/vunmap_noncontiguous() callback and handle the remap in the Hyper-V dma ops callback. Signed-off-by: Tianyu Lan --- include/linux

[PATCH 0/5] x86/Hyper-V: Add Hyper-V Isolation VM support(Second part)

2021-11-16 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-28 Thread Tianyu Lan
On 9/28/2021 1:39 PM, Christoph Hellwig wrote: On Mon, Sep 27, 2021 at 10:26:43PM +0800, Tianyu Lan wrote: Hi Christoph: Gentile ping. The swiotlb and shared memory mapping changes in this patchset needs your reivew. Could you have a look? > I'm a little too busy for a rev

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-27 Thread Tianyu Lan
Hi Christoph: Gentile ping. The swiotlb and shared memory mapping changes in this patchset needs your reivew. Could you have a look? Thanks. On 9/22/2021 6:34 PM, Tianyu Lan wrote: Hi Christoph:     This patch follows your purposal in the previous discussion. Could you have a look

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-22 Thread Tianyu Lan
chael Kelley wrote: From: Tianyu Lan Sent: Tuesday, September 14, 2021 6:39 AM In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() s

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-16 Thread Tianyu Lan
On 9/16/2021 12:21 AM, Michael Kelley wrote: I think you are proposing this approach to allocating memory for the send and receive buffers so that you can avoid having two virtual mappings for the memory, per comments from Christop Hellwig. But overall, the approach seems a bit complex and I

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-16 Thread Tianyu Lan
On 9/16/2021 12:46 AM, Haiyang Zhang wrote: + memset(vmap_pages, 0, + sizeof(*vmap_pages) * vmap_page_index); + vmap_page_index = 0; + + for (j = 0; j < i; j++) +

Re: [PATCH V5 09/12] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-09-16 Thread Tianyu Lan
On 9/15/2021 11:42 PM, Michael Kelley wrote: @@ -196,13 +199,34 @@ static void swiotlb_init_io_tlb_mem(struct io_tlb_mem *mem, phys_addr_t start, mem->slots[i].orig_addr = INVALID_PHYS_ADDR; mem->slots[i].alloc_size = 0; } + + if

Re: [PATCH V5 07/12] Drivers: hv: vmbus: Add SNP support for VMbus channel initiate message

2021-09-16 Thread Tianyu Lan
On 9/15/2021 11:41 PM, Michael Kelley wrote: diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 42f3d9d123a1..560cba916d1d 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -240,6 +240,8 @@ struct vmbus_connection { * is child->parent

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-09-14 Thread Tianyu Lan
Hi Michael and Christoph: I just sent out V5 patchset. I use alloc_pages() to allocate rx/tx ring buffer in Isolation VM and use vmap() to map rx/tx buffer first because the vmbus_establish_gpadl() still needs to va of low end memory to initialize gpadl buffer. After calling

[PATCH V5 08/12] Drivers: hv : vmbus: Initialize VMbus ring buffer for Isolation VM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan VMbus ring buffer are shared with host and it's need to be accessed via extra address space of Isolation VM with AMD SNP support. This patch is to map the ring buffer address in extra address space via vmap_pfn(). Hyperv set memory host visibility hvcall smears data in the ring

[PATCH V5 09/12] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH V5 11/12] scsi: storvsc: Add Isolation VM support for storvsc driver

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(scsi_dma_map/unmap

[PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH V5 10/12] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH V5 07/12] Drivers: hv: vmbus: Add SNP support for VMbus channel initiate message

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan The monitor pages in the CHANNELMSG_INITIATE_CONTACT msg are shared with host in Isolation VM and so it's necessary to use hvcall to set them visible to host. In Isolation VM with AMD SEV SNP, the access address should be in the extra space which is above shared gpa boundary. So

[PATCH V5 06/12] x86/hyperv: Add ghcb hvcall support for SNP VM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan hyperv provides ghcb hvcall to handle VMBus HVCALL_SIGNAL_EVENT and HVCALL_POST_MESSAGE msg in SNP Isolation VM. Add such support. Signed-off-by: Tianyu Lan --- Change since v3: * Add hv_ghcb_hypercall() stub function to avoid compile error for ARM. --- arch

[PATCH V5 05/12] x86/hyperv: Add Write/Read MSR registers via ghcb page

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Hyperv provides GHCB protocol to write Synthetic Interrupt Controller MSR registers in Isolation VM with AMD SEV SNP and these registers are emulated by hypervisor directly. Hyperv requires to write SINTx MSR registers twice. First writes MSR via GHCB page to communicate

[PATCH V5 04/12] Drivers: hv: vmbus: Mark vmbus ring buffer visible to host in Isolation VM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Mark vmbus ring buffer visible with set_memory_decrypted() when establish gpadl handle. Signed-off-by: Tianyu Lan --- Change sincv v4 * Change gpadl handle in netvsc and uio driver from u32 to struct vmbus_gpadl. * Change vmbus_establish_gpadl()'s

[PATCH V5 03/12] x86/hyperv: Add new hvcall guest address host visibility support

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Add new hvcall guest address host visibility support to mark memory visible to host. Call it inside set_memory_decrypted /encrypted(). Add HYPERVISOR feature check in the hv_is_isolation_supported() to optimize in non-virtualization environment. Acked-by: Dave Hansen Signed

[PATCH V5 02/12] x86/hyperv: Initialize shared memory boundary in the Isolation VM.

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Hyper-V exposes shared memory boundary via cpuid HYPERV_CPUID_ISOLATION_CONFIG and store it in the shared_gpa_boundary of ms_hyperv struct. This prepares to share memory with host for SNP guest. Signed-off-by: Tianyu Lan --- Change since v4: * Rename reserve field

[PATCH V5 01/12] x86/hyperv: Initialize GHCB page in Isolation VM

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Hyperv exposes GHCB page via SEV ES GHCB MSR for SNP guest to communicate with hypervisor. Map GHCB page for all cpus to read/write MSR register and submit hvcall request via ghcb page. Signed-off-by: Tianyu Lan --- Change since v4: * Fix typo comment Chagne since v3

[PATCH V5 00/12] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-09-14 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

Re: [PATCH V4 08/13] hyperv/vmbus: Initialize VMbus ring buffer for Isolation VM

2021-09-02 Thread Tianyu Lan
On 9/2/2021 8:23 AM, Michael Kelley wrote: + } else { + pages_wraparound = kcalloc(page_cnt * 2 - 1, + sizeof(struct page *), + GFP_KERNEL); + + pages_wraparound[0] = pages; +

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-09-02 Thread Tianyu Lan
On 9/2/2021 3:59 PM, Christoph Hellwig wrote: On Tue, Aug 31, 2021 at 05:16:19PM +, Michael Kelley wrote: As a quick overview, I think there are four places where the shared_gpa_boundary must be applied to adjust the guest physical address that is used. Each requires mapping a

Re: [PATCH V4 02/13] x86/hyperv: Initialize shared memory boundary in the Isolation VM.

2021-09-02 Thread Tianyu Lan
Hi Michael: Thanks for your review. On 9/2/2021 8:15 AM, Michael Kelley wrote: From: Tianyu Lan Sent: Friday, August 27, 2021 10:21 AM Hyper-V exposes shared memory boundary via cpuid HYPERV_CPUID_ISOLATION_CONFIG and store it in the shared_gpa_boundary of ms_hyperv struct

Re: [PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-08-31 Thread Tianyu Lan
Hi Christoph: On 8/30/2021 8:00 PM, Christoph Hellwig wrote: Sorry for the delayed answer, but I look at the vmap_pfn usage in the previous version and tried to come up with a better version. This mostly untested branch:

Re: [PATCH V4 05/13] hyperv: Add Write/Read MSR registers via ghcb page

2021-08-27 Thread Tianyu Lan
On 8/28/2021 1:41 AM, Greg KH wrote: On Fri, Aug 27, 2021 at 01:21:03PM -0400, Tianyu Lan wrote: From: Tianyu Lan Hyperv provides GHCB protocol to write Synthetic Interrupt Controller MSR registers in Isolation VM with AMD SEV SNP and these registers are emulated by hypervisor directly

Re: [PATCH V4 04/13] hyperv: Mark vmbus ring buffer visible to host in Isolation VM

2021-08-27 Thread Tianyu Lan
Hi Greg: Thanks for your review. On 8/28/2021 1:41 AM, Greg KH wrote: On Fri, Aug 27, 2021 at 01:21:02PM -0400, Tianyu Lan wrote: From: Tianyu Lan Mark vmbus ring buffer visible with set_memory_decrypted() when establish gpadl handle. Signed-off-by: Tianyu Lan --- Change since v3

[PATCH V4 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary

[PATCH V4 13/13] hv_storvsc: Add Isolation VM support for storvsc driver

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still needs to be handled. Use DMA API(dma_map_sg) to map

[PATCH V4 12/13] hv_netvsc: Add Isolation VM support for netvsc driver

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() stills need to be handled. Use DMA API to map/umap these memory

[PATCH V4 11/13] hyperv/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan hyperv Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which

[PATCH V4 09/13] DMA: Add dma_map_decrypted/dma_unmap_encrypted() function

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan In Hyper-V Isolation VM with AMD SEV, swiotlb boucne buffer needs to be mapped into address space above vTOM and so introduce dma_map_decrypted/dma_unmap_encrypted() to map/unmap bounce buffer memory. The platform can populate man/unmap callback in the dma memory decrypted ops

[PATCH V4 08/13] hyperv/vmbus: Initialize VMbus ring buffer for Isolation VM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan VMbus ring buffer are shared with host and it's need to be accessed via extra address space of Isolation VM with AMD SNP support. This patch is to map the ring buffer address in extra address space via vmap_pfn(). Hyperv set memory host visibility hvcall smears data in the ring

[PATCH V4 07/13] hyperv/Vmbus: Add SNP support for VMbus channel initiate message

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan The monitor pages in the CHANNELMSG_INITIATE_CONTACT msg are shared with host in Isolation VM and so it's necessary to use hvcall to set them visible to host. In Isolation VM with AMD SEV SNP, the access address should be in the extra space which is above shared gpa boundary. So

[PATCH V4 06/13] hyperv: Add ghcb hvcall support for SNP VM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan hyperv provides ghcb hvcall to handle VMBus HVCALL_SIGNAL_EVENT and HVCALL_POST_MESSAGE msg in SNP Isolation VM. Add such support. Signed-off-by: Tianyu Lan --- Change since v3: * Add hv_ghcb_hypercall() stub function to avoid compile error for ARM. --- arch

[PATCH V4 05/13] hyperv: Add Write/Read MSR registers via ghcb page

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Hyperv provides GHCB protocol to write Synthetic Interrupt Controller MSR registers in Isolation VM with AMD SEV SNP and these registers are emulated by hypervisor directly. Hyperv requires to write SINTx MSR registers twice. First writes MSR via GHCB page to communicate

[PATCH V4 04/13] hyperv: Mark vmbus ring buffer visible to host in Isolation VM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Mark vmbus ring buffer visible with set_memory_decrypted() when establish gpadl handle. Signed-off-by: Tianyu Lan --- Change since v3: * Change vmbus_teardown_gpadl() parameter and put gpadl handle, buffer and buffer size in the struct vmbus_gpadl. --- drivers

[PATCH V4 03/13] x86/hyperv: Add new hvcall guest address host visibility support

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Add new hvcall guest address host visibility support to mark memory visible to host. Call it inside set_memory_decrypted /encrypted(). Add HYPERVISOR feature check in the hv_is_isolation_supported() to optimize in non-virtualization environment. Acked-by: Dave Hansen Signed

[PATCH V4 02/13] x86/hyperv: Initialize shared memory boundary in the Isolation VM.

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Hyper-V exposes shared memory boundary via cpuid HYPERV_CPUID_ISOLATION_CONFIG and store it in the shared_gpa_boundary of ms_hyperv struct. This prepares to share memory with host for SNP guest. Signed-off-by: Tianyu Lan --- Change since v3: * user BIT_ULL to get

[PATCH V4 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

[PATCH V4 01/13] x86/hyperv: Initialize GHCB page in Isolation VM

2021-08-27 Thread Tianyu Lan
From: Tianyu Lan Hyperv exposes GHCB page via SEV ES GHCB MSR for SNP guest to communicate with hypervisor. Map GHCB page for all cpus to read/write MSR register and submit hvcall request via ghcb page. Signed-off-by: Tianyu Lan --- Chagne since v3: * Rename ghcb_base to hv_ghcb_pg

Re: [PATCH V3 12/13] HV/Netvsc: Add Isolation VM support for netvsc driver

2021-08-20 Thread Tianyu Lan
On 8/20/2021 2:14 AM, Michael Kelley wrote: @@ -477,6 +521,15 @@ static int netvsc_init_buf(struct hv_device *device, goto cleanup; } + if (hv_isolation_type_snp()) { + vaddr = netvsc_remap_buf(net_device->send_buf, buf_size); + if

Re: [PATCH V3 13/13] HV/Storvsc: Add Isolation VM support for storvsc driver

2021-08-20 Thread Tianyu Lan
On 8/21/2021 12:08 AM, Michael Kelley wrote: } The whole approach here is to do dma remapping on each individual page of the I/O buffer. But wouldn't it be possible to use dma_map_sg() to map each scatterlist entry as a unit? Each scatterlist entry describes a range of physically

Re: [PATCH V3 13/13] HV/Storvsc: Add Isolation VM support for storvsc driver

2021-08-20 Thread Tianyu Lan
On 8/20/2021 12:32 PM, h...@lst.de wrote: On Thu, Aug 19, 2021 at 06:17:40PM +, Michael Kelley wrote: +#define storvsc_dma_map(dev, page, offset, size, dir) \ + dma_map_page(dev, page, offset, size, dir) + +#define storvsc_dma_unmap(dev, dma_range, dir) \ +

Re: [PATCH V3 13/13] HV/Storvsc: Add Isolation VM support for storvsc driver

2021-08-20 Thread Tianyu Lan
On 8/20/2021 11:20 PM, Tianyu Lan wrote: The whole approach here is to do dma remapping on each individual page of the I/O buffer.  But wouldn't it be possible to use dma_map_sg() to map each scatterlist entry as a unit?  Each scatterlist entry describes a range of physically contiguous

Re: [PATCH V3 13/13] HV/Storvsc: Add Isolation VM support for storvsc driver

2021-08-20 Thread Tianyu Lan
On 8/20/2021 2:17 AM, Michael Kelley wrote: From: Tianyu Lan Sent: Monday, August 9, 2021 10:56 AM Subject line tag should be "scsi: storvsc:" In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it f

Re: [PATCH V3 12/13] HV/Netvsc: Add Isolation VM support for netvsc driver

2021-08-20 Thread Tianyu Lan
On 8/20/2021 12:21 PM, h...@lst.de wrote: On Thu, Aug 19, 2021 at 06:14:51PM +, Michael Kelley wrote: + if (!pfns) + return NULL; + + for (i = 0; i < size / HV_HYP_PAGE_SIZE; i++) + pfns[i] = virt_to_hvpfn(buf + i * HV_HYP_PAGE_SIZE) +

Re: [PATCH V3 11/13] HV/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-08-20 Thread Tianyu Lan
On 8/20/2021 2:11 AM, Michael Kelley wrote: } + +/* + * hv_map_memory - map memory to extra space in the AMD SEV-SNP Isolation VM. + */ +void *hv_map_memory(void *addr, unsigned long size) +{ + unsigned long *pfns = kcalloc(size / HV_HYP_PAGE_SIZE, +

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-19 Thread Tianyu Lan
On 8/19/2021 6:02 PM, Christoph Hellwig wrote: On Thu, Aug 19, 2021 at 05:59:02PM +0800, Tianyu Lan wrote: On 8/19/2021 4:49 PM, Christoph Hellwig wrote: On Mon, Aug 16, 2021 at 10:50:26PM +0800, Tianyu Lan wrote: Hi Christoph: Sorry to bother you.Please double check with these two

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-19 Thread Tianyu Lan
On 8/19/2021 4:49 PM, Christoph Hellwig wrote: On Mon, Aug 16, 2021 at 10:50:26PM +0800, Tianyu Lan wrote: Hi Christoph: Sorry to bother you.Please double check with these two patches " [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM" and

Re: [PATCH V3 08/13] HV/Vmbus: Initialize VMbus ring buffer for Isolation VM

2021-08-17 Thread Tianyu Lan
On 8/17/2021 1:28 AM, Michael Kelley wrote: This patch does the following: 1) The existing ring buffer wrap-around mapping functionality is still executed in hv_ringbuffer_init() when not doing SNP isolation. This mapping is based on an array of struct page's that describe the contiguous

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-16 Thread Tianyu Lan
On 8/14/2021 1:58 AM, Tianyu Lan wrote: On 8/12/2021 8:27 PM, Christoph Hellwig wrote: This is still broken.  You need to make sure the actual DMA allocations do have struct page backing. Hi Christoph: swiotlb_tbl_map_single() still returns PA below vTOM/share_gpa_ > bound

Re: [PATCH V3 04/13] HV: Mark vmbus ring buffer visible to host in Isolation VM

2021-08-15 Thread Tianyu Lan
On 8/13/2021 6:20 AM, Michael Kelley wrote: @@ -474,6 +482,13 @@ static int __vmbus_establish_gpadl(struct vmbus_channel *channel, if (ret) return ret; + ret = set_memory_decrypted((unsigned long)kbuffer, + HVPFN_UP(size)); +

Re: [PATCH V3 02/13] x86/HV: Initialize shared memory boundary in the Isolation VM.

2021-08-14 Thread Tianyu Lan
On 8/13/2021 3:18 AM, Michael Kelley wrote: From: Tianyu Lan Sent: Monday, August 9, 2021 10:56 AM Subject: [PATCH V3 02/13] x86/HV: Initialize shared memory boundary in the Isolation VM. As with Patch 1, use the "x86/hyperv:" tag in the Subject line. From: Tianyu Lan Hyper

Re: [PATCH V3 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-13 Thread Tianyu Lan
On 8/12/2021 8:27 PM, Christoph Hellwig wrote: This is still broken. You need to make sure the actual DMA allocations do have struct page backing. Hi Christoph: swiotlb_tbl_map_single() still returns PA below vTOM/share_gpa_ boundary. These PAs has backing pages and belong to system

Re: [Resend RFC PATCH V4 09/13] x86/Swiotlb/HV: Add Swiotlb bounce buffer remap function for HV IVM

2021-08-13 Thread Tianyu Lan
Hi Christoph: I followed your this suggestion to rework the latest version(https://lkml.org/lkml/2021/8/9/805). I just remove the arch prefix from your suggested name arch_dma_map_decrypted because the platform may populate their map/umap callback in the ops. But from your latest

Re: [PATCH V3 01/13] x86/HV: Initialize GHCB page in Isolation VM

2021-08-13 Thread Tianyu Lan
Hi Michael: Thanks for your review. On 8/13/2021 3:14 AM, Michael Kelley wrote: From: Tianyu Lan Sent: Monday, August 9, 2021 10:56 AM Subject: [PATCH V3 01/13] x86/HV: Initialize GHCB page in Isolation VM The subject line tag on patches under arch/x86/hyperv is generally "x86/h

Re: [PATCH V3 09/13] DMA: Add dma_map_decrypted/dma_unmap_encrypted() function

2021-08-12 Thread Tianyu Lan
On 8/12/2021 8:26 PM, Christoph Hellwig wrote: On Mon, Aug 09, 2021 at 01:56:13PM -0400, Tianyu Lan wrote: From: Tianyu Lan In Hyper-V Isolation VM with AMD SEV, swiotlb boucne buffer needs to be mapped into address space above vTOM and so introduce dma_map_decrypted/dma_unmap_encrypted

Re: [PATCH V3 03/13] x86/HV: Add new hvcall guest address host visibility support

2021-08-10 Thread Tianyu Lan
On 8/10/2021 6:12 AM, Dave Hansen wrote: On 8/9/21 10:56 AM, Tianyu Lan wrote: From: Tianyu Lan Add new hvcall guest address host visibility support to mark memory visible to host. Call it inside set_memory_decrypted /encrypted(). Add HYPERVISOR feature check in the hv_is_isolation_supported

  1   2   3   >