mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-03 05:10:55 +00:00
work on loading cmdline
This commit is contained in:
parent
444fb4e4b3
commit
8d1b970f65
@ -224,12 +224,12 @@ impl<I: BootImageLoader, P: BootSetupPlatform> BootSetup<I, P> {
|
||||
Ok(domain)
|
||||
}
|
||||
|
||||
pub async fn boot(&mut self, domain: &mut BootDomain, cmdline: &str) -> Result<()> {
|
||||
pub async fn boot(&mut self, domain: &mut BootDomain) -> Result<()> {
|
||||
let domain_info = self.call.get_domain_info(self.domid).await?;
|
||||
let shared_info_frame = domain_info.shared_info_frame;
|
||||
self.platform.setup_page_tables(domain).await?;
|
||||
self.platform
|
||||
.setup_start_info(domain, cmdline, shared_info_frame)
|
||||
.setup_start_info(domain, shared_info_frame)
|
||||
.await?;
|
||||
self.platform.setup_hypercall_page(domain).await?;
|
||||
self.platform.bootlate(domain).await?;
|
||||
@ -289,7 +289,6 @@ pub trait BootSetupPlatform: Clone {
|
||||
async fn setup_start_info(
|
||||
&mut self,
|
||||
domain: &mut BootDomain,
|
||||
cmdline: &str,
|
||||
shared_info_frame: u64,
|
||||
) -> Result<()>;
|
||||
|
||||
|
@ -291,7 +291,7 @@ impl XenClient {
|
||||
&config.cmdline,
|
||||
)
|
||||
.await?;
|
||||
boot.boot(&mut domain, &config.cmdline).await?;
|
||||
boot.boot(&mut domain).await?;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -754,7 +754,6 @@ impl BootSetupPlatform for X86PvPlatform {
|
||||
async fn setup_start_info(
|
||||
&mut self,
|
||||
domain: &mut BootDomain,
|
||||
cmdline: &str,
|
||||
shared_info_frame: u64,
|
||||
) -> Result<()> {
|
||||
let start_info_segment = self
|
||||
@ -800,7 +799,7 @@ impl BootSetupPlatform for X86PvPlatform {
|
||||
(*info).console.evtchn = console.0;
|
||||
(*info).mod_start = domain.initrd_segment.vstart;
|
||||
(*info).mod_len = domain.initrd_segment.size;
|
||||
for (i, c) in cmdline.chars().enumerate() {
|
||||
for (i, c) in domain.cmdline.chars().enumerate() {
|
||||
(*info).cmdline[i] = c as c_char;
|
||||
}
|
||||
(*info).cmdline[MAX_GUEST_CMDLINE - 1] = 0;
|
||||
|
@ -42,6 +42,10 @@ pub struct HvmStartInfo {
|
||||
pub reserved: u32,
|
||||
}
|
||||
|
||||
const HVM_START_MAX_CMDLINE_SIZE: usize = 1024;
|
||||
const HVM_START_MAX_MEMMAP_ENTRIES: usize = 8;
|
||||
const HVM_START_MAX_MODLIST_COUNT: usize = 8;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Copy, Clone, Debug)]
|
||||
pub struct HvmModlistEntry {
|
||||
@ -552,7 +556,6 @@ impl BootSetupPlatform for X86PvhPlatform {
|
||||
}
|
||||
|
||||
async fn alloc_magic_pages(&mut self, domain: &mut BootDomain) -> Result<()> {
|
||||
let memmap = self.construct_memmap()?;
|
||||
let mut special_array = vec![0u64; X86_HVM_NR_SPECIAL_PAGES as usize];
|
||||
for i in 0..X86_HVM_NR_SPECIAL_PAGES {
|
||||
special_array[i as usize] = special_pfn(i as u32);
|
||||
@ -629,8 +632,10 @@ impl BootSetupPlatform for X86PvhPlatform {
|
||||
.await?;
|
||||
|
||||
let mut start_info_size = size_of::<HvmStartInfo>();
|
||||
start_info_size += domain.cmdline.len() + 1;
|
||||
start_info_size += size_of::<HvmMemmapTableEntry>() * memmap.len();
|
||||
start_info_size += HVM_START_MAX_CMDLINE_SIZE;
|
||||
start_info_size += size_of::<HvmMemmapTableEntry>() * HVM_START_MAX_MEMMAP_ENTRIES;
|
||||
start_info_size += size_of::<HvmModlistEntry>() * HVM_START_MAX_MODLIST_COUNT;
|
||||
start_info_size += 1;
|
||||
self.start_info_segment = Some(domain.alloc_segment(0, start_info_size as u64).await?);
|
||||
|
||||
let pt = domain
|
||||
@ -670,7 +675,7 @@ impl BootSetupPlatform for X86PvhPlatform {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn setup_start_info(&mut self, domain: &mut BootDomain, _: &str, _: u64) -> Result<()> {
|
||||
async fn setup_start_info(&mut self, domain: &mut BootDomain, _: u64) -> Result<()> {
|
||||
let memmap = self.construct_memmap()?;
|
||||
let start_info_segment = self
|
||||
.start_info_segment
|
||||
@ -695,16 +700,19 @@ impl BootSetupPlatform for X86PvhPlatform {
|
||||
(start_info_segment.pfn << self.page_shift()) + size_of::<HvmStartInfo>() as u64;
|
||||
(*info).memmap_paddr = (start_info_segment.pfn << self.page_shift())
|
||||
+ size_of::<HvmStartInfo>() as u64
|
||||
+ domain.cmdline.len() as u64
|
||||
+ 1;
|
||||
+ HVM_START_MAX_CMDLINE_SIZE as u64;
|
||||
(*info).memmap_entries = memmap.len() as u32;
|
||||
(*info).rsdp_paddr = self.acpi_modules[0].guest_addr;
|
||||
(*info).nr_modules = 1;
|
||||
(*info).modlist_paddr = (start_info_segment.pfn << self.page_shift())
|
||||
+ size_of::<HvmStartInfo>() as u64
|
||||
+ (size_of::<HvmMemmapTableEntry>() * HVM_START_MAX_MEMMAP_ENTRIES) as u64;
|
||||
};
|
||||
let cmdline_ptr = (ptr + size_of::<HvmStartInfo>() as u64) as *mut u8;
|
||||
for (i, c) in domain.cmdline.chars().enumerate() {
|
||||
unsafe { *cmdline_ptr.add(i) = c as u8 };
|
||||
}
|
||||
let entries = (ptr + size_of::<HvmStartInfo>() as u64 + domain.cmdline.len() as u64 + 1)
|
||||
let entries = (ptr + size_of::<HvmStartInfo>() as u64 + HVM_START_MAX_CMDLINE_SIZE as u64)
|
||||
as *mut HvmMemmapTableEntry;
|
||||
let entries = unsafe { std::slice::from_raw_parts_mut(entries, memmap.len()) };
|
||||
for (i, e820) in memmap.iter().enumerate() {
|
||||
@ -714,6 +722,22 @@ impl BootSetupPlatform for X86PvhPlatform {
|
||||
entry.typ = e820.typ;
|
||||
entry.reserved = 0;
|
||||
}
|
||||
let modlist = (ptr
|
||||
+ (size_of::<HvmStartInfo>()
|
||||
+ HVM_START_MAX_CMDLINE_SIZE
|
||||
+ (size_of::<HvmMemmapTableEntry>() * HVM_START_MAX_MEMMAP_ENTRIES))
|
||||
as u64) as *mut HvmModlistEntry;
|
||||
let modlist_cmdline_paddr = (start_info_segment.pfn << self.page_shift())
|
||||
+ (size_of::<HvmStartInfo>()
|
||||
+ HVM_START_MAX_CMDLINE_SIZE
|
||||
+ (size_of::<HvmMemmapTableEntry>() * HVM_START_MAX_MEMMAP_ENTRIES)
|
||||
+ (size_of::<HvmModlistEntry>() * HVM_START_MAX_MODLIST_COUNT))
|
||||
as u64;
|
||||
unsafe {
|
||||
(*modlist).paddr = domain.initrd_segment.pfn << self.page_shift();
|
||||
(*modlist).size = domain.initrd_segment.size;
|
||||
(*modlist).cmdline_paddr = modlist_cmdline_paddr as u64;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user