Re: [PATCH V2] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables

2019-04-08 Thread Yu Zhao
On Mon, Apr 08, 2019 at 03:22:38PM +0100, Will Deacon wrote: > On Tue, Apr 02, 2019 at 10:04:30AM +0100, Will Deacon wrote: > > On Mon, Apr 01, 2019 at 12:34:25PM -0600, Yu Zhao wrote: > > > On Mon, Apr 01, 2019 at 05:16:38PM +0100, Will Deacon wrote: > > > > [+KVM/ARM folks, since I can't take

Re: [kvm-unit-tests PATCH] lib: arm: Use correct halt() prototype from smp.h

2019-04-08 Thread Sean Christopherson
On Mon, Apr 08, 2019 at 04:11:25PM +0100, Alexandru Elisei wrote: > The prototype for the halt() function is incorrect, because halt() doesn't > take any arguments. Fix it by using the prototype from smp.h. > > Signed-off-by: Alexandru Elisei > --- Reviewed-by: Sean Christopherson

Re: [PATCH v8 4/9] KVM: arm/arm64: preserve host HCR_EL2 value

2019-04-08 Thread Kristina Martsenko
On 08/04/2019 14:05, Amit Daniel Kachhap wrote: > Hi James, > > On 4/6/19 4:07 PM, James Morse wrote: >> Hi Amit, >> >> On 02/04/2019 03:27, Amit Daniel Kachhap wrote: >>> From: Mark Rutland >>> >>> When restoring HCR_EL2 for the host, KVM uses HCR_HOST_VHE_FLAGS, which >>> is a constant value.

Re: [PATCH] kvm: arm: Skip stage2 huge mappings for unaligned ipa backed by THP

2019-04-08 Thread Suzuki K Poulose
Hi Zenhui, On 04/08/2019 04:11 PM, Zenghui Yu wrote: Hi Suzuki, Thanks for the reply. ... Hi Suzuki, Why not making use of fault_supports_stage2_huge_mapping()?  Let it do some checks for us. fault_supports_stage2_huge_mapping() was intended to do a *two-step* check to tell us that can

Re: [PATCH] kvm: arm: Skip stage2 huge mappings for unaligned ipa backed by THP

2019-04-08 Thread Zenghui Yu
Hi Suzuki, Thanks for the reply. On 2019/4/8 18:35, Suzuki K Poulose wrote: On 04/08/2019 04:50 AM, Zenghui Yu wrote: On 2019/4/2 19:06, Suzuki K Poulose wrote: With commit a80868f398554842b14, we no longer ensure that the THP page is properly aligned in the guest IPA. Skip the stage2 huge

[kvm-unit-tests PATCH] lib: arm: Use correct halt() prototype from smp.h

2019-04-08 Thread Alexandru Elisei
The prototype for the halt() function is incorrect, because halt() doesn't take any arguments. Fix it by using the prototype from smp.h. Signed-off-by: Alexandru Elisei --- lib/arm/io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/arm/io.c b/lib/arm/io.c index

Re: [PATCH V2] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables

2019-04-08 Thread Will Deacon
On Tue, Apr 02, 2019 at 10:04:30AM +0100, Will Deacon wrote: > On Mon, Apr 01, 2019 at 12:34:25PM -0600, Yu Zhao wrote: > > On Mon, Apr 01, 2019 at 05:16:38PM +0100, Will Deacon wrote: > > > [+KVM/ARM folks, since I can't take this without an Ack in place from > > > them] > > > > > > My

Re: [PATCH v8 4/9] KVM: arm/arm64: preserve host HCR_EL2 value

2019-04-08 Thread Amit Daniel Kachhap
Hi James, On 4/6/19 4:07 PM, James Morse wrote: Hi Amit, On 02/04/2019 03:27, Amit Daniel Kachhap wrote: From: Mark Rutland When restoring HCR_EL2 for the host, KVM uses HCR_HOST_VHE_FLAGS, which is a constant value. This works today, as the host HCR_EL2 value is always the same, but this

[PATCH v7 21/23] vfio_pci: Allow to mmap the fault queue

2019-04-08 Thread Eric Auger
The Producer Fault region contains the fault queue in the second page. There is benefit to let the userspace mmap this area. So let's expose this mmappable area through a sparse mmap entry and implement the mmap operation. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 61

[PATCH v7 22/23] vfio-pci: Add VFIO_PCI_DMA_FAULT_IRQ_INDEX

2019-04-08 Thread Eric Auger
Add a new VFIO_PCI_DMA_FAULT_IRQ_INDEX index. This allows to set/unset an eventfd that will be triggered when DMA translation faults are detected at physical level when the nested mode is used. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 3 +++

[PATCH v7 17/23] iommu/smmuv3: Implement bind/unbind_guest_msi

2019-04-08 Thread Eric Auger
The bind/unbind_guest_msi() callbacks check the domain is NESTED and redirect to the dma-iommu implementation. Signed-off-by: Eric Auger --- v6 -> v7: - remove device handle argument --- drivers/iommu/arm-smmu-v3.c | 43 + 1 file changed, 43 insertions(+)

[PATCH v7 19/23] vfio-pci: Add a new VFIO_REGION_TYPE_NESTED region type

2019-04-08 Thread Eric Auger
This patch adds two new regions aiming to handle nested mode translation faults. The first region (two host kernel pages) is read-only from the user-space perspective. The first page contains an header that provides information about the circular buffer located in the second page. The circular

[PATCH v7 20/23] vfio-pci: Register an iommu fault handler

2019-04-08 Thread Eric Auger
This patch registers a fault handler which records faults in a circular buffer and then signals an eventfd. This buffer is exposed within the fault region. Signed-off-by: Eric Auger --- v3 -> v4: - move iommu_unregister_device_fault_handler to vfio_pci_release --- drivers/vfio/pci/vfio_pci.c

[PATCH v7 18/23] iommu/smmuv3: Report non recoverable faults

2019-04-08 Thread Eric Auger
When a stage 1 related fault event is read from the event queue, let's propagate it to potential external fault listeners, ie. users who registered a fault handler. Signed-off-by: Eric Auger --- v4 -> v5: - s/IOMMU_FAULT_PERM_INST/IOMMU_FAULT_PERM_EXEC --- drivers/iommu/arm-smmu-v3.c | 169

[PATCH v7 11/23] iommu/arm-smmu-v3: Maintain a SID->device structure

2019-04-08 Thread Eric Auger
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 136 ++-- 1 file

[PATCH v7 12/23] iommu/smmuv3: Get prepared for nested stage support

2019-04-08 Thread Eric Auger
To allow nested stage support, we need to store both stage 1 and stage 2 configurations (and remove the former union). A nested setup is characterized by both s1_cfg and s2_cfg set. We introduce a new ste.abort field that will be set upon guest stage1 configuration passing. If s1_cfg is NULL and

[PATCH v7 14/23] iommu/smmuv3: Implement cache_invalidate

2019-04-08 Thread Eric Auger
Implement domain-selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v6 -> v7 - check the uapi version v3 -> v4: - adapt to changes in the uapi - add support for leaf parameter - do not use arm_smmu_tlb_inv_range_nosync or arm_smmu_tlb_inv_context anymore v2 ->

[PATCH v7 13/23] iommu/smmuv3: Implement attach/detach_pasid_table

2019-04-08 Thread Eric Auger
On attach_pasid_table() we program STE S1 related info set by the guest into the actual physical STEs. At minimum we need to program the context descriptor GPA and compute whether the stage1 is translated/bypassed or aborted. Signed-off-by: Eric Auger --- v6 -> v7: - check versions and comment

[PATCH v7 15/23] dma-iommu: Implement NESTED_MSI cookie

2019-04-08 Thread Eric Auger
Up to now, when the type was UNMANAGED, we used to allocate IOVA pages within a reserved IOVA MSI range. If both the host and the guest are exposed with SMMUs, each would allocate an IOVA. The guest allocates an IOVA (gIOVA) to map onto the guest MSI doorbell (gDB). The Host allocates another

[PATCH v7 16/23] iommu/smmuv3: Nested mode single MSI doorbell per domain enforcement

2019-04-08 Thread Eric Auger
In nested mode we enforce the rule that all devices belonging to the same iommu_domain share the same msi_domain. Indeed if there were several physical MSI doorbells being used within a single iommu_domain, it becomes really difficult to resolve the nested stage mapping translating into the

[PATCH v7 10/23] iommu/arm-smmu-v3: Link domains and devices

2019-04-08 Thread Eric Auger
From: Jean-Philippe Brucker When removing a mapping from a domain, we need to send an invalidation to all devices that might have stored it in their Address Translation Cache (ATC). In addition with SVM, we'll need to invalidate context descriptors of all devices attached to a live domain.

[PATCH v7 08/23] vfio: VFIO_IOMMU_CACHE_INVALIDATE

2019-04-08 Thread Eric Auger
From: "Liu, Yi L" When the guest "owns" the stage 1 translation structures, the host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation requests are trapped and passed down to the host. This patch adds the VFIO_IOMMU_CACHE_INVALIDATE ioctl with aims at

[PATCH v7 03/23] iommu: introduce device fault report API

2019-04-08 Thread Eric Auger
From: Jacob Pan Traditionally, device specific faults are detected and handled within their own device drivers. When IOMMU is enabled, faults such as DMA related transactions are detected by IOMMU. There is no generic reporting mechanism to report faults back to the in-kernel device driver or

[PATCH v7 06/23] iommu: Introduce bind/unbind_guest_msi

2019-04-08 Thread Eric Auger
On ARM, MSI are translated by the SMMU. An IOVA is allocated for each MSI doorbell. If both the host and the guest are exposed with SMMUs, we end up with 2 different IOVAs allocated by each. guest allocates an IOVA (gIOVA) to map onto the guest MSI doorbell (gDB). The Host allocates another IOVA

[PATCH v7 07/23] vfio: VFIO_IOMMU_ATTACH/DETACH_PASID_TABLE

2019-04-08 Thread Eric Auger
From: "Liu, Yi L" This patch adds VFIO_IOMMU_ATTACH/DETACH_PASID_TABLE ioctl which aims to pass/withdraw the virtual iommu guest configuration to/from the VFIO driver downto to the iommu subsystem. Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --- v6 -> v7: -

[PATCH v7 05/23] iommu: Introduce cache_invalidate API

2019-04-08 Thread Eric Auger
From: "Liu, Yi L" In any virtualization use case, when the first translation stage is "owned" by the guest OS, the host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation activities are trapped by the virtualizer and passed down to the host. Since the

[PATCH v7 04/23] iommu: Introduce attach/detach_pasid_table API

2019-04-08 Thread Eric Auger
From: Jacob Pan In virtualization use case, when a guest is assigned a PCI host device, protected by a virtual IOMMU on the guest, the physical IOMMU must be programmed to be consistent with the guest mappings. If the physical IOMMU supports two translation stages it makes sense to program guest

[PATCH v7 02/23] iommu: introduce device fault data

2019-04-08 Thread Eric Auger
From: Jacob Pan Device faults detected by IOMMU can be reported outside the IOMMU subsystem for further processing. This patch introduces a generic device fault data structure. The fault can be either an unrecoverable fault or a page request, also referred to as a recoverable fault. We only

[PATCH v7 00/23] SMMUv3 Nested Stage Setup

2019-04-08 Thread Eric Auger
This series allows a virtualizer to program the nested stage mode. This is useful when both the host and the guest are exposed with an SMMUv3 and a PCI device is assigned to the guest using VFIO. In this mode, the physical IOMMU must be programmed to translate the two stages: the one set up by

[PATCH v7 01/23] driver core: add per device iommu param

2019-04-08 Thread Eric Auger
From: Jacob Pan DMA faults can be detected by IOMMU at device level. Adding a pointer to struct device allows IOMMU subsystem to report relevant faults back to the device driver for further handling. For direct assigned device (or user space drivers), guest OS holds responsibility to handle and

Re: [PATCH] kvm: arm: Skip stage2 huge mappings for unaligned ipa backed by THP

2019-04-08 Thread Suzuki K Poulose
On 04/08/2019 04:50 AM, Zenghui Yu wrote: On 2019/4/2 19:06, Suzuki K Poulose wrote: With commit a80868f398554842b14, we no longer ensure that the THP page is properly aligned in the guest IPA. Skip the stage2 huge mapping for unaligned IPA backed by transparent hugepages. Fixes:

Re: [PATCH V2] KVM: ARM: Remove pgtable page standard functions from stage-2 page tables

2019-04-08 Thread Marc Zyngier
On 01/04/2019 17:16, Will Deacon wrote: > [+KVM/ARM folks, since I can't take this without an Ack in place from them] > > My understanding is that this patch is intended to replace patch 3/4 in > this series: > > http://lists.infradead.org/pipermail/linux-arm-kernel/2019-March/638083.html > >

Re: [PATCH v8 8/9] KVM: arm64: Add capability to advertise ptrauth for guest

2019-04-08 Thread Amit Daniel Kachhap
Hi, On 4/5/19 4:33 PM, Dave Martin wrote: On Tue, Apr 02, 2019 at 07:57:16AM +0530, Amit Daniel Kachhap wrote: This patch advertises the capability of two cpu feature called address pointer authentication and generic pointer authentication. These capabilities depend upon system support for

Re: [kvmtool PATCH v8 9/9] KVM: arm/arm64: Add a vcpu feature for pointer authentication

2019-04-08 Thread Amit Daniel Kachhap
Hi Dave, On 4/5/19 4:34 PM, Dave Martin wrote: On Tue, Apr 02, 2019 at 07:57:17AM +0530, Amit Daniel Kachhap wrote: This is a runtime capabality for KVM tool to enable Arm64 8.3 Pointer Authentication in guest kernel. Two vcpu features KVM_ARM_VCPU_PTRAUTH_[ADDRESS/GENERIC] are supplied