ia64/xen-unstable

changeset 4287:d00a8ce82dcf

bitkeeper revision 1.1236.42.1 (42422fb2SvqEyBwXAZf3p2BJS-gfBA)

If Xen is told to use a serial console via a com1= or com2= directive
on the Xen command line, it now hides that particular UART from dom0.

This means that it's now safe to enable the 8250 driver in the Linux
config. If Xen has been told to use com1, the dom0 linux kernel will
not see /dev/ttyS0, but will see ttyS1,S2 etc if they are present,
enabling them to be used for mice, modems, printers etc.

Unfortunately, the 8250 driver will register itself for a ttyS even if
that particular UART isn't present. This is really annoying, as it
prevents the 'xencons' driver registering itself as ttyS0 even though
the 8250 won't see ttyS0 as present if Xen is using com1. This
prevents us from enabling 8250 in the default kernel config, as it
will change current behaviour.

If you want to use 8250 and xencons, the trick is to tell xencons to
grab a high numbered ttyS port that the 8250 driver will have left
alone. For example, put "xencons=ttyS31" on the Linux command line.
You'll then be able to edit /etc/inittab to add an entry for a
getty on ttyS31 if you want to be able to log in on the serial console
that is being shared with Xen.

If anyone knows a way of cleanly kicking the 8250 driver off a
particular char minor then please let me know!
author iap10@freefall.cl.cam.ac.uk
date Thu Mar 24 03:10:42 2005 +0000 (2005-03-24)
parents 4e75e4b2a644
children 6dd611b31171
files .rootkeys linux-2.6.11-xen-sparse/drivers/xen/console/console.c xen/arch/x86/setup.c xen/common/dom0_ops.c xen/common/physdev.c xen/drivers/char/serial.c xen/include/xen/physdev.h xen/include/xen/serial.h
line diff
     1.1 --- a/.rootkeys	Wed Mar 23 18:19:15 2005 +0000
     1.2 +++ b/.rootkeys	Thu Mar 24 03:10:42 2005 +0000
     1.3 @@ -1317,6 +1317,7 @@ 3ddb79c2Fg44_PBPVxHSC0gTOMq4Ow xen/inclu
     1.4  3ddb79c0MOVXq8qZDQRGb6z64_xAwg xen/include/xen/pci_ids.h
     1.5  3e54c38dlSCVdyVM4PKcrSfzLLxWUQ xen/include/xen/perfc.h
     1.6  3e54c38de9SUSYSAwxDf_DwkpAnQFA xen/include/xen/perfc_defn.h
     1.7 +42422fb0FVX-TJkSvAXnbfwMf19XFA xen/include/xen/physdev.h
     1.8  3ddb79c04nQVR3EYM5L4zxDV_MCo1g xen/include/xen/prefetch.h
     1.9  3e4540ccU1sgCx8seIMGlahmMfv7yQ xen/include/xen/reboot.h
    1.10  40589969nPq3DMzv24RDb5LXE9brHw xen/include/xen/sched-if.h
     2.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/console/console.c	Wed Mar 23 18:19:15 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/console/console.c	Thu Mar 24 03:10:42 2005 +0000
     2.3 @@ -63,15 +63,33 @@
     2.4   * warnings from standard distro startup scripts.
     2.5   */
     2.6  static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT;
     2.7 +static int xc_num = -1;
     2.8  
     2.9  static int __init xencons_setup(char *str)
    2.10  {
    2.11 -    if ( !strcmp(str, "tty") )
    2.12 +    char *q;
    2.13 +    int n;
    2.14 +
    2.15 +    if ( !strncmp(str, "ttyS", 4) )
    2.16 +        xc_mode = XC_SERIAL;
    2.17 +    else if ( !strncmp(str, "tty", 3) )
    2.18          xc_mode = XC_TTY;
    2.19 -    else if ( !strcmp(str, "ttyS") )
    2.20 -        xc_mode = XC_SERIAL;
    2.21 -    else if ( !strcmp(str, "off") )
    2.22 +    else if ( !strncmp(str, "off", 3) )
    2.23          xc_mode = XC_OFF;
    2.24 +
    2.25 +    switch (xc_mode)
    2.26 +    {
    2.27 +    case XC_SERIAL:
    2.28 +	n  = simple_strtol( str+4, &q, 10 );
    2.29 +	if ( q>str+4 ) xc_num = n;
    2.30 +	break;
    2.31 +
    2.32 +    case XC_TTY:
    2.33 +	n  = simple_strtol( str+3, &q, 10 );
    2.34 +	if ( q>str+3 ) xc_num = n;
    2.35 +	break;
    2.36 +    }
    2.37 +printk("xc_num = %d\n",xc_num);
    2.38      return 1;
    2.39  }
    2.40  __setup("xencons=", xencons_setup);
    2.41 @@ -187,15 +205,24 @@ void xen_console_init(void)
    2.42          kcons_info.write = kcons_write;
    2.43      }
    2.44  
    2.45 -    if ( xc_mode == XC_OFF )
    2.46 -        return __RETCODE;
    2.47 +    switch ( xc_mode )
    2.48 +    {
    2.49 +    case XC_SERIAL:
    2.50 +        strcpy(kcons_info.name, "ttyS");
    2.51 +	if ( xc_num == -1 ) xc_num = 0;
    2.52 +	break;
    2.53  
    2.54 -    if ( xc_mode == XC_SERIAL )
    2.55 -        strcpy(kcons_info.name, "ttyS");
    2.56 -    else
    2.57 +    case XC_TTY:
    2.58          strcpy(kcons_info.name, "tty");
    2.59 +	if ( xc_num == -1 ) xc_num = 1;
    2.60 +	break;
    2.61 +	
    2.62 +    default:
    2.63 +        return __RETCODE;
    2.64 +    }
    2.65  
    2.66      register_console(&kcons_info);
    2.67 +
    2.68      return __RETCODE;
    2.69  }
    2.70  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    2.71 @@ -705,14 +732,14 @@ static int __init xencons_init(void)
    2.72      if ( xc_mode == XC_SERIAL )
    2.73      {
    2.74          DRV(xencons_driver)->name        = "ttyS";
    2.75 -        DRV(xencons_driver)->minor_start = 64;
    2.76 -	DRV(xencons_driver)->name_base   = 0;
    2.77 +        DRV(xencons_driver)->minor_start = 64 + xc_num;
    2.78 +        DRV(xencons_driver)->name_base   = 0 + xc_num;
    2.79      }
    2.80      else
    2.81      {
    2.82          DRV(xencons_driver)->name        = "tty";
    2.83 -        DRV(xencons_driver)->minor_start = 1;
    2.84 -	DRV(xencons_driver)->name_base   = 1;
    2.85 +        DRV(xencons_driver)->minor_start = xc_num;
    2.86 +        DRV(xencons_driver)->name_base   = xc_num;
    2.87      }
    2.88  
    2.89  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    2.90 @@ -759,8 +786,9 @@ static int __init xencons_init(void)
    2.91          (void)ctrl_if_register_receiver(CMSG_CONSOLE, xencons_rx, 0);
    2.92      }
    2.93  
    2.94 -    printk("Xen virtual console successfully installed as %s\n",
    2.95 -           DRV(xencons_driver)->name);
    2.96 +    printk("Xen virtual console successfully installed as %s%d\n",
    2.97 +           DRV(xencons_driver)->name,
    2.98 +           DRV(xencons_driver)->name_base );
    2.99      
   2.100      return 0;
   2.101  }
     3.1 --- a/xen/arch/x86/setup.c	Wed Mar 23 18:19:15 2005 +0000
     3.2 +++ b/xen/arch/x86/setup.c	Thu Mar 24 03:10:42 2005 +0000
     3.3 @@ -8,6 +8,7 @@
     3.4  #include <xen/softirq.h>
     3.5  #include <xen/acpi.h>
     3.6  #include <xen/console.h>
     3.7 +#include <xen/serial.h>
     3.8  #include <xen/trace.h>
     3.9  #include <xen/multiboot.h>
    3.10  #include <asm/bitops.h>
    3.11 @@ -617,6 +618,9 @@ void __init __start_xen(multiboot_info_t
    3.12      /* Give up the VGA console if DOM0 is configured to grab it. */
    3.13      console_endboot(cmdline && strstr(cmdline, "tty0"));
    3.14  
    3.15 +    /* Hide UART from DOM0 if we're using it */
    3.16 +    serial_endboot();
    3.17 +
    3.18      domain_unpause_by_systemcontroller(current->domain);
    3.19      domain_unpause_by_systemcontroller(dom0);
    3.20      startup_cpu_idle_loop();
     4.1 --- a/xen/common/dom0_ops.c	Wed Mar 23 18:19:15 2005 +0000
     4.2 +++ b/xen/common/dom0_ops.c	Thu Mar 24 03:10:42 2005 +0000
     4.3 @@ -16,6 +16,7 @@
     4.4  #include <asm/domain_page.h>
     4.5  #include <xen/trace.h>
     4.6  #include <xen/console.h>
     4.7 +#include <xen/physdev.h>
     4.8  #include <asm/shadow.h>
     4.9  #include <public/sched_ctl.h>
    4.10  
    4.11 @@ -402,7 +403,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    4.12  
    4.13      case DOM0_PCIDEV_ACCESS:
    4.14      {
    4.15 -        extern int physdev_pci_access_modify(domid_t, int, int, int, int);
    4.16          ret = physdev_pci_access_modify(op->u.pcidev_access.domain, 
    4.17                                          op->u.pcidev_access.bus,
    4.18                                          op->u.pcidev_access.dev,
     5.1 --- a/xen/common/physdev.c	Wed Mar 23 18:19:15 2005 +0000
     5.2 +++ b/xen/common/physdev.c	Thu Mar 24 03:10:42 2005 +0000
     5.3 @@ -105,6 +105,20 @@ static int setup_ioport_memory_access(st
     5.4      return 0;
     5.5  }
     5.6  
     5.7 +void physdev_modify_ioport_access_range( struct domain *d, int enable, 
     5.8 +                                 int port, int num )
     5.9 +{
    5.10 +    int i;
    5.11 +    ASSERT( d->arch.iobmp_mask );
    5.12 +    for ( i = port; i < port+num; i++ )
    5.13 +    {
    5.14 +        if(enable)
    5.15 +            clear_bit(i, d->arch.iobmp_mask);
    5.16 +        else
    5.17 +            set_bit(i, d->arch.iobmp_mask);
    5.18 +    }
    5.19 +}
    5.20 +
    5.21  /* Add a device to a per-domain device-access list. */
    5.22  static int add_dev_to_task(struct domain *d, struct pci_dev *dev, int acc)
    5.23  {
     6.1 --- a/xen/drivers/char/serial.c	Wed Mar 23 18:19:15 2005 +0000
     6.2 +++ b/xen/drivers/char/serial.c	Thu Mar 24 03:10:42 2005 +0000
     6.3 @@ -15,6 +15,7 @@
     6.4  #include <xen/reboot.h>
     6.5  #include <xen/sched.h>
     6.6  #include <xen/serial.h>
     6.7 +#include <xen/physdev.h>
     6.8  #include <asm/io.h>
     6.9  
    6.10  /* Config serial port with a string <baud>,DPS,<io-base>,<irq>. */
    6.11 @@ -479,6 +480,21 @@ void serial_force_unlock(int handle)
    6.12          uart->lock = SPIN_LOCK_UNLOCKED;
    6.13  }
    6.14  
    6.15 +void serial_endboot()
    6.16 +{
    6.17 +    int i;
    6.18 +
    6.19 +    for (i=0;i<sizeof(com)/sizeof(struct uart);i++)
    6.20 +    {
    6.21 +        if( UART_ENABLED(&com[i]) )
    6.22 +        {
    6.23 +            /* remove access */
    6.24 +            physdev_modify_ioport_access_range( dom0, 0, com[i].io_base, 8 );
    6.25 +        }
    6.26 +    }
    6.27 +    
    6.28 +}
    6.29 +
    6.30  /*
    6.31   * Local variables:
    6.32   * mode: C
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/xen/include/xen/physdev.h	Thu Mar 24 03:10:42 2005 +0000
     7.3 @@ -0,0 +1,19 @@
     7.4 +/******************************************************************************
     7.5 + * physdev.h
     7.6 + */
     7.7 +
     7.8 +#ifndef __XEN_PHYSDEV_H__
     7.9 +#define __XEN_PHYSDEV_H__
    7.10 +
    7.11 +#include <public/physdev.h>
    7.12 +
    7.13 +void physdev_modify_ioport_access_range( struct domain *d, int enable, 
    7.14 +                                 int port, int num );
    7.15 +void physdev_destroy_state(struct domain *d);
    7.16 +int physdev_pci_access_modify(domid_t dom, int bus, int dev, int func, 
    7.17 +                              int enable);
    7.18 +int domain_iomem_in_pfn(struct domain *p, unsigned long pfn);
    7.19 +long do_physdev_op(physdev_op_t *uop);
    7.20 +void physdev_init_dom0(struct domain *d);
    7.21 +
    7.22 +#endif /* __XEN_PHYSDEV_H__ */
     8.1 --- a/xen/include/xen/serial.h	Wed Mar 23 18:19:15 2005 +0000
     8.2 +++ b/xen/include/xen/serial.h	Thu Mar 24 03:10:42 2005 +0000
     8.3 @@ -50,6 +50,8 @@ unsigned char irq_serial_getc(int handle
     8.4  
     8.5  void serial_force_unlock(int handle);
     8.6  
     8.7 +void serial_endboot(void);
     8.8 +
     8.9  #endif /* __XEN_SERIAL_H__ */
    8.10  
    8.11  /*