Skip to content

Commit

Permalink
Merge pull request #393 from msft-jlange/apic_fixes
Browse files Browse the repository at this point in the history
sev/ghcb: reorder #HV and guest APIC handling during guest entry
  • Loading branch information
joergroedel authored Jun 28, 2024
2 parents 4426095 + e7d3fb9 commit 8b2e1bc
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 9 additions & 0 deletions kernel/src/requests.rs
Original file line number Diff line number Diff line change
@@ -134,6 +134,15 @@ pub fn request_loop() {
// the guest to execute. When halting, assume that the hypervisor
// will schedule the guest VMPL on its own.
if update_mappings().is_ok() {
// Process any pending #HV events before leaving the SVSM. This
// must be done before updating guest APIC state so that any
// additional guest APIC updates generated by the host will block
// the VMPL transition and permit reevaluation of guest APIC
// state.
if let Some(hv_doorbell) = this_cpu().hv_doorbell() {
hv_doorbell.process_pending_events();
}

// Make VMSA runnable again by setting EFER.SVME. This requires a
// separate scope so the CPU reference does not outlive the use of
// the VMSA reference.
8 changes: 1 addition & 7 deletions kernel/src/sev/ghcb.rs
Original file line number Diff line number Diff line change
@@ -693,13 +693,7 @@ pub fn switch_to_vmpl(vmpl: u32) {
// correctly block the VMPL switch so that events can be processed.
let hv_doorbell = this_cpu().hv_doorbell();
let ptr = match hv_doorbell {
Some(doorbell) => {
// Process any pending #HV events before leaving the SVSM. No event
// can cancel the request to enter the guest VMPL, so proceed with
// guest entry once events have been handled.
doorbell.process_pending_events();
ptr::from_ref(doorbell)
}
Some(doorbell) => ptr::from_ref(doorbell),
None => ptr::null(),
};
unsafe {

0 comments on commit 8b2e1bc

Please sign in to comment.