Re: [PATCH v5 04/14] KVM: arm64: Don't pass kvm_pgtable through kvm_pgtable_walk_data

2022-11-09 Thread Oliver Upton
On Thu, Nov 10, 2022 at 01:30:08PM +0800, Gavin Shan wrote: > Hi Oliver, > > On 11/8/22 5:56 AM, Oliver Upton wrote: > > In order to tear down page tables from outside the context of > > kvm_pgtable (such as an RCU callback), stop passing a pointer through > > kvm_pgtable_walk_data. > > > > No fu

Re: [PATCH v5 03/14] KVM: arm64: Pass mm_ops through the visitor context

2022-11-09 Thread Gavin Shan
On 11/8/22 5:56 AM, Oliver Upton wrote: As a prerequisite for getting visitors off of struct kvm_pgtable, pass mm_ops through the visitor context. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 1 + arch/arm64/kvm/hyp/nvhe/setup.c

Re: [PATCH v5 04/14] KVM: arm64: Don't pass kvm_pgtable through kvm_pgtable_walk_data

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/8/22 5:56 AM, Oliver Upton wrote: In order to tear down page tables from outside the context of kvm_pgtable (such as an RCU callback), stop passing a pointer through kvm_pgtable_walk_data. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgt

Re: [PATCH v5 03/14] KVM: arm64: Pass mm_ops through the visitor context

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/8/22 5:56 AM, Oliver Upton wrote: As a prerequisite for getting visitors off of struct kvm_pgtable, pass mm_ops through the visitor context. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 1 + arch/arm64/kvm/hyp/nvhe/

Re: [PATCH v5 02/14] KVM: arm64: Stash observed pte value in visitor context

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/8/22 5:56 AM, Oliver Upton wrote: Rather than reading the ptep all over the shop, read the ptep once from __kvm_pgtable_visit() and stick it in the visitor context. Reread the ptep after visiting a leaf in case the callback installed a new table underneath. No functional change

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Gavin Shan
Hi Oliver, On 11/10/22 8:42 AM, Oliver Upton wrote: On Thu, Nov 10, 2022 at 08:23:36AM +0800, Gavin Shan wrote: On 11/8/22 5:56 AM, Oliver Upton wrote: Passing new arguments by value to the visitor callbacks is extremely inflexible for stuffing new parameters used by only some of the visitors.

[RFC PATCH 3/3] KVM: selftests: Test user hypercalls

2022-11-09 Thread Oliver Upton
Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/aarch64/user_hypercalls.c | 130 ++ 3 files changed, 132 insertions(+) create mode 100644 tools/testing/selftests/kvm/

[RFC PATCH 2/3] KVM: arm64: Allow userspace to trap SMCCC sub-ranges

2022-11-09 Thread Oliver Upton
As the SMCCC (and related specifications) march towards an 'everything and the kitchen sink' interface for interacting with a system, it is less likely that KVM will implement every supported feature. Add a capability that allows userspace to trap hypercall ranges, allowing the VMM to mix-and-matc

[RFC PATCH 1/3] KVM: arm64: Use a generalized accessor for SMCCC args

2022-11-09 Thread Oliver Upton
Avoid the need to introduce yet another accessor for every argument position with a generalized one instead. Align with the SMCCC specification and count arguments starting from 1. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_hypercalls.h | 22 ++

[RFC PATCH 0/3] KVM: arm64: Allow userspace to trap hypercall ranges

2022-11-09 Thread Oliver Upton
The Arm SMCCC is rather prescriptive in regards to the allocation of SMCCC function ID ranges. Many of the hypercall ranges have an associated specification from Arm (FF-A, PSCI, SDEI, etc.) with some room for vendor-specific implementations. The ever-expanding hypercall surface leaves a lot of wo

[RESEND PATCH] KVM: arm64: Move arch-specific headers out of include/kvm/

2022-11-09 Thread Oliver Upton
Long ago in a galaxy far, far away, KVM was supported on both 32 bit and 64 bit arm architectures. A considerable portion of the code was shared between these architectures, hence some headers needed to live in an arch-generic path. KVM/arm64 is the only supported arm KVM port now. Sweep some rema

[PATCH] KVM: arm64: Move arch-specific headers out of include/kvm/

2022-11-09 Thread Oliver Upton
Long ago in a galaxy far, far away, KVM was supported on both 32 bit and 64 bit arm architectures. A considerable portion of the code was shared between these architectures, hence some headers needed to live in an arch-generic path. KVM/arm64 is the only supported arm KVM port now. Sweep some rema

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Oliver Upton
Hi Gavin, On Thu, Nov 10, 2022 at 08:23:36AM +0800, Gavin Shan wrote: > On 11/8/22 5:56 AM, Oliver Upton wrote: > > Passing new arguments by value to the visitor callbacks is extremely > > inflexible for stuffing new parameters used by only some of the > > visitors. Use a context structure instead

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Gavin Shan
On 11/8/22 5:56 AM, Oliver Upton wrote: Passing new arguments by value to the visitor callbacks is extremely inflexible for stuffing new parameters used by only some of the visitors. Use a context structure instead and pass the pointer through to the visitor callback. While at it, redefine the '

Re: [PATCH v5 08/14] KVM: arm64: Protect stage-2 traversal with RCU

2022-11-09 Thread Oliver Upton
On Wed, Nov 09, 2022 at 09:53:45PM +, Sean Christopherson wrote: > On Mon, Nov 07, 2022, Oliver Upton wrote: > > Use RCU to safely walk the stage-2 page tables in parallel. Acquire and > > release the RCU read lock when traversing the page tables. Defer the > > freeing of table memory to an RCU

Re: [PATCH v5 11/14] KVM: arm64: Make block->table PTE changes parallel-aware

2022-11-09 Thread Oliver Upton
On Wed, Nov 09, 2022 at 02:26:36PM -0800, Ben Gardon wrote: > On Mon, Nov 7, 2022 at 1:59 PM Oliver Upton wrote: > > > > In order to service stage-2 faults in parallel, stage-2 table walkers > > must take exclusive ownership of the PTE being worked on. An additional > > requirement of the architec

Re: [PATCH v5 10/14] KVM: arm64: Split init and set for table PTE

2022-11-09 Thread Oliver Upton
On Wed, Nov 09, 2022 at 02:26:26PM -0800, Ben Gardon wrote: > On Mon, Nov 7, 2022 at 1:58 PM Oliver Upton wrote: > > > > Create a helper to initialize a table and directly call > > smp_store_release() to install it (for now). Prepare for a subsequent > > change that generalizes PTE writes with a h

Re: [PATCH v5 05/14] KVM: arm64: Add a helper to tear down unlinked stage-2 subtrees

2022-11-09 Thread Oliver Upton
On Wed, Nov 09, 2022 at 02:23:33PM -0800, Ben Gardon wrote: > On Mon, Nov 7, 2022 at 1:57 PM Oliver Upton wrote: > > > > A subsequent change to KVM will move the tear down of an unlinked > > stage-2 subtree out of the critical path of the break-before-make > > sequence. > > > > Introduce a new hel

Re: [PATCH v5 01/14] KVM: arm64: Combine visitor arguments into a context structure

2022-11-09 Thread Oliver Upton
On Wed, Nov 09, 2022 at 02:23:08PM -0800, Ben Gardon wrote: > On Mon, Nov 7, 2022 at 1:57 PM Oliver Upton wrote: > > > > Passing new arguments by value to the visitor callbacks is extremely > > inflexible for stuffing new parameters used by only some of the > > visitors. Use a context structure in

Re: [PATCH v5 09/14] KVM: arm64: Atomically update stage 2 leaf attributes in parallel walks

2022-11-09 Thread Sean Christopherson
On Wed, Nov 09, 2022, Ben Gardon wrote: > On Mon, Nov 7, 2022 at 1:58 PM Oliver Upton wrote: > > @@ -1054,7 +1066,7 @@ kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable > > *pgt, u64 addr) > > bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr) > > { > > kvm_pte_t pt

Re: [PATCH v5 08/14] KVM: arm64: Protect stage-2 traversal with RCU

2022-11-09 Thread Sean Christopherson
On Mon, Nov 07, 2022, Oliver Upton wrote: > Use RCU to safely walk the stage-2 page tables in parallel. Acquire and > release the RCU read lock when traversing the page tables. Defer the > freeing of table memory to an RCU callback. Indirect the calls into RCU > and provide stubs for hypervisor cod

Re: [v2 0/6] KVM: arm64: implement vcpu_is_preempted check

2022-11-09 Thread Usama Arif
On 07/11/2022 18:24, Punit Agrawal wrote: Hi Usama, Usama Arif writes: This patchset adds support for vcpu_is_preempted in arm64, which allows the guest to check if a vcpu was scheduled out, which is useful to know incase it was holding a lock. vcpu_is_preempted can be used to improve per

Re: [PATCH] arm64: paravirt: remove conduit check in has_pv_steal_clock

2022-11-09 Thread Will Deacon
On Fri, 4 Nov 2022 06:16:59 +, Usama Arif wrote: > arm_smccc_1_1_invoke() which is called later on in the function > will return failure if there's no conduit (or pre-SMCCC 1.1), > hence the check is unnecessary. > > Applied to arm64 (for-next/trivial), thanks! [1/1] arm64: paravirt: remove