Re: [RFC PATCH 0/3] kvm/arm: New VMID allocator based on asid(2nd approach)

2021-06-07 Thread Jean-Philippe Brucker
On Fri, Jun 04, 2021 at 04:27:39PM +0100, Marc Zyngier wrote: > > > Plus, I've found this nugget: > > > > > > > > max_pinned_vmids = NUM_USER_VMIDS - num_possible_cpus() - 2; > > > > > > > > > What is this "- 2"? My hunch is that it should really be "- 1" as VMID > > > 0 is reserved, and we h

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

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

[PATCH v14 0/8] MTE support for KVM guest

2021-06-07 Thread Steven Price
This series adds support for using the Arm Memory Tagging Extensions (MTE) in a KVM guest. Changes since v13[1]: * Add Reviewed-by tags from Catalin - thanks! * Introduce a new function mte_prepare_page_tags() for handling the initialisation of pages ready for a KVM guest. This takes the bi

[PATCH v14 1/8] arm64: mte: Handle race when synchronising tags

2021-06-07 Thread Steven Price
mte_sync_tags() used test_and_set_bit() to set the PG_mte_tagged flag before restoring/zeroing the MTE tags. However if another thread were to race and attempt to sync the tags on the same page before the first thread had completed restoring/zeroing then it would see the flag is already set and con

[PATCH v14 2/8] arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage()

2021-06-07 Thread Steven Price
From: Catalin Marinas Currently, on an anonymous page fault, the kernel allocates a zeroed page and maps it in user space. If the mapping is tagged (PROT_MTE), set_pte_at() additionally clears the tags under a spinlock to avoid a race on the page->flags. In order to optimise the lock, clear the p

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

2021-06-07 Thread Steven Price
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 check pages for which pte_access_permitted() returns false as these will not

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

2021-06-07 Thread Steven Price
Add a new VM feature 'KVM_ARM_CAP_MTE' which enables memory tagging for a VM. This will expose the feature to the guest and automatically tag memory pages touched by the VM as PG_mte_tagged (and clear the tag storage) to ensure that the guest cannot see stale tags, and so that the tags are correctl

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

2021-06-07 Thread Steven Price
Define the new system registers that MTE introduces and context switch them. The MTE feature is still hidden from the ID register as it isn't supported in a VM yet. Reviewed-by: Catalin Marinas Signed-off-by: Steven Price --- arch/arm64/include/asm/kvm_arm.h | 3 +- arch/arm64/includ

[PATCH v14 6/8] KVM: arm64: Expose KVM_ARM_CAP_MTE

2021-06-07 Thread Steven Price
It's now safe for the VMM to enable MTE in a guest, so expose the capability to user space. Reviewed-by: Catalin Marinas Signed-off-by: Steven Price --- arch/arm64/kvm/arm.c | 9 + arch/arm64/kvm/reset.c| 3 ++- arch/arm64/kvm/sys_regs.c | 3 +++ 3 files changed, 14 insertions(

[PATCH v14 8/8] KVM: arm64: Document MTE capability and ioctl

2021-06-07 Thread Steven Price
A new capability (KVM_CAP_ARM_MTE) identifies that the kernel supports granting a guest access to the tags, and provides a mechanism for the VMM to enable it. A new ioctl (KVM_ARM_MTE_COPY_TAGS) provides a simple way for a VMM to access the tags of a guest without having to maintain a PROT_MTE map

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

2021-06-07 Thread Steven Price
The VMM may not wish to have it's own mapping of guest memory mapped with PROT_MTE because this causes problems if the VMM has tag checking enabled (the guest controls the tags in physical RAM and it's unlikely the tags are correct for the VMM). Instead add a new ioctl which allows the VMM to easi

Re: [PATCH v2 4/7] KVM: arm64: Unify MMIO and mem host stage-2 pools

2021-06-07 Thread Quentin Perret
On Sunday 06 Jun 2021 at 11:31:20 (+0100), Marc Zyngier wrote: > On 2021-06-02 10:43, Quentin Perret wrote: > > We currently maintain two separate memory pools for the host stage-2, > > one for pages used in the page-table when mapping memory regions, and > > the other to map MMIO regions. The form

Re: [PATCH] KVM: selftests: Rename vm_handle_exception in evmcs test

