mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v5 0/8] Add SEV-SNP restricted injection hypervisor support
@ 2026-11-09  3:18 Melody Wang
  2026-11-09  3:18 ` [RFC PATCH v5 1/8] x86/sev: Define the #HV doorbell page structure Melody Wang
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Melody Wang @ 2026-11-09  3:18 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: LKML, kvm, Joerg Roedel, x86, Melody Wang

Hi all,

This v5 of the Restricted Injection hypervisor support patches.

The previous version:

https://lore.kernel.org/all/cover.1777048608.git.huibo.wang@amd.com

This is based on d4b7fb647204f0c81dfeae2d1a708e4d858e0c94 (kvm/next).

This series addresses v4 upstream review comments from Sashiko, Tom, and
Joerg.

The main changes in v5 include:

1. Guest-Driven IRR-to-ISR Transition: Instead of moving the vector from
   IRR to ISR directly upon reading (matching legacy interrupt injection),
   KVM now waits for the guest acknowledgment before moving the interrupt
   vector from IRR to ISR.

2. No-EOI Handling: Added handling for the 'no_eoi_required' case.

3. HLT Intercept and Architectural Alignment: Added a new patch to properly
   intercept HLT when Restricted Injection is active. This addresses the
   guest's loss of control over HLT/interrupt interactions by immediate guest
   re-entry on pending events.

4. Sleep-in-Atomic and Scheduling Fixes: Resolved critical issues caused by
   kvm_vcpu_map() calling paths in the HLT fast-path (sleeping with local
   IRQs disabled) and during normal vCPU block polling (incorrect
   TASK_INTERRUPTIBLE/TASK_RUNNING state transitions causing livelocks).

5. Refined Cancel Injection: When canceling injection, KVM now only cancels
   the #HV event while preserving the pending interrupt information in the
   doorbell page.

6. Priority-Based Vector Overwriting: KVM now overwrites the interrupt
   vector in the doorbell page when a higher-priority vector appears,
   avoiding sending an unnecessary duplicate #HV.

7. Documentation and Review Feedback: Improved several comments for clarity
   and implemented code fixes for valid issues pointed out by Sashiko during
   review.

This patch set remains an RFC. There is an alternative approach that I
will present at KVM Forum 2026 in the talk: "COCONUT-SVSM, KVM Planes,
and Secure Interrupt Injection - Upstream". I plan to update this series
further after gathering feedback from the KVM Forum community.

Thanks,
Melody

Changelog:
---------
v4

This is v4 of the Restricted Injection hypervisor support patches.

The previous version was submitted here:
https://lore.kernel.org/all/20241127225539.5567-1-huibo.wang@amd.com

The new series are rebased on commit 6b802031877a995456c528095c41d1948546bf45
(kvm/next).

Restricted Injection (RI) is not a prerequisite for Planes support. Even
though the SVSM requires RI, RI support can be submitted independently. Since
the number of Planes patches is large, submit RI as its own series.

v3

This is v3 of the Restricted Injection hypervisor support patches.

The previous, v2 version was submitted here:
https://lore.kernel.org/r/cover.1725945912.git.huibo.wang@amd.com

Since then, the series experienced the following changes:

1. Remove unused field in struct hvdb_events.

2. Add comments explaining sev_snp_blocked() with no_further_signal and vector.
   Explain that only a single interrupt vector is presented by the hypervisor
   in the doorbell page. Only when the interrupt is acked, the next interrupt
   is presented.

3. Add warning in sev_snp_cancel_injection() when vector is not #HV_VECTOR.

4. Update hvdb_map() failure handling. When it fails, no interrupt will be
   injected.

5. Remove sev_snp_queue_exception() in svm_update_soft_interrupt_rip(), since
   the soft interrupt is only BP_VECTOR and OF_VECTOR, so it will always return
   false, then sev_snp_queue_exception() will be executed in
   svm_inject_exception() always.

6. Add new #HV IPI feature in XAPIC and X2APIC mode, test each mode with three
   IPI types: broadcast, self-IPI, and allbutself.

v2

Hi all,

This is a v2 of the restricted injection hypervisor support patches.

The previous version was submitted here:
https://lore.kernel.org/r/cover.1722989996.git.huibo.wang@amd.com

Since the previous submission, one issue reported by the kernel test robot was
fixed.

All comments and review feedback are appreciated.

Thanks.

v1

Operating systems may not handle unexpected interrupt or exception sequences.
A malicious hypervisor can inject random interrupt or exception sequences,
putting guest drivers or guest OS kernels into an unexpected state, which could
lead to security issues.

To address this concern, SEV-SNP restricts the injection of interrupts and
exceptions to those only allowed by the guest. Restricted Injection disables
all hypervisor-based interrupt queuing and event injection for all vectors,
allowing only a single vector, #HV (28), which is reserved for SNP guest use
but is never generated by hardware. #HV is only permitted to be injected into
VMSAs that execute with Restricted Injection.

Guests operating with Restricted Injection are expected to communicate with the
hypervisor about events via a software-managed para-virtualization interface.
This interface can utilize #HV injection as a doorbell to inform the guest that
new events have occurred. This patch set implements Restricted Injection on the
KVM side directly into VMPL0.

Overview:

The GHCB 2.0 specification[1] defines #HV doorbell page and the #HV doorbell
page NAE event allows for an SEV-SNP guest to register a doorbell page for use
with the hypervisor injection exception (#HV). When Restricted Injection is
active, only #HV exceptions can be injected into the guest, and the hypervisor
follows the GHCB #HV doorbell communication to inject the exception or
interrupt. Restricted Injection can be enabled by setting the bit in
vmsa_features.

The patchset is rebased on the kvm/next (commit 15e1c3d65975524c5c792fcd59f7d89f00402261).

Testing:

The patchset has been tested with the sev-snp guest, ovmf and qemu supporting
restricted injection.

Four test sets:
1.ls -lr /
2.apt update
3.fio
4.perf


Melody Wang (8):
  x86/sev: Define the #HV doorbell page structure
  KVM: SVM: Add support for the SEV-SNP #HV doorbell page NAE event
  KVM: SVM: Inject #HV when Restricted Injection is active
  KVM: SVM: Inject NMIs when Restricted Injection is active
  KVM: SVM: Inject MCEs when Restricted Injection is active
  KVM: SVM: Handle HLT intercept when Restricted Injection is enabled.
  KVM: SVM: Add support for the SEV-SNP #HV IPI NAE event
  KVM: SVM: Enable Restricted Injection for an SEV-SNP guest

 arch/x86/include/asm/cpufeatures.h |   1 +
 arch/x86/include/asm/kvm-x86-ops.h |   3 +
 arch/x86/include/asm/kvm_host.h    |   4 +-
 arch/x86/include/asm/sev-common.h  |   1 +
 arch/x86/include/asm/svm.h         |  35 +++
 arch/x86/include/uapi/asm/svm.h    |   6 +
 arch/x86/kvm/i8259.c               |  45 +++-
 arch/x86/kvm/irq.c                 |  51 +++-
 arch/x86/kvm/irq.h                 |   3 +
 arch/x86/kvm/lapic.c               |  46 +++-
 arch/x86/kvm/lapic.h               |   3 +
 arch/x86/kvm/svm/sev.c             | 403 ++++++++++++++++++++++++++++-
 arch/x86/kvm/svm/svm.c             |  96 ++++++-
 arch/x86/kvm/svm/svm.h             |  35 +++
 arch/x86/kvm/vmx/main.c            |  10 +
 arch/x86/kvm/vmx/vmx.c             |   5 +
 arch/x86/kvm/vmx/x86_ops.h         |   1 +
 arch/x86/kvm/x86.c                 |   9 +
 18 files changed, 735 insertions(+), 22 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-09  3:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09  3:18 [RFC PATCH v5 0/8] Add SEV-SNP restricted injection hypervisor support Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 1/8] x86/sev: Define the #HV doorbell page structure Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 2/8] KVM: SVM: Add support for the SEV-SNP #HV doorbell page NAE event Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 3/8] KVM: SVM: Inject #HV when Restricted Injection is active Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 4/8] KVM: SVM: Inject NMIs " Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 5/8] KVM: SVM: Inject MCEs " Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 7/8] KVM: SVM: Add support for the SEV-SNP #HV IPI NAE event Melody Wang
2026-11-09  3:18 ` [RFC PATCH v5 8/8] KVM: SVM: Enable Restricted Injection for an SEV-SNP guest Melody Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®