Re: [PATCH v5 6/7] KVM: arm64: Mask FEAT_CCIDX

2023-01-05 Thread Oliver Upton
On Fri, Dec 30, 2022 at 06:54:51PM +0900, Akihiko Odaki wrote: > The CCSIDR access handler masks the associativity bits according to the > bit layout for processors without FEAT_CCIDX. KVM also assumes CCSIDR is > 32-bit where it will be 64-bit if FEAT_CCIDX is enabled. Mask FEAT_CCIDX > so that th

Re: [PATCH v4 6/7] KVM: arm64: Mask FEAT_CCIDX

2023-01-05 Thread Oliver Upton
Hi Akihiko, On Thu, Dec 22, 2022 at 05:40:15AM +0900, Akihiko Odaki wrote: > The CCSIDR access handler masks the associativity bits according to the > bit layout for processors without FEAT_CCIDX. KVM also assumes CCSIDR is > 32-bit where it will be 64-bit if FEAT_CCIDX is enabled. Mask FEAT_CCIDX

Re: [PATCH v5 7/7] KVM: arm64: Normalize cache configuration

2023-01-05 Thread Oliver Upton
Hi Akihiko, On Fri, Dec 30, 2022 at 06:54:52PM +0900, Akihiko Odaki wrote: [...] > @@ -417,6 +418,9 @@ struct kvm_vcpu_arch { > u64 last_steal; > gpa_t base; > } steal; > + > + /* Per-vcpu CCSIDR override or NULL */ > + u32 *ccsidr; I don't believe we n

Re: [PATCH 2/3] KVM: arm64: Handle S1PTW translation with TCR_HA set as a write

2022-12-22 Thread Oliver Upton
On Thu, Dec 22, 2022 at 09:01:15AM +, Marc Zyngier wrote: > On Wed, 21 Dec 2022 17:46:24 +0000, Oliver Upton > wrote: > > - When UFFD is in use, translation faults are reported to userspace as > >writes when from a RW memslot and reads when from an RO memsl

Re: [PATCH 1/3] KVM: arm64: Fix S1PTW handling on RO memslots

2022-12-21 Thread Oliver Upton
On Wed, Dec 21, 2022 at 05:53:58PM +, Marc Zyngier wrote: > On Wed, 21 Dec 2022 16:50:30 +, > Oliver Upton wrote: > > > > On Wed, Dec 21, 2022 at 09:35:06AM +, Marc Zyngier wrote: > > > > [...] > > > >

Re: [PATCH 2/3] KVM: arm64: Handle S1PTW translation with TCR_HA set as a write

2022-12-21 Thread Oliver Upton
On Wed, Dec 21, 2022 at 08:46:06AM -0800, Ricardo Koller wrote: [...] > > - return false; > > + /* Can't introspect TCR_EL1 with pKVM */ > > + if (kvm_vm_is_protected(vcpu->kvm)) > > + return false; > > + > > +

Re: [PATCH 1/3] KVM: arm64: Fix S1PTW handling on RO memslots