2021-06-07 Thread Marc Zyngier
On Mon, 07 Jun 2021 17:07:40 +0100, Sean Christopherson wrote: > > On Sun, Jun 06, 2021, Marc Zyngier wrote: > > This is becoming a bit messy. I'd rather drop the whole series from > > -next, and get something that doesn't break in the middle. Please > > resend the series tested on top of -rc4. >

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

2021-06-07 Thread Marc Zyngier
On Mon, 07 Jun 2021 17:05:01 +0100, "Jain, Jinank" wrote: > > On Thu, 2021-06-03 at 17:03 +0100, Marc Zyngier wrote: > > > > 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 > > > coun

Re: [PATCH v14 2/8] arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage()

2021-06-07 Thread Catalin Marinas
On Mon, Jun 07, 2021 at 12:08:10PM +0100, Steven Price wrote: > From: Catalin Marinas > > Currently, on an anonymous page fault, the kernel allocates a zeroed > page and maps it in user space. If the mapping is tagged (PROT_MTE), > set_pte_at() additionally clears the tags under a spinlock to avo

Re: [PATCH] KVM: selftests: Rename vm_handle_exception in evmcs test

2021-06-07 Thread Marc Zyngier
On Mon, 07 Jun 2021 17:56:59 +0100, Ricardo Koller wrote: > > On Mon, Jun 07, 2021 at 05:19:03PM +0100, Marc Zyngier wrote: > > On Mon, 07 Jun 2021 17:07:40 +0100, > > Sean Christopherson wrote: > > > > > > On Sun, Jun 06, 2021, Marc Zyngier wrote: > > > > This is becoming a bit messy. I'd rath

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

2021-06-07 Thread Catalin Marinas
On Mon, Jun 07, 2021 at 12:08:15PM +0100, Steven Price wrote: > The VMM may not wish to have it's own mapping of guest memory mapped > with PROT_MTE because this causes problems if the VMM has tag checking > enabled (the guest controls the tags in physical RAM and it's unlikely > the tags are corre

Re: [PATCH v14 8/8] KVM: arm64: Document MTE capability and ioctl

2021-06-07 Thread Catalin Marinas
On Mon, Jun 07, 2021 at 12:08:16PM +0100, Steven Price wrote: > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index 22d077562149..fc6f0cbc30b3 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -5034,6 +5034,42 @@ see KVM_XEN_V

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

2021-06-07 Thread Will Deacon
On Fri, Jun 04, 2021 at 03:01:17PM +0100, Mark Rutland wrote: > On Thu, Jun 03, 2021 at 07:33:44PM +0100, Will Deacon wrote: > > 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. > > IIUC, since the

Re: [PATCH] KVM: selftests: Rename vm_handle_exception in evmcs test

2021-06-07 Thread Ricardo Koller
On Mon, Jun 07, 2021 at 05:19:03PM +0100, Marc Zyngier wrote: > On Mon, 07 Jun 2021 17:07:40 +0100, > Sean Christopherson wrote: > > > > On Sun, Jun 06, 2021, Marc Zyngier wrote: > > > This is becoming a bit messy. I'd rather drop the whole series from > > > -next, and get something that doesn't

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

2021-06-07 Thread Jain, Jinank
On Thu, 2021-06-03 at 17:03 +0100, Marc Zyngier wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you can confirm the sender > and know the content is safe. > > > > Hi Jinank, > > On Thu, 03 Jun 2021 12:05:54 +0100, > Jinan

Re: [PATCH] KVM: selftests: Rename vm_handle_exception in evmcs test

2021-06-07 Thread Sean Christopherson
On Sun, Jun 06, 2021, Marc Zyngier wrote: > This is becoming a bit messy. I'd rather drop the whole series from > -next, and get something that doesn't break in the middle. Please > resend the series tested on top of -rc4. That'd be my preference too. I almost asked if it could be (temporarily) d

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

2021-06-07 Thread Jing Zhang
On Mon, Jun 7, 2021 at 2:23 PM Krish Sadhukhan wrote: > > > On 6/3/21 2:14 PM, Jing Zhang wrote: > > 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

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

2021-06-07 Thread Jing Zhang
On Mon, Jun 7, 2021 at 2:23 PM Krish Sadhukhan wrote: > > > On 6/3/21 2:14 PM, Jing Zhang wrote: > > 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 Koll

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

2021-06-07 Thread Jing Zhang
On Mon, Jun 7, 2021 at 2:23 PM Krish Sadhukhan wrote: > > > On 6/3/21 2:14 PM, Jing Zhang wrote: > > 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/.