WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-4.0-testing] x86: Correctly cook command lines for

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] x86: Correctly cook command lines for GRUB2.
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Aug 2010 02:45:19 -0700
Delivery-date: Thu, 12 Aug 2010 02:45:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1281451760 -3600
# Node ID 1da5224a287564ac6f86faf8fea0c6a88faa4010
# Parent  6b05eb35f1a9da79cc36fe0cf780b72678ef0a11
x86: Correctly cook command lines for GRUB2.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset:   21883:4207549948a4
xen-unstable date:        Wed Jul 28 08:32:01 2010 +0100
---
 xen/include/xen/multiboot2.h |   97 -------------------------------------------
 xen/arch/x86/boot/reloc.c    |    9 +++
 xen/arch/x86/setup.c         |   30 +++++++++++--
 xen/include/xen/multiboot.h  |   34 +++++++++++----
 4 files changed, 58 insertions(+), 112 deletions(-)

diff -r 6b05eb35f1a9 -r 1da5224a2875 xen/arch/x86/boot/reloc.c
--- a/xen/arch/x86/boot/reloc.c Mon Aug 09 16:51:30 2010 +0100
+++ b/xen/arch/x86/boot/reloc.c Tue Aug 10 15:49:20 2010 +0100
@@ -106,12 +106,17 @@ multiboot_info_t *reloc(multiboot_info_t
         mbi->mmap_addr = (u32)reloc_mbi_struct(
             (memory_map_t *)mbi->mmap_addr, mbi->mmap_length);
 
+    if ( mbi->flags & MBI_LOADERNAME )
+        mbi->boot_loader_name = (u32)reloc_mbi_string(
+            (char *)mbi->boot_loader_name);
+
     /* Mask features we don't understand or don't relocate. */
     mbi->flags &= (MBI_MEMLIMITS |
-                   MBI_DRIVES |
+                   MBI_BOOTDEV |
                    MBI_CMDLINE |
                    MBI_MODULES |
-                   MBI_MEMMAP);
+                   MBI_MEMMAP |
+                   MBI_LOADERNAME);
 
     return mbi;
 }
diff -r 6b05eb35f1a9 -r 1da5224a2875 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Mon Aug 09 16:51:30 2010 +0100
+++ b/xen/arch/x86/setup.c      Tue Aug 10 15:49:20 2010 +0100
@@ -431,22 +431,38 @@ void init_done(void)
     startup_cpu_idle_loop();
 }
 
-static char * __init cmdline_cook(char *p)
+static bool_t __init loader_is_grub2(const char *loader_name)
+{
+    /* GRUB1="GNU GRUB 0.xx"; GRUB2="GRUB 1.xx" */
+    const char *p = strstr(loader_name, "GRUB ");
+    return (p != NULL) && (p[5] != '0');
+}
+
+static char * __init cmdline_cook(char *p, char *loader_name)
 {
     p = p ? : "";
+
+    /* Strip leading whitespace. */
     while ( *p == ' ' )
         p++;
+
+    /* GRUB2 does not include image name as first item on command line. */
+    if ( loader_is_grub2(loader_name) )
+        return p;
+
+    /* Strip image name plus whitespace. */
     while ( (*p != ' ') && (*p != '\0') )
         p++;
     while ( *p == ' ' )
         p++;
+
     return p;
 }
 
 void __init __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
-    char *cmdline, *kextra;
+    char *cmdline, *kextra, *loader;
     unsigned long _initrd_start = 0, _initrd_len = 0;
     unsigned int initrdidx = 1;
     multiboot_info_t *mbi = __va(mbi_p);
@@ -464,9 +480,13 @@ void __init __start_xen(unsigned long mb
 
     set_intr_gate(TRAP_page_fault, &early_page_fault);
 
+    loader = (mbi->flags & MBI_LOADERNAME)
+        ? (char *)__va(mbi->boot_loader_name) : "unknown";
+
     /* Parse the command-line options. */
     cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
-                           __va(mbi->cmdline) : NULL);
+                           __va(mbi->cmdline) : NULL,
+                           loader);
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
         /*
@@ -507,6 +527,8 @@ void __init __start_xen(unsigned long mb
     ns16550.irq     = 3;
     ns16550_init(1, &ns16550);
     console_init_preirq();
+
+    printk("Bootloader: %s\n", loader);
 
     printk("Command line: %s\n", cmdline);
 
@@ -1109,7 +1131,7 @@ void __init __start_xen(unsigned long mb
     {
         static char dom0_cmdline[MAX_GUEST_CMDLINE];
 
-        cmdline = cmdline_cook(cmdline);
+        cmdline = cmdline_cook(cmdline, loader);
         safe_strcpy(dom0_cmdline, cmdline);
 
         if ( kextra != NULL )
diff -r 6b05eb35f1a9 -r 1da5224a2875 xen/include/xen/multiboot.h
--- a/xen/include/xen/multiboot.h       Mon Aug 09 16:51:30 2010 +0100
+++ b/xen/include/xen/multiboot.h       Tue Aug 10 15:49:20 2010 +0100
@@ -31,14 +31,17 @@
 /* The magic number passed by a Multiboot-compliant boot loader. */
 #define MULTIBOOT_BOOTLOADER_MAGIC     0x2BADB002
 
