Set and document clear precedence rules for boot argument processing.
Support the same builtin command line format in the 32-bit xen binary as
the 32-bit zImage binary does. Remove dead default_bootargs code.
This patch has been in use by an internal IBM project for some time. It
enables two important things: allowing developers and cluster
administrators the option of overriding the bootargs supplied by
firmware, and the ability to take a single gold master xen binary and
customize its bootargs across a cluster with a simple and well-tested
post-processing tool.
Signed-off-by: Amos Waterland <apw@xxxxxxxxxx>
---
b/xen/arch/powerpc/boot/arg32.c | 22 ++++++++++++++++++++++
xen/arch/powerpc/Makefile | 5 ++++-
xen/arch/powerpc/boot/boot32.S | 5 +++++
xen/arch/powerpc/boot_of.c | 17 +++++++++++++----
xen/arch/powerpc/ofd_fixup.c | 19 -------------------
xen/arch/powerpc/xen.lds.S | 4 ++++
6 files changed, 48 insertions(+), 24 deletions(-)
diff -r c9bf3af5624b xen/arch/powerpc/Makefile
--- a/xen/arch/powerpc/Makefile Thu Sep 28 12:34:01 2006 -0400
+++ b/xen/arch/powerpc/Makefile Thu Sep 28 14:41:54 2006 -0400
@@ -130,7 +130,10 @@ boot32.o: boot/boot32.S
$(CC) -m32 -Wa,-a32,-mppc64bridge \
-D__ASSEMBLY__ -D__BRIDGE64__ $(CFLAGS) -c $< -o $@
-$(TARGET): boot32.o $(TARGET).bin.o
+arg32.o: boot/arg32.c
+ $(CC) -m32 -DCMDLINE="\"$(IMAGENAME) $(CMDLINE)\"" -c $< -o $@
+
+$(TARGET): boot32.o arg32.o $(TARGET).bin.o
$(CC) -m32 -N -Wl,-melf32ppclinux -static -nostdlib \
-Wl,-Ttext,$(boot32_link_base) -Wl,-Tdata,$(xen_link_base) \
$(CFLAGS) $^ -o $@
diff -r c9bf3af5624b xen/arch/powerpc/boot/boot32.S
--- a/xen/arch/powerpc/boot/boot32.S Thu Sep 28 12:34:01 2006 -0400
+++ b/xen/arch/powerpc/boot/boot32.S Thu Sep 28 14:41:54 2006 -0400
@@ -36,6 +36,11 @@ _start:
## 51 12 00000000 00001000 ME Machine Check Enable
_real_start:
+ # pass the builtin command line as argument to hype_init
+ li 7, 0
+ oris 7, 7, builtin_cmdline@h
+ ori 7, 7, builtin_cmdline@l
+
# pass the original msr as argument to hype_init
mfmsr 8
diff -r c9bf3af5624b xen/arch/powerpc/boot_of.c
--- a/xen/arch/powerpc/boot_of.c Thu Sep 28 12:34:01 2006 -0400
+++ b/xen/arch/powerpc/boot_of.c Thu Sep 28 14:41:54 2006 -0400
@@ -460,13 +460,22 @@ static void boot_of_probemem(multiboot_i
}
}
-static void boot_of_bootargs(multiboot_info_t *mbi)
+static void
+boot_of_bootargs(multiboot_info_t *mbi, char *wrapper_builtin_cmdline)
{
int rc;
- rc = of_getprop(bof_chosen, "bootargs", &bootargs, sizeof (bootargs));
- if (rc == OF_FAILURE || bootargs[0] == '\0') {
+ /* Boot argument precedence rules:
+ * 1. Arguments from 32-bit wrapper override all else
+ * 2. Builtin arguments in 64-bit image override firmware
+ * 3. Firmware is used if neither of the above exist
+ */
+ if (wrapper_builtin_cmdline[0] != 0) {
+ strlcpy(bootargs, wrapper_builtin_cmdline, sizeof(bootargs));
+ } else if (builtin_cmdline[0] != 0) {
strlcpy(bootargs, builtin_cmdline, sizeof(bootargs));
+ } else {
+ rc = of_getprop(bof_chosen, "bootargs", &bootargs, sizeof (bootargs));
}
mbi->flags |= MBI_CMDLINE;
@@ -1197,7 +1206,7 @@ multiboot_info_t __init *boot_of_init(
boot_of_fix_maple();
boot_of_probemem(&mbi);
- boot_of_bootargs(&mbi);
+ boot_of_bootargs(&mbi, (char *)r7);
oft = boot_of_module(r3, r4, &mbi);
boot_of_cpus();
boot_of_serial(oft);
diff -r c9bf3af5624b xen/arch/powerpc/ofd_fixup.c
--- a/xen/arch/powerpc/ofd_fixup.c Thu Sep 28 12:34:01 2006 -0400
+++ b/xen/arch/powerpc/ofd_fixup.c Thu Sep 28 14:41:54 2006 -0400
@@ -244,12 +244,6 @@ static ofdn_t ofd_xics_props(void *m)
}
#endif
-/*
- * Good things you can stick here:
- * init=/bin/bash ip=dhcp root=/dev/hda2 ide=nodma
- */
-static char default_bootargs[] = "";
-
static ofdn_t ofd_chosen_props(void *m, const char *cmdline)
{
ofdn_t n;
@@ -257,7 +251,6 @@ static ofdn_t ofd_chosen_props(void *m,
static const char path[] = "/chosen";
char bootargs[256];
int bsz;
- int sz;
int rm;
n = ofd_node_find(m, path);
@@ -270,18 +263,6 @@ static ofdn_t ofd_chosen_props(void *m,
strcpy(bootargs, cmdline);
bsz = strlen(bootargs) + 1;
rm = sizeof (bootargs) - bsz;
-
- if (default_bootargs != NULL) {
- sz = strlen(default_bootargs);
- if (sz > rm) {
- panic("default_bootargs is too big: 0x%x > 0x%x\n",
- sz, rm);
- } else if (sz > 0) {
- memcpy(&bootargs[bsz - 1], default_bootargs, sz + 1);
- bsz += sz;
- rm -= sz;
- }
- }
printk("DOM0 bootargs: %s\n", bootargs);
ofd_prop_add(m, n, "bootargs", bootargs, bsz);
diff -r c9bf3af5624b xen/arch/powerpc/xen.lds.S
--- a/xen/arch/powerpc/xen.lds.S Thu Sep 28 12:34:01 2006 -0400
+++ b/xen/arch/powerpc/xen.lds.S Thu Sep 28 16:15:40 2006 -0400
@@ -179,6 +179,10 @@ SECTIONS
}
_edata = .;
PROVIDE (edata = .);
+ /* When we are nested in a 32-bit wrapper, it's data section goes here.
+ Since its only data is a command line buffer, and we know its size,
+ we just advance the cursor by that size. */
+ . = . + 512;
__bss_start = .;
.tocbss ALIGN(8) : { *(.tocbss)}
.sbss :
diff -r c9bf3af5624b xen/arch/powerpc/boot/arg32.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/powerpc/boot/arg32.c Thu Sep 28 15:37:02 2006 -0400
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2006 Jimi Xenidis <jimix@xxxxxxxxxxxxxx>, IBM Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#define COMMAND_LINE_SIZE 512
+char builtin_cmdline[COMMAND_LINE_SIZE]
+ __attribute__((section("__builtin_cmdline"))) = CMDLINE;
_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel
|