From: Ricardo Koller <ricarkol@google.com> To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, drjones@redhat.com Cc: pbonzini@redhat.com, maz@kernel.org, alexandru.elisei@arm.com, eric.auger@redhat.com, oupton@google.com, reijiw@google.com, rananta@google.com, bgardon@google.com, dmatlack@google.com, axelrasmussen@google.com, Ricardo Koller <ricarkol@google.com> Subject: [PATCH v4 00/13] KVM: selftests: Add aarch64/page_fault_test Date: Fri, 24 Jun 2022 14:32:44 -0700 [thread overview] Message-ID: <20220624213257.1504783-1-ricarkol@google.com> (raw) 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 and then checks that the access results in the right behavior (e.g., uffd faults with the right address and write/read flag). Some interesting combinations are: - loading an instruction leads to a stage 1 page-table-walk that misses on stage 2 because the backing memslot for the page table it not in host memory (a hole was punched right there) and the fault is handled using userfaultfd. The expected behavior is that this leads to a userfaultfd fault marked as a write. See commit c4ad98e4b72c ("KVM: arm64: Assume write fault on S1PTW permission fault on instruction fetch") for why that's a write. - a cas (compare-and-swap) on a readonly memslot leads to a failed vcpu run. - write-faulting on a memslot that's marked for userfaultfd handling and dirty logging should result in a uffd fault and having the respective bit set in the dirty log. The first 8 commits of this series add library support. The first one adds a new userfaultfd library (out of demand_paging_test.c). The next 3 add some library functions to get the GPA of a PTE, and to get the fd of a backing source. Commit 6 fixes a leaked fd when using shared backing stores. The last 5 commits add the new selftest, one type of test at a time. It first adds core tests, then uffd, then dirty logging, then readonly memslots tests, and finally combinations of the previous ones (like uffd and dirty logging at the same time). v3 -> v4: https://lore.kernel.org/kvmarm/20220408004120.1969099-1-ricarkol@google.com/ - rebased on top of latest kvm/queue. - addressed Oliver comments: vm_get_pte_gpa rename, page_fault_test and other nits. - adding MAIR entry for MT_DEVICE_nGnRnE. The value and indices are both 0, so the change is really esthetic. - allocating less memory for the test (smaller memslots). - better comments, including an ascii diagram about how memory is laid out for the test. v2 -> v3: Thank you very much Oliver and Ben - collected r-b's from Ben. [Ben] - moved some defitions (like TCR_EL1_HA) to common headers. [Oliver] - use FIELD_GET and ARM64_FEATURE_MASK. [Oliver] - put test data in a macro. [Oliver] - check for DCZID_EL1.DZP=0b0 before using "dc zva". [Oliver] - various new comments. [Oliver] - use 'asm' instead of hand assembly. [Oliver] - don't copy test descriptors into the guest. [Oliver] - rename large_page_size into backing_page_size. [Oliver] - add enumeration for memory types (4 is MT_NORMAL). [Oliver] - refactored the test macro definitions. v1 -> v2: https://lore.kernel.org/kvmarm/20220323225405.267155-1-ricarkol@google.com/ - collect r-b from Ben for the memslot lib commit. [Ben] - move userfaultfd desc struct to header. [Ben] - move commit "KVM: selftests: Add vm_mem_region_get_src_fd library function" to right before it's used. [Ben] - nit: wrong indentation in patch 6. [Ben] Ricardo Koller (13): KVM: selftests: Add a userfaultfd library KVM: selftests: aarch64: Add virt_get_pte_hva library function KVM: selftests: Add vm_alloc_page_table_in_memslot library function KVM: selftests: aarch64: Export _virt_pg_map with a pt_memslot arg KVM: selftests: Add missing close and munmap in __vm_mem_region_delete KVM: selftests: Add vm_mem_region_get_src_fd library function KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros tools: Copy bitfield.h from the kernel sources KVM: selftests: aarch64: Add aarch64/page_fault_test KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test KVM: selftests: aarch64: Add dirty logging tests into page_fault_test KVM: selftests: aarch64: Add readonly memslot tests into page_fault_test KVM: selftests: aarch64: Add mix of tests into page_fault_test tools/include/linux/bitfield.h | 176 +++ tools/testing/selftests/kvm/Makefile | 2 + .../selftests/kvm/aarch64/page_fault_test.c | 1236 +++++++++++++++++ .../selftests/kvm/demand_paging_test.c | 228 +-- .../selftests/kvm/include/aarch64/processor.h | 36 +- .../selftests/kvm/include/kvm_util_base.h | 2 + .../selftests/kvm/include/userfaultfd_util.h | 46 + .../selftests/kvm/lib/aarch64/processor.c | 27 +- tools/testing/selftests/kvm/lib/kvm_util.c | 37 +- .../selftests/kvm/lib/userfaultfd_util.c | 187 +++ 10 files changed, 1762 insertions(+), 215 deletions(-) create mode 100644 tools/include/linux/bitfield.h create mode 100644 tools/testing/selftests/kvm/aarch64/page_fault_test.c create mode 100644 tools/testing/selftests/kvm/include/userfaultfd_util.h create mode 100644 tools/testing/selftests/kvm/lib/userfaultfd_util.c -- 2.37.0.rc0.161.g10f37bed90-goog
WARNING: multiple messages have this Message-ID (diff)
From: Ricardo Koller <ricarkol@google.com> To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, drjones@redhat.com Cc: maz@kernel.org, bgardon@google.com, dmatlack@google.com, pbonzini@redhat.com, axelrasmussen@google.com Subject: [PATCH v4 00/13] KVM: selftests: Add aarch64/page_fault_test Date: Fri, 24 Jun 2022 14:32:44 -0700 [thread overview] Message-ID: <20220624213257.1504783-1-ricarkol@google.com> (raw) 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 and then checks that the access results in the right behavior (e.g., uffd faults with the right address and write/read flag). Some interesting combinations are: - loading an instruction leads to a stage 1 page-table-walk that misses on stage 2 because the backing memslot for the page table it not in host memory (a hole was punched right there) and the fault is handled using userfaultfd. The expected behavior is that this leads to a userfaultfd fault marked as a write. See commit c4ad98e4b72c ("KVM: arm64: Assume write fault on S1PTW permission fault on instruction fetch") for why that's a write. - a cas (compare-and-swap) on a readonly memslot leads to a failed vcpu run. - write-faulting on a memslot that's marked for userfaultfd handling and dirty logging should result in a uffd fault and having the respective bit set in the dirty log. The first 8 commits of this series add library support. The first one adds a new userfaultfd library (out of demand_paging_test.c). The next 3 add some library functions to get the GPA of a PTE, and to get the fd of a backing source. Commit 6 fixes a leaked fd when using shared backing stores. The last 5 commits add the new selftest, one type of test at a time. It first adds core tests, then uffd, then dirty logging, then readonly memslots tests, and finally combinations of the previous ones (like uffd and dirty logging at the same time). v3 -> v4: https://lore.kernel.org/kvmarm/20220408004120.1969099-1-ricarkol@google.com/ - rebased on top of latest kvm/queue. - addressed Oliver comments: vm_get_pte_gpa rename, page_fault_test and other nits. - adding MAIR entry for MT_DEVICE_nGnRnE. The value and indices are both 0, so the change is really esthetic. - allocating less memory for the test (smaller memslots). - better comments, including an ascii diagram about how memory is laid out for the test. v2 -> v3: Thank you very much Oliver and Ben - collected r-b's from Ben. [Ben] - moved some defitions (like TCR_EL1_HA) to common headers. [Oliver] - use FIELD_GET and ARM64_FEATURE_MASK. [Oliver] - put test data in a macro. [Oliver] - check for DCZID_EL1.DZP=0b0 before using "dc zva". [Oliver] - various new comments. [Oliver] - use 'asm' instead of hand assembly. [Oliver] - don't copy test descriptors into the guest. [Oliver] - rename large_page_size into backing_page_size. [Oliver] - add enumeration for memory types (4 is MT_NORMAL). [Oliver] - refactored the test macro definitions. v1 -> v2: https://lore.kernel.org/kvmarm/20220323225405.267155-1-ricarkol@google.com/ - collect r-b from Ben for the memslot lib commit. [Ben] - move userfaultfd desc struct to header. [Ben] - move commit "KVM: selftests: Add vm_mem_region_get_src_fd library function" to right before it's used. [Ben] - nit: wrong indentation in patch 6. [Ben] Ricardo Koller (13): KVM: selftests: Add a userfaultfd library KVM: selftests: aarch64: Add virt_get_pte_hva library function KVM: selftests: Add vm_alloc_page_table_in_memslot library function KVM: selftests: aarch64: Export _virt_pg_map with a pt_memslot arg KVM: selftests: Add missing close and munmap in __vm_mem_region_delete KVM: selftests: Add vm_mem_region_get_src_fd library function KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros tools: Copy bitfield.h from the kernel sources KVM: selftests: aarch64: Add aarch64/page_fault_test KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test KVM: selftests: aarch64: Add dirty logging tests into page_fault_test KVM: selftests: aarch64: Add readonly memslot tests into page_fault_test KVM: selftests: aarch64: Add mix of tests into page_fault_test tools/include/linux/bitfield.h | 176 +++ tools/testing/selftests/kvm/Makefile | 2 + .../selftests/kvm/aarch64/page_fault_test.c | 1236 +++++++++++++++++ .../selftests/kvm/demand_paging_test.c | 228 +-- .../selftests/kvm/include/aarch64/processor.h | 36 +- .../selftests/kvm/include/kvm_util_base.h | 2 + .../selftests/kvm/include/userfaultfd_util.h | 46 + .../selftests/kvm/lib/aarch64/processor.c | 27 +- tools/testing/selftests/kvm/lib/kvm_util.c | 37 +- .../selftests/kvm/lib/userfaultfd_util.c | 187 +++ 10 files changed, 1762 insertions(+), 215 deletions(-) create mode 100644 tools/include/linux/bitfield.h create mode 100644 tools/testing/selftests/kvm/aarch64/page_fault_test.c create mode 100644 tools/testing/selftests/kvm/include/userfaultfd_util.h create mode 100644 tools/testing/selftests/kvm/lib/userfaultfd_util.c -- 2.37.0.rc0.161.g10f37bed90-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next reply other threads:[~2022-06-24 21:33 UTC|newest] Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-24 21:32 Ricardo Koller [this message] 2022-06-24 21:32 ` [PATCH v4 00/13] KVM: selftests: Add aarch64/page_fault_test Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 01/13] KVM: selftests: Add a userfaultfd library Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 02/13] KVM: selftests: aarch64: Add virt_get_pte_hva library function Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:12 ` Andrew Jones 2022-07-12 9:12 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 03/13] KVM: selftests: Add vm_alloc_page_table_in_memslot " Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:13 ` Andrew Jones 2022-07-12 9:13 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 04/13] KVM: selftests: aarch64: Export _virt_pg_map with a pt_memslot arg Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:33 ` Andrew Jones 2022-07-12 9:33 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 05/13] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:35 ` Andrew Jones 2022-07-12 9:35 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 06/13] KVM: selftests: Add vm_mem_region_get_src_fd library function Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:40 ` Andrew Jones 2022-07-12 9:40 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 07/13] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-07-12 9:46 ` Andrew Jones 2022-07-12 9:46 ` Andrew Jones 2022-06-24 21:32 ` [PATCH v4 08/13] tools: Copy bitfield.h from the kernel sources Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 09/13] KVM: selftests: aarch64: Add aarch64/page_fault_test Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-28 23:43 ` Oliver Upton 2022-06-28 23:43 ` Oliver Upton 2022-06-29 1:32 ` Ricardo Koller 2022-06-29 1:32 ` Ricardo Koller 2022-07-21 1:29 ` Sean Christopherson 2022-07-21 1:29 ` Sean Christopherson 2022-07-22 17:19 ` Ricardo Koller 2022-07-22 17:19 ` Ricardo Koller 2022-07-22 18:20 ` Sean Christopherson 2022-07-22 18:20 ` Sean Christopherson 2022-07-23 8:22 ` Andrew Jones 2022-07-23 8:22 ` Andrew Jones 2022-07-26 18:15 ` Sean Christopherson 2022-07-26 18:15 ` Sean Christopherson 2022-08-23 23:37 ` Ricardo Koller 2022-08-23 23:37 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 10/13] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 11/13] KVM: selftests: aarch64: Add dirty logging " Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 12/13] KVM: selftests: aarch64: Add readonly memslot " Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller 2022-06-24 21:32 ` [PATCH v4 13/13] KVM: selftests: aarch64: Add mix of " Ricardo Koller 2022-06-24 21:32 ` Ricardo Koller
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220624213257.1504783-1-ricarkol@google.com \ --to=ricarkol@google.com \ --cc=alexandru.elisei@arm.com \ --cc=axelrasmussen@google.com \ --cc=bgardon@google.com \ --cc=dmatlack@google.com \ --cc=drjones@redhat.com \ --cc=eric.auger@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=maz@kernel.org \ --cc=oupton@google.com \ --cc=pbonzini@redhat.com \ --cc=rananta@google.com \ --cc=reijiw@google.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.