[PATCH v7 2/4] KVM: stats: Add fd-based API to read binary stats data

2021-06-03 Thread Jing Zhang
Provides a file descriptor per VM to read VM stats info/data. Provides a file descriptor per vCPU to read vCPU stats info/data. Reviewed-by: David Matlack Reviewed-by: Ricardo Koller Signed-off-by: Jing Zhang --- arch/arm64/kvm/guest.c| 26 +++ arch/mips/kvm/mips.c | 52

[PATCH v7 1/4] KVM: stats: Separate generic stats from architecture specific ones

2021-06-03 Thread Jing Zhang
Put all generic statistics in a separate structure to ease statistics handling for the incoming new statistics API. No functional change intended. Reviewed-by: David Matlack Reviewed-by: Ricardo Koller Signed-off-by: Jing Zhang --- arch/arm64/include/asm/kvm_host.h | 9 ++---

[PATCH v7 3/4] KVM: stats: Add documentation for statistics data binary interface

2021-06-03 Thread Jing Zhang
Update KVM API documentation for binary statistics. Reviewed-by: David Matlack Reviewed-by: Ricardo Koller Signed-off-by: Jing Zhang --- Documentation/virt/kvm/api.rst | 180 + 1 file changed, 180 insertions(+) diff --git a/Documentation/virt/kvm/api.rst

[PATCH v7 0/4] KVM statistics data fd-based binary interface

2021-06-03 Thread Jing Zhang
This patchset provides a file descriptor for every VM and VCPU to read KVM statistics data in binary format. It is meant to provide a lightweight, flexible, scalable and efficient lock-free solution for user space telemetry applications to pull the statistics data periodically for large scale

[PATCH v7 4/4] KVM: selftests: Add selftest for KVM statistics data binary interface

2021-06-03 Thread Jing Zhang
Add selftest to check KVM stats descriptors validity. Reviewed-by: David Matlack Reviewed-by: Ricardo Koller Signed-off-by: Jing Zhang --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 3 + .../testing/selftests/kvm/include/kvm_util.h

[RFC PATCH 4/4] KVM: arm64: Introduce KVM_CAP_ARM_PROTECTED_VM

2021-06-03 Thread Will Deacon
Introduce a new VM capability, KVM_CAP_ARM_PROTECTED_VM, which can be used to isolate guest memory from the host. For now, the EL2 portion is missing, so this documents and exposes the user ABI for the host. Signed-off-by: Will Deacon --- Documentation/virt/kvm/api.rst| 69

[PATCH 3/4] KVM: arm64: Parse reserved-memory node for pkvm guest firmware region

2021-06-03 Thread Will Deacon
Add support for a "linux,pkvm-guest-firmware-memory" reserved memory region, which can be used to identify a firmware image for protected VMs. Signed-off-by: Will Deacon --- arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/pkvm.c | 52 + 2 files changed,

[PATCH 2/4] KVM: arm64: Extend comment in has_vhe()

2021-06-03 Thread Will Deacon
has_vhe() expands to a compile-time constant when evaluated from the VHE or nVHE code, alternatively checking a static key when called from elsewhere in the kernel. On face value, this looks like a case of premature optimization, but in fact this allows symbol references on VHE-specific code paths

[PATCH 1/4] KVM: arm64: Ignore 'kvm-arm.mode=protected' when using VHE

2021-06-03 Thread Will Deacon
Ignore 'kvm-arm.mode=protected' when using VHE so that kvm_get_mode() only returns KVM_MODE_PROTECTED on systems where the feature is available. Cc: David Brazdil Signed-off-by: Will Deacon --- Documentation/admin-guide/kernel-parameters.txt | 1 - arch/arm64/kernel/cpufeature.c

[PATCH 0/4] kvm/arm64: Initial pKVM user ABI

2021-06-03 Thread Will Deacon
Hi folks, These patches implement support for userspace to request a "Protected VM" using KVM on arm64 when configured in Protected Mode (see the existing kvm-arm.mode=protected command-line option). The final patch documents the new ABI and its behaviour, so I won't reproduce that here. Please

Re: [RFC][PATCH] kvm: add suspend pm-notifier

