[RFC PATCH v2 4/9] KVM: arm64: nv: selftests: enable aarch32_id_regs test to run in vEL2
Ganapatrao Kulkarni
gankulkarni at os.amperecomputing.com
Mon May 12 03:52:46 PDT 2025
Extend the testing of AArch32 ID registers with guest code
with NV enabled.
NV is enabled using command line argument and it is disabled by default.
Signed-off-by: Ganapatrao Kulkarni <gankulkarni at os.amperecomputing.com>
---
.../selftests/kvm/arm64/aarch32_id_regs.c | 34 +++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/arm64/aarch32_id_regs.c b/tools/testing/selftests/kvm/arm64/aarch32_id_regs.c
index cef8f7323ceb..8a9afda8a3e2 100644
--- a/tools/testing/selftests/kvm/arm64/aarch32_id_regs.c
+++ b/tools/testing/selftests/kvm/arm64/aarch32_id_regs.c
@@ -11,6 +11,7 @@
#include <stdint.h>
#include "kvm_util.h"
+#include "nv_util.h"
#include "processor.h"
#include "test_util.h"
#include <linux/bitfield.h>
@@ -150,12 +151,38 @@ static bool vcpu_aarch64_only(struct kvm_vcpu *vcpu)
return el0 == ID_AA64PFR0_EL1_EL0_IMP;
}
-int main(void)
+static void help(const char *name)
+{
+ pr_info("Usage: %s [-g enable]\n", name);
+ pr_info("\t-g: Enable Nested Virtualization, run guest code as guest hypervisor (default: Disabled)\n");
+ exit(1);
+}
+
+int main(int argc, char **argv)
{
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
+ int gic_fd;
+ int opt;
+ bool is_nested = false;
+
+
+ while ((opt = getopt(argc, argv, "h:g:")) != -1) {
+ switch (opt) {
+ case 'g':
+ is_nested = atoi_non_negative("Is Nested", optarg);
+ break;
+ case 'h':
+ default:
+ help(argv[0]);
+ break;
+ }
+ }
- vm = vm_create_with_one_vcpu(&vcpu, guest_main);
+ if (is_nested)
+ vm = nv_vm_create_with_vcpus_gic(1, &vcpu, &gic_fd, guest_main);
+ else
+ vm = vm_create_with_one_vcpu(&vcpu, guest_main);
TEST_REQUIRE(vcpu_aarch64_only(vcpu));
@@ -163,5 +190,8 @@ int main(void)
test_user_raz_invariant(vcpu);
test_guest_raz(vcpu);
+ if (is_nested)
+ close(gic_fd);
+
kvm_vm_free(vm);
}
--
2.48.1
More information about the linux-arm-kernel
mailing list