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

2022-12-22 Thread Ricardo Koller
On Thu, Dec 22, 2022 at 08:58:40PM +, Oliver Upton wrote: > On Thu, Dec 22, 2022 at 09:01:15AM +, Marc Zyngier wrote: > > On Wed, 21 Dec 2022 17:46:24 +, Oliver Upton > > wrote: > > > - When UFFD is in use, translation faults are reported to userspace as > > >writes when from a

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

2022-12-22 Thread Ricardo Koller
Hi Marc, On Wed, Dec 21, 2022 at 05:43:03PM +, Marc Zyngier wrote: > Hi Ricardo, > > On Wed, 21 Dec 2022 16:46:06 +, > Ricardo Koller wrote: > > > > Hello, > > > > On Tue, Dec 20, 2022 at 08:09:22PM +, Marc Zyngier wrote: > > > As a m

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

2022-12-21 Thread Ricardo Koller
Need to send some changes for page_fault_test as many tests assume that any S1PTW is always a PT write, and are failing. Also need to add some new tests for PTs in RO memslots (as it didn't make much sense before this change). > } > } > > -- > 2.34.1 &g

[kvm-unit-tests PATCH v2 4/4] arm: pmu: Print counter values as hexadecimals

2022-12-19 Thread Ricardo Koller
The arm/pmu test prints the value of counters as %ld. Most tests start with counters around 0 or UINT_MAX, so having something like -16 instead of 0x_fff0 is not very useful. Report counter values as hexadecimals. Reported-by: Alexandru Elisei Signed-off-by: Ricardo Koller --- arm/pmu.c

[kvm-unit-tests PATCH v2 2/4] arm: pmu: Prepare for testing 64-bit overflows

2022-12-19 Thread Ricardo Koller
w_at_64bits". 3. Refactor the test invocations to use the new "run_test()" which adds a report prefix indicating whether the test uses 64 or 32-bit overflows. A subsequent commit will actually add the 64-bit overflow tests. Signed-off-by: Ricar

[kvm-unit-tests PATCH v2 3/4] arm: pmu: Add tests for 64-bit overflows

2022-12-19 Thread Ricardo Koller
MCR_EL0.LP == 1" (for more details see AArch64.IncrementEventCounter() pseudocode in the ARM ARM DDI 0487H.a, J1.1.1 "aarch64/debug"). Signed-off-by: Ricardo Koller --- arm/pmu.c | 97 --- 1 file changed, 64 insertions(+), 33

[kvm-unit-tests PATCH v2 1/4] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-19 Thread Ricardo Koller
counters on PMUv3p5. Fix tests by correctly checking overflowing-counters against the expected 64-bit value. Signed-off-by: Ricardo Koller --- arm/pmu.c | 37 + 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/arm/pmu.c b/arm/pmu.c index cd47b14

[kvm-unit-tests PATCH v2 0/4] arm: pmu: Add support for PMUv3p5

2022-12-19 Thread Ricardo Koller
(): cntr0 <-> cntr1 [0] https://lore.kernel.org/kvmarm/20221113163832.3154370-1-...@kernel.org/ [1] https://lore.kernel.org/kvmarm/y4jasyxvfrnvv...@google.com/ Ricardo Koller (4): arm: pmu: Fix overflow checks for PMUv3p5 long counters arm: pmu: Prepare for testing 64-bit overflows arm: pm

Re: [kvm-unit-tests PATCH 3/3] arm: pmu: Add tests for 64-bit overflows

2022-12-14 Thread Ricardo Koller
On Wed, Dec 14, 2022 at 10:45:07AM +, Alexandru Elisei wrote: > Hi, > > On Tue, Dec 13, 2022 at 10:04:04AM -0800, Ricardo Koller wrote: > > On Tue, Dec 13, 2022 at 05:03:40PM +, Alexandru Elisei wrote: > > > Hi, > > > > > > Checked that all p

Re: [kvm-unit-tests PATCH 1/3] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-14 Thread Ricardo Koller
On Wed, Dec 14, 2022 at 10:46:05AM +, Alexandru Elisei wrote: > Hi, > > On Tue, Dec 13, 2022 at 10:01:06AM -0800, Ricardo Koller wrote: > > On Tue, Dec 13, 2022 at 04:43:38PM +, Alexandru Elisei wrote: > > > Hi, > > > > > > On Tue, Dec 13, 2022

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

2022-12-13 Thread Ricardo Koller
On Fri, Dec 09, 2022 at 05:58:31PM +, Oliver Upton wrote: > On Fri, Dec 09, 2022 at 04:44:46PM +, James Clark wrote: > > ARMV8_PMU_PMCR_N_MASK is an unshifted value which results in the wrong > > reset value for PMCR_EL0, so shift it to fix it. > > That's just mean. *_MASK tends to be a

Re: [kvm-unit-tests PATCH 3/3] arm: pmu: Add tests for 64-bit overflows

2022-12-13 Thread Ricardo Koller
uld be changed to unsigned > long. The counters only increment, they don't decrement, and I can't think > how printing them as signed could be useful. > > One more comment below. > > On Fri, Dec 02, 2022 at 04:55:27AM +, Ricardo Koller wrote: > > Modify all tests

Re: [kvm-unit-tests PATCH 1/3] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-13 Thread Ricardo Koller
On Tue, Dec 13, 2022 at 04:43:38PM +, Alexandru Elisei wrote: > Hi, > > On Tue, Dec 13, 2022 at 08:21:24AM -0800, Ricardo Koller wrote: > > On Tue, Dec 13, 2022 at 12:36:14PM +, Alexandru Elisei wrote: > > > Hi, > > > > > > Some more comment

Re: [kvm-unit-tests PATCH 1/3] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-13 Thread Ricardo Koller
On Tue, Dec 13, 2022 at 12:36:14PM +, Alexandru Elisei wrote: > Hi, > > Some more comments below. > > On Fri, Dec 02, 2022 at 04:55:25AM +, Ricardo Koller wrote: > > PMUv3p5 uses 64-bit counters irrespective of whether the PMU is configured > > for o

Re: [kvm-unit-tests PATCH 1/3] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-12 Thread Ricardo Koller
On Fri, Dec 09, 2022 at 05:47:14PM +, Alexandru Elisei wrote: > Hi, > > On Fri, Dec 02, 2022 at 04:55:25AM +, Ricardo Koller wrote: > > PMUv3p5 uses 64-bit counters irrespective of whether the PMU is configured > > for overflowing at 32 or 64-bits. The consequence is

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

2022-12-08 Thread Ricardo Koller
On Thu, Dec 08, 2022 at 07:01:57PM +, Sean Christopherson wrote: > On Thu, Dec 08, 2022, Ricardo Koller wrote: > > On Thu, Dec 08, 2022 at 12:37:23AM +, Oliver Upton wrote: > > > On Thu, Dec 08, 2022 at 12:24:20AM +, Sean Christopherson wrote: > > > > >

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

2022-12-08 Thread Ricardo Koller
On Thu, Dec 08, 2022 at 12:37:23AM +, Oliver Upton wrote: > 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

Re: [PATCH v4 04/16] KVM: arm64: PMU: Distinguish between 64bit counter and 64bit overflow

2022-12-05 Thread Ricardo Koller
On Mon, Dec 05, 2022 at 12:05:32PM +, Marc Zyngier wrote: > On Thu, 01 Dec 2022 16:51:46 +, > Ricardo Koller wrote: > > > > On Thu, Dec 01, 2022 at 08:47:47AM -0800, Ricardo Koller wrote: > > > On Sun, Nov 13, 2022 at 04:38:20PM +, Marc Zyngier wrote: &

[kvm-unit-tests PATCH 3/3] arm: pmu: Add tests for 64-bit overflows

2022-12-01 Thread Ricardo Koller
MCR_EL0.LP == 1" (for more details see AArch64.IncrementEventCounter() pseudocode in the ARM ARM DDI 0487H.a, J1.1.1 "aarch64/debug"). Signed-off-by: Ricardo Koller --- arm/pmu.c | 91 --- 1 file changed, 60 insertions(+), 31

[kvm-unit-tests PATCH 2/3] arm: pmu: Prepare for testing 64-bit overflows

2022-12-01 Thread Ricardo Koller
w_at_64bits". 3. Refactor the test invocations to use the new "run_test()" which adds a report prefix indicating whether the test uses 64 or 32-bit overflows. A subsequent commit will actually add the 64-bit overflow tests. Signed-off-by: Ricar

[kvm-unit-tests PATCH 0/3] arm: pmu: Add support for PMUv3p5

2022-12-01 Thread Ricardo Koller
://lore.kernel.org/kvmarm/y4jasyxvfrnvv...@google.com/ Ricardo Koller (3): arm: pmu: Fix overflow checks for PMUv3p5 long counters arm: pmu: Prepare for testing 64-bit overflows arm: pmu: Add tests for 64-bit overflows arm/pmu.c | 217 +- 1 file

[kvm-unit-tests PATCH 1/3] arm: pmu: Fix overflow checks for PMUv3p5 long counters

2022-12-01 Thread Ricardo Koller
counters on PMUv3p5. Fix tests by correctly checking overflowing-counters against the expected 64-bit value. Signed-off-by: Ricardo Koller --- arm/pmu.c | 29 ++--- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/arm/pmu.c b/arm/pmu.c index cd47b14..eeac984

Re: [PATCH v4 04/16] KVM: arm64: PMU: Distinguish between 64bit counter and 64bit overflow

2022-12-01 Thread Ricardo Koller
On Thu, Dec 01, 2022 at 08:47:47AM -0800, Ricardo Koller wrote: > On Sun, Nov 13, 2022 at 04:38:20PM +, Marc Zyngier wrote: > > The PMU architecture makes a subtle difference between a 64bit > > counter and a counter that has a 64bit overflow. This is for example > >

Re: [PATCH v4 04/16] KVM: arm64: PMU: Distinguish between 64bit counter and 64bit overflow

2022-12-01 Thread Ricardo Koller
On Sun, Nov 13, 2022 at 04:38:20PM +, Marc Zyngier wrote: > The PMU architecture makes a subtle difference between a 64bit > counter and a counter that has a 64bit overflow. This is for example > the case of the cycle counter, which can generate an overflow on > a 32bit boundary if

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

2022-11-30 Thread Ricardo Koller
On Wed, Nov 30, 2022 at 08:21:17AM +, Marc Zyngier wrote: > On Wed, 30 Nov 2022 01:23:20 +, > Ricardo Koller wrote: > > > > On Tue, Nov 29, 2022 at 09:15:21PM +, Oliver Upton wrote: > > > Hi Ricardo, > > > > > > Thanks for having a loo

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

2022-11-29 Thread Ricardo Koller
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 3/4] KVM: arm64: Handle access faults behind the read lock

