[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2] xen: Allow a default compiled-in command line using Kconfig
Added 3 new config entries in common/Kconfig: CMDLINE_BOOL, CMDLINE and CMDLINE_OVERRIDE These 3 entries enable an embedded command line to be compiled in the hypervisor. If CMDLINE_BOOL is set to y, both arm and x86 startup routines will combine the compiled-in command line and the boot loader command line together to form a complete command line before calling cmdline_parse(). And if CMDLINE_OVERRIDE is set to y, boot loader command line will be ignored. This allows downstreams to set their defaults without modifying the source code all over the place. Also probably useful for the embedded space. See Also: https://xenproject.atlassian.net/projects/XEN/issues/XEN-41?filter=allopenissues Signed-off-by: Zhongze Liu <blackskygg@xxxxxxxxx> --- Changed since v1: * Added the missing CMDLINE_OVERRIDE config entry. * Combined built-in and boot loader command lines into one command line before calling cmdline_parse() (instead of calling cmdline_parse() twice). * Handled dom0 command line options (options after " -- " belong to dom0) in the x86 setup routine. --- xen/arch/arm/setup.c | 15 ++++++++++-- xen/arch/x86/setup.c | 66 ++++++++++++++++++++++++++++++++++++++-------------- xen/common/Kconfig | 38 ++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 92a2de6b70..9a68bda0fe 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -706,6 +706,7 @@ void __init start_xen(unsigned long boot_phys_offset, int cpus, i; paddr_t xen_paddr; const char *cmdline; + static xen_commandline_t __initdata complete_cmdline; struct bootmodule *xen_bootmodule; struct domain *dom0; struct xen_arch_domainconfig config; @@ -729,9 +730,19 @@ void __init start_xen(unsigned long boot_phys_offset, + (fdt_paddr & ((1 << SECOND_SHIFT) - 1)); fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr); +#ifdef CONFIG_CMDLINE + safe_strcpy(complete_cmdline, CONFIG_CMDLINE); + printk("Compiled-in command line: %s\n", complete_cmdline); +#endif + +#ifndef CONFIG_CMDLINE_OVERRIDE cmdline = boot_fdt_cmdline(device_tree_flattened); - printk("Command line: %s\n", cmdline); - cmdline_parse(cmdline); + safe_strcat(complete_cmdline, " "); + safe_strcat(complete_cmdline, cmdline); + printk("Command line: %s\n", complete_cmdline); +#endif + + cmdline_parse(complete_cmdline); /* Register Xen's load address as a boot module. */ xen_bootmodule = add_boot_module(BOOTMOD_XEN, diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dab67d5491..b8899aa443 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -636,10 +636,34 @@ static char * __init cmdline_cook(char *p, const char *loader_name) return p; } +/* + * Extracts dom0 options from the commandline. + * + * Options after ' -- ' separator belong to dom0. + * 1. Orphan dom0's options from Xen's command line. + * 2. Skip all but final leading space from dom0's options. + */ + +static inline char* __init extract_dom0_options(char *cmdline) +{ + char *kextra; + + if ( (kextra = strstr(cmdline, " -- ")) != NULL ) + { + *kextra = '\0'; + kextra += 3; + while ( kextra[1] == ' ' ) kextra++; + } + + return kextra; +} + void __init noreturn __start_xen(unsigned long mbi_p) { char *memmap_type = NULL; char *cmdline, *kextra, *loader; + static xen_commandline_t __initdata complete_cmdline; + static char __initdata complete_kextra[MAX_GUEST_CMDLINE]; unsigned int initrdidx, domcr_flags = DOMCRF_s3_integrity; multiboot_info_t *mbi = __va(mbi_p); module_t *mod = (module_t *)__va(mbi->mods_addr); @@ -672,25 +696,31 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Full exception support from here on in. */ +#ifdef CONFIG_CMDLINE + /* Process the built-in command line options. */ + + safe_strcpy(complete_cmdline, CONFIG_CMDLINE); + if ( (kextra = extract_dom0_options(complete_cmdline)) != NULL ) + safe_strcpy(complete_kextra, kextra); + printk("Compiled-in command line: %s\n", complete_cmdline); +#endif + loader = (mbi->flags & MBI_LOADERNAME) ? (char *)__va(mbi->boot_loader_name) : "unknown"; - /* Parse the command-line options. */ +#ifndef CONFIG_CMDLINE_OVERRIDE + /* Parse the command-line options passed by the bootloader. */ + cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ? __va(mbi->cmdline) : NULL, loader); - if ( (kextra = strstr(cmdline, " -- ")) != NULL ) - { - /* - * Options after ' -- ' separator belong to dom0. - * 1. Orphan dom0's options from Xen's command line. - * 2. Skip all but final leading space from dom0's options. - */ - *kextra = '\0'; - kextra += 3; - while ( kextra[1] == ' ' ) kextra++; - } - cmdline_parse(cmdline); + safe_strcat(complete_cmdline, " "); + safe_strcat(complete_cmdline, cmdline); + if ( (kextra = extract_dom0_options(cmdline)) != NULL ) + safe_strcat(complete_kextra, kextra); +#endif + + cmdline_parse(complete_cmdline); /* Must be after command line argument parsing and before * allocing any xenheap structures wanted in lower memory. */ @@ -713,7 +743,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("Bootloader: %s\n", loader); - printk("Command line: %s\n", cmdline); + printk("Command line: %s\n", complete_cmdline); printk("Video information:\n"); @@ -1566,16 +1596,16 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Grab the DOM0 command line. */ cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL); - if ( (cmdline != NULL) || (kextra != NULL) ) + if ( (cmdline != NULL) || (strlen(complete_kextra) != 0) ) { static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; cmdline = cmdline_cook(cmdline, loader); safe_strcpy(dom0_cmdline, cmdline); - if ( kextra != NULL ) - /* kextra always includes exactly one leading space. */ - safe_strcat(dom0_cmdline, kextra); + if ( complete_kextra != NULL ) + /* complete_kextra always includes exactly one leading space. */ + safe_strcat(dom0_cmdline, complete_kextra); /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") ) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index f2ecbc43d6..c5f4aaf7e9 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -237,4 +237,42 @@ config FAST_SYMBOL_LOOKUP The only user of this is Live patching. If unsure, say Y. + +config CMDLINE_BOOL + bool "Built-in hypervisor command line" + default n + ---help--- + Allow for specifying boot arguments to the hypervisor at + build time. On some systems (e.g. embedded ones), it is + necessary or convenient to provide some or all of the + hypervisor boot arguments with the hypervisor itself (that is, + to not rely on the boot loader to provide them.) + + To compile command line arguments into the hypervisor, + set this option to 'Y', then fill in the + boot arguments in CONFIG_CMDLINE. + +config CMDLINE + string "Built-in hypervisor command string" + depends on CMDLINE_BOOL + default "" + ---help--- + Enter arguments here that should be compiled into the hypervisor + image and used at boot time. If the boot loader provides a + command line at boot time, it is appended to this string to + form the full hypervisor command line, when the system boots. + + However, you can use the CONFIG_CMDLINE_OVERRIDE option to + change this behavior. + +config CMDLINE_OVERRIDE + bool "Built-in command line overrides boot loader arguments" + default n + depends on CMDLINE_BOOL + ---help--- + Set this option to 'Y' to have the hypervisor ignore the boot loader + command line, and use ONLY the built-in command line. + + This is used to work around broken boot loaders. This should + be set to 'N' under normal conditions. endmenu -- 2.12.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |