[PATCH 11/16] firmware/smccc: Call arch-specific hook on discovering KVM services

2021-07-15 Thread Marc Zyngier
arm64 will soon require its own callback to initialise services that are only availably on this architecture. Introduce a hook that can be overloaded by the architecture. Signed-off-by: Marc Zyngier --- arch/arm/include/asm/hypervisor.h | 1 + arch/arm64/include/asm/hypervisor.h | 1 +

[PATCH 14/16] arm64: Enroll into KVM's MMIO guard if required

2021-07-15 Thread Marc Zyngier
Should a guest desire to enroll into the MMIO guard, allow it to do so with a command-line option. Signed-off-by: Marc Zyngier --- .../admin-guide/kernel-parameters.txt | 3 ++ arch/arm64/include/asm/hypervisor.h | 1 + arch/arm64/kernel/setup.c | 6 +++

[PATCH 12/16] mm/ioremap: Add arch-specific callbacks on ioremap/iounmap calls

2021-07-15 Thread Marc Zyngier
Add a pair of hooks (ioremap_page_range_hook/iounmap_page_range_hook) that can be implemented by an architecture. Signed-off-by: Marc Zyngier --- include/linux/io.h | 3 +++ mm/ioremap.c | 13 - mm/vmalloc.c | 8 3 files changed, 23 insertions(+), 1

[PATCH 15/16] arm64: Add a helper to retrieve the PTE of a fixmap

2021-07-15 Thread Marc Zyngier
In order to transfer the early mapping state into KVM's MMIO guard infrastucture, provide a small helper that will retrieve the associated PTE. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/fixmap.h | 2 ++ arch/arm64/mm/mmu.c | 15 +++ 2 files changed, 17

[PATCH 16/16] arm64: Register earlycon fixmap with the MMIO guard

2021-07-15 Thread Marc Zyngier
On initialising the MMIO guard infrastructure, register the earlycon mapping if present. Signed-off-by: Marc Zyngier --- arch/arm64/mm/ioremap.c | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index d82b63bcc554..a27b58e03c93

[PATCH 13/16] arm64: Implement ioremap/iounmap hooks calling into KVM's MMIO guard

2021-07-15 Thread Marc Zyngier
Implement the previously defined ioremap/iounmap hooks for arm64, calling into KVM's MMIO guard if available. Signed-off-by: Marc Zyngier --- arch/arm64/mm/ioremap.c | 56 + 1 file changed, 56 insertions(+) diff --git a/arch/arm64/mm/ioremap.c

[PATCH 10/16] KVM: arm64: Add some documentation for the MMIO guard feature

2021-07-15 Thread Marc Zyngier
Document the hypercalls user for the MMIO guard infrastructure. Signed-off-by: Marc Zyngier --- Documentation/virt/kvm/arm/index.rst | 1 + Documentation/virt/kvm/arm/mmio-guard.rst | 73 +++ 2 files changed, 74 insertions(+) create mode 100644

[PATCH 08/16] KVM: arm64: Add tracepoint for failed MMIO guard check

2021-07-15 Thread Marc Zyngier
In order to make debugging easier, expose a new trace point that triggers when a MMIO check fails. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/mmu.c | 4 +++- arch/arm64/kvm/trace_arm.h | 17 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git

[PATCH 09/16] KVM: arm64: Advertise a capability for MMIO guard

2021-07-15 Thread Marc Zyngier
In order for userspace to find out whether the MMIO guard is exposed to a guest, expose a capability that says so. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arm.c | 1 + include/uapi/linux/kvm.h | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm64/kvm/arm.c

[PATCH 06/16] KVM: arm64: Force a full unmap on vpcu reinit

2021-07-15 Thread Marc Zyngier
As we now keep information in the S2PT, we must be careful not to keep it across a VM reboot, which could otherwise lead to interesting problems. Make sure that the S2 is completely discarded on reset of a vcpu, and remove the flag that enforces the MMIO check. Signed-off-by: Marc Zyngier ---

[PATCH 03/16] KVM: arm64: Turn kvm_pgtable_stage2_set_owner into kvm_pgtable_stage2_annotate

2021-07-15 Thread Marc Zyngier
kvm_pgtable_stage2_set_owner() could be generalised into a way to store up to 63 bits in the page tables, as long as we don't set bit 0. Let's just do that. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_pgtable.h | 12 +++- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 14

[PATCH 07/16] KVM: arm64: Wire MMIO guard hypercalls

2021-07-15 Thread Marc Zyngier
Plumb in the hypercall interface to allow a guest to discover, enroll, map and unmap MMIO regions. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hypercalls.c | 20 include/linux/arm-smccc.h | 28 2 files changed, 48 insertions(+) diff --git

[PATCH 05/16] KVM: arm64: Plumb MMIO checking into the fault handling

2021-07-15 Thread Marc Zyngier
Plumb the MMIO checking code into the MMIO fault handling code. Nothing allows a region to be registered yet, so there should be no funtional change either. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/mmio.c | 10 ++ 1 file changed, 10 insertions(+) diff --git

[PATCH 00/16] KVM: arm64: MMIO guard PV services

2021-07-15 Thread Marc Zyngier
KVM/arm64 currently considers that any memory access outside of a memslot is a MMIO access. This so far has served us very well, but obviously relies on the guest trusting the host, and especially userspace to do the right thing. As we keep on hacking away at pKVM, it becomes obvious that this

[PATCH 04/16] KVM: arm64: Add MMIO checking infrastructure

2021-07-15 Thread Marc Zyngier
Introduce the infrastructure required to identify an IPA region that is expected to be used as an MMIO window. This include mapping, unmapping and checking the regions. Nothing calls into it yet, so no expected functional change. Signed-off-by: Marc Zyngier ---

[PATCH 01/16] KVM: arm64: Generalise VM features into a set of flags

2021-07-15 Thread Marc Zyngier
We currently deal with a set of booleans for VM features, while they could be better represented as set of flags contained in an unsigned long, similarily to what we are doing on the CPU side. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 12 +++-

[PATCH 02/16] KVM: arm64: Don't issue CMOs when the physical address is invalid

2021-07-15 Thread Marc Zyngier
Make sure we don't issue CMOs when mapping something that is not a memory address in the S2 page tables. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/pgtable.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c

Any way to disable KVM VHE extension?

2021-07-15 Thread Qu Wenruo
Hi, Recently I'm playing around the Nvidia Xavier AGX board, which has VHE extension support. In theory, considering the CPU and memory, it should be pretty powerful compared to boards like RPI CM4. But to my surprise, KVM runs pretty poor on Xavier. Just booting the edk2 firmware could

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Qu Wenruo
On 2021/7/15 下午5:28, Robin Murphy wrote: On 2021-07-15 09:55, Qu Wenruo wrote: Hi, Recently I'm playing around the Nvidia Xavier AGX board, which has VHE extension support. In theory, considering the CPU and memory, it should be pretty powerful compared to boards like RPI CM4. But to

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Qu Wenruo
On 2021/7/15 下午4:55, Qu Wenruo wrote: Hi, Recently I'm playing around the Nvidia Xavier AGX board, which has VHE extension support. In theory, considering the CPU and memory, it should be pretty powerful compared to boards like RPI CM4. But to my surprise, KVM runs pretty poor on

Re: [PATCH 1/3] KVM: arm64: Narrow PMU sysreg reset values to architectural requirements

2021-07-15 Thread Marc Zyngier
On Thu, 15 Jul 2021 12:51:49 +0100, Robin Murphy wrote: > > On 2021-07-15 12:11, Marc Zyngier wrote: > > Hi Alex, > > > > On Wed, 14 Jul 2021 16:48:07 +0100, > > Alexandru Elisei wrote: > >> > >> Hi Marc, > >> > >> On 7/13/21 2:58 PM, Marc Zyngier wrote: > >>> A number of the PMU sysregs

Re: [PATCH 1/3] KVM: arm64: Narrow PMU sysreg reset values to architectural requirements

2021-07-15 Thread Robin Murphy
On 2021-07-15 12:11, Marc Zyngier wrote: Hi Alex, On Wed, 14 Jul 2021 16:48:07 +0100, Alexandru Elisei wrote: Hi Marc, On 7/13/21 2:58 PM, Marc Zyngier wrote: A number of the PMU sysregs expose reset values that are not in compliant with the architecture (set bits in the RES0 ranges, for

Re: [PATCH 1/3] KVM: arm64: Narrow PMU sysreg reset values to architectural requirements

2021-07-15 Thread Marc Zyngier
Hi Alex, On Wed, 14 Jul 2021 16:48:07 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 7/13/21 2:58 PM, Marc Zyngier wrote: > > A number of the PMU sysregs expose reset values that are not in > > compliant with the architecture (set bits in the RES0 ranges, > > for example). > > > > This in

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Marc Zyngier
On Thu, 15 Jul 2021 10:44:32 +0100, Qu Wenruo wrote: > > > > On 2021/7/15 下午5:28, Robin Murphy wrote: > > On 2021-07-15 09:55, Qu Wenruo wrote: > >> Hi, > >> > >> Recently I'm playing around the Nvidia Xavier AGX board, which has > >> VHE extension support. > >> > >> In theory, considering

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Mark Rutland
On Thu, Jul 15, 2021 at 11:00:42AM +0100, Robin Murphy wrote: > On 2021-07-15 10:44, Qu Wenruo wrote: > > > > > > On 2021/7/15 下午5:28, Robin Murphy wrote: > > > On 2021-07-15 09:55, Qu Wenruo wrote: > > > > Hi, > > > > > > > > Recently I'm playing around the Nvidia Xavier AGX board, which > > >

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Robin Murphy
On 2021-07-15 10:44, Qu Wenruo wrote: On 2021/7/15 下午5:28, Robin Murphy wrote: On 2021-07-15 09:55, Qu Wenruo wrote: Hi, Recently I'm playing around the Nvidia Xavier AGX board, which has VHE extension support. In theory, considering the CPU and memory, it should be pretty powerful

Re: [PATCH 5/5] KVM: arm64: nVHE: Remove unneeded isb() when modifying PMSCR_EL1

2021-07-15 Thread Alexandru Elisei
Hi Will, On 7/14/21 7:20 PM, Will Deacon wrote: > On Wed, Jul 14, 2021 at 10:56:01AM +0100, Alexandru Elisei wrote: >> According to ARM DDI 0487G.a, page D9-2930, profiling is disabled when >> the PE is executing at a higher exception level than the profiling >> buffer owning exception level.

Re: Any way to disable KVM VHE extension?

2021-07-15 Thread Robin Murphy
On 2021-07-15 09:55, Qu Wenruo wrote: Hi, Recently I'm playing around the Nvidia Xavier AGX board, which has VHE extension support. In theory, considering the CPU and memory, it should be pretty powerful compared to boards like RPI CM4. But to my surprise, KVM runs pretty poor on Xavier.

Re: [PATCH 0/3] kvm-arm64: Fix PMU reset values (and more)

2021-07-15 Thread Alexandre Chartre
On 7/13/21 3:58 PM, Marc Zyngier wrote: Hi all, After some back and forth with Alexandre about patch #3 of this series, it became apparent that some of the PMU code paths perform some unnecessary masking, only to hide the fact that some of the PMU register reset values are not