Skip to content

Commit

Permalink
kernel: Print COCONUT_VERSION on panic
Browse files Browse the repository at this point in the history
Add the version of COCONUT-SVSM to the panic message for easier
debugging.

Signed-off-by: Joerg Roedel <[email protected]>
  • Loading branch information
joergroedel committed Jan 21, 2025
1 parent 426f409 commit 819bdfb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ jobs:
- name: Touch libtcgtpm bindings
run: echo "" > libtcgtpm/src/bindings.rs

# release/src/git_version.rs is auto-generated via a build.rs file. Touch
# it here to avoid CI failures.
- name: Touch release/src/git_version.rs
run: echo "" > release/src/git_version.rs

- name: Format doctests
uses: actions-rs/cargo@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion kernel/src/stage2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use svsm::platform::{
use svsm::types::{PageSize, PAGE_SIZE, PAGE_SIZE_2M};
use svsm::utils::{is_aligned, MemoryRegion};

use release::COCONUT_VERSION;

extern "C" {
static mut pgtable: PageTable;
}
Expand Down Expand Up @@ -476,7 +478,8 @@ pub extern "C" fn stage2_main(launch_info: &Stage2LaunchInfo) {

#[panic_handler]
fn panic(info: &PanicInfo<'_>) -> ! {
log::error!("Panic: {}", info);
log::error!("Panic! COCONUT-SVSM Version: {}", COCONUT_VERSION);
log::error!("Info: {}", info);
loop {
platform::halt();
}
Expand Down
9 changes: 8 additions & 1 deletion kernel/src/svsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ use svsm::vtpm::vtpm_init;

use svsm::mm::validate::{init_valid_bitmap_ptr, migrate_valid_bitmap};

use release::COCONUT_VERSION;

use alloc::string::String;

extern "C" {
Expand Down Expand Up @@ -354,7 +356,12 @@ fn panic(info: &PanicInfo<'_>) -> ! {
secrets_page_mut().clear_vmpck(2);
secrets_page_mut().clear_vmpck(3);

log::error!("Panic: CPU[{}] {}", this_cpu().get_apic_id(), info);
log::error!(
"Panic on CPU[{}]! COCONUT-SVSM Version: {}",
this_cpu().get_apic_id(),
COCONUT_VERSION
);
log::error!("Info: {}", info);

print_stack(3);

Expand Down

0 comments on commit 819bdfb

Please sign in to comment.