-#define MBI_MEMLIMITS  (1<<0)
-#define MBI_DRIVES     (1<<1)
-#define MBI_CMDLINE    (1<<2)
-#define MBI_MODULES    (1<<3)
-#define MBI_AOUT_SYMS  (1<<4)
-#define MBI_ELF_SYMS   (1<<5)
-#define MBI_MEMMAP     (1<<6)
-#define MBI_LOADERNAME (1<<9)
+#define MBI_MEMLIMITS  (1u<< 0)
+#define MBI_BOOTDEV    (1u<< 1)
+#define MBI_CMDLINE    (1u<< 2)
+#define MBI_MODULES    (1u<< 3)
+#define MBI_AOUT_SYMS  (1u<< 4)
+#define MBI_ELF_SYMS   (1u<< 5)
+#define MBI_MEMMAP     (1u<< 6)
+#define MBI_DRIVES     (1u<< 7)
+#define MBI_BIOSCONFIG (1u<< 8)
+#define MBI_LOADERNAME (1u<< 9)
+#define MBI_APM        (1u<<10)
 
 #ifndef __ASSEMBLY__
 
@@ -66,7 +69,7 @@ typedef struct {
     u32 mem_lower;
     u32 mem_upper;
 
-    /* Valid if flags sets MBI_DRIVES */
+    /* Valid if flags sets MBI_BOOTDEV */
     u32 boot_device;
 
     /* Valid if flags sets MBI_CMDLINE */
@@ -85,6 +88,19 @@ typedef struct {
     /* Valid if flags sets MBI_MEMMAP */
     u32 mmap_length;
     u32 mmap_addr;
+
+    /* Valid if flags sets MBI_DRIVES */
+    u32 drives_length;
+    u32 drives_addr;
+
+    /* Valid if flags sets MBI_BIOSCONFIG */
+    u32 config_table;
+
+    /* Valid if flags sets MBI_LOADERNAME */
+    u32 boot_loader_name;
+
+    /* Valid if flags sets MBI_APM */
+    u32 apm_table;
 } multiboot_info_t;
 
 /* The module structure.  */
diff -r 6b05eb35f1a9 -r 1da5224a2875 xen/include/xen/multiboot2.h
--- a/xen/include/xen/multiboot2.h      Mon Aug 09 16:51:30 2010 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * 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, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * Copyright IBM Corp. 2006, 2007
- *
- * Authors: Hollis Blanchard <hollisb@xxxxxxxxxx>
- *          
- */
-
-#ifndef _MULTIBOOT2_H_
-#define _MULTIBOOT2_H_
-
-/* How many bytes from the start of the file we search for the header.  */
-#define MB2_HEADER_SEARCH           8192
-
-/* The magic field should contain this.  */
-#define MB2_HEADER_MAGIC            0xe85250d6
-
-/* Passed from the bootloader to the kernel.  */
-#define MB2_BOOTLOADER_MAGIC        0x36d76289
-
-#define for_each_tag(_tag, _tags) \
-    for ((_tag) = (_tags); \
-            ((_tag)->key != MB2_TAG_END && (_tag)->key != 0); \
-            (_tag) = (void *)(_tag) + (_tag)->len)
-
-typedef uint32_t mb2_word;
-
-struct mb2_header
-{
-  uint32_t magic;
-};
-
-struct mb2_tag_header
-{
-  uint32_t key;
-  uint32_t len;
-};
-
-#define MB2_TAG_START     1
-struct mb2_tag_start
-{
-  struct mb2_tag_header header;
-  mb2_word size; /* Total size of all mb2 tags. */
-};
-
-#define MB2_TAG_NAME      2
-struct mb2_tag_name
-{
-  struct mb2_tag_header header;
-  char name[1];
-};
-
-#define MB2_TAG_MODULE    3
-struct mb2_tag_module
-{
-  struct mb2_tag_header header;
-  mb2_word addr;
-  mb2_word size;
-  unsigned char type[36];
-  unsigned char cmdline[1];
-};
-
-#define MB2_TAG_MEMORY    4
-struct mb2_tag_memory
-{
-  struct mb2_tag_header header;
-  mb2_word addr;
-  mb2_word size;
-  mb2_word type;
-};
-
-#define MB2_TAG_UNUSED    5
-struct mb2_tag_unused
-{
-  struct mb2_tag_header header;
-};
-
-#define MB2_TAG_END       0xffff
-struct mb2_tag_end
-{
-  struct mb2_tag_header header;
-};
-
-#endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] x86: Correctly cook command lines for GRUB2., Xen patchbot-4.0-testing <=