Re: [PATCH v11 10/12] vduse: Implement an MMU-based software IOTLB

2021-08-27 Thread John Garry
On 18/08/2021 13:06, Xie Yongji wrote: + +static dma_addr_t +vduse_domain_alloc_iova(struct iova_domain *iovad, + unsigned long size, unsigned long limit) +{ + unsigned long shift = iova_shift(iovad); + unsigned long iova_len = iova_align(iovad, size) >> shift; +

Re: [PATCH v11 01/12] iova: Export alloc_iova_fast() and free_iova_fast()

2021-08-27 Thread John Garry
On 25/08/2021 13:17, Yongji Xie wrote: JFYI, There was a preliminary discussion to move the iova rcache code (which the iova fast alloc and free functions are based on) out of the iova code and maybe into dma-iommu (being the only user). There was other motivation. Would it be better to move th

Re: [PATCH v11 10/12] vduse: Implement an MMU-based software IOTLB

2021-08-27 Thread Yongji Xie
On Fri, Aug 27, 2021 at 4:53 PM John Garry wrote: > > On 18/08/2021 13:06, Xie Yongji wrote: > > + > > +static dma_addr_t > > +vduse_domain_alloc_iova(struct iova_domain *iovad, > > + unsigned long size, unsigned long limit) > > +{ > > + unsigned long shift = iova_shift(iov

Re: [PATCH 2/2] iommu/vt-d: Fix a deadlock in SVM

2021-08-27 Thread Lu Baolu
Hi Fenghua, On 2021/8/27 5:59, Fenghua Yu wrote: pasid_mutex and dev->iommu->param->lock are held while unbinding mm is flushing IO page fault workqueue and waiting for all page fault works to finish. But an in-flight page fault work also need to hold the two locks while unbinding mm are holding

Re: [PATCH 1/2] iommu/vt-d: Fix PASID leak

2021-08-27 Thread Lu Baolu
Hi Fenghua, On 2021/8/27 5:59, Fenghua Yu wrote: mm->pasid will be used in intel_svm_free_pasid() after load_pasid() during unbinding mm. Clearing it in load_pasid() will cause PASID cannot be freed in intel_svm_free_pasid(). Additionally mm->pasid was updated already before load_pasid() during

[PATCH v4 12/14] reboot: Secure Launch SEXIT support on reboot paths

2021-08-27 Thread Ross Philipson
If the MLE kernel is being powered off, rebooted or halted, then SEXIT must be called. Note that the SEXIT GETSEC leaf can only be called after a machine_shutdown() has been done on these paths. The machine_shutdown() is not called on a few paths like when poweroff action does not have a poweroff c

[PATCH v4 10/14] x86: Secure Launch SMP bringup support

2021-08-27 Thread Ross Philipson
On Intel, the APs are left in a well documented state after TXT performs the late launch. Specifically they cannot have #INIT asserted on them so a standard startup via INIT/SIPI/SIPI cannot be performed. Instead the early SL stub code parked the APs in a pause/jmp loop waiting for an NMI. The modi

[PATCH v4 11/14] kexec: Secure Launch kexec SEXIT support

2021-08-27 Thread Ross Philipson
Prior to running the next kernel via kexec, the Secure Launch code closes down private SMX resources and does an SEXIT. This allows the next kernel to start normally without any issues starting the APs etc. Signed-off-by: Ross Philipson --- arch/x86/kernel/slaunch.c | 71

[PATCH v4 06/14] x86: Secure Launch main header file

2021-08-27 Thread Ross Philipson
Introduce the main Secure Launch header file used in the early SL stub and the early setup code. Signed-off-by: Ross Philipson --- include/linux/slaunch.h | 532 1 file changed, 532 insertions(+) create mode 100644 include/linux/slaunch.h diff -

[PATCH v4 03/14] x86/boot: Place kernel_info at a fixed offset

2021-08-27 Thread Ross Philipson
From: Arvind Sankar There are use cases for storing the offset of a symbol in kernel_info. For example, the trenchboot series [0] needs to store the offset of the Measured Launch Environment header in kernel_info. Since commit (note: commit ID from tip/master) 527afc212231 ("x86/boot: Check t

[PATCH v4 07/14] x86: Add early SHA support for Secure Launch early measurements

2021-08-27 Thread Ross Philipson
From: "Daniel P. Smith" The SHA algorithms are necessary to measure configuration information into the TPM as early as possible before using the values. This implementation uses the established approach of #including the SHA libraries directly in the code since the compressed kernel is not uncomp

[PATCH v4 02/14] x86/boot: Add setup_indirect support in early_memremap_is_setup_data

2021-08-27 Thread Ross Philipson
The x86 boot documentation describes the setup_indirect structures and how they are used. Only one of the two functions in ioremap.c that needed to be modified to be aware of the introduction of setup_indirect functionality was updated. This adds comparable support to the other function where it wa

[PATCH v4 05/14] x86: Secure Launch Kconfig

2021-08-27 Thread Ross Philipson
Initial bits to bring in Secure Launch functionality. Add Kconfig options for compiling in/out the Secure Launch code. Signed-off-by: Ross Philipson --- arch/x86/Kconfig | 32 1 file changed, 32 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig inde

[PATCH v4 04/14] Documentation/x86: Secure Launch kernel documentation

2021-08-27 Thread Ross Philipson
Introduce background, overview and configuration/ABI information for the Secure Launch kernel feature. Signed-off-by: Daniel P. Smith Signed-off-by: Ross Philipson --- Documentation/x86/index.rst | 1 + Documentation/x86/secure-launch.rst | 716 2

[PATCH v4 01/14] x86/boot: Fix memremap of setup_indirect structures

2021-08-27 Thread Ross Philipson
As documented, the setup_indirect structure is nested inside the setup_data structures in the setup_data list. The code currently accesses the fields inside the setup_indirect structure but only the sizeof(struct setup_data) is being memremapped. No crash occured but this is just due to how the are

[PATCH v4 13/14] x86: Secure Launch late initcall platform module

2021-08-27 Thread Ross Philipson
From: "Daniel P. Smith" The Secure Launch platform module is a late init module. During the init call, the TPM event log is read and measurements taken in the early boot stub code are located. These measurements are extended into the TPM PCRs using the mainline TPM kernel driver. The platform mo

[PATCH v4 14/14] tpm: Allow locality 2 to be set when initializing the TPM for Secure Launch

2021-08-27 Thread Ross Philipson
The Secure Launch MLE environment uses PCRs that are only accessible from the DRTM locality 2. By default the TPM drivers always initialize the locality to 0. When a Secure Launch is in progress, initialize the locality to 2. Signed-off-by: Ross Philipson --- drivers/char/tpm/tpm-chip.c | 9

[PATCH v4 00/14] x86: Trenchboot secure dynamic launch Linux kernel support

2021-08-27 Thread Ross Philipson
The larger focus of the Trechboot project (https://github.com/TrenchBoot) is to enhance the boot security and integrity in a unified manner. The first area of focus has been on the Trusted Computing Group's Dynamic Launch for establishing a hardware Root of Trust for Measurement, also know as DRTM

[PATCH v4 08/14] x86: Secure Launch kernel early boot stub

2021-08-27 Thread Ross Philipson
The Secure Launch (SL) stub provides the entry point for Intel TXT (and later AMD SKINIT) to vector to during the late launch. The symbol sl_stub_entry is that entry point and its offset into the kernel is conveyed to the launching code using the MLE (Measured Launch Environment) header in the stru

[PATCH v4 09/14] x86: Secure Launch kernel late boot stub

2021-08-27 Thread Ross Philipson
The routine slaunch_setup is called out of the x86 specific setup_arch routine during early kernel boot. After determining what platform is present, various operations specific to that platform occur. This includes finalizing setting for the platform late launch and verifying that memory protection

Re: [PATCH v4 14/14] tpm: Allow locality 2 to be set when initializing the TPM for Secure Launch

2021-08-27 Thread Jason Gunthorpe
On Fri, Aug 27, 2021 at 09:28:37AM -0400, Ross Philipson wrote: > The Secure Launch MLE environment uses PCRs that are only accessible from > the DRTM locality 2. By default the TPM drivers always initialize the > locality to 0. When a Secure Launch is in progress, initialize the > locality to 2. >

[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 directly

[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-off

[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 and

[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 shared

[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/hv

[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 with hyp

[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 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 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 b

[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. T

[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. T

[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 is above

[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 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 these m

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

2021-08-27 Thread Greg KH
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: >* Change vmbus_teardown_gpadl() parameter and put gpadl ha

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

2021-08-27 Thread Greg KH
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. > Hyperv requires to write SINTx MSR

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:

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. Hyperv

[PATCH -next v3 2/2] iommu/arm-smmu-v3: Add suspend and resume support

2021-08-27 Thread Bixuan Cui
Add suspend and resume support for arm-smmu-v3 by low-power mode. When the smmu is suspended, it is powered off and the registers are cleared. So saves the msi_msg context during msi interrupt initialization of smmu. When resume happens it calls arm_smmu_device_reset() to restore the registers. S

[PATCH -next v3 1/2] platform-msi: Save the msg context to desc in platform_msi_write_msg()

2021-08-27 Thread Bixuan Cui
Save the msg context to desc when the msi interrupt is requested. The drivers can use it in special scenarios(such as resume). Signed-off-by: Bixuan Cui --- drivers/base/platform-msi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.