2021-06-03 Thread Peter Zijlstra
On Fri, Jun 04, 2021 at 01:43:15AM +0900, Sergey Senozhatsky wrote: > Add KVM suspend/hibernate PM-notifier which lets architectures > to implement arch-specific VM suspend code. For instance, on x86 > this sets PVCLOCK_GUEST_STOPPED on all the VCPUs. > > Our case is that user puts the host

Re: [PATCH v13 7/8] KVM: arm64: ioctl to fetch/store tags in a guest

2021-06-03 Thread Catalin Marinas
On Mon, May 24, 2021 at 11:45:12AM +0100, Steven Price wrote: > diff --git a/arch/arm64/include/uapi/asm/kvm.h > b/arch/arm64/include/uapi/asm/kvm.h > index 24223adae150..b3edde68bc3e 100644 > --- a/arch/arm64/include/uapi/asm/kvm.h > +++ b/arch/arm64/include/uapi/asm/kvm.h > @@ -184,6 +184,17 @@

Re: [PATCH v13 6/8] KVM: arm64: Expose KVM_ARM_CAP_MTE

2021-06-03 Thread Catalin Marinas
On Mon, May 24, 2021 at 11:45:11AM +0100, Steven Price wrote: > It's now safe for the VMM to enable MTE in a guest, so expose the > capability to user space. > > Signed-off-by: Steven Price Reviewed-by: Catalin Marinas ___ kvmarm mailing list

Re: [PATCH v13 5/8] KVM: arm64: Save/restore MTE registers

