[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250512105251.577874-8-gankulkarni@os.amperecomputing.com>
Date: Mon, 12 May 2025 03:52:49 -0700
From: Ganapatrao Kulkarni <gankulkarni@...amperecomputing.com>
To: linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.linux.dev,
linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: maz@...nel.org,
oliver.upton@...ux.dev,
joey.gouly@....com,
suzuki.poulose@....com,
yuzenghui@...wei.com,
seanjc@...gle.com,
darren@...amperecomputing.com,
gankulkarni@...amperecomputing.com
Subject: [RFC PATCH v2 7/9] KVM: arm64: nv: selftests: Enable test to run in vEL2
Modify the test to run the guest code with NV enabled.
Added code is only applicable to ARM64.
NV is enabled using command line argument and it is disabled by default.
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@...amperecomputing.com>
---
.../testing/selftests/kvm/guest_print_test.c | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/testing/selftests/kvm/guest_print_test.c b/tools/testing/selftests/kvm/guest_print_test.c
index bcf582852db9..4f786b88fdbe 100644
--- a/tools/testing/selftests/kvm/guest_print_test.c
+++ b/tools/testing/selftests/kvm/guest_print_test.c
@@ -15,6 +15,15 @@
#include "processor.h"
#include "ucall_common.h"
+#ifdef __aarch64__
+#include "nv_util.h"
+static void pr_usage(const char *name)
+{
+ pr_info("%s [-g nv] -h\n", name);
+ pr_info(" -g:\tEnable Nested Virtualization, run guest code as guest hypervisor (default: Disabled)\n");
+}
+#endif
+
struct guest_vals {
uint64_t a;
uint64_t b;
@@ -192,7 +201,30 @@ int main(int argc, char *argv[])
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
+#ifdef __aarch64__
+ int opt;
+ bool is_nested = false;
+ int gic_fd;
+
+ while ((opt = getopt(argc, argv, "g:")) != -1) {
+ switch (opt) {
+ case 'g':
+ is_nested = atoi_non_negative("Is Nested", optarg);
+ break;
+ case 'h':
+ default:
+ pr_usage(argv[0]);
+ return 1;
+ }
+ }
+
+ if (is_nested)
+ vm = nv_vm_create_with_vcpus_gic(1, &vcpu, &gic_fd, guest_code);
+ else
+ vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+#else
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
+#endif
test_type_i64(vcpu, -1, -1);
test_type_i64(vcpu, -1, 1);
--
2.48.1
Powered by blists - more mailing lists