Skip to content

Commit

Permalink
td-shim: use payload_parameter slice for boot_kernel()
Browse files Browse the repository at this point in the history
The address of payload paramter may be different in different
configurations so use slice instead.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 authored and jyao1 committed Feb 23, 2023
1 parent 1fae756 commit 5fa81ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions td-shim/src/bin/td-shim/linux/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum Error {
UnknownImageType,
}

pub fn setup_header(kernel_image: &[u8]) -> Result<SetupHeader, Error> {
pub fn setup_header(kernel_image: &[u8], kernel_parameter: &[u8]) -> Result<SetupHeader, Error> {
let mut setup_header = SetupHeader::from_file(kernel_image);

if setup_header.header != HDR_SIGNATURE {
Expand All @@ -51,13 +51,14 @@ pub fn setup_header(kernel_image: &[u8]) -> Result<SetupHeader, Error> {

setup_header.type_of_loader = HDR_TYPE_LOADER;
setup_header.code32_start = kernel_image.as_ptr() as u32 + setup_bytes;
setup_header.cmd_line_ptr = KERNEL_PARAMETER_BASE as u32;
setup_header.cmd_line_ptr = kernel_parameter.as_ptr() as u32;

Ok(setup_header)
}

pub fn boot_kernel(
kernel: &[u8],
kernel_parameter: &[u8],
rsdp_addr: u64,
e820: &[E820Entry],
mailbox: &mut [u8],
Expand All @@ -76,16 +77,16 @@ pub fn boot_kernel(
let image_type = TdPayloadInfoHobType::from(info.image_type);
let entry64 = match image_type {
TdPayloadInfoHobType::BzImage => {
params.hdr = setup_header(kernel)?;
params.hdr = setup_header(kernel, kernel_parameter)?;
params.hdr.code32_start as u64 + 0x200
}
TdPayloadInfoHobType::RawVmLinux => {
params.hdr.type_of_loader = HDR_TYPE_LOADER;
params.hdr.boot_flag = HDR_BOOT_FLAG;
params.hdr.header = HDR_SIGNATURE;
params.hdr.kernel_alignment = 0x0100_0000;
params.hdr.cmd_line_ptr = KERNEL_PARAMETER_BASE as u32;
params.hdr.cmdline_size = KERNEL_PARAMETER_SIZE as u32;
params.hdr.cmd_line_ptr = kernel_parameter.as_ptr() as u32;
params.hdr.cmdline_size = kernel_parameter.len() as u32;
info.entry_point
}
_ => return Err(Error::UnknownImageType),
Expand Down
1 change: 1 addition & 0 deletions td-shim/src/bin/td-shim/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ fn boot_linux_kernel(

linux::boot::boot_kernel(
payload,
payload_parameter,
rsdp,
e820_table.as_slice(),
mailbox,
Expand Down

0 comments on commit 5fa81ef

Please sign in to comment.