Repository navigation
Commit fe61f9c
vmm_tests: check that each backend refuses unsupported restore state
The backend contract tests had no case for a restore of a saved state
that holds an element that the partition lacks, which, before the
previous commit, panicked in the generated restore_all on every backend
(microsoft/nvx#1168). A save never holds one, since it holds only what
the partition has, so no other contract reached it.
A new module, unsupported_state, holds two contracts, which every native
backend owes and which register with the default, unenlightened fixture.
They craft the decoded snapshot from protobuf with the field numbers of
VpSavedState and VmSavedState, and require that the restore fails with
StateError::Unsupported naming the element:
- refuses_unsupported_cpu_state restores, one at a time, each element
that the fixture's partition lacks: SynIC state, which it always
lacks, and, depending on the backend, the host, and the CPUID of the
fixture, IA32_SPEC_CTRL, IA32_UMWAIT_CONTROL, IA32_DEBUGCTL, the
feature and power MSRs, and the machine-check state, of which MSHV and
WHP hold none of the last four. Each comes with registers that
precede it in the restore order and differ from the VP's, and the VP's
registers must stay as they were.
- refuses_unsupported_vm_state restores each element of the VM state,
the hypercall MSRs, the reference time, and the reference TSC page,
alone.
Both first check that the fixture's partition lacks Hyper-V
enlightenments. The module has a file of its own, registered between
time and xsave for the hosts of every native backend, since restore.rs
holds the contracts that only KVM owes and builds for Linux alone. The
Guide's page of the contract tests lists the cases.
Results, one process per case on Windows, nextest on Linux, debug build.
With restore_all as it was at 359169f, which asserts that each
element is present instead of refusing it, both new cases fail on every
backend with a panic in the restore, "assertion failed: <SyntheticMsrs
as ...>::is_present(self.caps())" for the CPU case, at the expansion of
state_trait! in vmm_core/virt/src/x86/vp.rs, and "<HypercallMsrs as
...>::is_present(self.caps())" for the VM case, in x86/vm.rs. With the
previous commit, both pass, and the other cases of the binary pass as
before:
WHP, Windows 11 on a Core i9-12900H (local) fail -> pass
WHP, nvx-whp-test (Windows VM) fail -> pass
MSHV, nvx-mshv-test (Azure Linux 3 VM) fail -> pass
KVM, nvx-kvm-test (Azure Linux 3 VM, Xeon
Platinum 8573C, Linux 6.18.57) fail -> pass
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 30ce395 commit fe61f9c
3 files changed
Lines changed: 182 additions & 0 deletions
File tree
- Guide/src/dev_guide/tests
- vmm_tests/vmm_tests/tests/virt_backend_tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
0 commit comments