aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2025-11-19 12:17:39 +0100
committerAlexander Potapenko <glider@google.com>2025-11-20 09:23:19 +0000
commitec988b2fb6c4aada0b3afcd9739ad27ec64b8249 (patch)
treeb9678fb9f3d1d25d91d35222b991514c04e5b930 /sys
parentf789f57f25de937cc56a2628ee6757af1ae60534 (diff)
sys/linux/test: add amd64-syz_kvm_nested_create_vm-hlt
Basic SYZOS test for NV that ensures an L2 VM is correctly created and executed.
Diffstat (limited to 'sys')
-rw-r--r--sys/linux/test/amd64-syz_kvm_nested_create_vm-hlt23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/linux/test/amd64-syz_kvm_nested_create_vm-hlt b/sys/linux/test/amd64-syz_kvm_nested_create_vm-hlt
new file mode 100644
index 000000000..1a26a4e82
--- /dev/null
+++ b/sys/linux/test/amd64-syz_kvm_nested_create_vm-hlt
@@ -0,0 +1,23 @@
+#
+# requires: arch=amd64 -threaded
+#
+r0 = openat$kvm(0, &AUTO='/dev/kvm\x00', 0x0, 0x0)
+r1 = ioctl$KVM_CREATE_VM(r0, AUTO, 0x0)
+r2 = syz_kvm_setup_syzos_vm$x86(r1, &(0x7f0000c00000/0x400000)=nil)
+
+# Create a nested VM that just HLTs.
+#
+r3 = syz_kvm_add_vcpu$x86(r2, &AUTO={0x0, &AUTO=[@enable_nested={AUTO, AUTO, 0x0}, @nested_create_vm={AUTO, AUTO, 0x0}, @nested_load_code={AUTO, AUTO, {0x0, "f4"}}, @nested_vmlaunch={AUTO, AUTO, 0x0}], AUTO})
+r4 = ioctl$KVM_GET_VCPU_MMAP_SIZE(r0, AUTO)
+r5 = mmap$KVM_VCPU(&(0x7f0000009000/0x1000)=nil, r4, 0x3, 0x1, r3, 0x0)
+
+# L2 VM should halt, after which the nested exit handle should uexit with 0xe2e20001
+# (0x1 is SYZOS_NESTED_EXIT_REASON_HLT).
+#
+ioctl$KVM_RUN(r3, AUTO, 0x0)
+syz_kvm_assert_syzos_uexit$x86(r5, 0xe2e20001)
+
+# KVM_RUN should exit with KVM_EXIT_MMIO due to guest_uexit(-1).
+#
+ioctl$KVM_RUN(r3, AUTO, 0x0)
+syz_kvm_assert_syzos_uexit$x86(r5, 0xffffffff)