Re: [PATCH v4 7/7] iommu/virtio: Add event queue

2018-11-15 Thread Auger Eric
Hi Jean, On 11/15/18 5:52 PM, Jean-Philippe Brucker wrote: > The event queue offers a way for the device to report access faults from > endpoints. It is implemented on virtqueue #1. Whenever the host needs to > signal a fault, it fills one of the buffers offered by the guest and > interrupts it.

Re: [PATCH v4 5/7] iommu: Add virtio-iommu driver

2018-11-15 Thread Auger Eric
Hi Jean, On 11/15/18 5:52 PM, Jean-Philippe Brucker wrote: > The virtio IOMMU is a para-virtualized device, allowing to send IOMMU > requests such as map/unmap over virtio transport without emulating page > tables. This implementation handles ATTACH, DETACH, MAP and UNMAP > requests. > > The

Re:Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread peng.hao2
>> >> When virtual machine starts, hang up. The kernel version of guest >> is 4.16. Host support vgic_v3. >> It was mainly due to the incorrect vgic_irq's(intid=27) group value >> during injection interruption. when kvm_vgic_vcpu_init is called, >> dist is not initialized at this time. Unable to

Re:Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread peng.hao2
>Hi, >> When virtual machine starts, hang up. > >I take it you mean the *guest* hangs? Because it doesn't get a timer >interrupt? > >> The kernel version of guest >> is 4.16. Host support vgic_v3. > >Your host kernel is something recent, I guess? > >> It was mainly due to the incorrect

Re: [PATCH 4/4] arm64: KVM: Enable support for :G/:H perf event modifiers

2018-11-15 Thread Andrew Murray
On Thu, Nov 15, 2018 at 02:00:39PM +, Julien Thierry wrote: > Hi Andrew, > > On 15/11/18 12:55, Andrew Murray wrote: > > Enable/disable event counters as appropriate when entering and exiting > > the guest to enable support for guest or host only event counting. > > > > For both VHE and

Re: [PATCH 3/4] arm64: arm_pmu: Exclude EL1,2 with :G :H perf attributes

2018-11-15 Thread Andrew Murray
On Thu, Nov 15, 2018 at 02:57:59PM +, Suzuki K Poulose wrote: > Hi Andrew, > > On 15/11/2018 12:55, Andrew Murray wrote: > > When using VHE, EL1 is unused by the host and EL2 is unused by the > > guest - therefore we can filter out these events with the PMU as per > > the 'exclude_host' and

Re: [RFC PATCH v2 20/23] KVM: arm64: Add arch vm ioctl hook

2018-11-15 Thread Dave Martin
On Fri, Nov 02, 2018 at 09:32:27AM +0100, Christoffer Dall wrote: > On Fri, Sep 28, 2018 at 02:39:24PM +0100, Dave Martin wrote: > > To enable arm64-specific vm ioctls to be added cleanly, this patch > > adds a kvm_arm_arch_vm_ioctl() hook so that these don't pollute the > > common code. > >

Re: [RFC PATCH v2 12/23] KVM: arm64/sve: System register context switch and access support

2018-11-15 Thread Dave Martin
On Thu, Nov 15, 2018 at 04:37:59PM +, Alex Bennée wrote: > > Dave Martin writes: > > > This patch adds the necessary support for context switching ZCR_EL1 > > for each vcpu. > > > > ZCR_EL1 is trapped alongside the FPSIMD/SVE registers, so it makes > > sense for it to be handled as part of

Re: [PATCH 4/4] arm64: KVM: Enable support for :G/:H perf event modifiers

2018-11-15 Thread Suzuki K Poulose
On 15/11/2018 15:57, Andrew Murray wrote: On Thu, Nov 15, 2018 at 02:00:39PM +, Julien Thierry wrote: Hi Andrew, On 15/11/18 12:55, Andrew Murray wrote: Enable/disable event counters as appropriate when entering and exiting the guest to enable support for guest or host only event

Re: [RFC PATCH v2 11/23] KVM: arm64: Support runtime sysreg filtering for KVM_GET_REG_LIST

