Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Gavin Shan
On 10/11/22 9:12 AM, Oliver Upton wrote: On Mon, Oct 10, 2022 at 08:20:29PM -0400, Peter Xu wrote: On Mon, Oct 10, 2022 at 11:58:22PM +, Oliver Upton wrote: I think this further drives the point home -- there's zero need for the bitmap with dirty ring on x86, so why even support it? The

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

2022-10-10 Thread Ricardo Koller
On Wed, Oct 05, 2022 at 11:50:09AM +0200, Eric Auger wrote: > Hi Alexandru, > > On 10/5/22 11:21, Alexandru Elisei wrote: > > Hi Eric, > > > > On Tue, Oct 04, 2022 at 07:31:25PM +0200, Eric Auger wrote: > >> Hi Alexandru, > >> > >> On 10/4/22 18:58, Alexandru Elisei wrote: > >>> Hi Eric, > >>> >

Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization

2022-10-10 Thread Denis Nikitin
On Sat, Oct 8, 2022 at 7:22 PM Marc Zyngier wrote: > > On Thu, 06 Oct 2022 17:28:17 +0100, > Denis Nikitin wrote: > > > > Hi Mark, > > s/k/c/ > > > > > This problem currently blocks the PGO roll on the ChromeOS kernel and > > we need some kind of a solution. > > I'm sorry, but I don't feel

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Oliver Upton
On Mon, Oct 10, 2022 at 08:20:29PM -0400, Peter Xu wrote: > On Mon, Oct 10, 2022 at 11:58:22PM +, Oliver Upton wrote: > > I think this further drives the point home -- there's zero need for the > > bitmap with dirty ring on x86, so why even support it? The proposal of > > ALLOW_BITMAP &&

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

2022-10-10 Thread Ricardo Koller
Now that kvm_vm allows specifying different memslots for code, page tables, and data, use the appropriate memslot when making allocations in common/libraty code. Change them accordingly: - code (allocated by lib/elf) use the CODE memslot - stacks, exception tables, and other core data pages (like

[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 ---

[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
Add a new test for stage 2 faults when using different combinations of guest accesses (e.g., write, S1PTW), backing source type (e.g., anon) and types of faults (e.g., read on hugetlbfs with a hole). The next commits will add different handling methods and more faults (e.g., uffd and dirty

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

2022-10-10 Thread Ricardo Koller
Refactor virt_arch_pgd_alloc() and vm_vaddr_alloc() in both RISC-V and aarch64 to fix the alignment of parameters in a couple of calls. This will make it easier to fix the alignment in a future commit that adds an extra parameter (that happens to be very long). No functional change intended.

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

2022-10-10 Thread Ricardo Koller
The vm_create() helpers are hardcoded to place most page types (code, page-tables, stacks, etc) in the same memslot #0, and always backed with anonymous 4K. There are a couple of issues with that. First, tests willing to differ a bit, like placing page-tables in a different backing source type

[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
Add the backing_src_type into struct userspace_mem_region. This struct already stores a lot of info about memory regions, except the backing source type. This info will be used by a future commit in order to determine the method for punching a hole. Reviewed-by: Oliver Upton Signed-off-by:

[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 ---

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

2022-10-10 Thread Ricardo Koller
Move the generic userfaultfd code out of demand_paging_test.c into a common library, userfaultfd_util. This library consists of a setup and a stop function. The setup function starts a thread for handling page faults using the handler callback function. This setup returns a uffd_desc object which

[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 ---

[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 ---

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

2022-10-10 Thread Ricardo Koller
This series adds a new aarch64 selftest for testing stage 2 fault handling for various combinations of guest accesses (e.g., write, S1PTW), backing sources (e.g., anon), and types of faults (e.g., read on hugetlbfs with a hole, write on a readonly memslot). Each test tries a different combination

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Peter Xu
On Mon, Oct 10, 2022 at 11:58:22PM +, Oliver Upton wrote: > I think this further drives the point home -- there's zero need for the > bitmap with dirty ring on x86, so why even support it? The proposal of > ALLOW_BITMAP && DIRTY_RING should be arm64-specific. Any other arch that > needs to

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Oliver Upton
On Mon, Oct 10, 2022 at 07:49:15PM -0400, Peter Xu wrote: > On Mon, Oct 10, 2022 at 11:18:55PM +, Oliver Upton wrote: > > On Fri, Oct 07, 2022 at 10:31:49AM -0400, Peter Xu wrote: > > > > [...] > > > > > > - In kvm_vm_ioctl_enable_dirty_log_ring(), set > > > > 'dirty_ring_allow_bitmap' to >

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Gavin Shan
Hi Peter and Oliver, On 10/11/22 7:49 AM, Peter Xu wrote: On Mon, Oct 10, 2022 at 11:18:55PM +, Oliver Upton wrote: On Fri, Oct 07, 2022 at 10:31:49AM -0400, Peter Xu wrote: [...] - In kvm_vm_ioctl_enable_dirty_log_ring(), set 'dirty_ring_allow_bitmap' to true when the capability is

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Peter Xu
On Mon, Oct 10, 2022 at 11:18:55PM +, Oliver Upton wrote: > On Fri, Oct 07, 2022 at 10:31:49AM -0400, Peter Xu wrote: > > [...] > > > > - In kvm_vm_ioctl_enable_dirty_log_ring(), set 'dirty_ring_allow_bitmap' > > > to > > > true when the capability is KVM_CAP_DIRTY_LONG_RING_ACQ_REL > >

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Oliver Upton
On Mon, Oct 10, 2022 at 11:18:55PM +, Oliver Upton wrote: > On Fri, Oct 07, 2022 at 10:31:49AM -0400, Peter Xu wrote: > > [...] > > > > - In kvm_vm_ioctl_enable_dirty_log_ring(), set 'dirty_ring_allow_bitmap' > > > to > > > true when the capability is KVM_CAP_DIRTY_LONG_RING_ACQ_REL > >

Re: [PATCH v5 3/7] KVM: x86: Allow to use bitmap in ring-based dirty page tracking

2022-10-10 Thread Oliver Upton
On Fri, Oct 07, 2022 at 10:31:49AM -0400, Peter Xu wrote: [...] > > - In kvm_vm_ioctl_enable_dirty_log_ring(), set 'dirty_ring_allow_bitmap' to > > true when the capability is KVM_CAP_DIRTY_LONG_RING_ACQ_REL > > What I wanted to do is to decouple the ACQ_REL with ALLOW_BITMAP, so mostly > as

Re: [PATCH] KVM: arm64: selftests: Fix multiple versions of GIC creation

2022-10-10 Thread Marc Zyngier
On Sun, 9 Oct 2022 11:31:31 +0800, Zenghui Yu wrote: > Commit 98f94ce42ac6 ("KVM: selftests: Move KVM_CREATE_DEVICE_TEST code to > separate helper") wrongly converted a "real" GIC device creation to > __kvm_test_create_device() and caused the test failure on my D05 (which > supports v2 emulation).