Skip to content

Add initial minimal nested-svm-vmrun testcase#13

Open
bernhardkaindl wants to merge 1 commit into
andyhhp:masterfrom
bernhard-xs:nested-svm-vmrun-0.1
Open

Add initial minimal nested-svm-vmrun testcase#13
bernhardkaindl wants to merge 1 commit into
andyhhp:masterfrom
bernhard-xs:nested-svm-vmrun-0.1

Conversation

@bernhardkaindl
Copy link
Copy Markdown
Contributor

Based on an initial experiment by Ross.

I refactored it 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

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>
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.

1 participant