Skip to content

Commit 2c9d4ca

Browse files
authored
Merge pull request #313 from haraldh/vmm_communication_exception
Add the VMM Communication Exception (#VC) to the InterruptDescriptorTable
2 parents e89bbb1 + 0e80711 commit 2c9d4ca

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/structures/idt.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,37 @@ pub struct InterruptDescriptorTable {
340340
/// vector nr. 20
341341
pub virtualization: Entry<HandlerFunc>,
342342

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

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

0 commit comments

Comments
 (0)