Skip to content

Commit

Permalink
test: exit using QEMU debug exit device
Browse files Browse the repository at this point in the history
This is cleaner than `request_terminator_msr` as that MSR is more
commonly used to signal errors rather than clean exits.

Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
  • Loading branch information
Freax13 committed Oct 15, 2023
1 parent 773b3b2 commit 0ef34e2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/testing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use log::info;
use test::ShouldPanic;

use crate::sev::msr_protocol::request_termination_msr;
use crate::{cpu::percpu::this_cpu_mut, sev::ghcb::GHCBIOSize};

pub fn svsm_test_runner(test_cases: &[&test::TestDescAndFn]) {
info!("running {} tests", test_cases.len());
Expand Down Expand Up @@ -29,5 +29,14 @@ pub fn svsm_test_runner(test_cases: &[&test::TestDescAndFn]) {

info!("All tests passed!");

request_termination_msr();
exit();
}

fn exit() -> ! {
const QEMU_EXIT_PORT: u16 = 0xf4;
this_cpu_mut()
.ghcb()
.ioio_out(QEMU_EXIT_PORT, GHCBIOSize::Size32, 0)
.unwrap();
unreachable!();
}

0 comments on commit 0ef34e2

Please sign in to comment.