2021-06-03 Thread Catalin Marinas
On Mon, May 24, 2021 at 11:45:10AM +0100, Steven Price wrote: > diff --git a/arch/arm64/include/asm/kvm_mte.h > b/arch/arm64/include/asm/kvm_mte.h > new file mode 100644 > index ..eae4bce9e269 > --- /dev/null > +++ b/arch/arm64/include/asm/kvm_mte.h > @@ -0,0 +1,68 @@ > +/*

Re: [PATCH] KVM: arm64: Properly restore PMU state during live-migration

2021-06-03 Thread Marc Zyngier
Hi Jinank, On Thu, 03 Jun 2021 12:05:54 +0100, Jinank Jain wrote: > > Currently if a guest is live-migrated while it is actively using perf > counters, then after live-migrate it will notice that all counters would > suddenly start reporting 0s. This is due to the fact we are not > re-creating

Re: [PATCH v13 4/8] KVM: arm64: Introduce MTE VM feature

2021-06-03 Thread Catalin Marinas
On Mon, May 24, 2021 at 11:45:09AM +0100, Steven Price wrote: > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index c5d1f3c87dbd..226035cf7d6c 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -822,6 +822,42 @@ transparent_hugepage_adjust(struct kvm_memory_slot >

[PATCH] KVM: arm64: Properly restore PMU state during live-migration

2021-06-03 Thread Jinank Jain
Currently if a guest is live-migrated while it is actively using perf counters, then after live-migrate it will notice that all counters would suddenly start reporting 0s. This is due to the fact we are not re-creating the relevant perf events inside the kernel. Usually on live-migration guest

Re: [PATCH] KVM: arm64: Properly restore PMU state during live-migration

2021-06-03 Thread kernel test robot
Hi Jinank, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on kvmarm/next] [also build test WARNING on arm/for-next soc/for-next arm64/for-next/core v5.13-rc4 next-20210603] [cannot apply to xlnx/master] [If your patch is applied to the wrong git tree, kindly

Re: [PATCH v13 3/8] arm64: mte: Sync tags for pages where PTE is untagged

2021-06-03 Thread Catalin Marinas
On Mon, May 24, 2021 at 11:45:08AM +0100, Steven Price wrote: > A KVM guest could store tags in a page even if the VMM hasn't mapped > the page with PROT_MTE. So when restoring pages from swap we will > need to check to see if there are any saved tags even if !pte_tagged(). > > However don't

Re: [PATCH v5 6/6] KVM: arm64: Distinguish cases of memcache allocations completely

2021-06-03 Thread wangyanan (Y)
Hi Quentin, On 2021/6/2 19:07, Quentin Perret wrote: On Thursday 15 Apr 2021 at 19:50:32 (+0800), Yanan Wang wrote: With a guest translation fault, the memcache pages are not needed if KVM is only about to install a new leaf entry into the existing page table. And with a guest permission

Re: [PATCH v5 1/6] KVM: arm64: Introduce KVM_PGTABLE_S2_GUEST stage-2 flag

2021-06-03 Thread wangyanan (Y)
Hi Quentin, On 2021/6/2 18:43, Quentin Perret wrote: Hi Yanan, On Thursday 15 Apr 2021 at 19:50:27 (+0800), Yanan Wang wrote: diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index c3674c47d48c..a43cbe697b37 100644 ---

Re: [PATCH v5 5/6] KVM: arm64: Move I-cache flush to the fault handlers

2021-06-03 Thread wangyanan (Y)
Hi Quentin, On 2021/6/2 18:58, Quentin Perret wrote: On Thursday 15 Apr 2021 at 19:50:31 (+0800), Yanan Wang wrote: In this patch, we move invalidation of I-cache to the fault handlers to Nit: please avoid using 'This patch' in commit messages, see

Re: [PATCH v5 4/6] KVM: arm64: Provide invalidate_icache_range at non-VHE EL2

2021-06-03 Thread wangyanan (Y)
Hi Marc, On 2021/6/2 18:22, Marc Zyngier wrote: On Thu, 15 Apr 2021 12:50:30 +0100, Yanan Wang wrote: We want to move I-cache maintenance for the guest to the stage-2 page table code for performance improvement. Before it can work, we should first make function invalidate_icache_range

Re: [PATCH v5 2/6] KVM: arm64: Move D-cache flush to the fault handlers

2021-06-03 Thread wangyanan (Y)
Hi Marc, On 2021/6/2 18:19, Marc Zyngier wrote: On Thu, 15 Apr 2021 12:50:28 +0100, Yanan Wang wrote: We currently uniformly permorm CMOs of D-cache and I-cache in function user_mem_abort before calling the fault handlers. If we get concurrent guest faults(e.g. translation faults, permission

Re: [PATCH v3 1/5] KVM: arm64: selftests: get-reg-list: Introduce vcpu configs

2021-06-03 Thread Andrew Jones
On Wed, Jun 02, 2021 at 04:40:28PM -0700, Ricardo Koller wrote: > On Mon, May 31, 2021 at 12:33:40PM +0200, Andrew Jones wrote: > > We already break register lists into sublists that get selected based > > on vcpu config. However, since we only had two configs (vregs and sve), > > we didn't

Re: [PATCH v4 00/66] KVM: arm64: ARMv8.3/8.4 Nested Virtualization support

2021-06-03 Thread Marc Zyngier
On Thu, 03 Jun 2021 09:39:09 +0100, Marc Zyngier wrote: > > Hi Jamie, > > Funny, your email has a "Mail-Followup-To:" field that contains > everyone but you... Not ideal! ;-) > > On Thu, 03 Jun 2021 08:07:22 +0100, > Jamie Iles wrote: > > > > Hi Marc, > > > > On Mon, May 10, 2021 at

Re: [PATCH v4 00/66] KVM: arm64: ARMv8.3/8.4 Nested Virtualization support

2021-06-03 Thread Jamie Iles
Hi Marc, On Mon, May 10, 2021 at 05:58:14PM +0100, Marc Zyngier wrote: > Here the bi-annual drop of the KVM/arm64 NV support code. > > Not a lot has changed since [1], except for a discovery mechanism for > the EL2 support, some tidying up in the idreg emulation, dropping RMR > support, and a

Re: [PATCH v4 00/66] KVM: arm64: ARMv8.3/8.4 Nested Virtualization support

2021-06-03 Thread Marc Zyngier
Hi Jamie, Funny, your email has a "Mail-Followup-To:" field that contains everyone but you... Not ideal! ;-) On Thu, 03 Jun 2021 08:07:22 +0100, Jamie Iles wrote: > > Hi Marc, > > On Mon, May 10, 2021 at 05:58:14PM +0100, Marc Zyngier wrote: > > Here the bi-annual drop of the KVM/arm64 NV