2022-12-21 Thread Oliver Upton
e flags > > > + * to be set. > > > + */ > > > + switch (kvm_vcpu_trap_get_fault_type(vcpu)) { > > > + case ESR_ELx_FSC_PERM: > > > + return true; > > > + default: > > > +

Re: [PATCH 1/3] KVM: arm64: Fix S1PTW handling on RO memslots

2022-12-20 Thread Oliver Upton
return true; > + default: > + return false; > + } > + } > > if (kvm_vcpu_trap_is_iabt(vcpu)) > return false; > -- > 2.34.1 > Besides the changelog/comment suggestions, the patch looks good to me. Reviewed-by: Oliver Upton -- Thanks, Oliver ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Re: [PATCH v1 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2

2022-12-20 Thread Oliver Upton
On Thu, Dec 15, 2022 at 06:12:14PM +, Oliver Upton wrote: > On Thu, Dec 15, 2022 at 09:33:17AM +, Ryan Roberts wrote: > > On 15/12/2022 00:52, Oliver Upton wrote: > > > On Tue, Dec 06, 2022 at 01:59:18PM +, Ryan Roberts wrote: > > >> (appologies, I'm

Re: [PATCH v1 10/12] KVM: arm64: Rework logic to en/decode VTCR_EL2.{SL0, SL2} fields

2022-12-20 Thread Oliver Upton
On Tue, Dec 20, 2022 at 09:01:19AM +, Ryan Roberts wrote: > On 20/12/2022 00:06, Oliver Upton wrote: > > Hi Ryan, > > > > On Tue, Dec 06, 2022 at 01:59:28PM +, Ryan Roberts wrote: > >> In order to support 5 level translation, FEAT_LPA2 introduces the 1-bit

Re: [PATCH v1 10/12] KVM: arm64: Rework logic to en/decode VTCR_EL2.{SL0, SL2} fields

2022-12-19 Thread Oliver Upton
Hi Ryan, On Tue, Dec 06, 2022 at 01:59:28PM +, Ryan Roberts wrote: > In order to support 5 level translation, FEAT_LPA2 introduces the 1-bit > SL2 field within VTCR_EL2 to extend the existing 2-bit SL0 field. The > SL2[0]:SL0[1:0] encodings have no simple algorithmic relationship to the > star

Re: [PATCH v1 05/12] KVM: arm64: Maintain page-table format info in struct kvm_pgtable

2022-12-19 Thread Oliver Upton
Hi Ryan, On Tue, Dec 06, 2022 at 01:59:23PM +, Ryan Roberts wrote: > As the next step on the journey to supporting FEAT_LPA2 in KVM, add a > flag to struct kvm_pgtable, which functions can then use to select the > approprate behavior for either the `classic` or `lpa2` page-table > formats. For

Re: [PATCH v1 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2

2022-12-15 Thread Oliver Upton
On Thu, Dec 15, 2022 at 09:33:17AM +, Ryan Roberts wrote: > On 15/12/2022 00:52, Oliver Upton wrote: > > On Tue, Dec 06, 2022 at 01:59:18PM +, Ryan Roberts wrote: > >> (appologies, I'm resending this series as I managed to send the cover > >> letter to &g

Re: [PATCH v1 01/12] arm64/mm: Add FEAT_LPA2 specific ID_AA64MMFR0.TGRAN[2]

2022-12-14 Thread Oliver Upton
On Wed, Dec 14, 2022 at 07:16:09PM +, Oliver Upton wrote: > On Tue, Dec 06, 2022 at 01:59:19PM +, Ryan Roberts wrote: > > From: Anshuman Khandual > > > > PAGE_SIZE support is tested against possible minimum and maximum values for > > its respective ID_AA64MMFR

Re: [PATCH v1 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2

2022-12-14 Thread Oliver Upton
On Tue, Dec 06, 2022 at 01:59:18PM +, Ryan Roberts wrote: > (appologies, I'm resending this series as I managed to send the cover letter > to > all but the following patches only to myself on first attempt). > > This is my first upstream feature submission so please go easy ;-) Welcome :) >

Re: [PATCH v1 01/12] arm64/mm: Add FEAT_LPA2 specific ID_AA64MMFR0.TGRAN[2]

2022-12-14 Thread Oliver Upton
On Tue, Dec 06, 2022 at 01:59:19PM +, Ryan Roberts wrote: > From: Anshuman Khandual > > PAGE_SIZE support is tested against possible minimum and maximum values for > its respective ID_AA64MMFR0.TGRAN field, depending on whether it is signed > or unsigned. But then FEAT_LPA2 implementation nee

Re: [PATCH 0/3] KVM: arm64: Normalize cache configuration

2022-12-13 Thread Oliver Upton
Hi Akihiko, On Sun, Dec 11, 2022 at 02:16:57PM +0900, Akihiko Odaki wrote: > Before this change, the cache configuration of the physical CPU was > exposed to vcpus. This is problematic because the cache configuration a > vcpu sees varies when it migrates between vcpus with different cache > config

Re: [RFC PATCH 01/37] KVM: x86/mmu: Store the address space ID directly in kvm_mmu_page_role

2022-12-12 Thread Oliver Upton
On Mon, Dec 12, 2022 at 05:39:38PM +, Sean Christopherson wrote: > On Fri, Dec 09, 2022, David Matlack wrote: > > On Fri, Dec 9, 2022 at 9:25 AM Oliver Upton wrote: > > > > > > On Fri, Dec 09, 2022 at 10:37:47AM +0800, Yang, Weijiang wrote: > > > > >

Re: [PATCH v2 7/7] KVM: selftests: Avoid infinite loop if ucall_alloc() fails

2022-12-09 Thread Oliver Upton
he guest into an infinite loop. > > Use -1 as the magic value, as a real ucall struct should never wrap. > > Reported-by: Oliver Upton > Signed-off-by: Sean Christopherson > --- > tools/testing/selftests/kvm/lib/ucall_common.c | 16 ++-- > 1 file changed, 14 ins

Re: [PATCH v2 4/7] KVM: selftests: Correctly initialize the VA space for TTBR0_EL1

2022-12-09 Thread Oliver Upton
On Fri, Dec 09, 2022 at 08:45:01PM +, Sean Christopherson wrote: > On Fri, Dec 09, 2022, Oliver Upton wrote: > > An interesting feature of the Arm architecture is that the stage-1 MMU > > supports two distinct VA regions, controlled by TTBR{0,1}_EL1. As KVM > > selftes

Re: [RFC PATCH 00/37] KVM: Refactor the KVM/x86 TDP MMU into common code

2022-12-09 Thread Oliver Upton
On Thu, Dec 08, 2022 at 11:38:20AM -0800, David Matlack wrote: > [ mm folks: You are being cc'd since this series includes a mm patch > ("mm: Introduce architecture-neutral PG_LEVEL macros"), but general > feedback is also welcome. I imagine there are a lot of lessons KVM can > learn from mm

Re: [RFC PATCH 23/37] KVM: MMU: Move VM-level TDP MMU state to struct kvm

2022-12-09 Thread Oliver Upton
On Fri, Dec 09, 2022 at 09:57:15AM -0800, David Matlack wrote: > On Fri, Dec 9, 2022 at 9:32 AM Oliver Upton wrote: > > > > Hey David, > > > > On Thu, Dec 08, 2022 at 11:38:43AM -0800, David Matlack wrote: > > > Move VM-level TDP MMU state to struct kvm so it

Re: [PATCH 1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value

2022-12-09 Thread Oliver Upton
gt; > target/arm/helper.c:1813: pmevcntr_rawwrite: Assertion `counter < > pmu_num_counters(env)' failed. > > Fixes: 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling") > Signed-off-by: James Clark Reviewed-by: Oliver Upton -- Thanks, Oliver &

Re: [RFC PATCH 23/37] KVM: MMU: Move VM-level TDP MMU state to struct kvm

2022-12-09 Thread Oliver Upton
Hey David, On Thu, Dec 08, 2022 at 11:38:43AM -0800, David Matlack wrote: > Move VM-level TDP MMU state to struct kvm so it can be accessed by > common code in a future commit. > > No functional change intended. Could you instead introduce a structure to hold all of the MMU state and stick that

Re: [RFC PATCH 01/37] KVM: x86/mmu: Store the address space ID directly in kvm_mmu_page_role

2022-12-09 Thread Oliver Upton
On Fri, Dec 09, 2022 at 10:37:47AM +0800, Yang, Weijiang wrote: > > On 12/9/2022 3:38 AM, David Matlack wrote: > > Rename kvm_mmu_page_role.smm with kvm_mmu_page_role.as_id and use it > > directly as the address space ID throughout the KVM MMU code. This > > eliminates a needless level of indirect

Re: [GIT PULL] KVM/arm64 updates for 6.2

2022-12-09 Thread Oliver Upton
Hey Paolo, On Fri, Dec 09, 2022 at 05:56:50PM +0100, Paolo Bonzini wrote: > On 12/7/22 22:51, Oliver Upton wrote: > > > > > > I haven't pushed to kvm/next yet to give you time to check, so the > > > merge is currently in kvm/queue only. > > Have a look a

Re: [PATCH v2 0/7] KVM: selftests: Fixes for ucall pool + page_fault_test

2022-12-09 Thread Oliver Upton
On Fri, Dec 09, 2022 at 09:24:23AM +0100, Andrew Jones wrote: > On Fri, Dec 09, 2022 at 01:52:59AM +0000, Oliver Upton wrote: > > base-commit: 89b2395859651113375101bb07cd6340b1ba3637 > > This commit doesn't seem to exist linux-next or kvm/queue, but the patch > context

[PATCH v2 7/7] KVM: selftests: Avoid infinite loop if ucall_alloc() fails

2022-12-08 Thread Oliver Upton
callsite and an associated comment about why assertions don't work here. It isn't perfect, at least the poor developer gets some signal out of the guest... Fixes: 426729b2cf2e ("KVM: selftests: Add ucall pool based implementation") Signed-off-by: Oliver Upton --- tools/testi

[PATCH v2 6/7] KVM: selftests: Allocate ucall pool from MEM_REGION_DATA

2022-12-08 Thread Oliver Upton
MEM_REGION_TEST_DATA is meant to hold data explicitly used by a selftest, not implicit allocations due to the selftests infrastructure. Allocate the ucall pool from MEM_REGION_DATA much like the rest of the selftests library allocations. Reviewed-by: Sean Christopherson Signed-off-by: Oliver

[PATCH v2 5/7] KVM: arm64: selftests: Don't identity map the ucall MMIO hole

2022-12-08 Thread Oliver Upton
map() instead to guarantee that the chosen VA isn't to something else. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/lib/aarch64/ucall.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/aarch64/ucall.c b/tools/testing/selftests

[PATCH v2 4/7] KVM: selftests: Correctly initialize the VA space for TTBR0_EL1

2022-12-08 Thread Oliver Upton
addressing schemes with a comment describing each. Signed-off-by: Oliver Upton --- .../selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c| 49 --- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/k

[PATCH v2 2/7] KVM: selftests: Setup ucall after loading program into guest memory

2022-12-08 Thread Oliver Upton
park the ucall MMIO addr after MEM_REGION_TEST_DATA. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/aarch64/page_fault_test.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftest

[PATCH v2 3/7] KVM: selftests: Mark correct page as mapped in virt_map()

2022-12-08 Thread Oliver Upton
The loop marks vaddr as mapped after incrementing it by page size, thereby marking the *next* page as mapped. Set the bit in vpages_mapped first instead. Fixes: 56fc7732031d ("KVM: selftests: Fill in vm->vpages_mapped bitmap in virt_map() too") Signed-off-by: Oliver Upton ---

[PATCH v2 1/7] KVM: selftests: Fix build due to ucall_uninit() removal

2022-12-08 Thread Oliver Upton
"KVM: selftests: Drop now-unnecessary ucall_uninit()") Fixes: 35c581015712 ("KVM: selftests: aarch64: Add aarch64/page_fault_test") Signed-off-by: Mark Brown Cc: Sean Christopherson Cc: Ricardo Koller Cc: Marc Zyngier Signed-off-by: Oliver Upton --- tools/testing/selftest

[PATCH v2 0/7] KVM: selftests: Fixes for ucall pool + page_fault_test

2022-12-08 Thread Oliver Upton
Mark Brown (1): KVM: selftests: Fix build due to ucall_uninit() removal Oliver Upton (6): KVM: selftests: Setup ucall after loading program into guest memory KVM: selftests: Mark correct page as mapped in virt_map() KVM: selftests: Correctly initialize the VA space for TTBR0_EL1 KVM:

Re: [PATCH 2/4] KVM: selftests: Setup ucall after loading program into guest memory

2022-12-07 Thread Oliver Upton
On Thu, Dec 08, 2022 at 12:24:20AM +, Sean Christopherson wrote: > On Thu, Dec 08, 2022, Oliver Upton wrote: > > On Wed, Dec 07, 2022 at 11:57:27PM +, Sean Christopherson wrote: > > > > diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > &g

Re: [PATCH 3/4] KVM: arm64: selftests: Align VA space allocator with TTBR0

2022-12-07 Thread Oliver Upton
On Thu, Dec 08, 2022 at 12:18:07AM +, Sean Christopherson wrote: [...] > Together, what about? The #ifdef is a bit gross, especially around > "hi_start", > but it's less duplicate code. And IMO, having things bundled in the same > place > makes it a lot easier for newbies (to arm64 or ker

Re: [PATCH 2/4] KVM: selftests: Setup ucall after loading program into guest memory

2022-12-07 Thread Oliver Upton
On Wed, Dec 07, 2022 at 11:57:27PM +, Sean Christopherson wrote: > On Wed, Dec 07, 2022, Oliver Upton wrote: > > The new ucall infrastructure needs to update a couple of guest globals > > to pass through the ucall MMIO addr and pool of ucall structs. A > > precondition of

Re: [PATCH 4/4] KVM: selftests: Allocate ucall pool from MEM_REGION_DATA

2022-12-07 Thread Oliver Upton
On Wed, Dec 07, 2022 at 11:44:50PM +, Sean Christopherson wrote: > On Wed, Dec 07, 2022, Oliver Upton wrote: > > MEM_REGION_TEST_DATA is meant to hold data explicitly used by a > > selftest, not implicit allocations due to the selftests infrastructure. > > Allocat

Re: [GIT PULL] KVM/arm64 updates for 6.2

2022-12-07 Thread Oliver Upton
On Tue, Dec 06, 2022 at 06:41:21PM +0100, Paolo Bonzini wrote: > On 12/5/22 16:58, Marc Zyngier wrote: > > - There is a lot of selftest conflicts with your own branch, see: > > > >https://lore.kernel.org/r/20221201112432.4cb9a...@canb.auug.org.au > >https://lore.kernel.org/r/20221201113626

[PATCH 4/4] KVM: selftests: Allocate ucall pool from MEM_REGION_DATA

2022-12-07 Thread Oliver Upton
based implementation") Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/lib/ucall_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/ucall_common.c b/tools/testing/selftests/kvm/lib/ucall_common.c index 820ce6c82829..0c

[PATCH 3/4] KVM: arm64: selftests: Align VA space allocator with TTBR0

2022-12-07 Thread Oliver Upton
t VA space layout. Make use of the override to align vpages_valid with the behavior of TTBR0 on arm64. Signed-off-by: Oliver Upton --- .../testing/selftests/kvm/include/kvm_util_base.h | 1 + .../testing/selftests/kvm/lib/aarch64/processor.c | 10 ++ tools/testing/selftests/kvm/lib/

[PATCH 2/4] KVM: selftests: Setup ucall after loading program into guest memory

2022-12-07 Thread Oliver Upton
the ucall MMIO addr after MEM_REGION_TEST_DATA. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/aarch64/page_fault_test.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm

[PATCH 1/4] KVM: selftests: Fix build due to ucall_uninit() removal

2022-12-07 Thread Oliver Upton
"KVM: selftests: Drop now-unnecessary ucall_uninit()") Fixes: 35c581015712 ("KVM: selftests: aarch64: Add aarch64/page_fault_test") Signed-off-by: Mark Brown Cc: Sean Christopherson Cc: Ricardo Koller Cc: Marc Zyngier Signed-off-by: Oliver Upton --- tools/testing/selftest

[PATCH 0/4] KVM: selftests: Fixes for ucall pool + page_fault_test

2022-12-07 Thread Oliver Upton
lo's merge resolution, if desired. Mark Brown (1): KVM: selftests: Fix build due to ucall_uninit() removal Oliver Upton (3): KVM: selftests: Setup ucall after loading program into guest memory KVM: arm64: selftests: Align VA space allocator with TTBR0 KVM: selftests: Allocate

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

2022-12-04 Thread Oliver Upton
Hi Mingwei, On Mon, Dec 05, 2022 at 05:51:13AM +, Mingwei Zhang wrote: > On Mon, Nov 14, 2022, Oliver Upton wrote: [...] > > As hyp stage-1 is protected by a spinlock there is no actual need for > > RCU in that case. I'll post something later on today that add

Re: [PATCH 0/3] KVM: arm64: Handle CCSIDR associativity mismatches

2022-12-02 Thread Oliver Upton
On Thu, Dec 01, 2022 at 11:14:43PM +, Marc Zyngier wrote: > On Thu, 01 Dec 2022 18:29:51 +, > Oliver Upton wrote: > > Could we extend your suggestion about accepting different topologies to > > effectively tolerate _any_ topology provided by userspace? KVM can > >

[PATCH v2 6/6] KVM: arm64: Condition HW AF updates on config option

2022-12-02 Thread Oliver Upton
the stage-2 access fault path on Armv8.1+ implementations. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 30575b5f5dcd..3d61bd3e591d 100644 --- a/arch/arm64/kvm/hyp

[PATCH v2 5/6] KVM: arm64: Handle access faults behind the read lock

2022-12-02 Thread Oliver Upton
As the underlying software walkers are able to traverse and update stage-2 in parallel there is no need to serialize access faults. Only take the read lock when handling an access fault. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 3 ++- arch/arm64/kvm/mmu.c | 4

[PATCH v2 3/6] KVM: arm64: Return EAGAIN for invalid PTE in attr walker

2022-12-02 Thread Oliver Upton
Return EAGAIN for invalid PTEs in the attr walker, signaling to the caller that any serialization and/or invalidation can be elided. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b

[PATCH v2 2/6] KVM: arm64: Ignore EAGAIN for walks outside of a fault

2022-12-02 Thread Oliver Upton
behavior is undesirable for walkers that operate outside a fault handler. Suppress EAGAIN and continue the walk if operating outside a fault handler. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 3 +++ arch/arm64/kvm/hyp/pgtable.c | 30

[PATCH v2 4/6] KVM: arm64: Don't serialize if the access flag isn't set

2022-12-02 Thread Oliver Upton
Of course, if the PTE wasn't changed then there are absolutely no serialization requirements. Skip the DSB for an unsuccessful update to the access flag. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --

[PATCH v2 0/6] KVM: arm64: Parallel access faults

2022-12-02 Thread Oliver Upton
abled. v1 -> v2: - Don't serialize if attr walker fails due to an invalid PTE (Ricardo) - Rejig the error handling path in the table walker to suppress EAGAIN in non-fault handling paths v1: https://lore.kernel.org/kvmarm/20221129191946.1735662-1-oliver.up...@linux.dev Oliver Upt

[PATCH v2 1/6] KVM: arm64: Use KVM's pte type/helpers in handle_access_fault()

2022-12-02 Thread Oliver Upton
Consistently use KVM's own pte types and helpers in handle_access_fault(). No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 5 + arch/arm64/kvm/mmu.c | 10 -- 2 files changed, 9 insertions(+), 6 dele

Re: [PATCH 0/3] KVM: arm64: Handle CCSIDR associativity mismatches

2022-12-01 Thread Oliver Upton
On Thu, Dec 01, 2022 at 11:06:50AM +, Marc Zyngier wrote: [...] > It would be a lot better to expose a virtual topology > (one set, one way, one level). It would also save us from the CCSIDRX > silliness. > > The only complexity would be to still accept different topologies from > userspace

Re: [PATCH 2/4] KVM: arm64: Don't serialize if the access flag isn't set

2022-12-01 Thread Oliver Upton
On Tue, Nov 29, 2022 at 09:15:21PM +, Oliver Upton wrote: > Hi Ricardo, > > Thanks for having a look. > > On Tue, Nov 29, 2022 at 12:52:12PM -0800, Ricardo Koller wrote: > > On Tue, Nov 29, 2022 at 07:19:44PM +, Oliver Upton wrote: > > [...] > > > &g

Re: [PATCH 2/4] KVM: arm64: Don't serialize if the access flag isn't set

2022-11-29 Thread Oliver Upton
Hi Ricardo, Thanks for having a look. On Tue, Nov 29, 2022 at 12:52:12PM -0800, Ricardo Koller wrote: > On Tue, Nov 29, 2022 at 07:19:44PM +0000, Oliver Upton wrote: [...] > > + ret = stage2_update_leaf_attrs(pgt, addr, 1, > > KVM_PTE_LEAF_A

[PATCH 4/4] KVM: arm64: Condition HW AF updates on config option

2022-11-29 Thread Oliver Upton
the stage-2 access fault path on Armv8.1+ implementations. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 1a3dd9774707..9c651b6d4092 100644 --- a/arch/arm64/kvm/hyp

[PATCH 2/4] KVM: arm64: Don't serialize if the access flag isn't set

2022-11-29 Thread Oliver Upton
Of course, if the PTE wasn't changed then there are absolutely no serialization requirements. Skip the DSB for an unsuccessful update to the access flag. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --

[PATCH 3/4] KVM: arm64: Handle access faults behind the read lock

2022-11-29 Thread Oliver Upton
As the underlying software walkers are able to traverse and update stage-2 in parallel there is no need to serialize access faults. Only take the read lock when handling an access fault. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 2 +- arch/arm64/kvm/mmu.c | 4

[PATCH 1/4] KVM: arm64: Use KVM's pte type/helpers in handle_access_fault()

2022-11-29 Thread Oliver Upton
Consistently use KVM's own pte types and helpers in handle_access_fault(). No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 5 + arch/arm64/kvm/mmu.c | 10 -- 2 files changed, 9 insertions(+), 6 dele

[PATCH 0/4] KVM: arm64: Parallel access faults

2022-11-29 Thread Oliver Upton
d that, I won't throw a fit if it gets dropped either. Applies to kvmarm/next due to the dependency on the larger parallel faults series. Tested on Ampere Altra w/ VTCR_EL2.HA=0 as well as a Raspberry Pi 4. Oliver Upton (4): KVM: arm64: Use KVM's pte type/helpers in handle_access_faul

[PATCH v2 1/2] KVM: selftests: Have perf_test_util signal when to stop vCPUs

2022-11-18 Thread Oliver Upton
the exact opposite problem, where subsequent test runs complete immediately as 'run_vcpus' remains false. Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson [oliver: added commit message, preserve spin_wait_for_next_iteration()] Signed-off-by: Oliver Upton ---

[PATCH v2 0/2] KVM: selftests: Enable access_tracking_perf_test for arm64

2022-11-18 Thread Oliver Upton
left off Gavin's R-b on the first patch as it was retooled. v1: https://lore.kernel.org/kvmarm/2022231946.944807-1-oliver.up...@linux.dev/ Oliver Upton (2): KVM: selftests: Have perf_test_util signal when to stop vCPUs KVM: selftests: Build access_tracking_perf_test for arm64

[PATCH v2 2/2] KVM: selftests: Build access_tracking_perf_test for arm64

2022-11-18 Thread Oliver Upton
Does exactly what it says on the tin. Reviewed-by: Gavin Shan Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 0172eb6cb6ee..4c0ff91a8964

[PATCH v4 3/3] KVM: arm64: Reject shared table walks in the hyp code

2022-11-18 Thread Oliver Upton
Exclusive table walks are the only supported table walk in the hyp, as there is no construct like RCU available in the hypervisor code. Reject any attempt to do a shared table walk by returning an error and allowing the caller to clean up the mess. Suggested-by: Will Deacon Signed-off-by: Oliver

[PATCH v4 2/3] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-18 Thread Oliver Upton
kernel_init+0x24/0x130 ret_from_fork+0x10/0x20 Since the hyp stage-1 table walkers are serialized by kvm_hyp_pgd_mutex, RCU protection really doesn't add anything. Don't acquire the RCU read lock for an exclusive walk. Reported-by: Marek Szyprowski Signed-off-by: Oliver Upton --- arch/arm

[PATCH v4 1/3] KVM: arm64: Take a pointer to walker data in kvm_dereference_pteref()

2022-11-18 Thread Oliver Upton
their use. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 144 ++- arch/arm64/kvm/hyp/pgtable.c | 6 +- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h

[PATCH v4 0/3] KVM: arm64: Fixes for parallel faults series

2022-11-18 Thread Oliver Upton
} and lockdep. Applies on top of the parallel faults series picked up last week. v3: https://lore.kernel.org/kvmarm/20221116165655.2649475-1-oliver.up...@linux.dev/ v3 -> v4: - Return an error instead of WARN() in hyp for shared walks (Will) Oliver Upton (3): KVM: arm64: Take a pointer to wal

Re: [PATCH v3 2/2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-18 Thread Oliver Upton
On Fri, Nov 18, 2022 at 12:19:50PM +, Will Deacon wrote: > On Thu, Nov 17, 2022 at 06:23:23PM +0000, Oliver Upton wrote: > > On Thu, Nov 17, 2022 at 05:49:52PM +, Will Deacon wrote: > > > On Wed, Nov 16, 2022 at 04:56:55PM +, Oliver Upton wrote: > > > &

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

2022-11-18 Thread Oliver Upton
On Fri, Nov 18, 2022 at 02:56:38PM +, Will Deacon wrote: > On Thu, Nov 10, 2022 at 01:53:26AM +0000, Oliver Upton wrote: > > As the SMCCC (and related specifications) march towards an > > 'everything and the kitchen sink' interface for interacting with a > > sys

Re: [PATCH v3 2/2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-17 Thread Oliver Upton
Hi Will, Thanks for having a look. On Thu, Nov 17, 2022 at 05:49:52PM +, Will Deacon wrote: > On Wed, Nov 16, 2022 at 04:56:55PM +0000, Oliver Upton wrote: [...] > > -static inline void kvm_pgtable_walk_begin(void) {} > > -static inline void kvm_pgtable_walk_end(void) {} >

Re: [PATCH 2/2] KVM: arm64: selftests: Disable single-step without relying on ucall()

2022-11-16 Thread Oliver Upton
will hang as the local exclusive monitor is reset by eret, > i.e. the stlxr will always fail due to the VM-Exit for the debug > exception. ... due to the debug exception taken to EL2. What's a VM-Exit anyways? ;-) > Link: https://lore.kernel.org/all/20221006003409.649993-8-sea...@g

Re: [PATCH 1/2] KVM: arm64: selftests: Disable single-step with correct KVM define

2022-11-16 Thread Oliver Upton
effectively disables single-step debug. > > No functional change intended. > > Cc: Reiji Watanabe > Fixes: b18e4d4aebdd ("KVM: arm64: selftests: Add a test case for > KVM_GUESTDBG_SINGLESTEP") > Signed-off-by: Sean Christopherson Re

Re: [PATCH 03/12] KVM: arm64: Block unsafe FF-A calls from the host

2022-11-16 Thread Oliver Upton
Sorry, hit send a bit too early. Reviewing the patch itself: On Wed, Nov 16, 2022 at 05:03:26PM +, Quentin Perret wrote: [...] > +static bool ffa_call_unsupported(u64 func_id) > +{ > + switch (func_id) { > + /* Unsupported memory management calls */ > + case FFA_FN64_MEM_RETRIEVE

Re: [PATCH 03/12] KVM: arm64: Block unsafe FF-A calls from the host

2022-11-16 Thread Oliver Upton
On Wed, Nov 16, 2022 at 05:03:26PM +, Quentin Perret wrote: > From: Will Deacon > > When KVM is initialised in protected mode, we must take care to filter > certain FFA calls from the host kernel so that the integrity of guest > and hypervisor memory is maintained and is not made available to

[PATCH v3 2/2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-16 Thread Oliver Upton
d walks in the hypervisor code. Reported-by: Marek Szyprowski Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 22 -- arch/arm64/kvm/hyp/pgtable.c | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/kvm

[PATCH v3 1/2] KVM: arm64: Take a pointer to walker data in kvm_dereference_pteref()

2022-11-16 Thread Oliver Upton
their use. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 144 ++- arch/arm64/kvm/hyp/pgtable.c | 6 +- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h

[PATCH v3 0/2] KVM: arm64: Fixes for parallel faults series

2022-11-16 Thread Oliver Upton
}. Applies to the parallel faults series picked up last week. v2: https://lore.kernel.org/kvmarm/20221115225502.2240227-1-oliver.up...@linux.dev/ v2 -> v3: - Pass a pointer to the walker instead of a bool (Marc) - Apply the aforementioned change to kvm_dereference_pteref() Oliver Upton (2):

Re: [PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-16 Thread Oliver Upton
On Wed, Nov 16, 2022 at 07:27:27AM +, Oliver Upton wrote: > On Wed, Nov 16, 2022 at 03:08:49AM +, Marc Zyngier wrote: > > I'm not crazy about this sort of parameters. I think it would make a > > lot more sense to pass a pointer to the walker structure and do the >

Re: [PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-15 Thread Oliver Upton
On Wed, Nov 16, 2022 at 03:08:49AM +, Marc Zyngier wrote: > I'm not crazy about this sort of parameters. I think it would make a > lot more sense to pass a pointer to the walker structure and do the > flag check inside the helper. > > That way, we avoid extra churn if/when we need extra state

Re: [RFC PATCH 04/12] KVM: arm64: Add kvm_pgtable_stage2_split()

2022-11-15 Thread Oliver Upton
On Tue, Nov 15, 2022 at 03:27:18PM -0800, Ricardo Koller wrote: > On Tue, Nov 15, 2022 at 03:03:42PM -0800, Ricardo Koller wrote: > > On Mon, Nov 14, 2022 at 08:54:52PM +0000, Oliver Upton wrote: [...] > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pg

[PATCH v2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks

2022-11-15 Thread Oliver Upton
d walks in the hypervisor code. Reported-by: Marek Szyprowski Signed-off-by: Oliver Upton --- Applies on top of the parallel faults series that was picked up last week. Tested with kvm-arm.mode={nvhe,protected} on an Ampere Altra system. v1 -> v2: - Took Will's suggestion of conditio

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

2022-11-15 Thread Oliver Upton
On Tue, Nov 15, 2022 at 10:47:37AM -0800, Ricardo Koller wrote: > On Wed, Nov 09, 2022 at 11:55:31PM +0000, Oliver Upton wrote: > > On Wed, Nov 09, 2022 at 09:53:45PM +, Sean Christopherson wrote: > > > On Mon, Nov 07, 2022, Oliver Upton wrote: > > > > Use RCU t

Re: [PATCH 1/1] KVM: arm64: Use a separate function for hyp stage-1 walks

2022-11-15 Thread Oliver Upton
Hey Will, On Tue, Nov 15, 2022 at 01:25:34PM +, Will Deacon wrote: [...] > On Mon, Nov 14, 2022 at 08:11:27PM +0000, Oliver Upton wrote: > > +int kvm_pgtable_hyp_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, > > +struct kvm_pgtable_walker *walker);

Re: [PATCH 1/2] KVM: selftests: Allow >1 guest mode in access_tracking_perf_test

2022-11-14 Thread Oliver Upton
On Mon, Nov 14, 2022 at 05:12:48PM +, Sean Christopherson wrote: > On Fri, Nov 11, 2022, Oliver Upton wrote: > > As the name implies, for_each_guest_mode() will run the test case for > > all supported guest addressing modes. On x86 that doesn't amount to > > anythin

Re: [RFC PATCH 01/12] KVM: arm64: Relax WARN check in stage2_make_pte()

2022-11-14 Thread Oliver Upton
Hi Ricardo, On Sat, Nov 12, 2022 at 08:17:03AM +, Ricardo Koller wrote: > stage2_make_pte() throws a warning when used in a non-shared walk, as PTEs > are not "locked" when walking non-shared. Add a check so it can be used > non-shared. > > Signed-off-by: Ricardo Koller I would very much pr

Re: [RFC PATCH 04/12] KVM: arm64: Add kvm_pgtable_stage2_split()

2022-11-14 Thread Oliver Upton
Hi Ricardo, On Sat, Nov 12, 2022 at 08:17:06AM +, Ricardo Koller wrote: [...] > +/** > + * kvm_pgtable_stage2_split() - Split a range of huge pages into leaf PTEs > pointing > + * to PAGE_SIZE guest pages. > + * @pgt: Page-table structure initialised by kvm_pgt

[PATCH 1/1] KVM: arm64: Use a separate function for hyp stage-1 walks

2022-11-14 Thread Oliver Upton
hyp stage-1 tables. Call directly into __kvm_pgtable_walk() as table concatenation is not a supported feature at stage-1. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 24 arch/arm64/kvm/hyp/nvhe/setup.c | 2

[PATCH 0/1] KVM: arm64: Skip RCU protection for hyp stage-1

2022-11-14 Thread Oliver Upton
.26861-1-w...@kernel.org/ Oliver Upton (1): KVM: arm64: Use a separate function for hyp stage-1 walks arch/arm64/include/asm/kvm_pgtable.h | 24 arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- arch/arm64/kvm/hyp/pgtable.c | 18 +++--- 3 files c

Re: [RFC PATCH 06/12] KVM: arm64: Split block PTEs without using break-before-make

2022-11-14 Thread Oliver Upton
On Sat, Nov 12, 2022 at 08:17:08AM +, Ricardo Koller wrote: > Breaking a huge-page block PTE into an equivalent table of smaller PTEs > does not require using break-before-make (BBM) when FEAT_BBM level 2 is > implemented. Add the respective check for eager page splitting and avoid > using BBM.

Re: [RFC PATCH 02/12] KVM: arm64: Allow visiting block PTEs in post-order

2022-11-14 Thread Oliver Upton
On Sat, Nov 12, 2022 at 08:17:04AM +, Ricardo Koller wrote: > The page table walker does not visit block PTEs in post-order. But there > are some cases where doing so would be beneficial, for example: breaking a > 1G block PTE into a full tree in post-order avoids visiting the new tree. > > Al

Re: [RFC PATCH 00/12] KVM: arm64: Eager huge-page splitting for dirty-logging

2022-11-14 Thread Oliver Upton
is that this ioctl takes ranges, and not complete > memslots like when enabling dirty logging. This means that the cost of > splitting (mainly broadcasted TLBIs) can be throttled: split a range, wait > for a bit, split another range, etc. The benefits of this approach were > presented

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

2022-11-14 Thread Oliver Upton
Hi Marek, On Mon, Nov 14, 2022 at 03:29:14PM +0100, Marek Szyprowski wrote: > This patch landed in today's linux-next (20221114) as commit > c3119ae45dfb ("KVM: arm64: Protect stage-2 traversal with RCU"). > Unfortunately it introduces a following warning: Thanks for the bug report :) I had fai

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

2022-11-11 Thread Oliver Upton
On Fri, Nov 11, 2022 at 08:26:02AM +, Marc Zyngier wrote: > On Thu, 10 Nov 2022 21:13:54 +0000, Oliver Upton > wrote: > > The goal of what I was trying to get at is that either the kernel or > > userspace takes ownership of a range that has an ABI, but not both. i.e. >

[PATCH 0/2] KVM: selftests: Enable access_tracking_perf_test for arm64

2022-11-11 Thread Oliver Upton
Small series to add support for arm64 to access_tracking_perf_test. Well, really this corrects a bug that is benign on x86, but you get the point. Tested on an Ampere Altra system w/ all supported guest modes for that platform. Oliver Upton (2): KVM: selftests: Allow >1 guest mode

[PATCH 2/2] KVM: selftests: Build access_tracking_perf_test for arm64

2022-11-11 Thread Oliver Upton
Does exactly what it says on the tin. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 0172eb6cb6ee..4c0ff91a8964 100644 --- a/tools/testing

[PATCH 1/2] KVM: selftests: Allow >1 guest mode in access_tracking_perf_test

2022-11-11 Thread Oliver Upton
n the second test case, as the 'done' global remains set between test iterations. Clear it after VM teardown in anticipation of a subsequent test case. Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/access_tracking_perf_test.c | 3 +++ 1 file changed, 3 insertions(+) dif

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

2022-11-10 Thread Oliver Upton
On Thu, Nov 10, 2022 at 12:22:12PM +, Marc Zyngier wrote: > > diff --git a/arch/arm64/include/asm/kvm_host.h > > b/arch/arm64/include/asm/kvm_host.h > > index e33ed7c09a28..cc3872f1900c 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -52,6

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_pgt

  1   2   3   4   5   6   7   >