Skip to content

Add initial minimal nested-svm-vmrun testcase#1

Open
bernhardkaindl wants to merge 1 commit into
masterfrom
nested-svm-vmrun-0.1
Open

Add initial minimal nested-svm-vmrun testcase#1
bernhardkaindl wants to merge 1 commit into
masterfrom
nested-svm-vmrun-0.1

Conversation

@bernhardkaindl
Copy link
Copy Markdown

@bernhardkaindl bernhardkaindl commented May 11, 2026

Based on an initial experiment by Ross with these changes (summary):

  • vmcb.h: replaced the GPL-only 640-line copy of Xen's vmcb_struct (with all its bit-fields, unions and VMCB_ACCESSORS macros) with a 128-line BSD-licensed minimal struct vmcb. Only the fields the test actually uses are named; reserved areas are kept as anonymous padding. _Static_asserts pin all named fields to their architectural offsets per the AMD APM Vol. 2 Appendix B layout.
  • main.c: dropped the horrible vmcb_set_* accessors in favour of plain field assignments (l2_vmcb.cr3 = read_cr3();). Replaced the lidt + ud2 shutdown trick (which depended on SHUTDOWN intercept) with a clean L2 → L1 handshake: L2 writes a sentinel, executes HLT (intercepted), L1 verifies both the exit code and the sentinel. Removed dead code (l2_cpuinfo, the GDT/TSS plumbing the test never used, the result/shutdown_ptr globals, the #if 0 block).
  • entry.S: collapsed the 100-line l2_cpuinfo save/restore (which was never populated from C) to a 6-instruction trampoline. Documented why VMSAVE/VMLOAD of the L2 VMCB bracket the VMRUN.
  • setup.c: restored the original xen_console_write body — the L2-side console garbling went away once L2 stopped trying to invoke the inherited Xen hypercall page (in Xen's nested-SVM model, VMMCALL from L2 unconditionally exits to L1, so L2 cannot hit Xen's hypercall path; the new test sticks to a pure HLT exit)

Signed-off-by: Ross Lagerwall ross.lagerwall@citrix.com
Signed-off-by: Bernhard Kaindl bernhard.kaindl@citrix.com

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new in-development XTF test intended to smoke-test Xen’s nested SVM support by entering an L2 guest via VMRUN using a minimal VMCB definition and a small assembly trampoline.

Changes:

  • Introduces a new nested-svm-vmrun test target (Makefile + Xen config snippet).
  • Adds a minimal VMCB layout header with compile-time offset/size checks.
  • Implements the L1/L2 test logic in C plus an SVM VMLOAD/VMRUN/VMSAVE trampoline in assembly, and wires the test into the documentation index.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/nested-svm-vmrun/vmcb.h Minimal VMCB struct layout + intercept/exitcode constants for the new test.
tests/nested-svm-vmrun/Makefile Registers the new test build target and objects.
tests/nested-svm-vmrun/main.c Implements L1 setup and L2 entry/handshake logic using a constructed VMCB.
tests/nested-svm-vmrun/extra.cfg.in Enables nested HVM for the test domain.
tests/nested-svm-vmrun/entry.S Provides the svm_vmrun() trampoline executing VMLOAD/VMRUN/VMSAVE.
docs/all-tests.dox Adds the new test page to the global test list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/nested-svm-vmrun/main.c Outdated
Comment thread tests/nested-svm-vmrun/main.c Outdated
Comment thread tests/nested-svm-vmrun/main.c Outdated
Comment thread tests/nested-svm-vmrun/main.c
Comment thread tests/nested-svm-vmrun/entry.S
@bernhardkaindl bernhardkaindl force-pushed the nested-svm-vmrun-0.1 branch 2 times, most recently from dd9f8a3 to 33d50b7 Compare May 11, 2026 18:07
@bernhardkaindl bernhardkaindl force-pushed the nested-svm-vmrun-0.1 branch from 3cfd6ee to c9bb971 Compare May 11, 2026 20:54
Based on an initial experiment by Ross

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@citrix.com>
@bernhardkaindl bernhardkaindl force-pushed the nested-svm-vmrun-0.1 branch from c9bb971 to 1c3bbd8 Compare May 12, 2026 07:30
@bernhardkaindl
Copy link
Copy Markdown
Author

As I saw no further issues, I opened a PR for Andy's in repo:
andyhhp#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants