Skip to content

Commit

Permalink
platform: move greq driver initialization to the SNP platform
Browse files Browse the repository at this point in the history
The notion of "guest request" is specific to the SNP platform.
Therefore, the global `SnpGuestRequestDriver` object should only be
initialized on the SNP platform.

Signed-off-by: Jon Lange <[email protected]>
  • Loading branch information
msft-jlange committed Sep 26, 2024
1 parent f23151f commit 5958f7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions kernel/src/igvm_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl IgvmParams<'_> {

pub fn load_cpu_info(&self) -> Result<Vec<ACPICPUInfo>, SvsmError> {
let mut cpus: Vec<ACPICPUInfo> = Vec::new();
log::info!("CPU count is {}", { self.igvm_param_page.cpu_count });
for i in 0..self.igvm_param_page.cpu_count {
let cpu = ACPICPUInfo {
apic_id: i,
Expand Down
5 changes: 4 additions & 1 deletion kernel/src/platform/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::cpu::cpuid::{cpuid_table, CpuidResult};
use crate::cpu::percpu::{current_ghcb, this_cpu, PerCpu};
use crate::error::ApicError::Registration;
use crate::error::SvsmError;
use crate::greq::driver::guest_request_driver_init;
use crate::io::IOPort;
use crate::platform::{PageEncryptionMasks, PageStateChangeOp, SvsmPlatform};
use crate::serial::SerialPort;
Expand Down Expand Up @@ -67,7 +68,9 @@ impl SvsmPlatform for SnpPlatform {
}

fn env_setup_svsm(&self) -> Result<(), SvsmError> {
this_cpu().configure_hv_doorbell()
this_cpu().configure_hv_doorbell()?;
guest_request_driver_init();
Ok(())
}

fn setup_percpu(&self, cpu: &PerCpu) -> Result<(), SvsmError> {
Expand Down
3 changes: 0 additions & 3 deletions kernel/src/svsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use svsm::debug::stacktrace::print_stack;
use svsm::error::SvsmError;
use svsm::fs::{initialize_fs, populate_ram_fs};
use svsm::fw_cfg::FwCfg;
use svsm::greq::driver::guest_request_driver_init;
use svsm::igvm_params::IgvmParams;
use svsm::kernel_region::new_kernel_region;
use svsm::mm::alloc::{memory_info, print_memory_info, root_mem_init};
Expand Down Expand Up @@ -442,8 +441,6 @@ pub extern "C" fn svsm_main() {
validate_fw(&config, &LAUNCH_INFO).expect("Failed to validate flash memory");
}

guest_request_driver_init();

if let Some(ref fw_meta) = fw_metadata {
prepare_fw_launch(fw_meta).expect("Failed to setup guest VMSA/CAA");
}
Expand Down

0 comments on commit 5958f7c

Please sign in to comment.