Re: [PATCH v13 00/15] SMMUv3 Nested Stage Setup (IOMMU part)

2021-03-16 Thread Auger Eric
Hi Krishna, On 3/15/21 7:04 PM, Krishna Reddy wrote: > Tested-by: Krishna Reddy > >> 1) pass the guest stage 1 configuration > > Validated Nested SMMUv3 translations for NVMe PCIe device from Guest VM along > with patch series "v11 SMMUv3 Nested Stage Setup (VFIO part)" and QEMU patch >

RE: [PATCH v11 00/13] SMMUv3 Nested Stage Setup (VFIO part)

2021-03-16 Thread Krishna Reddy
Tested-by: Krishna Reddy > 1) pass the guest stage 1 configuration > 3) invalidate stage 1 related caches Validated Nested SMMUv3 translations for NVMe PCIe device from Guest VM along with patch series "v13 SMMUv3 Nested Stage Setup (IOMMU part)" and QEMU patch series "vSMMUv3/pSMMUv3 2 stage

RE: [PATCH v13 00/15] SMMUv3 Nested Stage Setup (IOMMU part)

2021-03-16 Thread Krishna Reddy
Tested-by: Krishna Reddy > 1) pass the guest stage 1 configuration Validated Nested SMMUv3 translations for NVMe PCIe device from Guest VM along with patch series "v11 SMMUv3 Nested Stage Setup (VFIO part)" and QEMU patch series "vSMMUv3/pSMMUv3 2 stage VFIO integration" from

[PATCH 05/10] KVM: arm64: Rework SVE host-save/guest-restore

2021-03-16 Thread Marc Zyngier
In order to keep the code readable, move the host-save/guest-restore sequences in their own functions, with the following changes: - the hypervisor ZCR is now set from C code - ZCR_EL2 is always used as the EL2 accessor This results in some minor assembler macro rework. No functional change

[PATCH 00/10] KVM: arm64: Enable SVE support on nVHE systems

2021-03-16 Thread Marc Zyngier
This series enables SVE support for KVM on nVHE hardware (or more likely, software models), and is an alternative to Daniel's patch[1] which has gone through 3 versions, but still has a number of issues. Instead of waiting for things to happen, I decided to try and see what I could come up with.

[PATCH 06/10] KVM: arm64: Map SVE context at EL2 when available

2021-03-16 Thread Marc Zyngier
When running on nVHE, and that the vcpu supports SVE, map the SVE state at EL2 so that KVM can access it. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index

[PATCH 03/10] KVM: arm64: Let vcpu_sve_pffr() handle HYP VAs

2021-03-16 Thread Marc Zyngier
The vcpu_sve_pffr() returns a pointer, which can be an interesting thing to do on nVHE. Wrap the pointer with kern_hyp_va(), and take this opportunity to remove the unnecessary casts (sve_state being a void *). Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 4 ++-- 1 file

[PATCH 07/10] KVM: arm64: Save guest's ZCR_EL1 before saving the FPSIMD state

2021-03-16 Thread Marc Zyngier
Make sure the guest's ZCR_EL1 is saved before we save/flush the state. This will be useful in later patches. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index

[PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

2021-03-16 Thread Marc Zyngier
ZCR_EL2 controls the upper bound for ZCR_EL1, and is set to a potentially lower limit when the guest uses SVE. In order to restore the SVE state on the EL1 host, we must first reset ZCR_EL2 to its original value. Provide a hypervall that perform this reset. Signed-off-by: Marc Zyngier ---

[PATCH 09/10] KVM: arm64: Save/restore SVE state for nVHE

2021-03-16 Thread Marc Zyngier
Implement the SVE save/restore for nVHE, following a similar logic to that of the VHE implementation: - the SVE state is switched on trap from EL1 to EL2 - no further changes to ZCR_EL2 occur as long as the guest isn't preempted or exit to userspace - on vcpu_put(), ZCR_EL2 is reset to its

[PATCH 02/10] KVM: arm64: Use {read, write}_sysreg_el1 to access ZCR_EL1

2021-03-16 Thread Marc Zyngier
Switch to the unified EL1 accessors for ZCR_EL1, which will make things easier for nVHE support. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 3 ++- arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git

[PATCH 01/10] KVM: arm64: Provide KVM's own save/restore SVE primitives

2021-03-16 Thread Marc Zyngier
as we are about to change the way KVM deals with SVE, provide KVM with its own save/restore SVE primitives. No functional change intended. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/fpsimdmacros.h | 2 ++ arch/arm64/include/asm/kvm_hyp.h| 2 ++

[PATCH 04/10] KVM: arm64: Introduce vcpu_sve_vq() helper

2021-03-16 Thread Marc Zyngier
The KVM code contains a number of "sve_vq_from_vl(vcpu->arch.sve_max_vl)" instances, and we are about to add more. Introduce vcpu_sve_vq() as a shorthand for this expression. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 4 +++- arch/arm64/kvm/guest.c

[PATCH 10/10] KVM: arm64: Enable SVE support for nVHE

2021-03-16 Thread Marc Zyngier
From: Daniel Kiss Now that KVM is equipped to deal with SVE on nVHE, remove the code preventing it from being used as well as the bits of documentation that were mentioning the incompatibility. Signed-off-by: Daniel Kiss Signed-off-by: Marc Zyngier --- arch/arm64/Kconfig| 7

[RFC PATCH v2 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-03-16 Thread Keqian Zhu
The MMIO region of a device maybe huge (GB level), try to use block mapping in stage2 to speedup both map and unmap. Compared to normal memory mapping, we should consider two more points when try block mapping for MMIO region: 1. For normal memory mapping, the PA(host physical address) and HVA

[RFC PATCH v2 0/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-03-16 Thread Keqian Zhu
Hi all, We have two pathes to build stage2 mapping for MMIO regions. Create time's path and stage2 fault path. Patch#1 removes the creation time's mapping of MMIO regions Patch#2 tries stage2 block mapping for host device MMIO at fault path Thanks, Keqian Keqian Zhu (2): kvm/arm64: Remove

[RFC PATCH v2 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-03-16 Thread Keqian Zhu
The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes these two mapping path hard to sync. Remove the mapping code while keep the useful sanity check. Signed-off-by: Keqian Zhu ---

Re: [PATCH 01/10] KVM: arm64: Provide KVM's own save/restore SVE primitives

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 10:13:03 (+), Marc Zyngier wrote: > diff --git a/arch/arm64/kvm/hyp/fpsimd.S b/arch/arm64/kvm/hyp/fpsimd.S > index 01f114aa47b0..e4010d1acb79 100644 > --- a/arch/arm64/kvm/hyp/fpsimd.S > +++ b/arch/arm64/kvm/hyp/fpsimd.S > @@ -19,3 +19,13 @@

Re: [PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

2021-03-16 Thread Marc Zyngier
On Tue, 16 Mar 2021 10:45:55 +, Quentin Perret wrote: > > On Tuesday 16 Mar 2021 at 10:13:10 (+), Marc Zyngier wrote: > > diff --git a/arch/arm64/include/asm/kvm_host.h > > b/arch/arm64/include/asm/kvm_host.h > > index c4afe3d3397f..9108ccc80653 100644 > > ---

Re: [kvm-unit-tests PATCH 2/6] arm/arm64: Remove dcache_line_size global variable

2021-03-16 Thread Andre Przywara
On Mon, 15 Mar 2021 15:46:09 + Alexandru Elisei wrote: Hi Alex, > On 3/4/21 3:00 PM, Andre Przywara wrote: > > On Sat, 27 Feb 2021 10:41:57 + > > Alexandru Elisei wrote: > > > >> Compute the dcache line size when doing dcache maintenance instead of using > >> a global variable

Re: [PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

2021-03-16 Thread Marc Zyngier
On Tue, 16 Mar 2021 14:24:38 +, Andrew Scull wrote: > > On Tue, Mar 16, 2021 at 10:13:10AM +, Marc Zyngier wrote: > > ZCR_EL2 controls the upper bound for ZCR_EL1, and is set to > > a potentially lower limit when the guest uses SVE. > > > > In order to restore the SVE state on the EL1

Re: [PATCH 01/10] KVM: arm64: Provide KVM's own save/restore SVE primitives

2021-03-16 Thread Marc Zyngier
On Tue, 16 Mar 2021 10:31:46 +, Quentin Perret wrote: > > On Tuesday 16 Mar 2021 at 10:13:03 (+), Marc Zyngier wrote: > > diff --git a/arch/arm64/kvm/hyp/fpsimd.S b/arch/arm64/kvm/hyp/fpsimd.S > > index 01f114aa47b0..e4010d1acb79 100644 > > --- a/arch/arm64/kvm/hyp/fpsimd.S > > +++

Re: [PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 10:13:10 (+), Marc Zyngier wrote: > diff --git a/arch/arm64/include/asm/kvm_host.h > b/arch/arm64/include/asm/kvm_host.h > index c4afe3d3397f..9108ccc80653 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -593,7 +593,9

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > Testing the latest version of the patchset, we seem to have found another > thing related to FEAT_S2FWB. Argh! I wish I could put my hands on hardware with FWB. Thanks again for the report. > This function always sets Normal

Re: [PATCH kvmtool v3 13/22] hw/serial: Refactor trap handler

2021-03-16 Thread Alexandru Elisei
Hi Andre, On 3/15/21 3:33 PM, Andre Przywara wrote: > With the planned retirement of the special ioport emulation code, we > need to provide an emulation function compatible with the MMIO prototype. > > Adjust the trap handler to use that new function, and provide shims to > implement the old

[PATCH 10/11] irqchip/apple-aic: Initialise SYS_APL_VM_TMR_FIQ_ENA_EL1 at boot time

2021-03-16 Thread Marc Zyngier
Instead of masking the guest timer at the source, take advantage of the SYS_APL_VM_TMR_FIQ_ENA_EL1 register and properly mask the timers at init time. For a good measure, add the missing ISB that synchronises all the previous sysreg accesses. Signed-off-by: Marc Zyngier ---

[PATCH 11/11] irqchip/apple-aic: Advertise some level of vGICv3 compatibility

2021-03-16 Thread Marc Zyngier
The CPUs in the Apple M1 SoC partially implement a virtual GICv3 CPU interface, although one that is incapable of HW deactivation of interrupts. Advertise the support to KVM. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-apple-aic.c | 7 +++ 1 file changed, 7 insertions(+) diff

[PATCH 06/11] KVM: arm64: vgic: Implement SW-driven deactivation

2021-03-16 Thread Marc Zyngier
In order to deal with these systems that do not offer HW-based deactivation of interrupts, let implement a SW-based approach: - When the irq is queued into a LR, treat it as a pure virtual interrupt and set the EOI flag in the LR. - When the interrupt state is read back from the LR, force a

[PATCH 05/11] KVM: arm64: vgic: move irq->get_input_level into an ops structure

2021-03-16 Thread Marc Zyngier
We already have the option to attach a callback to an interrupt to retrieve its pending state. As we are planning to expand this facility, move this callback into its own data structure. This will limit the size of individual interrupts as the ops structures can be shared across multiple

[PATCH 07/11] KVM: arm64: timer: Refactor IRQ configuration

2021-03-16 Thread Marc Zyngier
As we are about to add some more things to the timer IRQ configuration, move this code out of the main timer init code into its own set of functions. No functional changes. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arch_timer.c | 61 ++--- 1 file changed,

[PATCH 09/11] irqchip/apple-aic: Fix [un]masking of guest timers

2021-03-16 Thread Marc Zyngier
As the enabling of the guest timer interrupts is done by accessing a system register, make sure the access is correctly synchronised. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-apple-aic.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/irqchip/irq-apple-aic.c

[PATCH 08/11] KVM: arm64: timer: Add support for SW-based deactivation

2021-03-16 Thread Marc Zyngier
In order to deal with the lack of active state, we need to use the mask/unmask primitives (after all, the active state is just an additional mask on top of the normal one). To avoid adding a bunch of ugly conditionals in the timer and vgic code, let's use a timer-specific irqdomain to deal with

[PATCH 03/11] KVM: arm64: vgic: Be tolerant to the lack of maintenance interrupt

2021-03-16 Thread Marc Zyngier
As it turns out, not all the interrupt controllers are able to expose a vGIC maintenance interrupt as a distrete signal. And to be fair, it doesn't really matter as all we require is for *something* to kick us out of guest mode out way or another. On systems that do not expose a maintenance

[PATCH 02/11] KVM: arm64: Handle physical FIQ as an IRQ while running a guest

2021-03-16 Thread Marc Zyngier
As we we now entertain the possibility of FIQ being used on the host, treat the signalling of a FIQ while running a guest as an IRQ, causing an exit instead of a HYP panic. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/hyp-entry.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)

[PATCH 00/11] KVM: arm64: Initial host support for the Apple M1

2021-03-16 Thread Marc Zyngier
I've spent the past few weekends trying to see how I could support the M1 as a KVM host. It started by being pretty ugly, but the end result is actually not too horrible. Just a wee bit horrible. The M1 has no GIC. And as everybody know, "KVM" stands for "The GIC Emulator". Yes, Avi got the TLA

[PATCH 04/11] KVM: arm64: vgic: Let an interrupt controller advertise lack of HW deactivation

2021-03-16 Thread Marc Zyngier
The vGIC, as architected by ARM, allows a virtual interrupt to trigger the deactivation of a physical interrupt. This allows the following interrupt to be delivered without requiring an exit. However, some implementations have choosen not to implement this, meaning that we will need some

[PATCH 01/11] irqchip/gic: Split vGIC probing information from the GIC code

2021-03-16 Thread Marc Zyngier
The vGIC advertising code is unsurprisingly very much tied to the GIC implementations. However, we are about to extend the support to lesser implementations. Let's dissociate the vgic registration from the GIC code and move it into KVM, where it makes a bit more sense. This also allows us to mark

Re: [RFC PATCH 3/4] KVM: stats: Add ioctl commands to pull statistics in binary format

2021-03-16 Thread Paolo Bonzini
On 15/03/21 23:31, Jing Zhang wrote: We are considering about how to create the file descriptor. It might be risky to create an extra fd for every vCPU. It will easily hit the fd limit for the process or the system for machines running a ton of small VMs. You already have a file descriptor for

Re: [PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

2021-03-16 Thread Andrew Scull
On Tue, Mar 16, 2021 at 10:13:10AM +, Marc Zyngier wrote: > ZCR_EL2 controls the upper bound for ZCR_EL1, and is set to > a potentially lower limit when the guest uses SVE. > > In order to restore the SVE state on the EL1 host, we must first > reset ZCR_EL2 to its original value. > > Provide

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 12:53:53 (+), Quentin Perret wrote: > On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > > Changing the value of MT_S2_FWB_NORMAL to 7 would change this behavior, and > > the resulting memory type would be device. > > Sounds like the correct fix here

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Mate Toth-Pal
On 2021-03-15 15:35, Quentin Perret wrote: +static int host_stage2_idmap(u64 addr) +{ + enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R | KVM_PGTABLE_PROT_W; + struct kvm_mem_range range; + bool is_memory = find_mem_range(addr, ); + struct hyp_pool *pool = is_memory ?

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Mate Toth-Pal
On 2021-03-16 15:29, Quentin Perret wrote: On Tuesday 16 Mar 2021 at 12:53:53 (+), Quentin Perret wrote: On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: Changing the value of MT_S2_FWB_NORMAL to 7 would change this behavior, and the resulting memory type would be device.

RE: [PATCH v13 00/15] SMMUv3 Nested Stage Setup (IOMMU part)

2021-03-16 Thread Krishna Reddy
> Hi Krishna, > On 3/15/21 7:04 PM, Krishna Reddy wrote: > > Tested-by: Krishna Reddy > > > >> 1) pass the guest stage 1 configuration > > > > Validated Nested SMMUv3 translations for NVMe PCIe device from Guest VM > along with patch series "v11 SMMUv3 Nested Stage Setup (VFIO part)" and > QEMU

Re: [PATCH v5 33/36] KVM: arm64: Wrap the host with a stage 2

2021-03-16 Thread Quentin Perret
On Tuesday 16 Mar 2021 at 16:16:18 (+0100), Mate Toth-Pal wrote: > On 2021-03-16 15:29, Quentin Perret wrote: > > On Tuesday 16 Mar 2021 at 12:53:53 (+), Quentin Perret wrote: > > > On Tuesday 16 Mar 2021 at 13:28:42 (+0100), Mate Toth-Pal wrote: > > > > Changing the value of MT_S2_FWB_NORMAL