Skip to content

Commit b1b876c

Browse files
stefano-garzarellabonzini
authored andcommitted
optionrom/pvh: load initrd from fw_cfg
If we found initrd through fw_cfg, we can load it and use the first module of hvm_start_info to pass initrd address and size to the kernel. Signed-off-by: Stefano Garzarella <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Liam Merwick <[email protected]> Based-on: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 1fb0d70 commit b1b876c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pc-bios/optionrom/pvh_main.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct pvh_e820_table {
4646
struct pvh_e820_table pvh_e820 asm("pvh_e820") __attribute__ ((aligned));
4747

4848
static struct hvm_start_info start_info;
49+
static struct hvm_modlist_entry ramdisk_mod;
4950
static uint8_t cmdline_buffer[CMDLINE_BUFSIZE];
5051

5152

@@ -71,8 +72,8 @@ extern void pvh_load_kernel(void) asm("pvh_load_kernel");
7172
void pvh_load_kernel(void)
7273
{
7374
void *cmdline_addr = &cmdline_buffer;
74-
void *kernel_entry;
75-
uint32_t cmdline_size, fw_cfg_version = bios_cfg_version();
75+
void *kernel_entry, *initrd_addr;
76+
uint32_t cmdline_size, initrd_size, fw_cfg_version = bios_cfg_version();
7677

7778
start_info.magic = XEN_HVM_START_MAGIC_VALUE;
7879
start_info.version = 1;
@@ -110,6 +111,22 @@ void pvh_load_kernel(void)
110111
fw_cfg_version);
111112
start_info.cmdline_paddr = (uintptr_t)cmdline_addr;
112113

114+
/* Check if we have the initrd to load */
115+
bios_cfg_read_entry(&initrd_size, FW_CFG_INITRD_SIZE, 4, fw_cfg_version);
116+
if (initrd_size) {
117+
bios_cfg_read_entry(&initrd_addr, FW_CFG_INITRD_ADDR, 4,
118+
fw_cfg_version);
119+
bios_cfg_read_entry(initrd_addr, FW_CFG_INITRD_DATA, initrd_size,
120+
fw_cfg_version);
121+
122+
ramdisk_mod.paddr = (uintptr_t)initrd_addr;
123+
ramdisk_mod.size = initrd_size;
124+
125+
/* The first module is always ramdisk. */
126+
start_info.modlist_paddr = (uintptr_t)&ramdisk_mod;
127+
start_info.nr_modules = 1;
128+
}
129+
113130
bios_cfg_read_entry(&kernel_entry, FW_CFG_KERNEL_ENTRY, 4, fw_cfg_version);
114131

115132
asm volatile("jmp *%1" : : "b"(&start_info), "c"(kernel_entry));

pc-bios/pvh.bin

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)