Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the VMM Communication Exception (#VC) to the InterruptDescriptorTable #313

Merged
merged 2 commits into from
Nov 6, 2021
Merged
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
36 changes: 33 additions & 3 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,37 @@ pub struct InterruptDescriptorTable {
/// vector nr. 20
pub virtualization: Entry<HandlerFunc>,

/// vector nr. 21-29
reserved_2: [Entry<HandlerFunc>; 9],
/// vector nr. 21-28
reserved_2: [Entry<HandlerFunc>; 8],

/// The VMM Communication Exception (`#VC`) is always generated by hardware when an `SEV-ES`
/// enabled guest is running and an `NAE` event occurs.
///
/// `SEV-ES` stands for the _"Encrypted State"_ feature of the _"AMD Secure Encrypted Virtualization"_
/// technology. `NAE` stands for an _"Non-Automatic Exit"_, which is an `VMEXIT` event that requires
/// hypervisor emulation. See
/// [this whitepaper](https://www.amd.com/system/files/TechDocs/Protecting%20VM%20Register%20State%20with%20SEV-ES.pdf)
/// for an overview of the `SEV-ES` feature.
///
/// The `#VC` exception is a precise, contributory, fault-type exception utilizing exception vector 29.
/// This exception cannot be masked. The error code of the `#VC` exception is equal
/// to the `#VMEXIT` code of the event that caused the `NAE`.
///
/// In response to a `#VC` exception, a typical flow would involve the guest handler inspecting the error
/// code to determine the cause of the exception and deciding what register state must be copied to the
/// `GHCB` (_"Guest Hypervisor Communication Block"_) for the event to be handled. The handler
/// should then execute the `VMGEXIT` instruction to
/// create an `AE` and invoke the hypervisor. After a later `VMRUN`, guest execution will resume after the
/// `VMGEXIT` instruction where the handler can view the results from the hypervisor and copy state from
/// the `GHCB` back to its internal state as needed.
///
/// Note that it is inadvisable for the hypervisor to set the `VMCB` (_"Virtual Machine Control Block"_)
/// intercept bit for the `#VC` exception as
/// this would prevent proper handling of `NAE`s by the guest. Similarly, the hypervisor should avoid
/// setting intercept bits for events that would occur in the `#VC` handler (such as `IRET`).
///
/// The vector number of the ``#VC`` exception is 29.
pub vmm_communication_exception: Entry<HandlerFuncWithErrCode>,

/// The Security Exception (`#SX`) signals security-sensitive events that occur while
/// executing the VMM, in the form of an exception so that the VMM may take appropriate
Expand Down Expand Up @@ -407,7 +436,8 @@ impl InterruptDescriptorTable {
machine_check: Entry::missing(),
simd_floating_point: Entry::missing(),
virtualization: Entry::missing(),
reserved_2: [Entry::missing(); 9],
reserved_2: [Entry::missing(); 8],
vmm_communication_exception: Entry::missing(),
security_exception: Entry::missing(),
reserved_3: Entry::missing(),
interrupts: [Entry::missing(); 256 - 32],
Expand Down