2022-11-29 Thread Ricardo Koller
kvm_set_pfn_accessed(kvm_pte_to_pfn(pte)); > -- > 2.38.1.584.g0f3c55d4c2-goog > > ___ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm Reviewed-by: Ricardo Koller ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

2022-11-29 Thread Ricardo Koller
On Tue, Nov 29, 2022 at 07:19:44PM +, Oliver Upton wrote: > 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

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

2022-11-17 Thread Ricardo Koller
On Tue, Nov 15, 2022 at 11:54:27PM +, Oliver Upton wrote: > 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 +, Oliver Upton wrote: > > [...]

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

2022-11-15 Thread Ricardo Koller
On Tue, Nov 15, 2022 at 03:03:42PM -0800, Ricardo Koller wrote: > On Mon, Nov 14, 2022 at 08:54:52PM +, Oliver Upton wrote: > > Hi Ricardo, > > > > On Sat, Nov 12, 2022 at 08:17:06AM +, Ricardo Koller wrote: > > > > [...] > > > > > +

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

2022-11-15 Thread Ricardo Koller
On Mon, Nov 14, 2022 at 08:54:52PM +, Oliver Upton wrote: > Hi Ricardo, > > On Sat, Nov 12, 2022 at 08:17:06AM +, Ricardo Koller wrote: > > [...] > > > +/** > > + * kvm_pgtable_stage2_split() - Split a range of huge page

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

2022-11-15 Thread Ricardo Koller
On Wed, Nov 09, 2022 at 11:55:31PM +, 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 to safely walk the stage-2 page tables in parallel. Acquire and > > > release the RCU read lock when

[RFC PATCH 12/12] KVM: arm64: Use local TLBI on permission relaxation

2022-11-12 Thread Ricardo Koller
permission relaxation (i.e., not having changes broadcasted to all PEs). Signed-off-by: Marc Zyngier Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/kvm_asm.h | 4 +++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 10 ++ arch/arm64/kvm/hyp/nvhe/tlb.c | 54

[RFC PATCH 09/12] KVM: arm64: Split huge pages when dirty logging is enabled

2022-11-12 Thread Ricardo Koller
B per vCPU, 50% reads, and 2MB HugeTLB memory, the time it takes vCPUs to access all of their memory after dirty logging is enabled decreased by 44% from 2.58s to 1.42s. Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/kvm_host.h | 30 arch/arm64/kvm/mmu.c

[RFC PATCH 11/12] KVM: arm64: Split huge pages during KVM_CLEAR_DIRTY_LOG

2022-11-12 Thread Ricardo Koller
_DIRTY_LOG. And do not split when enabling dirty logging if KVM_DIRTY_LOG_INITIALLY_SET is set. Signed-off-by: Ricardo Koller --- arch/arm64/kvm/mmu.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 78

[RFC PATCH 10/12] KVM: arm64: Open-code kvm_mmu_write_protect_pt_masked()

2022-11-12 Thread Ricardo Koller
Move the functionality of kvm_mmu_write_protect_pt_masked() into its caller, kvm_arch_mmu_enable_log_dirty_pt_masked(). This will be used in a subsequent commit in order to share some of the code in kvm_arch_mmu_enable_log_dirty_pt_masked(). No functional change intended. Signed-off-by: Ricardo

[RFC PATCH 05/12] arm64: Add a capability for FEAT_BBM level 2

2022-11-12 Thread Ricardo Koller
Add a new capability to detect "Stage-2 Translation table break-before-make" (FEAT_BBM) level 2. Signed-off-by: Ricardo Koller --- arch/arm64/kernel/cpufeature.c | 11 +++ arch/arm64/tools/cpucaps | 1 + 2 files changed, 12 insertions(+) diff --git a/arch/ar

[RFC PATCH 08/12] KVM: arm64: Add kvm_uninit_stage2_mmu()

2022-11-12 Thread Ricardo Koller
Add kvm_uninit_stage2_mmu() and move kvm_free_stage2_pgd() into it. A future commit will add some more things to do inside of kvm_uninit_stage2_mmu(). No functional change intended. Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/kvm_mmu.h | 1 + arch/arm64/kvm/mmu.c | 7

[RFC PATCH 07/12] KVM: arm64: Refactor kvm_arch_commit_memory_region()

2022-11-12 Thread Ricardo Koller
Refactor kvm_arch_commit_memory_region() as a preparation for a future commit to look cleaner and more understandable. Also, it looks more like its x86 counterpart (in kvm_mmu_slot_apply_flags()). No functional change intended. Signed-off-by: Ricardo Koller --- arch/arm64/kvm/mmu.c | 15

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

2022-11-12 Thread Ricardo Koller
for large ranges (e.g., all guest memory in 1G chunks at a time). No functional change intended. This new function will be used in a Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/kvm_pgtable.h | 29 +++ arch/arm64/kvm/hyp/pgtable.c | 74 2 files

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

2022-11-12 Thread Ricardo Koller
specified in the Arm ARM (DDI 0487H.a) section "Support levels for changing block size" D5.10.1, this can result in a Conflict abort. So, handle it by clearing all VM TLB entries. Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/esr.h | 1 + arch/arm64/include/asm/kvm_

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

2022-11-12 Thread Ricardo Koller
commit for eagerly breaking huge pages. Signed-off-by: Ricardo Koller --- arch/arm64/include/asm/kvm_pgtable.h | 4 ++-- arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- arch/arm64/kvm/hyp/pgtable.c | 25 - 3 files changed, 15 insertions(+), 16 deletions(-) diff --git

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

2022-11-12 Thread Ricardo Koller
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 --- arch/arm64/kvm/hyp/pgtable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)

[RFC PATCH 03/12] KVM: arm64: Add stage2_create_removed()

2022-11-12 Thread Ricardo Koller
tree, and then use it to replace the 1G PTE in a single step. This will be used in a subsequent commit for eager huge page splitting. No functional change intended. This new function will be used in a subsequent commit. Signed-off-by: Ricardo Koller --- arch/arm64/kvm/hyp/pgtable.c | 93

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

2022-11-12 Thread Ricardo Koller
https://github.com/ricarkol/linux/commit/f78e9102b2bff4fb7f30bee810d7d611a537b46d [3] https://lore.kernel.org/kvmarm/20221107215644.1895162-1-oliver.up...@linux.dev/ Marc Zyngier (1): KVM: arm64: Use local TLBI on permission relaxation Ricardo Koller (11): KVM: arm64: Relax WARN check in sta

Re: [PATCH v4 07/14] KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make

2022-11-03 Thread Ricardo Koller
On Thu, Nov 03, 2022 at 09:11:33AM +, Oliver Upton wrote: > The break-before-make sequence is a bit annoying as it opens a window > wherein memory is unmapped from the guest. KVM should replace the PTE > as quickly as possible and avoid unnecessary work in between. > > Presently, the stage-2

Re: [PATCH v3 12/15] KVM: arm64: Make block->table PTE changes parallel-aware

2022-11-01 Thread Ricardo Koller
On Thu, Oct 27, 2022 at 10:22:47PM +, 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 architecture is that software must perform a > 'break-before-make'

Re: [PATCH v2 06/15] KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make

2022-10-28 Thread Ricardo Koller
On Fri, Oct 28, 2022 at 11:43:33AM -0700, Ricardo Koller wrote: > On Fri, Oct 28, 2022 at 11:41:57AM -0700, Ricardo Koller wrote: > > On Fri, Oct 07, 2022 at 11:28:09PM +, Oliver Upton wrote: > > > The break-before-make sequence is a bit annoying as it opens a window &g

Re: [PATCH v2 06/15] KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make

2022-10-28 Thread Ricardo Koller
On Fri, Oct 28, 2022 at 11:41:57AM -0700, Ricardo Koller wrote: > On Fri, Oct 07, 2022 at 11:28:09PM +, Oliver Upton wrote: > > The break-before-make sequence is a bit annoying as it opens a window > > wherein memory is unmapped from the guest. KVM should replace the PTE

Re: [PATCH v2 06/15] KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make

2022-10-28 Thread Ricardo Koller
On Fri, Oct 07, 2022 at 11:28:09PM +, Oliver Upton wrote: > The break-before-make sequence is a bit annoying as it opens a window > wherein memory is unmapped from the guest. KVM should replace the PTE > as quickly as possible and avoid unnecessary work in between. > > Presently, the stage-2

[PATCH v10 12/14] KVM: selftests: aarch64: Add dirty logging tests into page_fault_test

2022-10-17 Thread Ricardo Koller
Add some dirty logging tests into page_fault_test. Mark the data and/or page-table memory regions for dirty logging, perform some accesses, and check that the dirty log bits are set or clean when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 76

[PATCH v10 13/14] KVM: selftests: aarch64: Add readonly memslot tests into page_fault_test

2022-10-17 Thread Ricardo Koller
Add some readonly memslot tests into page_fault_test. Mark the data and/or page-table memory regions as readonly, perform some accesses, and check that the right fault is triggered when expected (e.g., a store with no write-back should lead to an mmio exit). Signed-off-by: Ricardo Koller

[PATCH v10 14/14] KVM: selftests: aarch64: Add mix of tests into page_fault_test

2022-10-17 Thread Ricardo Koller
Add some mix of tests into page_fault_test: memory regions with all the pairwise combinations of read-only, userfaultfd, and dirty-logging. For example, writing into a read-only region which has a hole handled with userfaultfd. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64

[PATCH v10 11/14] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test

2022-10-17 Thread Ricardo Koller
Add some userfaultfd tests into page_fault_test. Punch holes into the data and/or page-table memslots, perform some accesses, and check that the faults are taken (or not taken) when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 187

[PATCH v10 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-10-17 Thread Ricardo Koller
). This first commit starts by adding two sanity checks for all types of accesses: AF setting by the hw, and accessing memslots with holes. Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests

[PATCH v10 09/14] KVM: selftests: Use the right memslot for code, page-tables, and data allocations

2022-10-17 Thread Ricardo Koller
-by: Ricardo Koller Reviewed-by: Sean Christopherson Reviewed-by: Andrew Jones --- .../selftests/kvm/include/kvm_util_base.h | 4 ++ .../selftests/kvm/lib/aarch64/processor.c | 12 ++-- tools/testing/selftests/kvm/lib/elf.c | 3 +- tools/testing/selftests/kvm/lib/kvm_util.c| 57

[PATCH v10 08/14] KVM: selftests: Fix alignment in virt_arch_pgd_alloc() and vm_vaddr_alloc()

2022-10-17 Thread Ricardo Koller
. Suggested-by: Sean Christopherson Signed-off-by: Ricardo Koller Reviewed-by: Andrew Jones --- .../selftests/kvm/lib/aarch64/processor.c | 27 ++- .../selftests/kvm/lib/riscv/processor.c | 27 ++- 2 files changed, 30 insertions(+), 24 deletions(-) diff

[PATCH v10 04/14] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros

2022-10-17 Thread Ricardo Koller
Define macros for memory type indexes and construct DEFAULT_MAIR_EL1 with macros from asm/sysreg.h. The index macros can then be used when constructing PTEs (instead of using raw numbers). Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v10 07/14] KVM: selftests: Add vm->memslots[] and enum kvm_mem_region_type

2022-10-17 Thread Ricardo Koller
the pt memslot. Cc: Sean Christopherson Cc: Andrew Jones Signed-off-by: Ricardo Koller Reviewed-by: Andrew Jones Reviewed-by: Sean Christopherson --- .../selftests/kvm/include/kvm_util_base.h | 26 +-- tools/testing/selftests/kvm/lib/kvm_util.c| 18 +++-- 2 files c

[PATCH v10 06/14] KVM: selftests: Stash backing_src_type in struct userspace_mem_region

2022-10-17 Thread Ricardo Koller
-by: Ricardo Koller --- tools/testing/selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index

[PATCH v10 05/14] tools: Copy bitfield.h from the kernel sources

2022-10-17 Thread Ricardo Koller
Copy bitfield.h from include/linux/bitfield.h. A subsequent change will make use of some FIELD_{GET,PREP} macros defined in this header. The header was copied as-is, no changes needed. Cc: Jakub Kicinski Cc: Arnaldo Carvalho de Melo Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller

[PATCH v10 01/14] KVM: selftests: Add a userfaultfd library

2022-10-17 Thread Ricardo Koller
is then used in the stop function (to wait and destroy the threads). Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/demand_paging_test.c| 228 +++--- .../selftests

[PATCH v10 03/14] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete()

2022-10-17 Thread Ricardo Koller
Deleting a memslot (when freeing a VM) is not closing the backing fd, nor it's unmapping the alias mapping. Fix by adding the missing close and munmap. Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm

[PATCH v10 02/14] KVM: selftests: aarch64: Add virt_get_pte_hva() library function

2022-10-17 Thread Ricardo Koller
Add a library function to get the PTE (a host virtual address) of a given GVA. This will be used in a future commit by a test to clear and check the access flag of a particular page. Reviewed-by: Oliver Upton Reviewed-by: Andrew Jones Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v10 00/14] KVM: selftests: Add aarch64/page_fault_test

2022-10-17 Thread Ricardo Koller
rew and Oliver in commit "KVM: selftests: Use the right memslot for code, page-tables, and data allocations", as the commit changed quite a bit (again). Thanks for the reviews! would it have been OK to keep it? not sure how strict we all are about collecting r-b's on a commit that changed.

Re: [PATCH v9 00/14] KVM: selftests: Add aarch64/page_fault_test

2022-10-14 Thread Ricardo Koller
On Fri, Oct 14, 2022 at 09:30:10PM +, Sean Christopherson wrote: > On Tue, Oct 11, 2022, Ricardo Koller wrote: > > Ricardo Koller (14): > > KVM: selftests: Add a userfaultfd library > > KVM: selftests: aarch64: Add virt_get_pte_hva() library function > > KVM: s

Re: [kvm-unit-tests PATCH v3 0/3] arm: pmu: Fixes for bare metal

2022-10-10 Thread Ricardo Koller
n 10/4/22 18:58, Alexandru Elisei wrote: > >>> Hi Eric, > >>> > >>> On Tue, Oct 04, 2022 at 06:20:23PM +0200, Eric Auger wrote: > >>>> Hi Ricardo, Marc, > >>>> > >>>> On 8/5/22 02:41, Ricardo Koller wrote: > >>&

[PATCH v9 09/14] KVM: selftests: Use the right memslot for code, page-tables, and data allocations

2022-10-10 Thread Ricardo Koller
-by: Ricardo Koller Reviewed-by: Sean Christopherson --- .../selftests/kvm/include/kvm_util_base.h | 4 ++ .../selftests/kvm/lib/aarch64/processor.c | 12 ++-- tools/testing/selftests/kvm/lib/elf.c | 3 +- tools/testing/selftests/kvm/lib/kvm_util.c| 57

[PATCH v9 14/14] KVM: selftests: aarch64: Add mix of tests into page_fault_test

2022-10-10 Thread Ricardo Koller
Add some mix of tests into page_fault_test: memory regions with all the pairwise combinations of read-only, userfaultfd, and dirty-logging. For example, writing into a read-only region which has a hole handled with userfaultfd. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64

[PATCH v9 12/14] KVM: selftests: aarch64: Add dirty logging tests into page_fault_test

2022-10-10 Thread Ricardo Koller
Add some dirty logging tests into page_fault_test. Mark the data and/or page-table memory regions for dirty logging, perform some accesses, and check that the dirty log bits are set or clean when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 75

[PATCH v9 11/14] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test

2022-10-10 Thread Ricardo Koller
Add some userfaultfd tests into page_fault_test. Punch holes into the data and/or page-table memslots, perform some accesses, and check that the faults are taken (or not taken) when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 189

[PATCH v9 13/14] KVM: selftests: aarch64: Add readonly memslot tests into page_fault_test

2022-10-10 Thread Ricardo Koller
Add some readonly memslot tests into page_fault_test. Mark the data and/or page-table memory regions as readonly, perform some accesses, and check that the right fault is triggered when expected (e.g., a store with no write-back should lead to an mmio exit). Signed-off-by: Ricardo Koller

[PATCH v9 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-10-10 Thread Ricardo Koller
). This first commit starts by adding two sanity checks for all types of accesses: AF setting by the hw, and accessing memslots with holes. Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests

[PATCH v9 08/14] KVM: selftests: Fix alignment in virt_arch_pgd_alloc() and vm_vaddr_alloc()

2022-10-10 Thread Ricardo Koller
. Suggested-by: Sean Christopherson Signed-off-by: Ricardo Koller --- .../selftests/kvm/lib/aarch64/processor.c | 27 ++- .../selftests/kvm/lib/riscv/processor.c | 27 ++- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests

[PATCH v9 07/14] KVM: selftests: Add vm->memslots[] and enum kvm_mem_region_type

2022-10-10 Thread Ricardo Koller
the pt memslot. Cc: Sean Christopherson Cc: Andrew Jones Signed-off-by: Ricardo Koller Reviewed-by: Andrew Jones Reviewed-by: Sean Christopherson --- .../selftests/kvm/include/kvm_util_base.h | 26 +-- tools/testing/selftests/kvm/lib/kvm_util.c| 18 +++-- 2 files c

[PATCH v9 05/14] tools: Copy bitfield.h from the kernel sources

2022-10-10 Thread Ricardo Koller
Copy bitfield.h from include/linux/bitfield.h. A subsequent change will make use of some FIELD_{GET,PREP} macros defined in this header. The header was copied as-is, no changes needed. Cc: Jakub Kicinski Cc: Arnaldo Carvalho de Melo Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller

[PATCH v9 06/14] KVM: selftests: Stash backing_src_type in struct userspace_mem_region

2022-10-10 Thread Ricardo Koller
-by: Ricardo Koller --- tools/testing/selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index

[PATCH v9 03/14] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete()

2022-10-10 Thread Ricardo Koller
Deleting a memslot (when freeing a VM) is not closing the backing fd, nor it's unmapping the alias mapping. Fix by adding the missing close and munmap. Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm

[PATCH v9 01/14] KVM: selftests: Add a userfaultfd library

2022-10-10 Thread Ricardo Koller
is then used in the stop function (to wait and destroy the threads). Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/demand_paging_test.c| 228 +++--- .../selftests

[PATCH v9 04/14] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros

2022-10-10 Thread Ricardo Koller
Define macros for memory type indexes and construct DEFAULT_MAIR_EL1 with macros from asm/sysreg.h. The index macros can then be used when constructing PTEs (instead of using raw numbers). Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v9 02/14] KVM: selftests: aarch64: Add virt_get_pte_hva() library function

2022-10-10 Thread Ricardo Koller
Add a library function to get the PTE (a host virtual address) of a given GVA. This will be used in a future commit by a test to clear and check the access flag of a particular page. Reviewed-by: Oliver Upton Reviewed-by: Andrew Jones Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v9 00/14] KVM: selftests: Add aarch64/page_fault_test

2022-10-10 Thread Ricardo Koller
strict we all are about collecting r-b's on a commit that changed. Ricardo Koller (14): KVM: selftests: Add a userfaultfd library KVM: selftests: aarch64: Add virt_get_pte_hva() library function KVM: selftests: Add missing close and munmap in __vm_mem_region_delete() KVM: selftests:

Re: [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-09-28 Thread Ricardo Koller
On Wed, Sep 28, 2022 at 04:58:53PM +, Sean Christopherson wrote: > On Tue, Sep 27, 2022, Ricardo Koller wrote: > > On Tue, Sep 27, 2022 at 10:06:23PM +, Sean Christopherson wrote: > > > On Mon, Sep 26, 2022, Ricardo Koller wrote: > > > > On Thu, Sep 22,

Re: [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-09-27 Thread Ricardo Koller
On Tue, Sep 27, 2022 at 10:06:23PM +, Sean Christopherson wrote: > On Mon, Sep 26, 2022, Ricardo Koller wrote: > > On Thu, Sep 22, 2022 at 07:32:42PM +, Sean Christopherson wrote: > > > On Thu, Sep 22, 2022, Ricardo Koller wrote: > > > > +

Re: [PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-09-26 Thread Ricardo Koller
On Thu, Sep 22, 2022 at 07:32:42PM +, Sean Christopherson wrote: > On Thu, Sep 22, 2022, Ricardo Koller wrote: > > +/* Returns true to continue the test, and false if it should be skipped. */ > > +static bool punch_hole_in_memslot(struct kvm_vm *vm, > > This is a very mis

[PATCH v8 14/14] KVM: selftests: aarch64: Add mix of tests into page_fault_test

2022-09-21 Thread Ricardo Koller
Add some mix of tests into page_fault_test: memslots with all the pairwise combinations of read-only, userfaultfd, and dirty-logging. For example, writing into a read-only memslot which has a hole handled with userfaultfd. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64

[PATCH v8 11/14] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test

2022-09-21 Thread Ricardo Koller
Add some userfaultfd tests into page_fault_test. Punch holes into the data and/or page-table memslots, perform some accesses, and check that the faults are taken (or not taken) when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 190

[PATCH v8 13/14] KVM: selftests: aarch64: Add readonly memslot tests into page_fault_test

2022-09-21 Thread Ricardo Koller
Add some readonly memslot tests into page_fault_test. Mark the data and/or page-table memslots as readonly, perform some accesses, and check that the right fault is triggered when expected (e.g., a store with no write-back should lead to an mmio exit). Signed-off-by: Ricardo Koller

[PATCH v8 09/14] KVM: selftests: Use the right memslot for code, page-tables, and data allocations

2022-09-21 Thread Ricardo Koller
-by: Ricardo Koller --- .../selftests/kvm/include/kvm_util_base.h | 4 ++ .../selftests/kvm/lib/aarch64/processor.c | 12 ++-- tools/testing/selftests/kvm/lib/elf.c | 3 +- tools/testing/selftests/kvm/lib/kvm_util.c| 57 --- .../selftests/kvm/lib/riscv/processor.c

[PATCH v8 05/14] tools: Copy bitfield.h from the kernel sources

2022-09-21 Thread Ricardo Koller
Copy bitfield.h from include/linux/bitfield.h. A subsequent change will make use of some FIELD_{GET,PREP} macros defined in this header. The header was copied as-is, no changes needed. Cc: Jakub Kicinski Cc: Arnaldo Carvalho de Melo Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller

[PATCH v8 12/14] KVM: selftests: aarch64: Add dirty logging tests into page_fault_test

2022-09-21 Thread Ricardo Koller
Add some dirty logging tests into page_fault_test. Mark the data and/or page-table memslots for dirty logging, perform some accesses, and check that the dirty log bits are set or clean when expected. Signed-off-by: Ricardo Koller --- .../selftests/kvm/aarch64/page_fault_test.c | 75

[PATCH v8 08/14] KVM: selftests: Fix alignment in virt_arch_pgd_alloc() and vm_vaddr_alloc()

2022-09-21 Thread Ricardo Koller
. Suggested-by: Sean Christopherson Signed-off-by: Ricardo Koller --- .../selftests/kvm/lib/aarch64/processor.c | 27 ++- .../selftests/kvm/lib/riscv/processor.c | 27 ++- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/tools/testing/selftests

[PATCH v8 10/14] KVM: selftests: aarch64: Add aarch64/page_fault_test

2022-09-21 Thread Ricardo Koller
). This first commit starts by adding two sanity checks for all types of accesses: AF setting by the hw, and accessing memslots with holes. Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/.gitignore| 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests

[PATCH v8 06/14] KVM: selftests: Stash backing_src_type in struct userspace_mem_region

2022-09-21 Thread Ricardo Koller
-by: Ricardo Koller --- tools/testing/selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index

[PATCH v8 07/14] KVM: selftests: Add vm->memslots[] and enum kvm_mem_region_type

2022-09-21 Thread Ricardo Koller
the pt memslot. Cc: Sean Christopherson Cc: Andrew Jones Signed-off-by: Ricardo Koller Reviewed-by: Andrew Jones --- .../selftests/kvm/include/kvm_util_base.h | 26 +-- tools/testing/selftests/kvm/lib/kvm_util.c| 18 +++-- 2 files changed, 34 insertions(+), 10 del

[PATCH v8 02/14] KVM: selftests: aarch64: Add virt_get_pte_hva() library function

2022-09-21 Thread Ricardo Koller
Add a library function to get the PTE (a host virtual address) of a given GVA. This will be used in a future commit by a test to clear and check the access flag of a particular page. Reviewed-by: Oliver Upton Reviewed-by: Andrew Jones Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v8 03/14] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete()

2022-09-21 Thread Ricardo Koller
Deleting a memslot (when freeing a VM) is not closing the backing fd, nor it's unmapping the alias mapping. Fix by adding the missing close and munmap. Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm

[PATCH v8 04/14] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros

2022-09-21 Thread Ricardo Koller
Define macros for memory type indexes and construct DEFAULT_MAIR_EL1 with macros from asm/sysreg.h. The index macros can then be used when constructing PTEs (instead of using raw numbers). Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton Signed-off-by: Ricardo Koller --- .../selftests/kvm

[PATCH v8 01/14] KVM: selftests: Add a userfaultfd library

2022-09-21 Thread Ricardo Koller
is then used in the stop function (to wait and destroy the threads). Reviewed-by: Oliver Upton Reviewed-by: Ben Gardon Signed-off-by: Ricardo Koller --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/demand_paging_test.c| 228 +++--- .../selftests

[PATCH v8 00/14] KVM: selftests: Add aarch64/page_fault_test

2022-09-21 Thread Ricardo Koller
tests: Add vm_mem_region_get_src_fd library function - addressed Oliver comments in commit "KVM: selftests: aarch64: Add aarch64/page_fault_test" - collect r-b's from Andrew Ricardo Koller (14): KVM: selftests: Add a userfaultfd library KVM: selftests: aarch64: Add virt_get_

  1   2   3   >