/** Null-terminated boot protocol identifier */
char bootprotocol[16];
- /** Address of null-terminated kernel command line */
+ /** Address of the kernel command line. The string is not necessarily
+ * null-terminated.
+ */
__u64 cmdline;
+ /** Size of the kernel command-line without the null terminator */
+ __u64 cmdline_len;
+
/**
* List of memory regions. Must be the last member as the
* memory regions directly follow this boot information structure
struct ukplat_memregion_list mrds;
} __packed __align(__SIZEOF_LONG__);
-UK_CTASSERT(sizeof(struct ukplat_bootinfo) == 56);
+UK_CTASSERT(sizeof(struct ukplat_bootinfo) == 64);
#ifdef CONFIG_UKPLAT_MEMRNAME
#if __SIZEOF_LONG__ == 8
struct ukplat_memregion_desc *mrdp;
multiboot_memory_map_t *m;
multiboot_module_t *mods;
- __sz offset;
+ __sz offset, cmdline_len;
__paddr_t start, end;
__u32 i;
/* Add the cmdline */
if (mi->flags & MULTIBOOT_INFO_CMDLINE) {
if (mi->cmdline) {
+ cmdline_len = strlen((const char *)(__uptr)mi->cmdline);
mrd.pbase = mi->cmdline;
mrd.vbase = mi->cmdline; /* 1:1 mapping */
- mrd.len = strlen((const char *)(__uptr)mi->cmdline);
+ mrd.len = cmdline_len;
mrd.type = UKPLAT_MEMRT_CMDLINE;
mrd.flags = UKPLAT_MEMRF_READ | UKPLAT_MEMRF_MAP;
mrd_insert(bi, &mrd);
bi->cmdline = mi->cmdline;
+ bi->cmdline_len = cmdline_len;
}
}
static inline int cmdline_init(struct ukplat_bootinfo *bi)
{
- char *cmdl = (bi->cmdline) ? (char *)bi->cmdline : CONFIG_UK_NAME;
+ char *cmdl;
- cmdline_len = strlen(cmdl) + 1;
+ if (bi->cmdline_len) {
+ cmdl = (char *)bi->cmdline;
+ cmdline_len = bi->cmdline_len;
+ } else {
+ cmdl = CONFIG_UK_NAME;
+ cmdline_len = sizeof(CONFIG_UK_NAME) - 1;
+ }
- cmdline = bootmemory_palloc(cmdline_len, UKPLAT_MEMRT_CMDLINE);
+ cmdline = bootmemory_palloc(cmdline_len + 1, UKPLAT_MEMRT_CMDLINE);
if (unlikely(!cmdline))
return -ENOMEM;
- strncpy(cmdline, cmdl, cmdline_len);
+ memcpy(cmdline, cmdl, cmdline_len);
+ cmdline[cmdline_len] = 0;
+
return 0;
}
UKPLAT_MEMR_NAME_LEN = 36
# Boot info structure (see include/uk/plat/common/bootinfo.h)
-UKPLAT_BOOTINFO_SIZE = 56
+UKPLAT_BOOTINFO_SIZE = 64
UKPLAT_BOOTINFO_MAGIC = 0xB007B0B0 # Boot Bobo
UKPLAT_BOOTINFO_VERSION = 0x01
secobj.write(b'\0' * 16) # bootloader
secobj.write(b'\0' * 16) # bootprotocol
secobj.write(b'\0' * 8) # cmdline
+ secobj.write(b'\0' * 8) # cmdline_len
secobj.write(cap.to_bytes(4, endianness)) # mrds.capacity
secobj.write(b'\0' * 4) # mrds.count