2018-11-15 Thread Dave Martin
On Fri, Nov 02, 2018 at 09:16:25AM +0100, Christoffer Dall wrote: > On Fri, Sep 28, 2018 at 02:39:15PM +0100, Dave Martin wrote: > > KVM_GET_REG_LIST should only enumerate registers that are actually > > accessible, so it is necessary to filter out any register that is > > not exposed to the

Re: [RFC PATCH v2 10/23] KVM: arm64: Extend reset_unknown() to handle mixed RES0/UNKNOWN registers

2018-11-15 Thread Dave Martin
On Fri, Nov 02, 2018 at 09:11:19AM +0100, Christoffer Dall wrote: > On Fri, Sep 28, 2018 at 02:39:14PM +0100, Dave Martin wrote: > > The reset_unknown() system register helper initialises a guest > > register to a distinctive junk value on vcpu reset, to help expose > > and debug deficient

Re: [RFC PATCH v2 06/23] arm64/sve: Check SVE virtualisability

2018-11-15 Thread Dave Martin
On Thu, Nov 15, 2018 at 03:39:01PM +, Alex Bennée wrote: > > Dave Martin writes: > > > Due to the way the effective SVE vector length is controlled and > > trapped at different exception levels, certain mismatches in the > > sets of vector lengths supported by different physical CPUs in the

[PATCH v4 2/7] dt-bindings: virtio: Add virtio-pci-iommu node

2018-11-15 Thread Jean-Philippe Brucker
Some systems implement virtio-iommu as a PCI endpoint. The operating system needs to discover the relationship between IOMMU and masters long before the PCI endpoint gets probed. Add a PCI child node to describe the virtio-iommu device. The virtio-pci-iommu is conceptually split between a PCI

