From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com, seanjc@google.com,
darren@os.amperecomputing.com,
gankulkarni@os.amperecomputing.com
Subject: [RFC PATCH v2 9/9] KVM: arm64: nv: selftests: Enable page_fault_test test to run in vEL2
Date: Mon, 12 May 2025 03:52:51 -0700 [thread overview]
Message-ID: <20250512105251.577874-10-gankulkarni@os.amperecomputing.com> (raw)
In-Reply-To: <20250512105251.577874-1-gankulkarni@os.amperecomputing.com>
Extend page_fault_test to run guest code with NV enabled.
NV is enabled using command line argument and it is disabled by default.
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
---
.../selftests/kvm/arm64/page_fault_test.c | 35 ++++++++++++++++---
1 file changed, 30 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/kvm/arm64/page_fault_test.c b/tools/testing/selftests/kvm/arm64/page_fault_test.c
index ec33a8f9c908..e3d91cb68a71 100644
--- a/tools/testing/selftests/kvm/arm64/page_fault_test.c
+++ b/tools/testing/selftests/kvm/arm64/page_fault_test.c
@@ -11,6 +11,7 @@
#include <fcntl.h>
#include <test_util.h>
#include <kvm_util.h>
+#include <nv_util.h>
#include <processor.h>
#include <asm/sysreg.h>
#include <linux/bitfield.h>
@@ -70,6 +71,8 @@ struct test_params {
struct test_desc *test_desc;
};
+static bool is_nested;
+
static inline void flush_tlb_page(uint64_t vaddr)
{
uint64_t page = vaddr >> 12;
@@ -701,14 +704,27 @@ static void run_test(enum vm_guest_mode mode, void *arg)
struct kvm_vm *vm;
struct kvm_vcpu *vcpu;
struct uffd_desc *pt_uffd, *data_uffd;
+ int gic_fd = -1;
print_test_banner(mode, p);
- vm = ____vm_create(VM_SHAPE(mode));
- setup_memslots(vm, p);
+ if (is_nested) {
+ struct kvm_vcpu_init init;
+
+ vm = ____vm_create(VM_SHAPE(mode));
+ setup_memslots(vm, p);
+ vm_ioctl(vm, KVM_ARM_PREFERRED_TARGET, &init);
+ init_vcpu_nested(&init);
+ vcpu = aarch64_vcpu_add(vm, 0, &init, guest_code);
+ gic_fd = vgic_v3_setup(vm, 1, 64);
+ } else {
+ vm = ____vm_create(VM_SHAPE(mode));
+ setup_memslots(vm, p);
+ vcpu = vm_vcpu_add(vm, 0, guest_code);
+ }
+
kvm_vm_elf_load(vm, program_invocation_name);
setup_ucall(vm);
- vcpu = vm_vcpu_add(vm, 0, guest_code);
setup_gva_maps(vm);
@@ -728,6 +744,9 @@ static void run_test(enum vm_guest_mode mode, void *arg)
vcpu_run_loop(vm, vcpu, test);
+ if (is_nested)
+ close(gic_fd);
+
kvm_vm_free(vm);
free_uffd(test, pt_uffd, data_uffd);
@@ -742,7 +761,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
static void help(char *name)
{
puts("");
- printf("usage: %s [-h] [-s mem-type]\n", name);
+ printf("usage: %s [-h] [-s mem-type] [-g nested]\n", name);
puts("");
guest_modes_help();
backing_src_help("-s");
@@ -1115,7 +1134,7 @@ int main(int argc, char *argv[])
src_type = DEFAULT_VM_MEM_SRC;
- while ((opt = getopt(argc, argv, "hm:s:")) != -1) {
+ while ((opt = getopt(argc, argv, "hm:s:g:")) != -1) {
switch (opt) {
case 'm':
guest_modes_cmdline(optarg);
@@ -1123,6 +1142,9 @@ int main(int argc, char *argv[])
case 's':
src_type = parse_backing_src_type(optarg);
break;
+ case 'g':
+ is_nested = atoi_non_negative("Is Nested", optarg);
+ break;
case 'h':
default:
help(argv[0]);
@@ -1130,6 +1152,9 @@ int main(int argc, char *argv[])
}
}
+ if (is_nested)
+ TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_EL2));
+
for_each_test_and_guest_mode(src_type);
return 0;
}
--
2.48.1
next prev parent reply other threads:[~2025-05-12 10:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 10:52 [RFC PATCH v2 0/9] KVM: Enable Nested Virt selftests Ganapatrao Kulkarni
2025-05-12 10:52 ` [RFC PATCH v2 1/9] KVM: arm64: nv: selftests: Add support to run guest code in vEL2 Ganapatrao Kulkarni
2025-05-28 13:33 ` Eric Auger
2025-05-28 23:39 ` [PATCH RFC " Itaru Kitayama
2025-05-29 9:04 ` Eric Auger
2025-05-29 11:50 ` [RFC PATCH " Marc Zyngier
2025-05-12 10:52 ` [RFC PATCH v2 2/9] KVM: arm64: nv: selftests: Add simple test " Ganapatrao Kulkarni
2025-06-09 3:14 ` Itaru Kitayama
2025-05-12 10:52 ` [RFC PATCH v2 3/9] KVM: arm64: nv: selftests: Enable hypervisor timer tests to run " Ganapatrao Kulkarni
2025-05-28 13:58 ` Eric Auger
2025-05-12 10:52 ` [RFC PATCH v2 4/9] KVM: arm64: nv: selftests: enable aarch32_id_regs test " Ganapatrao Kulkarni
2025-05-12 10:52 ` [RFC PATCH v2 5/9] KVM: arm64: nv: selftests: Enable vgic tests " Ganapatrao Kulkarni
2025-05-12 10:52 ` [RFC PATCH v2 6/9] KVM: arm64: nv: selftests: Enable set_id_regs test " Ganapatrao Kulkarni
2025-05-12 10:52 ` [RFC PATCH v2 7/9] KVM: arm64: nv: selftests: Enable " Ganapatrao Kulkarni
2025-05-12 10:52 ` [RFC PATCH v2 8/9] KVM: selftests: arm64: Extend kvm_page_table_test to run guest code " Ganapatrao Kulkarni
2025-06-02 6:04 ` Itaru Kitayama
2025-06-02 15:38 ` Marc Zyngier
2025-05-12 10:52 ` Ganapatrao Kulkarni [this message]
2025-05-28 13:28 ` [RFC PATCH v2 0/9] KVM: Enable Nested Virt selftests Eric Auger
2025-05-29 10:29 ` Ganapatrao Kulkarni
2025-05-29 11:48 ` Marc Zyngier
2025-06-19 9:40 ` Ganapatrao Kulkarni
2025-06-19 11:45 ` Marc Zyngier
2025-06-23 10:31 ` Ganapatrao Kulkarni
2025-06-23 14:11 ` Marc Zyngier
2025-07-25 10:01 ` Ganapatrao Kulkarni
2025-07-25 10:59 ` Marc Zyngier
2025-05-30 17:49 ` Miguel Luis
2025-05-30 21:32 ` Oliver Upton
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=20250512105251.577874-10-gankulkarni@os.amperecomputing.com \
--to=gankulkarni@os.amperecomputing.com \
--cc=darren@os.amperecomputing.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=seanjc@google.com \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®