Skip to content

Commit

Permalink
svsm: Launch svsm_main as task
Browse files Browse the repository at this point in the history
Replace the existing jump to the svsm_main() entry point
with the creation of a Task which is then launched on the
current CPU.

Signed-off-by: Roy Hopkins <rhopkins@suse.de>
  • Loading branch information
roy-hopkins committed Jul 20, 2023
1 parent e6e2e25 commit dec966c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/svsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate alloc;
use alloc::vec::Vec;
use svsm::fw_meta::{parse_fw_meta_data, print_fw_meta, validate_fw_memory, SevFWMetaData};

use core::arch::{asm, global_asm};
use core::arch::global_asm;
use core::panic::PanicInfo;
use core::slice;
use svsm::acpi::tables::load_acpi_cpu_info;
Expand Down Expand Up @@ -46,6 +46,7 @@ use svsm::sev::sev_status_init;
use svsm::sev::utils::{rmp_adjust, RMPFlags};
use svsm::svsm_console::SVSMIOPort;
use svsm::svsm_paging::{init_page_table, invalidate_stage2};
use svsm::task::{create_task, TASK_FLAG_SHARE_PT};
use svsm::types::{GUEST_VMPL, PAGE_SIZE};
use svsm::utils::{halt, immut_after_init::ImmutAfterInitCell, zero_mem_region};

Expand Down Expand Up @@ -396,13 +397,15 @@ pub extern "C" fn svsm_start(li: &KernelLaunchInfo, vb_addr: VirtAddr) {

log::info!("BSP Runtime stack starts @ {:#018x}", bp);

// Enable runtime stack and jump to main function
unsafe {
asm!("movq %rax, %rsp
jmp svsm_main",
in("rax") bp.bits(),
options(att_syntax));
}
// Create the root task that runs the entry point then handles the request loop
create_task(
svsm_main,
TASK_FLAG_SHARE_PT,
Some(this_cpu().get_apic_id()),
)
.expect("Failed to create initial task");

panic!("SVSM entry point terminated unexpectedly");
}

#[no_mangle]
Expand Down

0 comments on commit dec966c

Please sign in to comment.