[PATCH v4 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Jean-Philippe Brucker
When the device offers the probe feature, send a probe request for each device managed by the IOMMU. Extract RESV_MEM information. When we encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. This will tell other subsystems that there is no need to map the MSI doorbell in the

[PATCH v4 3/7] of: Allow the iommu-map property to omit untranslated devices

2018-11-15 Thread Jean-Philippe Brucker
In PCI root complex nodes, the iommu-map property describes the IOMMU that translates each endpoint. On some platforms, the IOMMU itself is presented as a PCI endpoint (e.g. AMD IOMMU and virtio-iommu). This isn't supported by the current OF driver, which expects all endpoints to have an IOMMU.

[PATCH v4 4/7] PCI: OF: Initialize dev->fwnode appropriately

2018-11-15 Thread Jean-Philippe Brucker
For PCI devices that have an OF node, set the fwnode as well. This way drivers that rely on fwnode don't need the special case described by commit f94277af03ea ("of/platform: Initialise dev->fwnode appropriately"). Acked-by: Bjorn Helgaas Signed-off-by: Jean-Philippe Brucker ---

[PATCH v4 7/7] iommu/virtio: Add event queue

2018-11-15 Thread Jean-Philippe Brucker
The event queue offers a way for the device to report access faults from endpoints. It is implemented on virtqueue #1. Whenever the host needs to signal a fault, it fills one of the buffers offered by the guest and interrupts it. Signed-off-by: Jean-Philippe Brucker ---

[PATCH v4 5/7] iommu: Add virtio-iommu driver

2018-11-15 Thread Jean-Philippe Brucker
The virtio IOMMU is a para-virtualized device, allowing to send IOMMU requests such as map/unmap over virtio transport without emulating page tables. This implementation handles ATTACH, DETACH, MAP and UNMAP requests. The bulk of the code transforms calls coming from the IOMMU API into

[PATCH v4 0/7] Add virtio-iommu driver

2018-11-15 Thread Jean-Philippe Brucker
Implement the virtio-iommu driver, following specification v0.8 [1]. Changes since v3 [2]: * Rebase onto v4.20-rc2. Patch 3 now touches drivers/of/base.c instead of drivers/pci/of.c, since the map_rid() function has moved. * Removed the request timeout, that depended on DEBUG. * Other small

[PATCH v4 1/7] dt-bindings: virtio-mmio: Add IOMMU description

2018-11-15 Thread Jean-Philippe Brucker
The nature of a virtio-mmio node is discovered by the virtio driver at probe time. However the DMA relation between devices must be described statically. When a virtio-mmio node is a virtio-iommu device, it needs an "#iommu-cells" property as specified by bindings/iommu/iommu.txt. Otherwise, the

Re: [RFC PATCH v2 05/23] KVM: arm: Add arch vcpu uninit hook

2018-11-15 Thread Dave Martin
On Fri, Nov 02, 2018 at 09:05:36AM +0100, Christoffer Dall wrote: > On Fri, Sep 28, 2018 at 02:39:09PM +0100, Dave Martin wrote: > > In preparation for adding support for SVE in guests on arm64, a > > hook is needed for freeing additional per-vcpu memory when a vcpu > > is freed. > > Can this

Re: [RFC PATCH v2 12/23] KVM: arm64/sve: System register context switch and access support

2018-11-15 Thread Alex Bennée
Dave Martin writes: > This patch adds the necessary support for context switching ZCR_EL1 > for each vcpu. > > ZCR_EL1 is trapped alongside the FPSIMD/SVE registers, so it makes > sense for it to be handled as part of the guest FPSIMD/SVE context > for context switch purposes instead of

Re: [PATCH v3 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Jean-Philippe Brucker
Fixed all of these, thanks Jean On 15/11/2018 13:20, Auger Eric wrote: > Hi Jean, > On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: >> When the device offers the probe feature, send a probe request for each >> device managed by the IOMMU. Extract RESV_MEM information. When we >> encounter a

Re: [RFC PATCH v2 09/23] KVM: arm64: Propagate vcpu into read_id_reg()

2018-11-15 Thread Alex Bennée
Dave Martin writes: > Architecture features that are conditionally visible to the guest > will require run-time checks in the ID register accessor functions. > In particular, read_id_reg() will need to perform checks in order > to generate the correct emulated value for certain ID register >

Re: [RFC PATCH v2 08/23] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2018-11-15 Thread Alex Bennée
Dave Martin writes: > Since SVE will be enabled or disabled on a per-vcpu basis, a flag > is needed in order to track which vcpus have it enabled. > > This patch adds a suitable flag and a helper for checking it. > > Signed-off-by: Dave Martin Reviewed-by: Alex Bennée > --- > > Changes

Re: [RFC PATCH v2 06/23] arm64/sve: Check SVE virtualisability

2018-11-15 Thread Alex Bennée
Dave Martin writes: > Due to the way the effective SVE vector length is controlled and > trapped at different exception levels, certain mismatches in the > sets of vector lengths supported by different physical CPUs in the > system may prevent straightforward virtualisation of SVE at parity >

[PATCH 2/4] arm64: arm_pmu: Add support for exclude_host/exclude_guest attributes

2018-11-15 Thread Andrew Murray
Add support for the :G and :H attributes in perf by handling the exclude_host/exclude_guest event attributes. We notify KVM of counters that we wish to be enabled or disabled on guest entry/exit and thus defer from starting or stopping :G events as per the events exclude_host attribute.

[PATCH 3/4] arm64: arm_pmu: Exclude EL1,2 with :G :H perf attributes

2018-11-15 Thread Andrew Murray
When using VHE, EL1 is unused by the host and EL2 is unused by the guest - therefore we can filter out these events with the PMU as per the 'exclude_host' and 'exclude_guest' attributes. With both VHE and non-VHE we switch the counters between host/guest at EL2. With non-VHE when using

[PATCH 0/4] arm64: Support perf event modifiers :G and :H

2018-11-15 Thread Andrew Murray
This patchset provides support for perf event modifiers :G and :H which allows for filtering of PMU events between host and guests when used with KVM. As the underlying hardware cannot distinguish between guest and host context, the performance counters must be stopped and started upon entry/exit

[PATCH 1/4] arm64: KVM: add accessors to track guest/host only counters

2018-11-15 Thread Andrew Murray
In order to effeciently enable/disable guest/host only perf counters at guest entry/exit we add bitfields to kvm_cpu_context for guest and host only events as well as accessors for updating them. Signed-off-by: Andrew Murray --- arch/arm64/include/asm/kvm_host.h | 20 1

[PATCH 4/4] arm64: KVM: Enable support for :G/:H perf event modifiers

2018-11-15 Thread Andrew Murray
Enable/disable event counters as appropriate when entering and exiting the guest to enable support for guest or host only event counting. For both VHE and non-VHE we switch the counters between host/guest at EL2. EL2 is filtered out by the PMU when we are using the :G modifier. Signed-off-by:

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread Marc Zyngier
On Thu, 15 Nov 2018 15:14:08 +, Peng Hao wrote: > > When virtual machine starts, hang up. The kernel version of guest > is 4.16. Host support vgic_v3. > It was mainly due to the incorrect vgic_irq's(intid=27) group value > during injection interruption. when kvm_vgic_vcpu_init is called, >

Re: [PATCH 3/4] arm64: arm_pmu: Exclude EL1,2 with :G :H perf attributes

2018-11-15 Thread Suzuki K Poulose
Hi Andrew, On 15/11/2018 12:55, Andrew Murray wrote: When using VHE, EL1 is unused by the host and EL2 is unused by the guest - therefore we can filter out these events with the PMU as per the 'exclude_host' and 'exclude_guest' attributes. With both VHE and non-VHE we switch the counters

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread Andre Przywara
On Thu, 15 Nov 2018 23:14:08 +0800 Peng Hao wrote: Hi, > When virtual machine starts, hang up. I take it you mean the *guest* hangs? Because it doesn't get a timer interrupt? > The kernel version of guest > is 4.16. Host support vgic_v3. Your host kernel is something recent, I guess? > It

Re: [PATCH v3 2/7] arm64/kvm: context-switch ptrauth registers

2018-11-15 Thread Amit Daniel Kachhap
On Tue, Nov 13, 2018 at 7:16 PM Christoffer Dall wrote: > > On Mon, Nov 12, 2018 at 10:32:12PM +, Catalin Marinas wrote: > > On Fri, Nov 02, 2018 at 09:37:25AM +0100, Christoffer Dall wrote: > > > On Wed, Oct 17, 2018 at 04:17:55PM +0530, Amit Daniel Kachhap wrote: > > > > From: Mark Rutland

Re: [PATCH 4/4] arm64: KVM: Enable support for :G/:H perf event modifiers

2018-11-15 Thread Julien Thierry
Hi Andrew, On 15/11/18 12:55, Andrew Murray wrote: Enable/disable event counters as appropriate when entering and exiting the guest to enable support for guest or host only event counting. For both VHE and non-VHE we switch the counters between host/guest at EL2. EL2 is filtered out by the PMU

Re: [PATCH v3 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > When the device offers the probe feature, send a probe request for each > device managed by the IOMMU. Extract RESV_MEM information. When we > encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. > This will tell other

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread Julien Thierry
On 15/11/18 10:22, peng.h...@zte.com.cn wrote: Hi Peng, On 15/11/18 15:14, Peng Hao wrote: When virtual machine starts, hang up. The kernel version of guest is 4.16. Host support vgic_v3. I don't understand the issue here. the vgic_irq->group field does not exist in 4.16 (neither in the

Re:Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread peng.hao2
>Hi Peng, > >On 15/11/18 15:14, Peng Hao wrote: >> When virtual machine starts, hang up. The kernel version of guest >> is 4.16. Host support vgic_v3. > >I don't understand the issue here. the vgic_irq->group field does not >exist in 4.16 (neither in the first nor the last version). Nor does the

Re: [PATCH] kvm: arm/arm64 : fix vm's hanging at startup time

2018-11-15 Thread Julien Thierry
Hi Peng, On 15/11/18 15:14, Peng Hao wrote: When virtual machine starts, hang up. The kernel version of guest is 4.16. Host support vgic_v3. I don't understand the issue here. the vgic_irq->group field does not exist in 4.16 (neither in the first nor the last version). Nor does the line you

Re: [PATCH v3 2/7] dt-bindings: virtio: Add virtio-pci-iommu node

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > Some systems implement virtio-iommu as a PCI endpoint. The operating > systems needs to discover the relationship between IOMMU and masters long s/systems/system > before the PCI endpoint gets probed. Add a PCI child node to describe

Re: [PATCH v3 1/7] dt-bindings: virtio-mmio: Add IOMMU description

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > The nature of a virtio-mmio node is discovered by the virtio driver at > probe time. However the DMA relation between devices must be described > statically. When a virtio-mmio node is a virtio-iommu device, it needs an > "#iommu-cells"