Skip to content

Commit 198f200

Browse files
fyin1lijinxia
authored andcommitted
hv: pass kernel cmdline from SBL to vm0 kernel
The SBL could pass cmdline to vm0 kernel by using mbi->mi_cmdline which should be passed to vm0 kernel as well. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
1 parent b22cc43 commit 198f200

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

hypervisor/boot/sbl/multiboot.c

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343

4444
#define ACRN_DBG_BOOT 6
4545

46+
/* There are two sources for vm0 kernel cmdline:
47+
* - cmdline from sbl. mbi->cmdline
48+
* - cmdline from acrn stitching tool. mod[0].mm_string
49+
* We need to merge them together
50+
*/
51+
static char kernel_cmdline[MEM_2K];
52+
4653
/*now modules support: FIRMWARE & RAMDISK */
4754
static void parse_other_modules(struct vm *vm,
4855
struct multiboot_module *mods, int mods_count)
@@ -163,12 +170,38 @@ int init_vm0_boot_info(struct vm *vm)
163170
vm->sw.kernel_info.kernel_load_addr =
164171
get_kernel_load_addr(vm->sw.kernel_info.kernel_src_addr);
165172

166-
vm->sw.linux_info.bootargs_src_addr =
167-
(void *)(uint64_t)mods[0].mm_string;
168-
vm->sw.linux_info.bootargs_load_addr =
169-
(void *)BOOT_ARGS_LOAD_ADDR;
170-
vm->sw.linux_info.bootargs_size =
171-
strnlen_s((char *)(uint64_t) mods[0].mm_string, MEM_2K);
173+
174+
/*
175+
* If there is cmdline from mbi->mi_cmdline, merge it with
176+
* mods[0].mm_string
177+
*/
178+
if (mbi->mi_flags & MULTIBOOT_INFO_HAS_CMDLINE) {
179+
char *cmd_src, *cmd_dst;
180+
int off = 0;
181+
182+
cmd_dst = kernel_cmdline;
183+
cmd_src = HPA2HVA((uint64_t)mbi->mi_cmdline);
184+
strncpy_s(cmd_dst, MEM_2K, cmd_src, strnlen_s(cmd_src, MEM_2K));
185+
off = strnlen_s(cmd_dst, MEM_2K);
186+
cmd_dst[off] = ' '; /* insert space */
187+
off += 1;
188+
189+
cmd_dst += off;
190+
cmd_src = HPA2HVA((uint64_t)mods[0].mm_string);
191+
strncpy_s(cmd_dst, MEM_2K - off, cmd_src,
192+
strnlen_s(cmd_src, MEM_2K - off));
193+
194+
vm->sw.linux_info.bootargs_src_addr = kernel_cmdline;
195+
vm->sw.linux_info.bootargs_size =
196+
strnlen_s(kernel_cmdline, MEM_2K);
197+
} else {
198+
vm->sw.linux_info.bootargs_src_addr =
199+
(void *)(uint64_t)mods[0].mm_string;
200+
vm->sw.linux_info.bootargs_size =
201+
strnlen_s((char *)(uint64_t) mods[0].mm_string, MEM_2K);
202+
}
203+
204+
vm->sw.linux_info.bootargs_load_addr = (void *)BOOT_ARGS_LOAD_ADDR;
172205

173206
if (mbi->mi_mods_count > 1) {
174207
/*parse other modules, like firmware /ramdisk */

0 commit comments

Comments
 (0)