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-ppc-devel

[XenPPC] [PATCH] Booting xen_maple_defconfig kernel on bare hardware

These patches allow a single Linux kernel binary, including one with
builtin console=X command line arguments, to run on bare hardware and as
a dom0 under Xen.  

The basic approach is to have the Xen virtual console driver react
gracefully in the case that a real serial driver has already registered
ttyS0-ttyS3.  It's current behavior is to fail if the 8250 driver was
initialized ahead of it, and console is lost.  In the process I found a
bug in Linux, and have included the patch for it since otherwise the Xen
driver initialization will succeed but with negative side effects in the
kobject subsystem.

Note that the preferred console system is subverted by Xen's driver, in
that it uses a value of -1 for index, which means that any ttySX in the
command line arguments will get Xen's tty driver.  See register_console().

Built and booted up to nfsroot on JS20 and JS21 with and without Xen.  
I am posting here for review: if the approach is not voted down, I will
send the individual patches to their respective Xen and Linux mailing lists.

Signed-off-by: Amos Waterland <apw@xxxxxxxxxx>

---

 arch/powerpc/configs/xen_maple_defconfig |   12 ++++++++++--
 drivers/xen/console/console.c            |   11 +++++++++++
 fs/char_dev.c                            |    7 +++++--
 3 files changed, 26 insertions(+), 4 deletions(-)

diff -r 17aa29a18b08 arch/powerpc/configs/xen_maple_defconfig
--- a/arch/powerpc/configs/xen_maple_defconfig  Thu Jul 27 18:57:20 2006 -0400
+++ b/arch/powerpc/configs/xen_maple_defconfig  Mon Jul 31 21:04:17 2006 -0400
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.17
-# Wed Jul 26 14:58:48 2006
+# Fri Jul 28 14:16:34 2006
 #
 CONFIG_PPC64=y
 CONFIG_64BIT=y
@@ -704,10 +704,18 @@ CONFIG_HW_CONSOLE=y
 #
 # Serial drivers
 #
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
 
 #
 # Non-8250 serial port support
 #
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_ICOM is not set
 # CONFIG_SERIAL_JSM is not set
 CONFIG_UNIX98_PTYS=y
@@ -1307,7 +1315,7 @@ CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
 CONFIG_XEN_SCRUB_PAGES=y
-CONFIG_XEN_DISABLE_SERIAL=y
+# CONFIG_XEN_DISABLE_SERIAL is not set
 CONFIG_XEN_SYSFS=y
 # CONFIG_XEN_COMPAT_030002_AND_LATER is not set
 CONFIG_XEN_COMPAT_LATEST_ONLY=y
diff -r 17aa29a18b08 drivers/xen/console/console.c
--- a/drivers/xen/console/console.c     Thu Jul 27 18:57:20 2006 -0400
+++ b/drivers/xen/console/console.c     Mon Jul 31 21:04:17 2006 -0400
@@ -70,6 +70,7 @@
  */
 static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
 static int xc_num = -1;
+enum { XC_NUM_MAX = 8 };
 
 #ifdef CONFIG_MAGIC_SYSRQ
 static unsigned long sysrq_requested;
@@ -576,6 +577,7 @@ static int __init xencons_init(void)
 
        xencons_ring_init();
 
+retry:
        xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ?
                                          1 : MAX_NR_CONSOLES);
        if (xencons_driver == NULL)
@@ -612,6 +614,15 @@ static int __init xencons_init(void)
                       DRV(xencons_driver)->name_base);
                put_tty_driver(xencons_driver);
                xencons_driver = NULL;
+
+               /* Somebody, almost certainly the real serial port
+                  driver, registered ahead of us, so find the first
+                  unused minor.  */
+               if (xc_num <= XC_NUM_MAX) {
+                   xc_num++;
+                   goto retry;
+               }
+
                return rc;
        }
 
diff -r 17aa29a18b08 fs/char_dev.c
--- a/fs/char_dev.c     Thu Jul 27 18:57:20 2006 -0400
+++ b/fs/char_dev.c     Mon Jul 31 21:04:17 2006 -0400
@@ -111,10 +111,13 @@ __register_chrdev_region(unsigned int ma
 
        for (cp = &chrdevs[i]; *cp; cp = &(*cp)->next)
                if ((*cp)->major > major ||
-                   ((*cp)->major == major && (*cp)->baseminor >= baseminor))
+                   ((*cp)->major == major &&
+                    (((*cp)->baseminor >= baseminor) ||
+                     ((*cp)->baseminor + (*cp)->minorct > baseminor))))
                        break;
        if (*cp && (*cp)->major == major &&
-           (*cp)->baseminor < baseminor + minorct) {
+           (((*cp)->baseminor < baseminor + minorct) ||
+            ((*cp)->baseminor + (*cp)->minorct > baseminor))) {
                ret = -EBUSY;
                goto out;
        }

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