Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions doc/design/1.5-compatibility-and-versioning-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,13 @@ The guest's speculation controls (`IA32_SPEC_CTRL`) are held by such an element;
[CPU Profiles](2.2-cpu-and-topology.md#221-cpu-profiles) says which guests have
it.

The state that guests write at boot and the processor keeps follows: the
user-wait control (`IA32_UMWAIT_CONTROL`), the debug control
(`IA32_DEBUGCTL`), the feature and power controls (`IA32_MISC_ENABLE`,
`MSR_MISC_FEATURES_ENABLES`, and `IA32_POWER_CTL`), and the machine-check state.
The state that guests write and the processor keeps follows: the user-wait
control (`IA32_UMWAIT_CONTROL`), MPX's supervisor configuration
(`IA32_BNDCFGS`), the debug control (`IA32_DEBUGCTL`), the feature and power
controls (`IA32_MISC_ENABLE`, `MSR_MISC_FEATURES_ENABLES`, and `IA32_POWER_CTL`),
the machine-check state, AMD's SVM control and host save area (`VM_CR` and
`VM_HSAVE_PA`), and AMD's OS-visible workaround registers (`OSVW_ID_LENGTH` and
`OSVW_STATUS`).
[Guest-Writable Processor State](2.2-cpu-and-topology.md#2214-guest-writable-processor-state)
says which guests have each. A snapshot holds an element only where the backend
that captured it can read the state, and a restore needs a backend that can
Expand Down Expand Up @@ -210,6 +213,15 @@ the pair. Every snapshot restores the same on both. A restore refuses any other
pending exception, which KVM would drop and only a damaged or crafted snapshot
holds.

The activity has no place for a software interrupt (`INT n`) or a software
exception (`INT3`, `INTO`, or `INT1`) that the hypervisor was delivering when it
stopped the processor, which it delivers with the length of the instruction that
raised it. MSHV and WHP can hold one, and refuse to capture such a processor
rather than drop the event, as they refuse a pending event of a kind that the
activity does not know; a guest-requested capture then rolls back, and the guest
continues and takes the event. KVM never reports one: it has the guest run the
instruction again.

The activity also holds the kind of an interrupt shadow in a field of its own. A
`MOV SS` or `POP SS` leaves a shadow that lasts one instruction and also blocks
NMIs and suppresses certain debug exceptions at the next instruction boundary,
Expand Down
56 changes: 36 additions & 20 deletions doc/design/2.2-cpu-and-topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,39 +171,55 @@ A guest writes registers that no CPU profile pins, and a snapshot keeps what it
wrote as
[processor state elements](1.5-compatibility-and-versioning-model.md#154-processor-state-elements),
which a restore sets before the guest runs, as it does for the speculation
controls of [Effective CPUID](#2211-effective-cpuid). Only the KVM backend holds
them, and only where the host lets it read the state, so a CPU profile does not
decide what a snapshot holds. A snapshot holds:
controls of [Effective CPUID](#2211-effective-cpuid). A backend holds an element
only where it can read and write the state, so a CPU profile does not decide
alone what a snapshot holds. A snapshot holds:

- The user-wait control (`IA32_UMWAIT_CONTROL`), where the CPU profile's CPUID
enumerates `WAITPKG`, as the Alder Lake and Granite Rapids profiles do and the
other pinned profiles do not, and the host's KVM lists the MSR, which needs
hardware with WAITPKG. Linux writes it on every processor at boot.
- The debug control (`IA32_DEBUGCTL`), for every CPU profile. Every KVM
other pinned profiles do not: on KVM where the host's KVM lists the MSR, which
needs hardware with WAITPKG, and on MSHV and WHP, whose hypervisor keeps it as
a register of the virtual processor. Linux writes it on every processor at
boot.
- MPX's supervisor configuration (`IA32_BNDCFGS`), where the CPU profile's CPUID
enumerates MPX, as only the Skylake-SP profile does: on KVM where the host's
KVM lists the MSR, which it does on hardware with MPX, and on MSHV and WHP as
a register. Linux 5.6 dropped MPX for its own processes, but still enables
MPX's state components for KVM's guests, so a KVM guest can write the
register.
- The debug control (`IA32_DEBUGCTL`), for every CPU profile, on KVM. Every KVM
virtualizes it, so the host's MSR list does not decide it.
- The feature and power controls (`IA32_MISC_ENABLE`, the CPUID-faulting bit of
`MSR_MISC_FEATURES_ENABLES`, and `IA32_POWER_CTL`), for every CPU profile, where
the host's KVM lists the three MSRs, and the machine-check state:
`MSR_MISC_FEATURES_ENABLES`, and `IA32_POWER_CTL`), for every CPU profile, on
KVM where the host's KVM lists the three MSRs, and the machine-check state:
`IA32_MCG_STATUS`, `IA32_MCG_CTL`, and the control, status, address,
miscellaneous, and corrected-error control registers of every error-reporting
bank, where it lists `IA32_MCG_STATUS`, since it does not list the registers of
the banks. A guest with machine-check support programs them at boot. KVM keeps
them in the virtual processor, and a new one starts with the VMM's values, so a
restore without them reverts what the guest wrote.
- AMD's SVM control and host save area (`VM_CR` and `VM_HSAVE_PA`), on KVM on an
AMD host, which keeps both for every guest, although no CPU profile enumerates
SVM. A restore refuses a `VM_HSAVE_PA` that is not a page address that the
guest has, or a `VM_CR` that disables SVM while the restored `EFER` enables
it, which no guest can hold, before it writes either register.
- AMD's OS-visible workaround registers (`OSVW_ID_LENGTH` and `OSVW_STATUS`),
where the CPU profile's CPUID enumerates OSVW, as every AMD profile does, on
KVM on an AMD host. KVM gives a new virtual processor values that it derives
from the host's; a snapshot keeps the ones that the guest saw, and a VM reset
puts KVM's back.

A snapshot of an SNP guest holds none of them, since the host cannot read its
registers. MSHV and WHP hold none of these elements yet. Three groups of
registers that guests can write have no element:

- `IA32_BNDCFGS`, which MPX uses. Only the Skylake-SP profile enumerates MPX,
and KVM has not presented MPX since Linux 5.6, because the kernel does not
enable its state components, so a KVM guest cannot write the register.
- `MSR_VM_HSAVE_PA`, which SVM uses. No CPU profile enumerates SVM, so no guest
runs the instructions that use the register.
- AMD's legacy performance counters (`0xc0010000` through `0xc0010007`), whose
state KVM keeps in its virtual PMU where that is on. The guest has no PMU, so
[the VMM raises #GP for them](3.2-clock-and-time.md#322-msrs) under an AMD CPU
profile instead.
registers. MSHV and WHP hold the user-wait control and MPX's configuration, and
none of the other elements: the Microsoft hypervisor drops a guest's writes of
the debug control and `IA32_MISC_ENABLE`, raises #GP for the other feature and
power controls, and gives the guest no machine-check banks, and on WHP the VMM
serves the OSVW registers itself, reading 0 and refusing writes. One group of
registers that guests can write has no element: AMD's legacy performance
counters (`0xc0010000` through `0xc0010007`), whose state KVM keeps in its
virtual PMU where that is on. The guest has no PMU, so
[the VMM raises #GP for them](3.2-clock-and-time.md#322-msrs) under an AMD CPU
profile instead.

## 2.2.2 Processor Capacity

Expand Down
Loading
Loading