Skip to content

SNP: Secure AVIC support #1172

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

romank-msft
Copy link
Contributor

@romank-msft romank-msft commented Apr 10, 2025

Enable secure AVIC support to offload interrupt state computation to the hardware to be fast and secure.

In AMD's own words:

"The Secure AVIC feature provides support for managing guest-owned APIC state for SEV-SNP guests using a private, guest-owned backing page per vCPU."
-- SEV-ES GHCB Standartizarion

"In a virtualized computer system, each guest operating system needs access to an interrupt controller to send and receive device and interprocessor interrupts. When there is no hardware acceleration, it falls to the virtual machine monitor (VMM) to intercept guest-initiated attempts to access the interrupt controller registers and provide direct emulation of the controller system programming interface allowing the guest to initiate and process interrupts. The VMM uses the underlying physical and virtual interrupt delivery mechanisms of the system to deliver interrupts from I/O devices and virtual processors to the target guest virtual processor and to handle any required end of interrupt processing.

Given the high rate of device and interprocessor interrupt generation in certain scenarios, in particular on server-class systems, the emulation of a local APIC can be a significant burden for the VMM. The AVIC architecture addresses the overhead of guest interrupt processing in a virtualized environment by applying hardware acceleration to the following components of interrupt processing:

  • Providing a guest operating system access to performance-critical interrupt controller registers
  • Initiating intra- and inter-processor interrupts (IPIs) in and between virtual processors in a guest"
    -- AMD64 PPR Vol. 3

Laundry list:

  • IGVM parameter for disabling secure AVIC (would someone like that for testing maybe??)
  • Definitions
  • High-level wiring
  • resolve TODOs in the IGVM file generator
  • Auto-enable secure AVIC in the boot shim (from the hw arch pov considered dicey, not doing that)
  • need the secure AVIC kernel patch (comes with kernel 6.12)
  • update the VTL driver to allocate, RMP adjust, and fill out the AVIC backing page,
  • update the kernel interface to map the AVIC page
  • plumbing for (un)registering the backing page in the user mode
  • Implement handling for the non-accelerated AVIC SEV exit
  • Implement handling for the incomplete IPI AVIC SEV exit
  • Make sure INIT and SIPI are delivered
  • Make sure IPIs are delivered
  • Support MpState::Idle and kernel idle and halt state offloading for better performance
  • Fix the existing logic for advancing the RIP (assumes the next RIP is always provided which is true for the automatic exits only, and Windows reads the CCR AVIC register that results in non-AE so the RIP was set to 0 due to next RIP not filled out)
  • Make sure TPR and CR8 are not trashed
  • Fix TMR handling to service level-triggered interrupts reliably
  • Boot multi-proc WIndows
  • Test save/restore, pause/resume, servicing, stress-test

OHCL-Linux-Kernel draft: microsoft/OHCL-Linux-Kernel#67

The change boots multi-proc Linux guests atm and gets past HAL init in Windows

@romank-msft romank-msft force-pushed the savic branch 4 times, most recently from c2a6131 to 29dc5e4 Compare April 23, 2025 19:14
@romank-msft romank-msft force-pushed the savic branch 2 times, most recently from da9191e to 082bdc5 Compare April 30, 2025 19:37
@romank-msft romank-msft force-pushed the savic branch 5 times, most recently from 86af935 to 3687496 Compare May 8, 2025 21:59
@romank-msft romank-msft force-pushed the savic branch 2 times, most recently from aabca2d to 074cb5d Compare May 10, 2025 16:34
@@ -9,7 +9,8 @@
"shared_gpa_boundary_bits": 46,
"policy": 196639,
"enable_debug": true,
"injection_type": "normal"
"injection_type": "normal",
"secure_avic": "enabled"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert to "disabled"

@romank-msft romank-msft force-pushed the savic branch 2 times, most recently from a17bbe0 to 4ead4cf Compare May 10, 2025 20:27
@romank-msft romank-msft force-pushed the savic branch 3 times, most recently from 91e198d to 3ab9286 Compare May 15, 2025 17:16
@romank-msft romank-msft force-pushed the savic branch 4 times, most recently from 5ab32f2 to 3472a20 Compare May 30, 2025 21:54
@romank-msft romank-msft force-pushed the savic branch 3 times, most recently from ab868e9 to 925a258 Compare June 11, 2025 21:49
@romank-msft romank-msft force-pushed the savic branch 2 times, most recently from a4010a8 to f0d8c97 Compare June 17, 2025 00:14
@romank-msft romank-msft force-pushed the savic branch 7 times, most recently from eb422e9 to accd50e Compare July 1, 2025 18:23
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.

6 participants