ia64/xen-unstable

changeset 19511:19919f01f2c5

merge with xen-unstable.hg
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue Apr 07 11:32:24 2009 +0900 (2009-04-07)
parents 22fe8c499431 accf139b2eb9
children 8c806c66a597
files tools/misc/fakei386xen tools/misc/netfix tools/misc/xen-clone.README
line diff
     1.1 --- a/Config.mk	Tue Apr 07 11:29:44 2009 +0900
     1.2 +++ b/Config.mk	Tue Apr 07 11:32:24 2009 +0900
     1.3 @@ -19,8 +19,6 @@ HOSTCFLAGS += -fno-strict-aliasing
     1.4  
     1.5  DISTDIR     ?= $(XEN_ROOT)/dist
     1.6  DESTDIR     ?= /
     1.7 -DOCDIR      ?= /usr/share/doc/xen
     1.8 -MANDIR      ?= /usr/share/man
     1.9  
    1.10  # Allow phony attribute to be listed as dependency rather than fake target
    1.11  .PHONY: .phony
    1.12 @@ -28,6 +26,10 @@ MANDIR      ?= /usr/share/man
    1.13  include $(XEN_ROOT)/config/$(XEN_OS).mk
    1.14  include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk
    1.15  
    1.16 +SHAREDIR    ?= $(PREFIX)/share
    1.17 +DOCDIR      ?= $(SHAREDIR)/doc/xen
    1.18 +MANDIR      ?= $(SHAREDIR)/man
    1.19 +
    1.20  ifneq ($(EXTRA_PREFIX),)
    1.21  EXTRA_INCLUDES += $(EXTRA_PREFIX)/include
    1.22  EXTRA_LIB += $(EXTRA_PREFIX)/$(LIBLEAFDIR)
     3.1 --- a/config/StdGNU.mk	Tue Apr 07 11:29:44 2009 +0900
     3.2 +++ b/config/StdGNU.mk	Tue Apr 07 11:32:24 2009 +0900
     3.3 @@ -31,7 +31,8 @@ LIBDIR = $(PREFIX)/$(LIBLEAFDIR)
     3.4  LIBDIR_x86_32 = $(PREFIX)/$(LIBLEAFDIR_x86_32)
     3.5  LIBDIR_x86_64 = $(PREFIX)/$(LIBLEAFDIR_x86_64)
     3.6  LIBEXEC = $(LIBDIR_x86_32)/xen/bin
     3.7 -MANDIR = $(PREFIX)/share/man
     3.8 +SHAREDIR = $(PREFIX)/share
     3.9 +MANDIR = $(SHAREDIR)/man
    3.10  MAN1DIR = $(MANDIR)/man1
    3.11  MAN8DIR = $(MANDIR)/man8
    3.12  SBINDIR = $(PREFIX)/sbin
     4.1 --- a/extras/mini-os/include/blkfront.h	Tue Apr 07 11:29:44 2009 +0900
     4.2 +++ b/extras/mini-os/include/blkfront.h	Tue Apr 07 11:32:24 2009 +0900
     4.3 @@ -8,6 +8,8 @@ struct blkfront_aiocb
     4.4      uint8_t *aio_buf;
     4.5      size_t aio_nbytes;
     4.6      off_t aio_offset;
     4.7 +    size_t total_bytes;
     4.8 +    uint8_t is_write;
     4.9      void *data;
    4.10  
    4.11      grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/extras/mini-os/lib/stack_chk_fail.c	Tue Apr 07 11:32:24 2009 +0900
     5.3 @@ -0,0 +1,8 @@
     5.4 +#include <kernel.h>
     5.5 +#include <console.h>
     5.6 +
     5.7 +void __stack_chk_fail(void)
     5.8 +{
     5.9 +    printk("stack smashing detected\n");
    5.10 +    do_exit();
    5.11 +}
     6.1 --- a/stubdom/Makefile	Tue Apr 07 11:29:44 2009 +0900
     6.2 +++ b/stubdom/Makefile	Tue Apr 07 11:32:24 2009 +0900
     6.3 @@ -91,6 +91,7 @@ newlib-$(NEWLIB_VERSION).tar.gz:
     6.4  newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
     6.5  	tar xzf $<
     6.6  	patch -d $@ -p0 < newlib.patch
     6.7 +	patch -d $@ -p0 < newlib-chk.patch
     6.8  	touch $@
     6.9  
    6.10  NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/stubdom/newlib-chk.patch	Tue Apr 07 11:32:24 2009 +0900
     7.3 @@ -0,0 +1,155 @@
     7.4 +--- newlib/libc/stdio/fprintf_chk.c	1969-12-31 19:00:00.000000000 -0500
     7.5 ++++ newlib/libc/stdio/fprintf_chk.c	2009-02-26 19:02:53.000000000 -0500
     7.6 +@@ -0,0 +1,21 @@
     7.7 ++#include <stdarg.h>
     7.8 ++#include <stdio.h>
     7.9 ++
    7.10 ++/*
    7.11 ++ * Stub implementation of __fprintf_chk adapted from glibc 2.7.  This 
    7.12 ++ * doesn't actually implement any buffer overflow protection.  It just makes
    7.13 ++ * the linker happy :)
    7.14 ++*/
    7.15 ++int
    7.16 ++__fprintf_chk (FILE *fp, int flag, const char *format, ...)
    7.17 ++{
    7.18 ++  va_list ap;
    7.19 ++  int done;
    7.20 ++
    7.21 ++  va_start (ap, format);
    7.22 ++  done = vfprintf (fp, format, ap);
    7.23 ++  va_end (ap);
    7.24 ++
    7.25 ++  return done;
    7.26 ++}
    7.27 ++
    7.28 +--- newlib/libc/stdio/Makefile.am	2007-08-02 16:23:06.000000000 -0400
    7.29 ++++ newlib/libc/stdio/Makefile.am	2009-02-26 18:14:53.000000000 -0500
    7.30 +@@ -20,6 +20,7 @@
    7.31 + 	flags.c			\
    7.32 + 	fopen.c			\
    7.33 + 	fprintf.c			\
    7.34 ++	fprintf_chk.c		\
    7.35 + 	fputc.c			\
    7.36 + 	fputs.c			\
    7.37 + 	fread.c			\
    7.38 +@@ -65,6 +66,7 @@
    7.39 + 	sniprintf.c			\
    7.40 + 	snprintf.c			\
    7.41 + 	sprintf.c			\
    7.42 ++	sprintf_chk.c			\
    7.43 + 	sscanf.c			\
    7.44 + 	stdio.c			\
    7.45 + 	tmpfile.c			\
    7.46 +--- newlib/libc/stdio/Makefile.in	2007-12-19 17:36:38.000000000 -0500
    7.47 ++++ newlib/libc/stdio/Makefile.in	2009-02-26 18:43:52.000000000 -0500
    7.48 +@@ -63,7 +63,8 @@
    7.49 + 	lib_a-fgets.$(OBJEXT) lib_a-fileno.$(OBJEXT) \
    7.50 + 	lib_a-findfp.$(OBJEXT) lib_a-fiprintf.$(OBJEXT) \
    7.51 + 	lib_a-flags.$(OBJEXT) lib_a-fopen.$(OBJEXT) \
    7.52 +-	lib_a-fprintf.$(OBJEXT) lib_a-fputc.$(OBJEXT) \
    7.53 ++	lib_a-fprintf.$(OBJEXT) lib_a-fprintf_chk.$(OBJEXT) \
    7.54 ++	lib_a-fputc.$(OBJEXT) \
    7.55 + 	lib_a-fputs.$(OBJEXT) lib_a-fread.$(OBJEXT) \
    7.56 + 	lib_a-freopen.$(OBJEXT) lib_a-fscanf.$(OBJEXT) \
    7.57 + 	lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \
    7.58 +@@ -86,6 +87,7 @@
    7.59 + 	lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \
    7.60 + 	lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \
    7.61 + 	lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \
    7.62 ++	lib_a-sprintf_chk.$(OBJEXT) \
    7.63 + 	lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \
    7.64 + 	lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \
    7.65 + 	lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \
    7.66 +@@ -122,15 +124,15 @@
    7.67 + LTLIBRARIES = $(noinst_LTLIBRARIES)
    7.68 + am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \
    7.69 + 	fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
    7.70 +-	fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo fputs.lo \
    7.71 +-	fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
    7.72 ++	fiprintf.lo flags.lo fopen.lo fprintf.lo fprintf_chk.lo fputc.lo \
    7.73 ++	fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
    7.74 + 	ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
    7.75 + 	getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
    7.76 + 	iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo putc.lo \
    7.77 + 	putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \
    7.78 + 	rename.lo rewind.lo rget.lo scanf.lo sccl.lo setbuf.lo \
    7.79 + 	setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo siscanf.lo \
    7.80 +-	sniprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \
    7.81 ++	sniprintf.lo snprintf.lo sprintf.lo sprintf_chk.lo sscanf.lo stdio.lo \
    7.82 + 	tmpfile.lo tmpnam.lo ungetc.lo vdiprintf.lo vdprintf.lo \
    7.83 + 	viprintf.lo viscanf.lo vprintf.lo vscanf.lo vsiprintf.lo \
    7.84 + 	vsiscanf.lo vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \
    7.85 +@@ -344,6 +346,7 @@
    7.86 + 	flags.c			\
    7.87 + 	fopen.c			\
    7.88 + 	fprintf.c			\
    7.89 ++	fprintf_chk.c			\
    7.90 + 	fputc.c			\
    7.91 + 	fputs.c			\
    7.92 + 	fread.c			\
    7.93 +@@ -389,6 +392,7 @@
    7.94 + 	sniprintf.c			\
    7.95 + 	snprintf.c			\
    7.96 + 	sprintf.c			\
    7.97 ++	sprintf_chk.c			\
    7.98 + 	sscanf.c			\
    7.99 + 	stdio.c			\
   7.100 + 	tmpfile.c			\
   7.101 +@@ -508,6 +512,7 @@
   7.102 + 	siprintf.def		\
   7.103 + 	siscanf.def		\
   7.104 + 	sprintf.def		\
   7.105 ++	sprintf_chk.def		\
   7.106 + 	sscanf.def		\
   7.107 + 	tmpfile.def		\
   7.108 + 	tmpnam.def		\
   7.109 +@@ -678,6 +683,12 @@
   7.110 + lib_a-fprintf.obj: fprintf.c
   7.111 + 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf.obj `if test -f 'fprintf.c'; then $(CYGPATH_W) 'fprintf.c'; else $(CYGPATH_W) '$(srcdir)/fprintf.c'; fi`
   7.112 + 
   7.113 ++lib_a-fprintf_chk.o: fprintf_chk.c
   7.114 ++	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.o `test -f 'fprintf_chk.c' || echo '$(srcdir)/'`fprintf_chk.c
   7.115 ++
   7.116 ++lib_a-fprintf_chk.obj: fprintf_chk.c
   7.117 ++	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.obj `if test -f 'fprintf_chk.c'; then $(CYGPATH_W) 'fprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/fprintf_chk.c'; fi`
   7.118 ++
   7.119 + lib_a-fputc.o: fputc.c
   7.120 + 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc.o `test -f 'fputc.c' || echo '$(srcdir)/'`fputc.c
   7.121 + 
   7.122 +@@ -948,6 +959,12 @@
   7.123 + lib_a-sprintf.obj: sprintf.c
   7.124 + 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf.obj `if test -f 'sprintf.c'; then $(CYGPATH_W) 'sprintf.c'; else $(CYGPATH_W) '$(srcdir)/sprintf.c'; fi`
   7.125 + 
   7.126 ++lib_a-sprintf_chk.o: sprintf_chk.c
   7.127 ++	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.o `test -f 'sprintf_chk.c' || echo '$(srcdir)/'`sprintf_chk.c
   7.128 ++
   7.129 ++lib_a-sprintf_chk.obj: sprintf_chk.c
   7.130 ++	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.obj `if test -f 'sprintf_chk.c'; then $(CYGPATH_W) 'sprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/sprintf_chk.c'; fi`
   7.131 ++
   7.132 + lib_a-sscanf.o: sscanf.c
   7.133 + 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sscanf.o `test -f 'sscanf.c' || echo '$(srcdir)/'`sscanf.c
   7.134 + 
   7.135 +--- newlib/libc/stdio/sprintf_chk.c	1969-12-31 19:00:00.000000000 -0500
   7.136 ++++ newlib/libc/stdio/sprintf_chk.c	2009-02-26 19:02:26.000000000 -0500
   7.137 +@@ -0,0 +1,21 @@
   7.138 ++#include <stdarg.h>
   7.139 ++#include <stdio.h>
   7.140 ++
   7.141 ++/*
   7.142 ++ * Stub implementation of __sprintf_chk adapted from glibc 2.7.  This 
   7.143 ++ * doesn't actually implement any buffer overflow protection.  It just makes
   7.144 ++ * the linker happy :)
   7.145 ++*/
   7.146 ++int
   7.147 ++__sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
   7.148 ++{
   7.149 ++  va_list arg;
   7.150 ++  int done;
   7.151 ++
   7.152 ++  va_start (arg, format);
   7.153 ++  done = vsprintf (s, format, arg);
   7.154 ++  va_end (arg);
   7.155 ++
   7.156 ++  return done;
   7.157 ++}
   7.158 ++
     8.1 --- a/tools/Rules.mk	Tue Apr 07 11:29:44 2009 +0900
     8.2 +++ b/tools/Rules.mk	Tue Apr 07 11:32:24 2009 +0900
     8.3 @@ -33,10 +33,12 @@ CFLAGS += -D__XEN_TOOLS__
     8.4  CFLAGS += -MMD -MF .$(@F).d
     8.5  DEPS = .*.d
     8.6  
     8.7 +ifneq ($(XEN_OS),NetBSD)
     8.8  # Enable implicit LFS support *and* explicit LFS names.
     8.9  CFLAGS  += $(shell getconf LFS_CFLAGS)
    8.10  CFLAGS  += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
    8.11  LDFLAGS += $(shell getconf LFS_LDFLAGS)
    8.12 +endif
    8.13  
    8.14  # 32-bit x86 does not perform well with -ve segment accesses on Xen.
    8.15  CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs)
     9.1 --- a/tools/firmware/hvmloader/acpi/dsdt.asl	Tue Apr 07 11:29:44 2009 +0900
     9.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.asl	Tue Apr 07 11:32:24 2009 +0900
     9.3 @@ -123,7 +123,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
     9.4             Name (_BBN, 0x00)
     9.5  
     9.6             /*
     9.7 -            * Reserve the IO port ranges [0x10c0, 0x10c2] and [0xb044, 0xb047].
     9.8 +            * Reserve the IO port ranges [0x10c0, 0x10e1] and [0xb044, 0xb047].
     9.9              * Or else, for a hotplugged-in device, the port IO BAR assigned
    9.10              * by guest OS may conflict with the ranges here.
    9.11              */
    9.12 @@ -131,7 +131,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
    9.13             {
    9.14                 Name(_HID, EISAID("PNP0C02"))
    9.15                 Name(_CRS, ResourceTemplate() {
    9.16 -                   IO (Decode16, 0x10c0, 0x10c0, 0x00, 0x03)
    9.17 +                   IO (Decode16, 0x10c0, 0x10c0, 0x00, 0x22)
    9.18                     IO (Decode16, 0xb044, 0xb044, 0x00, 0x04)
    9.19                 })
    9.20             }
    9.21 @@ -2067,104 +2067,133 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, 
    9.22              Store (SLT, DPT1)
    9.23              Store (EVT, DPT2)
    9.24  
    9.25 -            Switch (SLT)
    9.26 +            If ( LEqual(SLT, 0x00) )
    9.27 +            {
    9.28 +                Notify (\_SB.PCI0.S00, EVT)
    9.29 +            }
    9.30 +            ElseIf ( LEqual(SLT, 0x01) )
    9.31 +            {
    9.32 +                Notify (\_SB.PCI0.S01, EVT)
    9.33 +            }
    9.34 +            ElseIf ( LEqual(SLT, 0x02) )
    9.35 +            {
    9.36 +                Notify (\_SB.PCI0.S02, EVT)
    9.37 +            }
    9.38 +            ElseIf ( LEqual(SLT, 0x03) )
    9.39 +            {
    9.40 +                Notify (\_SB.PCI0.S03, EVT)
    9.41 +            }
    9.42 +            ElseIf ( LEqual(SLT, 0x04) )
    9.43 +            {
    9.44 +                Notify (\_SB.PCI0.S04, EVT)
    9.45 +            }
    9.46 +            ElseIf ( LEqual(SLT, 0x05) )
    9.47 +            {
    9.48 +                Notify (\_SB.PCI0.S05, EVT)
    9.49 +            }
    9.50 +            ElseIf ( LEqual(SLT, 0x06) )
    9.51 +            {
    9.52 +                Notify (\_SB.PCI0.S06, EVT)
    9.53 +            }
    9.54 +            ElseIf ( LEqual(SLT, 0x07) )
    9.55 +            {
    9.56 +                Notify (\_SB.PCI0.S07, EVT)
    9.57 +            }
    9.58 +            ElseIf ( LEqual(SLT, 0x08) )
    9.59 +            {
    9.60 +                Notify (\_SB.PCI0.S08, EVT)
    9.61 +            }
    9.62 +            ElseIf ( LEqual(SLT, 0x09) )
    9.63 +            {
    9.64 +                Notify (\_SB.PCI0.S09, EVT)
    9.65 +            }
    9.66 +            ElseIf ( LEqual(SLT, 0x0a) )
    9.67 +            {
    9.68 +                Notify (\_SB.PCI0.S0A, EVT)
    9.69 +            }
    9.70 +            ElseIf ( LEqual(SLT, 0x0b) )
    9.71 +            {
    9.72 +                Notify (\_SB.PCI0.S0B, EVT)
    9.73 +            }
    9.74 +            ElseIf ( LEqual(SLT, 0x0c) )
    9.75 +            {
    9.76 +                Notify (\_SB.PCI0.S0C, EVT)
    9.77 +            }
    9.78 +            ElseIf ( LEqual(SLT, 0x0d) )
    9.79 +            {
    9.80 +                Notify (\_SB.PCI0.S0D, EVT)
    9.81 +            }
    9.82 +            ElseIf ( LEqual(SLT, 0x0e) )
    9.83 +            {
    9.84 +                Notify (\_SB.PCI0.S0E, EVT)
    9.85 +            }
    9.86 +            ElseIf ( LEqual(SLT, 0x0f) )
    9.87              {
    9.88 -                Case (0x00) {
    9.89 -                    Notify (\_SB.PCI0.S00, EVT)
    9.90 -                }
    9.91 -                Case (0x01) {
    9.92 -                    Notify (\_SB.PCI0.S01, EVT)
    9.93 -                }
    9.94 -                Case (0x02) {
    9.95 -                    Notify (\_SB.PCI0.S02, EVT)
    9.96 -                }
    9.97 -                Case (0x03) {
    9.98 -                    Notify (\_SB.PCI0.S03, EVT)
    9.99 -                }
   9.100 -                Case (0x04) {
   9.101 -                    Notify (\_SB.PCI0.S04, EVT)
   9.102 -                }
   9.103 -                Case (0x05) {
   9.104 -                    Notify (\_SB.PCI0.S05, EVT)
   9.105 -                }
   9.106 -                Case (0x06) {
   9.107 -                    Notify (\_SB.PCI0.S06, EVT)
   9.108 -                }
   9.109 -                Case (0x07) {
   9.110 -                    Notify (\_SB.PCI0.S07, EVT)
   9.111 -                }
   9.112 -                Case (0x08) {
   9.113 -                    Notify (\_SB.PCI0.S08, EVT)
   9.114 -                }
   9.115 -                Case (0x09) {
   9.116 -                    Notify (\_SB.PCI0.S09, EVT)
   9.117 -                }
   9.118 -                Case (0x0a) {
   9.119 -                    Notify (\_SB.PCI0.S0A, EVT)
   9.120 -                }
   9.121 -                Case (0x0b) {
   9.122 -                    Notify (\_SB.PCI0.S0B, EVT)
   9.123 -                }
   9.124 -                Case (0x0c) {
   9.125 -                    Notify (\_SB.PCI0.S0C, EVT)
   9.126 -                }
   9.127 -                Case (0x0d) {
   9.128 -                    Notify (\_SB.PCI0.S0D, EVT)
   9.129 -                }
   9.130 -                Case (0x0e) {
   9.131 -                    Notify (\_SB.PCI0.S0E, EVT)
   9.132 -                }
   9.133 -                Case (0x0f) {
   9.134 -                    Notify (\_SB.PCI0.S0F, EVT)
   9.135 -                }
   9.136 -                Case (0x10) {
   9.137 -                    Notify (\_SB.PCI0.S10, EVT)
   9.138 -                }
   9.139 -                Case (0x11) {
   9.140 -                    Notify (\_SB.PCI0.S11, EVT)
   9.141 -                }
   9.142 -                Case (0x12) {
   9.143 -                    Notify (\_SB.PCI0.S12, EVT)
   9.144 -                }
   9.145 -                Case (0x13) {
   9.146 -                    Notify (\_SB.PCI0.S13, EVT)
   9.147 -                }
   9.148 -                Case (0x14) {
   9.149 -                    Notify (\_SB.PCI0.S14, EVT)
   9.150 -                }
   9.151 -                Case (0x15) {
   9.152 -                    Notify (\_SB.PCI0.S15, EVT)
   9.153 -                }
   9.154 -                Case (0x16) {
   9.155 -                    Notify (\_SB.PCI0.S16, EVT)
   9.156 -                }
   9.157 -                Case (0x17) {
   9.158 -                    Notify (\_SB.PCI0.S17, EVT)
   9.159 -                }
   9.160 -                Case (0x18) {
   9.161 -                    Notify (\_SB.PCI0.S18, EVT)
   9.162 -                }
   9.163 -                Case (0x19) {
   9.164 -                    Notify (\_SB.PCI0.S19, EVT)
   9.165 -                }
   9.166 -                Case (0x1a) {
   9.167 -                    Notify (\_SB.PCI0.S1A, EVT)
   9.168 -                }
   9.169 -                Case (0x1b) {
   9.170 -                    Notify (\_SB.PCI0.S1B, EVT)
   9.171 -                }
   9.172 -                Case (0x1c) {
   9.173 -                    Notify (\_SB.PCI0.S1C, EVT)
   9.174 -                }
   9.175 -                Case (0x1d) {
   9.176 -                    Notify (\_SB.PCI0.S1D, EVT)
   9.177 -                }
   9.178 -                Case (0x1e) {
   9.179 -                    Notify (\_SB.PCI0.S1E, EVT)
   9.180 -                }
   9.181 -                Case (0x1f) {
   9.182 -                    Notify (\_SB.PCI0.S1F, EVT)
   9.183 -                }
   9.184 +                Notify (\_SB.PCI0.S0F, EVT)
   9.185 +            }
   9.186 +            ElseIf ( LEqual(SLT, 0x10) )
   9.187 +            {
   9.188 +                Notify (\_SB.PCI0.S10, EVT)
   9.189 +            }
   9.190 +            ElseIf ( LEqual(SLT, 0x11) )
   9.191 +            {
   9.192 +                Notify (\_SB.PCI0.S11, EVT)
   9.193 +            }
   9.194 +            ElseIf ( LEqual(SLT, 0x12) )
   9.195 +            {
   9.196 +                Notify (\_SB.PCI0.S12, EVT)
   9.197 +            }
   9.198 +            ElseIf ( LEqual(SLT, 0x13) )
   9.199 +            {
   9.200 +                Notify (\_SB.PCI0.S13, EVT)
   9.201 +            }
   9.202 +            ElseIf ( LEqual(SLT, 0x14) )
   9.203 +            {
   9.204 +                Notify (\_SB.PCI0.S14, EVT)
   9.205 +            }
   9.206 +            ElseIf ( LEqual(SLT, 0x15) )
   9.207 +            {
   9.208 +                Notify (\_SB.PCI0.S15, EVT)
   9.209 +            }
   9.210 +            ElseIf ( LEqual(SLT, 0x16) )
   9.211 +            {
   9.212 +                Notify (\_SB.PCI0.S16, EVT)
   9.213 +            }
   9.214 +            ElseIf ( LEqual(SLT, 0x17) )
   9.215 +            {
   9.216 +                Notify (\_SB.PCI0.S17, EVT)
   9.217 +            }
   9.218 +            ElseIf ( LEqual(SLT, 0x18) )
   9.219 +            {
   9.220 +                Notify (\_SB.PCI0.S18, EVT)
   9.221 +            }
   9.222 +            ElseIf ( LEqual(SLT, 0x19) )
   9.223 +            {
   9.224 +                Notify (\_SB.PCI0.S19, EVT)
   9.225 +            }
   9.226 +            ElseIf ( LEqual(SLT, 0x1a) )
   9.227 +            {
   9.228 +                Notify (\_SB.PCI0.S1A, EVT)
   9.229 +            }
   9.230 +            ElseIf ( LEqual(SLT, 0x1b) )
   9.231 +            {
   9.232 +                Notify (\_SB.PCI0.S1B, EVT)
   9.233 +            }
   9.234 +            ElseIf ( LEqual(SLT, 0x1c) )
   9.235 +            {
   9.236 +                Notify (\_SB.PCI0.S1C, EVT)
   9.237 +            }
   9.238 +            ElseIf ( LEqual(SLT, 0x1d) )
   9.239 +            {
   9.240 +                Notify (\_SB.PCI0.S1D, EVT)
   9.241 +            }
   9.242 +            ElseIf ( LEqual(SLT, 0x1e) )
   9.243 +            {
   9.244 +                Notify (\_SB.PCI0.S1E, EVT)
   9.245 +            }
   9.246 +            ElseIf ( LEqual(SLT, 0x1f) )
   9.247 +            {
   9.248 +                Notify (\_SB.PCI0.S1F, EVT)
   9.249              }
   9.250          }
   9.251      }
    10.1 --- a/tools/firmware/hvmloader/acpi/dsdt.c	Tue Apr 07 11:29:44 2009 +0900
    10.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.c	Tue Apr 07 11:32:24 2009 +0900
    10.3 @@ -1,22 +1,22 @@
    10.4  /*
    10.5   * 
    10.6   * Intel ACPI Component Architecture
    10.7 - * ASL Optimizing Compiler version 20090220 [Mar  9 2009]
    10.8 - * Copyright (C) 2000 - 2009 Intel Corporation
    10.9 + * ASL Optimizing Compiler version 20081204 [Jan 23 2009]
   10.10 + * Copyright (C) 2000 - 2008 Intel Corporation
   10.11   * Supports ACPI Specification Revision 3.0a
   10.12   * 
   10.13 - * Compilation of "dsdt.asl" - Tue Mar 17 10:44:21 2009
   10.14 + * Compilation of "dsdt.asl" - Tue Mar 31 13:24:51 2009
   10.15   * 
   10.16   * C source code output
   10.17   *
   10.18   */
   10.19  unsigned char AmlCode[] =
   10.20  {
   10.21 -    0x44,0x53,0x44,0x54,0x02,0x32,0x00,0x00,  /* 00000000    "DSDT.2.." */
   10.22 -    0x02,0xC6,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
   10.23 +    0x44,0x53,0x44,0x54,0xF3,0x31,0x00,0x00,  /* 00000000    "DSDT.1.." */
   10.24 +    0x02,0x12,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
   10.25      0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
   10.26      0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   10.27 -    0x20,0x02,0x09,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    " .. .PMB" */
   10.28 +    0x04,0x12,0x08,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
   10.29      0x53,0x0B,0x00,0x0C,0x08,0x50,0x4D,0x4C,  /* 00000028    "S....PML" */
   10.30      0x4E,0x0A,0x08,0x08,0x49,0x4F,0x42,0x31,  /* 00000030    "N...IOB1" */
   10.31      0x00,0x08,0x49,0x4F,0x4C,0x31,0x00,0x08,  /* 00000038    "..IOL1.." */
   10.32 @@ -81,7 +81,7 @@ unsigned char AmlCode[] =
   10.33      0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000210    "._HID.A." */
   10.34      0x0C,0x02,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000218    "..._CRS." */
   10.35      0x15,0x0A,0x12,0x47,0x01,0xC0,0x10,0xC0,  /* 00000220    "...G...." */
   10.36 -    0x10,0x00,0x03,0x47,0x01,0x44,0xB0,0x44,  /* 00000228    "...G.D.D" */
   10.37 +    0x10,0x00,0x22,0x47,0x01,0x44,0xB0,0x44,  /* 00000228    ".."G.D.D" */
   10.38      0xB0,0x00,0x04,0x79,0x00,0x14,0x4E,0x0C,  /* 00000230    "...y..N." */
   10.39      0x5F,0x43,0x52,0x53,0x00,0x08,0x50,0x52,  /* 00000238    "_CRS..PR" */
   10.40      0x54,0x30,0x11,0x42,0x07,0x0A,0x6E,0x88,  /* 00000240    "T0.B..n." */
   10.41 @@ -1446,7 +1446,7 @@ unsigned char AmlCode[] =
   10.42      0x44,0x50,0x54,0x31,0x70,0x0A,0x89,0x5C,  /* 00002CB8    "DPT1p..\" */
   10.43      0x2E,0x5F,0x47,0x50,0x45,0x44,0x50,0x54,  /* 00002CC0    "._GPEDPT" */
   10.44      0x32,0xA4,0x5C,0x2E,0x5F,0x47,0x50,0x45,  /* 00002CC8    "2.\._GPE" */
   10.45 -    0x50,0x48,0x31,0x46,0x10,0x4D,0x52,0x5F,  /* 00002CD0    "PH1F.MR_" */
   10.46 +    0x50,0x48,0x31,0x46,0x10,0x4E,0x51,0x5F,  /* 00002CD0    "PH1F.NQ_" */
   10.47      0x47,0x50,0x45,0x5B,0x80,0x50,0x48,0x50,  /* 00002CD8    "GPE[.PHP" */
   10.48      0x5F,0x01,0x0B,0xC0,0x10,0x0A,0x22,0x5B,  /* 00002CE0    "_....."[" */
   10.49      0x81,0x41,0x0B,0x50,0x48,0x50,0x5F,0x01,  /* 00002CE8    ".A.PHP_." */
   10.50 @@ -1475,143 +1475,141 @@ unsigned char AmlCode[] =
   10.51      0x01,0x0B,0x44,0xB0,0x0A,0x04,0x5B,0x81,  /* 00002DA0    "..D...[." */
   10.52      0x10,0x44,0x47,0x31,0x5F,0x01,0x44,0x50,  /* 00002DA8    ".DG1_.DP" */
   10.53      0x54,0x31,0x08,0x44,0x50,0x54,0x32,0x08,  /* 00002DB0    "T1.DPT2." */
   10.54 -    0x14,0x49,0x44,0x5F,0x4C,0x30,0x33,0x08,  /* 00002DB8    ".ID_L03." */
   10.55 -    0x08,0x5F,0x54,0x5F,0x30,0x00,0x08,0x53,  /* 00002DC0    "._T_0..S" */
   10.56 -    0x4C,0x54,0x5F,0x00,0x08,0x45,0x56,0x54,  /* 00002DC8    "LT_..EVT" */
   10.57 -    0x5F,0x00,0x70,0x50,0x53,0x54,0x41,0x61,  /* 00002DD0    "_.pPSTAa" */
   10.58 -    0x7B,0x61,0x0A,0x0F,0x45,0x56,0x54,0x5F,  /* 00002DD8    "{a..EVT_" */
   10.59 -    0x70,0x50,0x53,0x54,0x42,0x61,0x7B,0x61,  /* 00002DE0    "pPSTBa{a" */
   10.60 -    0x0A,0xFF,0x53,0x4C,0x54,0x5F,0x70,0x53,  /* 00002DE8    "..SLT_pS" */
   10.61 -    0x4C,0x54,0x5F,0x44,0x50,0x54,0x31,0x70,  /* 00002DF0    "LT_DPT1p" */
   10.62 -    0x45,0x56,0x54,0x5F,0x44,0x50,0x54,0x32,  /* 00002DF8    "EVT_DPT2" */
   10.63 -    0x70,0x53,0x4C,0x54,0x5F,0x5F,0x54,0x5F,  /* 00002E00    "pSLT__T_" */
   10.64 -    0x30,0xA0,0x1B,0x93,0x5F,0x54,0x5F,0x30,  /* 00002E08    "0..._T_0" */
   10.65 -    0x00,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002E10    "..\/._SB" */
   10.66 -    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x30,  /* 00002E18    "_PCI0S00" */
   10.67 -    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4C,0x3D,  /* 00002E20    "_EVT_.L=" */
   10.68 -    0xA0,0x1B,0x93,0x5F,0x54,0x5F,0x30,0x01,  /* 00002E28    "..._T_0." */
   10.69 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002E30    ".\/._SB_" */
   10.70 -    0x50,0x43,0x49,0x30,0x53,0x30,0x31,0x5F,  /* 00002E38    "PCI0S01_" */
   10.71 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x3B,0xA0,  /* 00002E40    "EVT_.M;." */
   10.72 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x02,  /* 00002E48    ".._T_0.." */
   10.73 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002E50    ".\/._SB_" */
   10.74 -    0x50,0x43,0x49,0x30,0x53,0x30,0x32,0x5F,  /* 00002E58    "PCI0S02_" */
   10.75 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x39,0xA0,  /* 00002E60    "EVT_.M9." */
   10.76 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x03,  /* 00002E68    ".._T_0.." */
   10.77 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002E70    ".\/._SB_" */
   10.78 -    0x50,0x43,0x49,0x30,0x53,0x30,0x33,0x5F,  /* 00002E78    "PCI0S03_" */
   10.79 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x37,0xA0,  /* 00002E80    "EVT_.M7." */
   10.80 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x04,  /* 00002E88    ".._T_0.." */
   10.81 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002E90    ".\/._SB_" */
   10.82 -    0x50,0x43,0x49,0x30,0x53,0x30,0x34,0x5F,  /* 00002E98    "PCI0S04_" */
   10.83 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x35,0xA0,  /* 00002EA0    "EVT_.M5." */
   10.84 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x05,  /* 00002EA8    ".._T_0.." */
   10.85 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002EB0    ".\/._SB_" */
   10.86 -    0x50,0x43,0x49,0x30,0x53,0x30,0x35,0x5F,  /* 00002EB8    "PCI0S05_" */
   10.87 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x33,0xA0,  /* 00002EC0    "EVT_.M3." */
   10.88 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x06,  /* 00002EC8    ".._T_0.." */
   10.89 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002ED0    ".\/._SB_" */
   10.90 -    0x50,0x43,0x49,0x30,0x53,0x30,0x36,0x5F,  /* 00002ED8    "PCI0S06_" */
   10.91 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x31,0xA0,  /* 00002EE0    "EVT_.M1." */
   10.92 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x07,  /* 00002EE8    ".._T_0.." */
   10.93 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002EF0    ".\/._SB_" */
   10.94 -    0x50,0x43,0x49,0x30,0x53,0x30,0x37,0x5F,  /* 00002EF8    "PCI0S07_" */
   10.95 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2F,0xA0,  /* 00002F00    "EVT_.M/." */
   10.96 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x08,  /* 00002F08    ".._T_0.." */
   10.97 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002F10    ".\/._SB_" */
   10.98 -    0x50,0x43,0x49,0x30,0x53,0x30,0x38,0x5F,  /* 00002F18    "PCI0S08_" */
   10.99 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2D,0xA0,  /* 00002F20    "EVT_.M-." */
  10.100 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x09,  /* 00002F28    ".._T_0.." */
  10.101 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002F30    ".\/._SB_" */
  10.102 -    0x50,0x43,0x49,0x30,0x53,0x30,0x39,0x5F,  /* 00002F38    "PCI0S09_" */
  10.103 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2B,0xA0,  /* 00002F40    "EVT_.M+." */
  10.104 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0A,  /* 00002F48    ".._T_0.." */
  10.105 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002F50    ".\/._SB_" */
  10.106 -    0x50,0x43,0x49,0x30,0x53,0x30,0x41,0x5F,  /* 00002F58    "PCI0S0A_" */
  10.107 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x29,0xA0,  /* 00002F60    "EVT_.M)." */
  10.108 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0B,  /* 00002F68    ".._T_0.." */
  10.109 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002F70    ".\/._SB_" */
  10.110 -    0x50,0x43,0x49,0x30,0x53,0x30,0x42,0x5F,  /* 00002F78    "PCI0S0B_" */
  10.111 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x27,0xA0,  /* 00002F80    "EVT_.M'." */
  10.112 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0C,  /* 00002F88    ".._T_0.." */
  10.113 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002F90    ".\/._SB_" */
  10.114 -    0x50,0x43,0x49,0x30,0x53,0x30,0x43,0x5F,  /* 00002F98    "PCI0S0C_" */
  10.115 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x25,0xA0,  /* 00002FA0    "EVT_.M%." */
  10.116 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0D,  /* 00002FA8    ".._T_0.." */
  10.117 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002FB0    ".\/._SB_" */
  10.118 -    0x50,0x43,0x49,0x30,0x53,0x30,0x44,0x5F,  /* 00002FB8    "PCI0S0D_" */
  10.119 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x23,0xA0,  /* 00002FC0    "EVT_.M#." */
  10.120 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0E,  /* 00002FC8    ".._T_0.." */
  10.121 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002FD0    ".\/._SB_" */
  10.122 -    0x50,0x43,0x49,0x30,0x53,0x30,0x45,0x5F,  /* 00002FD8    "PCI0S0E_" */
  10.123 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x21,0xA0,  /* 00002FE0    "EVT_.M!." */
  10.124 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x0F,  /* 00002FE8    ".._T_0.." */
  10.125 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00002FF0    ".\/._SB_" */
  10.126 -    0x50,0x43,0x49,0x30,0x53,0x30,0x46,0x5F,  /* 00002FF8    "PCI0S0F_" */
  10.127 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1F,0xA0,  /* 00003000    "EVT_.M.." */
  10.128 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x10,  /* 00003008    ".._T_0.." */
  10.129 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003010    ".\/._SB_" */
  10.130 -    0x50,0x43,0x49,0x30,0x53,0x31,0x30,0x5F,  /* 00003018    "PCI0S10_" */
  10.131 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1D,0xA0,  /* 00003020    "EVT_.M.." */
  10.132 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x11,  /* 00003028    ".._T_0.." */
  10.133 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003030    ".\/._SB_" */
  10.134 -    0x50,0x43,0x49,0x30,0x53,0x31,0x31,0x5F,  /* 00003038    "PCI0S11_" */
  10.135 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1B,0xA0,  /* 00003040    "EVT_.M.." */
  10.136 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x12,  /* 00003048    ".._T_0.." */
  10.137 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003050    ".\/._SB_" */
  10.138 -    0x50,0x43,0x49,0x30,0x53,0x31,0x32,0x5F,  /* 00003058    "PCI0S12_" */
  10.139 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x19,0xA0,  /* 00003060    "EVT_.M.." */
  10.140 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x13,  /* 00003068    ".._T_0.." */
  10.141 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003070    ".\/._SB_" */
  10.142 -    0x50,0x43,0x49,0x30,0x53,0x31,0x33,0x5F,  /* 00003078    "PCI0S13_" */
  10.143 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x17,0xA0,  /* 00003080    "EVT_.M.." */
  10.144 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x14,  /* 00003088    ".._T_0.." */
  10.145 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003090    ".\/._SB_" */
  10.146 -    0x50,0x43,0x49,0x30,0x53,0x31,0x34,0x5F,  /* 00003098    "PCI0S14_" */
  10.147 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x15,0xA0,  /* 000030A0    "EVT_.M.." */
  10.148 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x15,  /* 000030A8    ".._T_0.." */
  10.149 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 000030B0    ".\/._SB_" */
  10.150 -    0x50,0x43,0x49,0x30,0x53,0x31,0x35,0x5F,  /* 000030B8    "PCI0S15_" */
  10.151 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x13,0xA0,  /* 000030C0    "EVT_.M.." */
  10.152 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x16,  /* 000030C8    ".._T_0.." */
  10.153 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 000030D0    ".\/._SB_" */
  10.154 -    0x50,0x43,0x49,0x30,0x53,0x31,0x36,0x5F,  /* 000030D8    "PCI0S16_" */
  10.155 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x11,0xA0,  /* 000030E0    "EVT_.M.." */
  10.156 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x17,  /* 000030E8    ".._T_0.." */
  10.157 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 000030F0    ".\/._SB_" */
  10.158 -    0x50,0x43,0x49,0x30,0x53,0x31,0x37,0x5F,  /* 000030F8    "PCI0S17_" */
  10.159 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0F,0xA0,  /* 00003100    "EVT_.M.." */
  10.160 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x18,  /* 00003108    ".._T_0.." */
  10.161 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003110    ".\/._SB_" */
  10.162 -    0x50,0x43,0x49,0x30,0x53,0x31,0x38,0x5F,  /* 00003118    "PCI0S18_" */
  10.163 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0D,0xA0,  /* 00003120    "EVT_.M.." */
  10.164 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x19,  /* 00003128    ".._T_0.." */
  10.165 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003130    ".\/._SB_" */
  10.166 -    0x50,0x43,0x49,0x30,0x53,0x31,0x39,0x5F,  /* 00003138    "PCI0S19_" */
  10.167 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0B,0xA0,  /* 00003140    "EVT_.M.." */
  10.168 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x1A,  /* 00003148    ".._T_0.." */
  10.169 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003150    ".\/._SB_" */
  10.170 -    0x50,0x43,0x49,0x30,0x53,0x31,0x41,0x5F,  /* 00003158    "PCI0S1A_" */
  10.171 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x09,0xA0,  /* 00003160    "EVT_.M.." */
  10.172 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x1B,  /* 00003168    ".._T_0.." */
  10.173 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003170    ".\/._SB_" */
  10.174 -    0x50,0x43,0x49,0x30,0x53,0x31,0x42,0x5F,  /* 00003178    "PCI0S1B_" */
  10.175 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x07,0xA0,  /* 00003180    "EVT_.M.." */
  10.176 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x1C,  /* 00003188    ".._T_0.." */
  10.177 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 00003190    ".\/._SB_" */
  10.178 -    0x50,0x43,0x49,0x30,0x53,0x31,0x43,0x5F,  /* 00003198    "PCI0S1C_" */
  10.179 -    0x45,0x56,0x54,0x5F,0xA1,0x4D,0x05,0xA0,  /* 000031A0    "EVT_.M.." */
  10.180 -    0x1C,0x93,0x5F,0x54,0x5F,0x30,0x0A,0x1D,  /* 000031A8    ".._T_0.." */
  10.181 -    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 000031B0    ".\/._SB_" */
  10.182 -    0x50,0x43,0x49,0x30,0x53,0x31,0x44,0x5F,  /* 000031B8    "PCI0S1D_" */
  10.183 -    0x45,0x56,0x54,0x5F,0xA1,0x3D,0xA0,0x1C,  /* 000031C0    "EVT_.=.." */
  10.184 -    0x93,0x5F,0x54,0x5F,0x30,0x0A,0x1E,0x86,  /* 000031C8    "._T_0..." */
  10.185 -    0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,0x50,  /* 000031D0    "\/._SB_P" */
  10.186 -    0x43,0x49,0x30,0x53,0x31,0x45,0x5F,0x45,  /* 000031D8    "CI0S1E_E" */
  10.187 -    0x56,0x54,0x5F,0xA1,0x1E,0xA0,0x1C,0x93,  /* 000031E0    "VT_....." */
  10.188 -    0x5F,0x54,0x5F,0x30,0x0A,0x1F,0x86,0x5C,  /* 000031E8    "_T_0...\" */
  10.189 -    0x2F,0x03,0x5F,0x53,0x42,0x5F,0x50,0x43,  /* 000031F0    "/._SB_PC" */
  10.190 -    0x49,0x30,0x53,0x31,0x46,0x5F,0x45,0x56,  /* 000031F8    "I0S1F_EV" */
  10.191 -    0x54,0x5F,
  10.192 +    0x14,0x4A,0x43,0x5F,0x4C,0x30,0x33,0x08,  /* 00002DB8    ".JC_L03." */
  10.193 +    0x08,0x53,0x4C,0x54,0x5F,0x00,0x08,0x45,  /* 00002DC0    ".SLT_..E" */
  10.194 +    0x56,0x54,0x5F,0x00,0x70,0x50,0x53,0x54,  /* 00002DC8    "VT_.pPST" */
  10.195 +    0x41,0x61,0x7B,0x61,0x0A,0x0F,0x45,0x56,  /* 00002DD0    "Aa{a..EV" */
  10.196 +    0x54,0x5F,0x70,0x50,0x53,0x54,0x42,0x61,  /* 00002DD8    "T_pPSTBa" */
  10.197 +    0x7B,0x61,0x0A,0xFF,0x53,0x4C,0x54,0x5F,  /* 00002DE0    "{a..SLT_" */
  10.198 +    0x70,0x53,0x4C,0x54,0x5F,0x44,0x50,0x54,  /* 00002DE8    "pSLT_DPT" */
  10.199 +    0x31,0x70,0x45,0x56,0x54,0x5F,0x44,0x50,  /* 00002DF0    "1pEVT_DP" */
  10.200 +    0x54,0x32,0xA0,0x1B,0x93,0x53,0x4C,0x54,  /* 00002DF8    "T2...SLT" */
  10.201 +    0x5F,0x00,0x86,0x5C,0x2F,0x03,0x5F,0x53,  /* 00002E00    "_..\/._S" */
  10.202 +    0x42,0x5F,0x50,0x43,0x49,0x30,0x53,0x30,  /* 00002E08    "B_PCI0S0" */
  10.203 +    0x30,0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4C,  /* 00002E10    "0_EVT_.L" */
  10.204 +    0x3D,0xA0,0x1B,0x93,0x53,0x4C,0x54,0x5F,  /* 00002E18    "=...SLT_" */
  10.205 +    0x01,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002E20    "..\/._SB" */
  10.206 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x31,  /* 00002E28    "_PCI0S01" */
  10.207 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x3B,  /* 00002E30    "_EVT_.M;" */
  10.208 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002E38    "...SLT_." */
  10.209 +    0x02,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002E40    "..\/._SB" */
  10.210 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x32,  /* 00002E48    "_PCI0S02" */
  10.211 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x39,  /* 00002E50    "_EVT_.M9" */
  10.212 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002E58    "...SLT_." */
  10.213 +    0x03,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002E60    "..\/._SB" */
  10.214 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x33,  /* 00002E68    "_PCI0S03" */
  10.215 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x37,  /* 00002E70    "_EVT_.M7" */
  10.216 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002E78    "...SLT_." */
  10.217 +    0x04,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002E80    "..\/._SB" */
  10.218 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x34,  /* 00002E88    "_PCI0S04" */
  10.219 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x35,  /* 00002E90    "_EVT_.M5" */
  10.220 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002E98    "...SLT_." */
  10.221 +    0x05,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002EA0    "..\/._SB" */
  10.222 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x35,  /* 00002EA8    "_PCI0S05" */
  10.223 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x33,  /* 00002EB0    "_EVT_.M3" */
  10.224 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002EB8    "...SLT_." */
  10.225 +    0x06,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002EC0    "..\/._SB" */
  10.226 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x36,  /* 00002EC8    "_PCI0S06" */
  10.227 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x31,  /* 00002ED0    "_EVT_.M1" */
  10.228 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002ED8    "...SLT_." */
  10.229 +    0x07,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002EE0    "..\/._SB" */
  10.230 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x37,  /* 00002EE8    "_PCI0S07" */
  10.231 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2F,  /* 00002EF0    "_EVT_.M/" */
  10.232 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002EF8    "...SLT_." */
  10.233 +    0x08,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002F00    "..\/._SB" */
  10.234 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x38,  /* 00002F08    "_PCI0S08" */
  10.235 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2D,  /* 00002F10    "_EVT_.M-" */
  10.236 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002F18    "...SLT_." */
  10.237 +    0x09,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002F20    "..\/._SB" */
  10.238 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x39,  /* 00002F28    "_PCI0S09" */
  10.239 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x2B,  /* 00002F30    "_EVT_.M+" */
  10.240 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002F38    "...SLT_." */
  10.241 +    0x0A,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002F40    "..\/._SB" */
  10.242 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x41,  /* 00002F48    "_PCI0S0A" */
  10.243 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x29,  /* 00002F50    "_EVT_.M)" */
  10.244 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002F58    "...SLT_." */
  10.245 +    0x0B,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002F60    "..\/._SB" */
  10.246 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x42,  /* 00002F68    "_PCI0S0B" */
  10.247 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x27,  /* 00002F70    "_EVT_.M'" */
  10.248 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002F78    "...SLT_." */
  10.249 +    0x0C,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002F80    "..\/._SB" */
  10.250 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x43,  /* 00002F88    "_PCI0S0C" */
  10.251 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x25,  /* 00002F90    "_EVT_.M%" */
  10.252 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002F98    "...SLT_." */
  10.253 +    0x0D,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002FA0    "..\/._SB" */
  10.254 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x44,  /* 00002FA8    "_PCI0S0D" */
  10.255 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x23,  /* 00002FB0    "_EVT_.M#" */
  10.256 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002FB8    "...SLT_." */
  10.257 +    0x0E,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002FC0    "..\/._SB" */
  10.258 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x45,  /* 00002FC8    "_PCI0S0E" */
  10.259 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x21,  /* 00002FD0    "_EVT_.M!" */
  10.260 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002FD8    "...SLT_." */
  10.261 +    0x0F,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00002FE0    "..\/._SB" */
  10.262 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x30,0x46,  /* 00002FE8    "_PCI0S0F" */
  10.263 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1F,  /* 00002FF0    "_EVT_.M." */
  10.264 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00002FF8    "...SLT_." */
  10.265 +    0x10,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003000    "..\/._SB" */
  10.266 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x30,  /* 00003008    "_PCI0S10" */
  10.267 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1D,  /* 00003010    "_EVT_.M." */
  10.268 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003018    "...SLT_." */
  10.269 +    0x11,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003020    "..\/._SB" */
  10.270 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x31,  /* 00003028    "_PCI0S11" */
  10.271 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x1B,  /* 00003030    "_EVT_.M." */
  10.272 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003038    "...SLT_." */
  10.273 +    0x12,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003040    "..\/._SB" */
  10.274 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x32,  /* 00003048    "_PCI0S12" */
  10.275 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x19,  /* 00003050    "_EVT_.M." */
  10.276 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003058    "...SLT_." */
  10.277 +    0x13,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003060    "..\/._SB" */
  10.278 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x33,  /* 00003068    "_PCI0S13" */
  10.279 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x17,  /* 00003070    "_EVT_.M." */
  10.280 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003078    "...SLT_." */
  10.281 +    0x14,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003080    "..\/._SB" */
  10.282 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x34,  /* 00003088    "_PCI0S14" */
  10.283 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x15,  /* 00003090    "_EVT_.M." */
  10.284 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003098    "...SLT_." */
  10.285 +    0x15,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 000030A0    "..\/._SB" */
  10.286 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x35,  /* 000030A8    "_PCI0S15" */
  10.287 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x13,  /* 000030B0    "_EVT_.M." */
  10.288 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 000030B8    "...SLT_." */
  10.289 +    0x16,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 000030C0    "..\/._SB" */
  10.290 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x36,  /* 000030C8    "_PCI0S16" */
  10.291 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x11,  /* 000030D0    "_EVT_.M." */
  10.292 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 000030D8    "...SLT_." */
  10.293 +    0x17,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 000030E0    "..\/._SB" */
  10.294 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x37,  /* 000030E8    "_PCI0S17" */
  10.295 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0F,  /* 000030F0    "_EVT_.M." */
  10.296 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 000030F8    "...SLT_." */
  10.297 +    0x18,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003100    "..\/._SB" */
  10.298 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x38,  /* 00003108    "_PCI0S18" */
  10.299 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0D,  /* 00003110    "_EVT_.M." */
  10.300 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003118    "...SLT_." */
  10.301 +    0x19,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003120    "..\/._SB" */
  10.302 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x39,  /* 00003128    "_PCI0S19" */
  10.303 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x0B,  /* 00003130    "_EVT_.M." */
  10.304 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003138    "...SLT_." */
  10.305 +    0x1A,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003140    "..\/._SB" */
  10.306 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x41,  /* 00003148    "_PCI0S1A" */
  10.307 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x09,  /* 00003150    "_EVT_.M." */
  10.308 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003158    "...SLT_." */
  10.309 +    0x1B,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003160    "..\/._SB" */
  10.310 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x42,  /* 00003168    "_PCI0S1B" */
  10.311 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x07,  /* 00003170    "_EVT_.M." */
  10.312 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003178    "...SLT_." */
  10.313 +    0x1C,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 00003180    "..\/._SB" */
  10.314 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x43,  /* 00003188    "_PCI0S1C" */
  10.315 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x4D,0x05,  /* 00003190    "_EVT_.M." */
  10.316 +    0xA0,0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,  /* 00003198    "...SLT_." */
  10.317 +    0x1D,0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,  /* 000031A0    "..\/._SB" */
  10.318 +    0x5F,0x50,0x43,0x49,0x30,0x53,0x31,0x44,  /* 000031A8    "_PCI0S1D" */
  10.319 +    0x5F,0x45,0x56,0x54,0x5F,0xA1,0x3D,0xA0,  /* 000031B0    "_EVT_.=." */
  10.320 +    0x1C,0x93,0x53,0x4C,0x54,0x5F,0x0A,0x1E,  /* 000031B8    "..SLT_.." */
  10.321 +    0x86,0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,  /* 000031C0    ".\/._SB_" */
  10.322 +    0x50,0x43,0x49,0x30,0x53,0x31,0x45,0x5F,  /* 000031C8    "PCI0S1E_" */
  10.323 +    0x45,0x56,0x54,0x5F,0xA1,0x1E,0xA0,0x1C,  /* 000031D0    "EVT_...." */
  10.324 +    0x93,0x53,0x4C,0x54,0x5F,0x0A,0x1F,0x86,  /* 000031D8    ".SLT_..." */
  10.325 +    0x5C,0x2F,0x03,0x5F,0x53,0x42,0x5F,0x50,  /* 000031E0    "\/._SB_P" */
  10.326 +    0x43,0x49,0x30,0x53,0x31,0x46,0x5F,0x45,  /* 000031E8    "CI0S1F_E" */
  10.327 +    0x56,0x54,0x5F,
  10.328  };
  10.329  int DsdtLen=sizeof(AmlCode);
    11.1 --- a/tools/firmware/hvmloader/acpi/static_tables.c	Tue Apr 07 11:29:44 2009 +0900
    11.2 +++ b/tools/firmware/hvmloader/acpi/static_tables.c	Tue Apr 07 11:32:24 2009 +0900
    11.3 @@ -69,7 +69,7 @@ struct acpi_20_fadt Fadt = {
    11.4      .p_lvl3_lat = 0x0fff, /* >1000, means we do not support C3 state */
    11.5      .iapc_boot_arch = ACPI_8042,
    11.6      .flags = (ACPI_PROC_C1 | ACPI_SLP_BUTTON |
    11.7 -              ACPI_WBINVD | ACPI_PWR_BUTTON |
    11.8 +              ACPI_WBINVD |
    11.9                ACPI_FIX_RTC | ACPI_TMR_VAL_EXT),
   11.10  
   11.11      .reset_reg = {
    12.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Apr 07 11:29:44 2009 +0900
    12.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Apr 07 11:32:24 2009 +0900
    12.3 @@ -88,8 +88,8 @@ asm (
    12.4      "    .align 8                    \n"
    12.5      "gdt:                            \n"
    12.6      "    .quad 0x0000000000000000    \n"
    12.7 -    "    .quad 0x00009a000000ffff    \n" /* Ring 0 code, base 0 limit 0xffff */
    12.8 -    "    .quad 0x000092000000ffff    \n" /* Ring 0 data, base 0 limit 0xffff */
    12.9 +    "    .quad 0x008f9a000000ffff    \n" /* Ring 0 16b code, base 0 limit 4G */
   12.10 +    "    .quad 0x008f92000000ffff    \n" /* Ring 0 16b data, base 0 limit 4G */
   12.11      "gdt_end:                        \n"
   12.12      "                                \n"
   12.13      "    .bss                        \n"
    13.1 --- a/tools/firmware/rombios/32bitgateway.c	Tue Apr 07 11:29:44 2009 +0900
    13.2 +++ b/tools/firmware/rombios/32bitgateway.c	Tue Apr 07 11:32:24 2009 +0900
    13.3 @@ -56,13 +56,13 @@ gdt_entry_pm_32bit_cs:
    13.4      .byte 0x00, 0x9b, 0xcf, 0x00
    13.5  gdt_entry_pm_16bit_cs:
    13.6      .word 0xffff, 0x0000
    13.7 -    .byte REAL_MODE_CODE_OFFSET >> 16, 0x9b, 0x0, 0x0
    13.8 +    .byte REAL_MODE_CODE_OFFSET >> 16, 0x9b, 0x8f, 0x0
    13.9  gdt_entry_pm_32bit_ds:
   13.10      .word 0xffff, 0x0000
   13.11      .byte 0x0, 0x93, 0xcf, 0x0
   13.12  gdt_entry_pm_16bit_ds:
   13.13      .word 0xffff, 0x0000
   13.14 -    .byte 0x0, 0x93, 0x0, 0x0
   13.15 +    .byte 0x0, 0x93, 0x8f, 0x0
   13.16  gdt_entry_end:
   13.17  
   13.18  protmode_gdtdesc:
    14.1 --- a/tools/hotplug/Linux/network-bridge	Tue Apr 07 11:29:44 2009 +0900
    14.2 +++ b/tools/hotplug/Linux/network-bridge	Tue Apr 07 11:32:24 2009 +0900
    14.3 @@ -106,7 +106,7 @@ get_ip_info() {
    14.4  }
    14.5      
    14.6  do_ifup() {
    14.7 -    if ! ifup $1 ; then
    14.8 +    if [ $1 != "${netdev}" ] || ! ifup $1 ; then
    14.9          if [ -n "$addr_pfx" ] ; then
   14.10              # use the info from get_ip_info()
   14.11              ip addr flush $1
   14.12 @@ -223,9 +223,9 @@ op_start () {
   14.13  
   14.14      preiftransfer ${netdev}
   14.15      transfer_addrs ${netdev} ${tdev}
   14.16 +    # Remember the IP details for do_ifup.
   14.17 +    get_ip_info ${netdev}
   14.18      if ! ifdown ${netdev}; then
   14.19 -	# If ifdown fails, remember the IP details.
   14.20 -	get_ip_info ${netdev}
   14.21  	ip link set ${netdev} down
   14.22  	ip addr flush ${netdev}
   14.23      fi
    15.1 --- a/tools/hotplug/Linux/xend.rules	Tue Apr 07 11:29:44 2009 +0900
    15.2 +++ b/tools/hotplug/Linux/xend.rules	Tue Apr 07 11:32:24 2009 +0900
    15.3 @@ -1,3 +1,3 @@
    15.4  SUBSYSTEM=="pci", RUN+="socket:/org/xen/xend/udev_event"
    15.5 -#SUBSYSTEM=="scsi", RUN+="socket:/org/xen/xend/udev_event"
    15.6 +SUBSYSTEM=="scsi", RUN+="socket:/org/xen/xend/udev_event"
    15.7  #SUBSYSTEM=="net", KERNEL!="vif[0-9]*.[0-9]*|tap[0-9]*.[0-9]*", RUN+="socket:/org/xen/xend/udev_event"
    16.1 --- a/tools/libxc/xc_pagetab.c	Tue Apr 07 11:29:44 2009 +0900
    16.2 +++ b/tools/libxc/xc_pagetab.c	Tue Apr 07 11:32:24 2009 +0900
    16.3 @@ -32,7 +32,7 @@ unsigned long xc_translate_foreign_addre
    16.4                                               &ctx, sizeof ctx) != 0)
    16.5              return 0;
    16.6          if (!(ctx.cr0 & CR0_PG))
    16.7 -            return virt;
    16.8 +            return virt >> PAGE_SHIFT;
    16.9          pt_levels = (ctx.msr_efer&EFER_LMA) ? 4 : (ctx.cr4&CR4_PAE) ? 3 : 2;
   16.10          paddr = ctx.cr3 & ((pt_levels == 3) ? ~0x1full : ~0xfffull);
   16.11      } else {
    17.1 --- a/tools/libxc/xc_pm.c	Tue Apr 07 11:29:44 2009 +0900
    17.2 +++ b/tools/libxc/xc_pm.c	Tue Apr 07 11:32:24 2009 +0900
    17.3 @@ -362,3 +362,66 @@ int xc_set_sched_opt_smt(int xc_handle, 
    17.4     return rc;
    17.5  }
    17.6  
    17.7 +int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value)
    17.8 +{
    17.9 +   int rc;
   17.10 +   DECLARE_SYSCTL;
   17.11 +
   17.12 +   sysctl.cmd = XEN_SYSCTL_pm_op;
   17.13 +   sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_vcpu_migration_delay;
   17.14 +   sysctl.u.pm_op.cpuid = 0;
   17.15 +   sysctl.u.pm_op.set_vcpu_migration_delay = value;
   17.16 +   rc = do_sysctl(xc_handle, &sysctl);
   17.17 +
   17.18 +   return rc;
   17.19 +}
   17.20 +
   17.21 +int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value)
   17.22 +{
   17.23 +   int rc;
   17.24 +   DECLARE_SYSCTL;
   17.25 +
   17.26 +   sysctl.cmd = XEN_SYSCTL_pm_op;
   17.27 +   sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_vcpu_migration_delay;
   17.28 +   sysctl.u.pm_op.cpuid = 0;
   17.29 +   rc = do_sysctl(xc_handle, &sysctl);
   17.30 +
   17.31 +   if (!rc && value)
   17.32 +       *value = sysctl.u.pm_op.get_vcpu_migration_delay;
   17.33 +
   17.34 +   return rc;
   17.35 +}
   17.36 +
   17.37 +int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value)
   17.38 +{
   17.39 +    int rc;
   17.40 +    DECLARE_SYSCTL;
   17.41 +
   17.42 +    if ( xc_handle < 0 || !value )
   17.43 +        return -EINVAL;
   17.44 +
   17.45 +    sysctl.cmd = XEN_SYSCTL_pm_op;
   17.46 +    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_get_max_cstate;
   17.47 +    sysctl.u.pm_op.cpuid = 0;
   17.48 +    sysctl.u.pm_op.get_max_cstate = 0;
   17.49 +    rc = do_sysctl(xc_handle, &sysctl);
   17.50 +    *value = sysctl.u.pm_op.get_max_cstate;
   17.51 +
   17.52 +    return rc;
   17.53 +}
   17.54 +
   17.55 +int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value)
   17.56 +{
   17.57 +    DECLARE_SYSCTL;
   17.58 +
   17.59 +    if ( xc_handle < 0 )
   17.60 +        return -EINVAL;
   17.61 +
   17.62 +    sysctl.cmd = XEN_SYSCTL_pm_op;
   17.63 +    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_set_max_cstate;
   17.64 +    sysctl.u.pm_op.cpuid = 0;
   17.65 +    sysctl.u.pm_op.set_max_cstate = value;
   17.66 +
   17.67 +    return do_sysctl(xc_handle, &sysctl);
   17.68 +}
   17.69 +
    18.1 --- a/tools/libxc/xenctrl.h	Tue Apr 07 11:29:44 2009 +0900
    18.2 +++ b/tools/libxc/xenctrl.h	Tue Apr 07 11:32:24 2009 +0900
    18.3 @@ -1261,5 +1261,10 @@ struct xc_get_cputopo {
    18.4  int xc_get_cputopo(int xc_handle, struct xc_get_cputopo *info);
    18.5  
    18.6  int xc_set_sched_opt_smt(int xc_handle, uint32_t value);
    18.7 +int xc_set_vcpu_migration_delay(int xc_handle, uint32_t value);
    18.8 +int xc_get_vcpu_migration_delay(int xc_handle, uint32_t *value);
    18.9 +
   18.10 +int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
   18.11 +int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
   18.12  
   18.13  #endif /* XENCTRL_H */
    19.1 --- a/tools/misc/Makefile	Tue Apr 07 11:29:44 2009 +0900
    19.2 +++ b/tools/misc/Makefile	Tue Apr 07 11:32:24 2009 +0900
    19.3 @@ -22,7 +22,7 @@ INSTALL_BIN-y := xencons
    19.4  INSTALL_BIN-$(CONFIG_X86) += xen-detect
    19.5  INSTALL_BIN := $(INSTALL_BIN-y)
    19.6  
    19.7 -INSTALL_SBIN-y := netfix xm xen-bugtool xen-python-path xend xenperf xsview xenpm
    19.8 +INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm
    19.9  INSTALL_SBIN := $(INSTALL_SBIN-y)
   19.10  
   19.11  DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
    20.1 --- a/tools/misc/fakei386xen	Tue Apr 07 11:29:44 2009 +0900
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,32 +0,0 @@
    20.4 -#!/bin/bash
    20.5 -
    20.6 -cln () {
    20.7 -while [ $# -gt 0 ]; do
    20.8 -  (
    20.9 -    test -f "$1" || { echo "$1: No such file or directory" 1>&2; exit 1; }
   20.10 -    { cp $1 cln$$ && rm $1 && mv cln$$ $1; } || { rm -f cln$$; exit 1; }
   20.11 -  )
   20.12 -  shift
   20.13 -done
   20.14 -}
   20.15 -
   20.16 -
   20.17 -for i in `find include/asm-xen arch/xen -type l | xargs ls -l | egrep '../(asm-)?i386/' | awk '{print $9}'`
   20.18 -do
   20.19 -  echo $i
   20.20 -  cln $i
   20.21 -done
   20.22 -
   20.23 -mv include/asm-i386 include/asm-Xi386
   20.24 -mv include/asm-xen include/asm-i386
   20.25 -ln -s asm-i386 include/asm-xen
   20.26 -rm include/asm
   20.27 -ln -s asm-i386 include/asm
   20.28 -mv arch/i386 arch/Xi386
   20.29 -mv arch/xen arch/i386
   20.30 -ln -s i386 arch/xen
   20.31 -
   20.32 -mv Makefile XMakefile
   20.33 -#sed -e 's/^EXTRAVERSION =.*/EXTRAVERSION = -xen/' <XMakefile >Makefile
   20.34 -echo ARCH=i386 >Makefile ; cat XMakefile >>Makefile
   20.35 -
    21.1 --- a/tools/misc/netfix	Tue Apr 07 11:29:44 2009 +0900
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,69 +0,0 @@
    21.4 -#!/usr/bin/env python
    21.5 -#  -*- mode: python; -*-
    21.6 -#============================================================================
    21.7 -# Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
    21.8 -#============================================================================
    21.9 -# Move the IP address from eth0 onto the Xen bridge (xenbr0).
   21.10 -# Only works if the bridge control utils (brctl) have been installed.
   21.11 -#============================================================================
   21.12 -
   21.13 -from getopt import getopt
   21.14 -
   21.15 -# add fallback path for non-native python path installs if needed
   21.16 -sys.path.append('/usr/lib/python')
   21.17 -sys.path.append('/usr/lib64/python')
   21.18 -from xen.util.Brctl import *
   21.19 -
   21.20 -short_options = 'hvqni:b:c'
   21.21 -long_options  = ['help', 'verbose', 'quiet',
   21.22 -                 'interface=', 'bridge=', 'create']
   21.23 -
   21.24 -defaults['interface'] = 'eth0'
   21.25 -defaults['bridge'] = 'xenbr0'
   21.26 -
   21.27 -def usage():
   21.28 -    print """Usage:
   21.29 -    %s [options]
   21.30 -
   21.31 -    Reconfigure routing so that <bridge> has the IP address from
   21.32 -    <interface>. This lets IP carry on working when <interface>
   21.33 -    is attached to <bridge> for virtual networking.
   21.34 -    Uses brctl to add <interface> to <bridge>,
   21.35 -    so this can be run before any domains have been created.
   21.36 -    """ % sys.argv[0]
   21.37 -    print """
   21.38 -    -i, --interface <interface>    interface, default %(interface)s.
   21.39 -    -b, --bridge <bridge>          bridge, default %(bridge)s.
   21.40 -    -c, --create                   create the bridge.
   21.41 -    -v, --verbose                  Print commands.
   21.42 -    -q, --quiet                    Don't print commands.
   21.43 -    -n, --dry-run                  Don't execute commands.
   21.44 -    -h, --help                     Print this help.
   21.45 -    """ % defaults
   21.46 -    sys.exit(1)
   21.47 -
   21.48 -
   21.49 -def main():
   21.50 -    lopts = set_opts(Opts(defaults))
   21.51 -    lopts.dryrun = 0
   21.52 -    (options, args) = getopt(sys.argv[1:], short_options, long_options)
   21.53 -    if args: usage()
   21.54 -    for k, v in options:
   21.55 -        if k in ['-h', '--help']:
   21.56 -            usage()
   21.57 -        elif k in ['-c', '--create']:
   21.58 -            lopts.create = 1
   21.59 -        elif k in ['-i', '--interface']:
   21.60 -            lopts.interface = v
   21.61 -        elif k in ['-b', '--bridge']:
   21.62 -            lopts.bridge = v
   21.63 -        elif k in ['-q', '--quiet']:
   21.64 -            lopts.verbose = 0
   21.65 -        elif k in ['-v', '--verbose']:
   21.66 -            lopts.verbose = 1
   21.67 -        elif k in ['-n', '--dry-run']:
   21.68 -            lopts.dryrun = 1
   21.69 -    reconfigure(lopts.interface, lopts.bridge)
   21.70 -
   21.71 -if __name__ == '__main__':
   21.72 -    main()
    22.1 --- a/tools/misc/xen-clone.README	Tue Apr 07 11:29:44 2009 +0900
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,23 +0,0 @@
    22.4 -
    22.5 -xen-clone
    22.6 -
    22.7 -usage: xen-clone <bk_repository> <dest_dir> <orig_linux_dir>
    22.8 -
    22.9 -This script can be used to 'bk clone' and build a xen and xenolinux image 
   22.10 -from the master BK repository, either from a local copy, or from the
   22.11 -public repository bk://xen.bkbits.net/xeno.bk
   22.12 -
   22.13 -In many circumstances, it can be invoked without any arguments and
   22.14 -just `does the right thing'.
   22.15 -
   22.16 -The default dest_dir is 'xeno-clone', relative to the current directory.
   22.17 -
   22.18 -To build xenolinux, the script needs a pristine copy of the equivalent 
   22.19 -linux tree. The script looks in a couple of places on the local filesystem, 
   22.20 -then tries a download from from ftp://ftp.kernel.org/pub/linux/kernel/v2.4/
   22.21 -
   22.22 -The script also tries a number of optional UCCL site-specific operations
   22.23 -that configure the test machine booting infrastructure to boot the 
   22.24 -resultant image.
   22.25 -
   22.26 -
    23.1 --- a/tools/misc/xenpm.c	Tue Apr 07 11:29:44 2009 +0900
    23.2 +++ b/tools/misc/xenpm.c	Tue Apr 07 11:32:24 2009 +0900
    23.3 @@ -57,6 +57,9 @@ void show_help(void)
    23.4              "                                     it is used in ondemand governor.\n"
    23.5              " get-cpu-topology                    get thread/core/socket topology info\n"
    23.6              " set-sched-smt           enable|disable enable/disable scheduler smt power saving\n"
    23.7 +            " set-vcpu-migration-delay      <num> set scheduler vcpu migration delay in us\n"
    23.8 +            " get-vcpu-migration-delay            get scheduler vcpu migration delay\n"
    23.9 +            " set-max-cstate        <num>         set the C-State limitation (<num> >= 0)\n"
   23.10              " start [seconds]                     start collect Cx/Px statistics,\n"
   23.11              "                                     output after CTRL-C or SIGINT or several seconds.\n"
   23.12              );
   23.13 @@ -122,6 +125,18 @@ static int get_cxstat_by_cpuid(int xc_fd
   23.14      return 0;
   23.15  }
   23.16  
   23.17 +static int show_max_cstate(int xc_fd)
   23.18 +{
   23.19 +    int ret = 0;
   23.20 +    uint32_t value;
   23.21 +
   23.22 +    if ( (ret = xc_get_cpuidle_max_cstate(xc_fd, &value)) )
   23.23 +        return ret;
   23.24 +
   23.25 +    printf("Max C-state: C%d\n\n", value);
   23.26 +    return 0;
   23.27 +}
   23.28 +
   23.29  static int show_cxstat_by_cpuid(int xc_fd, int cpuid)
   23.30  {
   23.31      int ret = 0;
   23.32 @@ -148,6 +163,8 @@ void cxstat_func(int argc, char *argv[])
   23.33      if ( cpuid >= max_cpu_nr )
   23.34          cpuid = -1;
   23.35  
   23.36 +    show_max_cstate(xc_fd);
   23.37 +
   23.38      if ( cpuid < 0 )
   23.39      {
   23.40          /* show cxstates on all cpus */
   23.41 @@ -864,7 +881,72 @@ void set_sched_smt_func(int argc, char *
   23.42  
   23.43      rc = xc_set_sched_opt_smt(xc_fd, value);
   23.44      printf("%s sched_smt_power_savings %s\n", argv[0],
   23.45 -                    rc? "failed":"successeed" );
   23.46 +                    rc? "failed":"succeeded" );
   23.47 +
   23.48 +    return;
   23.49 +}
   23.50 +
   23.51 +void set_vcpu_migration_delay_func(int argc, char *argv[])
   23.52 +{
   23.53 +    int value;
   23.54 +    int rc;
   23.55 +
   23.56 +    if (argc != 1){
   23.57 +        show_help();
   23.58 +        exit(-1);
   23.59 +    }
   23.60 +
   23.61 +    value = atoi(argv[0]);
   23.62 +
   23.63 +    if (value < 0)
   23.64 +    {
   23.65 +        printf("Please try non-negative vcpu migration delay\n");
   23.66 +        exit(-1);
   23.67 +    }
   23.68 +
   23.69 +    rc = xc_set_vcpu_migration_delay(xc_fd, value);
   23.70 +    printf("%s to set vcpu migration delay to %d us\n",
   23.71 +                    rc? "Fail":"Succeed", value );
   23.72 +
   23.73 +    return;
   23.74 +}
   23.75 +
   23.76 +void get_vcpu_migration_delay_func(int argc, char *argv[])
   23.77 +{
   23.78 +    uint32_t value;
   23.79 +    int rc;
   23.80 +
   23.81 +    if (argc != 0){
   23.82 +        show_help();
   23.83 +        exit(-1);
   23.84 +    }
   23.85 +
   23.86 +    rc = xc_get_vcpu_migration_delay(xc_fd, &value);
   23.87 +    if (!rc)
   23.88 +    {
   23.89 +        printf("Schduler vcpu migration delay is %d us\n", value);
   23.90 +    }
   23.91 +    else
   23.92 +    {
   23.93 +        printf("Failed to get scheduler vcpu migration delay, errno=%d\n", errno);
   23.94 +    }
   23.95 +
   23.96 +    return;
   23.97 +}
   23.98 +
   23.99 +void set_max_cstate_func(int argc, char *argv[])
  23.100 +{
  23.101 +    int value, rc;
  23.102 +
  23.103 +    if ( argc != 1 || sscanf(argv[0], "%d", &value) != 1 || value < 0 )
  23.104 +    {
  23.105 +        show_help();
  23.106 +        exit(-1);
  23.107 +    }
  23.108 +
  23.109 +    rc = xc_set_cpuidle_max_cstate(xc_fd, (uint32_t)value);
  23.110 +    printf("set max_cstate to C%d %s\n", value,
  23.111 +                    rc? "failed":"succeeded" );
  23.112  
  23.113      return;
  23.114  }
  23.115 @@ -886,6 +968,9 @@ struct {
  23.116      { "set-up-threshold", scaling_up_threshold_func },
  23.117      { "get-cpu-topology", cpu_topology_func},
  23.118      { "set-sched-smt", set_sched_smt_func},
  23.119 +    { "get-vcpu-migration-delay", get_vcpu_migration_delay_func},
  23.120 +    { "set-vcpu-migration-delay", set_vcpu_migration_delay_func},
  23.121 +    { "set-max-cstate", set_max_cstate_func},
  23.122  };
  23.123  
  23.124  int main(int argc, char *argv[])
    24.1 --- a/tools/pygrub/Makefile	Tue Apr 07 11:29:44 2009 +0900
    24.2 +++ b/tools/pygrub/Makefile	Tue Apr 07 11:32:24 2009 +0900
    24.3 @@ -12,7 +12,7 @@ build:
    24.4  ifndef XEN_PYTHON_NATIVE_INSTALL
    24.5  install: LIBPATH=$(shell PYTHONPATH=../python/xen/util python -c "import auxbin; print auxbin.libpath()")
    24.6  install: all
    24.7 -	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --install-lib="$(DESTDIR)$(LIBPATH)/python"
    24.8 +	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)$(PREFIX)" --prefix="" --install-lib="$(DESTDIR)$(LIBDIR)/python"
    24.9  	$(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
   24.10  else
   24.11  install: all
    25.1 --- a/tools/pygrub/src/pygrub	Tue Apr 07 11:29:44 2009 +0900
    25.2 +++ b/tools/pygrub/src/pygrub	Tue Apr 07 11:32:24 2009 +0900
    25.3 @@ -316,7 +316,11 @@ class Grub:
    25.4                  curline = len(img.lines) - 1
    25.5  
    25.6          if self.isdone:
    25.7 -            origimg.reset(img.lines)
    25.8 +           # Fix to allow pygrub command-line editing in Lilo bootloader (used by IA64)
    25.9 +           if platform.machine() == 'ia64':
   25.10 +              origimg.reset(img.lines, img.path)
   25.11 +           else:
   25.12 +              origimg.reset(img.lines)
   25.13  
   25.14      def edit_line(self, line):
   25.15          self.screen.erase()
   25.16 @@ -532,7 +536,7 @@ def run_grub(file, entry, fs, arg):
   25.17  
   25.18      try:
   25.19          img = g.cf.images[sel]
   25.20 -    except:
   25.21 +    except IndexError:
   25.22          log.debug("PyGrub: Default selection is not valid, using first boot configuration...")
   25.23          img = g.cf.images[0]
   25.24  
    26.1 --- a/tools/python/Makefile	Tue Apr 07 11:29:44 2009 +0900
    26.2 +++ b/tools/python/Makefile	Tue Apr 07 11:32:24 2009 +0900
    26.3 @@ -12,7 +12,7 @@ PODIR := xen/xm/messages
    26.4  POTFILE := $(PODIR)/xen-xm.pot
    26.5  I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
    26.6  CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
    26.7 -NLSDIR = /usr/share/locale
    26.8 +NLSDIR = $(SHAREDIR)/locale
    26.9  
   26.10  .PHONY: build buildpy
   26.11  buildpy: 
   26.12 @@ -57,19 +57,19 @@ refresh-po: $(POTFILE)
   26.13  ifndef XEN_PYTHON_NATIVE_INSTALL
   26.14  install: LIBPATH=$(shell PYTHONPATH=xen/util python -c "import auxbin; print auxbin.libpath()")
   26.15  install: install-messages install-dtd
   26.16 -	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force --install-lib="$(DESTDIR)$(LIBPATH)/python"
   26.17 +	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)$(PREFIX)" --prefix="" --force --install-lib="$(DESTDIR)$(LIBDIR)/python"
   26.18  else
   26.19  install: install-messages install-dtd
   26.20  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
   26.21  endif
   26.22  
   26.23  install-dtd: all
   26.24 -	$(INSTALL_DIR) $(DESTDIR)/usr/share/xen
   26.25 -	$(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)/usr/share/xen
   26.26 +	$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
   26.27 +	$(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR)
   26.28  
   26.29  install-messages: all
   26.30  	set -e; if which $(MSGFMT) >/dev/null ; then \
   26.31 -		mkdir -p $(DESTDIR)$(NLSDIR); \
   26.32 +		$(INSTALL_DIR) $(DESTDIR)$(NLSDIR); \
   26.33  		for l in $(LINGUAS); do \
   26.34  			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
   26.35  			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
    27.1 --- a/tools/python/README.XendConfig	Tue Apr 07 11:29:44 2009 +0900
    27.2 +++ b/tools/python/README.XendConfig	Tue Apr 07 11:32:24 2009 +0900
    27.3 @@ -25,6 +25,7 @@ name_label                      name
    27.4  name_description
    27.5  user_version
    27.6  is_a_template
    27.7 +auto_power_on
    27.8  resident_on
    27.9  memory_static_min               memory
   27.10  memory_static_max               maxmem
    28.1 --- a/tools/python/xen/util/acmpolicy.py	Tue Apr 07 11:29:44 2009 +0900
    28.2 +++ b/tools/python/xen/util/acmpolicy.py	Tue Apr 07 11:32:24 2009 +0900
    28.3 @@ -216,7 +216,7 @@ ACM_SCHEMA="""<?xml version="1.0" encodi
    28.4  		<xsd:complexType>
    28.5  			<xsd:sequence>
    28.6  				<xsd:element name="Name" type="NameWithFrom"></xsd:element>
    28.7 -				<xsd:element ref="SimpleTypeEnforcementTypes" minOccurs="0" maxOccurs="unbounded" />
    28.8 +				<xsd:element ref="SimpleTypeEnforcementTypes" minOccurs="0" maxOccurs="1" />
    28.9  				<xsd:element ref="ChineseWallTypes" minOccurs="0" maxOccurs="unbounded" />
   28.10  			</xsd:sequence>
   28.11  		</xsd:complexType>
    29.1 --- a/tools/python/xen/util/blkif.py	Tue Apr 07 11:29:44 2009 +0900
    29.2 +++ b/tools/python/xen/util/blkif.py	Tue Apr 07 11:32:24 2009 +0900
    29.3 @@ -75,7 +75,7 @@ def _parse_uname(uname):
    29.4      fn = taptype = None
    29.5      if uname.find(":") != -1:
    29.6          (typ, fn) = uname.split(":", 1)
    29.7 -        if typ == "phy" and not fn.startswith("/"):
    29.8 +        if typ in ("phy", "drbd") and not fn.startswith("/"):
    29.9              fn = "/dev/%s" %(fn,)
   29.10          if typ == "tap":
   29.11              (taptype, fn) = fn.split(":", 1)
    30.1 --- a/tools/python/xen/util/pci.py	Tue Apr 07 11:29:44 2009 +0900
    30.2 +++ b/tools/python/xen/util/pci.py	Tue Apr 07 11:32:24 2009 +0900
    30.3 @@ -417,7 +417,10 @@ class PciDevice:
    30.4  
    30.5      def find_the_uppermost_pci_bridge(self):
    30.6          # Find the uppermost PCI/PCI-X bridge
    30.7 -        (dom, b, d, f) = self.find_parent()
    30.8 +        dev = self.find_parent()
    30.9 +        if dev is None:
   30.10 +            return None
   30.11 +        (dom, b, d, f) = dev
   30.12          dev = dev_parent = PciDevice(dom, b, d, f)
   30.13          while dev_parent.dev_type != DEV_TYPE_PCIe_BRIDGE:
   30.14              parent = dev_parent.find_parent()
   30.15 @@ -463,6 +466,11 @@ class PciDevice:
   30.16                  element,  the caller itself can remove it explicitly.
   30.17          '''
   30.18          dev = self.find_the_uppermost_pci_bridge()
   30.19 +
   30.20 +        # The 'self' device is on bus0.
   30.21 +        if dev is None:
   30.22 +            return [self.name]
   30.23 +
   30.24          dev_list = dev.find_all_devices_behind_the_bridge(ignore_bridge)
   30.25          dev_list = re.findall(PCI_DEV_REG_EXPRESS_STR, '%s' % dev_list)
   30.26          return dev_list
   30.27 @@ -559,7 +567,8 @@ class PciDevice:
   30.28              return self.find_all_the_multi_functions()
   30.29          elif self.dev_type == DEV_TYPE_PCI and not self.pci_af_flr:
   30.30              coassigned_pci_list = self.find_coassigned_pci_devices(True)
   30.31 -            del coassigned_pci_list[0]
   30.32 +            if len(coassigned_pci_list) > 1:
   30.33 +                del coassigned_pci_list[0]
   30.34              return coassigned_pci_list
   30.35          else:
   30.36              return [self.name]
    31.1 --- a/tools/python/xen/util/vscsi_util.py	Tue Apr 07 11:29:44 2009 +0900
    31.2 +++ b/tools/python/xen/util/vscsi_util.py	Tue Apr 07 11:32:24 2009 +0900
    31.3 @@ -36,6 +36,11 @@ SYSFS_SCSI_DEV_TYPEID_PATH = '/type'
    31.4  SYSFS_SCSI_DEV_REVISION_PATH = '/rev'
    31.5  SYSFS_SCSI_DEV_SCSILEVEL_PATH = '/scsi_level'
    31.6  
    31.7 +SCSI_ID_COMMANDS = [
    31.8 +    "/lib/udev/scsi_id -gu --sg-version 3 -d /dev/%s 2>/dev/null",
    31.9 +    "/sbin/scsi_id -gu -s /class/scsi_generic/%s 2>/dev/null"
   31.10 +]
   31.11 +
   31.12  def _vscsi_get_devname_by(name, scsi_devices):
   31.13      """A device name is gotten by the HCTL.
   31.14      (e.g., '0:0:0:0' to '/dev/sda')
   31.15 @@ -79,9 +84,10 @@ def _vscsi_get_hctl_by(phyname, scsi_dev
   31.16  
   31.17  
   31.18  def _vscsi_get_scsiid(sg):
   31.19 -    scsi_id = os.popen('/sbin/scsi_id -gu -s /class/scsi_generic/' + sg).read().split()
   31.20 -    if len(scsi_id):
   31.21 -        return scsi_id[0]
   31.22 +    for scsi_id_command in SCSI_ID_COMMANDS:
   31.23 +        scsi_id = os.popen(scsi_id_command % sg).read().split()
   31.24 +        if len(scsi_id):
   31.25 +            return scsi_id[0]
   31.26      return None
   31.27  
   31.28  
   31.29 @@ -225,40 +231,50 @@ def get_scsi_scsilevel(pHCTL):
   31.30      except:
   31.31          return None
   31.32  
   31.33 -def get_all_scsi_devices():
   31.34 -
   31.35 -    scsi_devs = []
   31.36 +def _make_scsi_record(scsi_info):
   31.37 +    scsi_rec = {
   31.38 +        'physical_HCTL': scsi_info[0],
   31.39 +        'dev_name': None,
   31.40 +        'sg_name': scsi_info[2],
   31.41 +        'scsi_id': None
   31.42 +    }
   31.43 +    if scsi_info[1] is not None:
   31.44 +        scsi_rec['dev_name'] = scsi_info[1] 
   31.45 +    if scsi_info[3] is not None:
   31.46 +        scsi_rec['scsi_id'] = scsi_info[3] 
   31.47  
   31.48 -    for scsi_info in vscsi_get_scsidevices():
   31.49 -        scsi_dev = {
   31.50 -            'physical_HCTL': scsi_info[0],
   31.51 -            'dev_name': None,
   31.52 -            'sg_name': scsi_info[2],
   31.53 -            'scsi_id': None
   31.54 -        }
   31.55 -        if scsi_info[1] is not None:
   31.56 -            scsi_dev['dev_name'] = scsi_info[1] 
   31.57 -        if scsi_info[3] is not None:
   31.58 -            scsi_dev['scsi_id'] = scsi_info[3] 
   31.59 +    scsi_rec['vendor_name'] = \
   31.60 +        get_scsi_vendor(scsi_rec['physical_HCTL'])
   31.61 +    scsi_rec['model'] = \
   31.62 +        get_scsi_model(scsi_rec['physical_HCTL'])
   31.63 +    scsi_rec['type_id'] = \
   31.64 +        get_scsi_typeid(scsi_rec['physical_HCTL'])
   31.65 +    scsi_rec['revision'] = \
   31.66 +        get_scsi_revision(scsi_rec['physical_HCTL'])
   31.67 +    scsi_rec['scsi_level'] = \
   31.68 +        get_scsi_scsilevel(scsi_rec['physical_HCTL'])
   31.69  
   31.70 -        scsi_dev['vendor_name'] = \
   31.71 -            get_scsi_vendor(scsi_dev['physical_HCTL'])
   31.72 -        scsi_dev['model'] = \
   31.73 -            get_scsi_model(scsi_dev['physical_HCTL'])
   31.74 -        scsi_dev['type_id'] = \
   31.75 -            get_scsi_typeid(scsi_dev['physical_HCTL'])
   31.76 -        scsi_dev['revision'] = \
   31.77 -            get_scsi_revision(scsi_dev['physical_HCTL'])
   31.78 -        scsi_dev['scsi_level'] = \
   31.79 -            get_scsi_scsilevel(scsi_dev['physical_HCTL'])
   31.80 +    try:
   31.81 +        lsscsi_info = os.popen('lsscsi %s 2>/dev/null' % scsi_rec['physical_HCTL']).read().split()
   31.82 +        scsi_rec['type'] = lsscsi_info[1]
   31.83 +    except:
   31.84 +        scsi_rec['type'] = None
   31.85 +
   31.86 +    return scsi_rec
   31.87  
   31.88 -        try:
   31.89 -            lsscsi_info = os.popen('lsscsi %s 2>/dev/null' % scsi_dev['physical_HCTL']).read().split()
   31.90 -            scsi_dev['type'] = lsscsi_info[1]
   31.91 -        except:
   31.92 -            scsi_dev['type'] = None
   31.93 +def get_scsi_device(pHCTL):
   31.94 +    scsis_info = _vscsi_get_scsidevices_by_lsscsi(pHCTL)
   31.95 +    if not scsis_info:
   31.96 +        scsis_info = _vscsi_get_scsidevices_by_sysfs()
   31.97 +    for scsi_info in scsis_info:
   31.98 +        if scsi_info[0] == pHCTL:
   31.99 +            return _make_scsi_record(scsi_info)
  31.100 +    return None
  31.101  
  31.102 -        scsi_devs.append(scsi_dev)
  31.103 +def get_all_scsi_devices():
  31.104 +    scsi_records = []
  31.105 +    for scsi_info in vscsi_get_scsidevices():
  31.106 +        scsi_record = _make_scsi_record(scsi_info)
  31.107 +        scsi_records.append(scsi_record)
  31.108 +    return scsi_records
  31.109  
  31.110 -    return scsi_devs
  31.111 -
    32.1 --- a/tools/python/xen/web/connection.py	Tue Apr 07 11:29:44 2009 +0900
    32.2 +++ b/tools/python/xen/web/connection.py	Tue Apr 07 11:32:24 2009 +0900
    32.3 @@ -317,6 +317,8 @@ class SocketDgramListener:
    32.4  
    32.5      def main(self):
    32.6          try:
    32.7 +            fcntl.fcntl(self.sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC)
    32.8 +
    32.9              while True:
   32.10                  try:
   32.11                      data = self.sock.recv(BUFFER_SIZE)
    33.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Apr 07 11:29:44 2009 +0900
    33.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Apr 07 11:32:24 2009 +0900
    33.3 @@ -1352,6 +1352,9 @@ class XendAPI(object):
    33.4      def VM_get_is_a_template(self, session, ref):
    33.5          return self.VM_get('is_a_template', session, ref)
    33.6      
    33.7 +    def VM_get_auto_power_on(self, session, vm_ref):
    33.8 +        return self.VM_get('auto_power_on', session, vm_ref)
    33.9 +    
   33.10      def VM_get_memory_dynamic_max(self, session, vm_ref):
   33.11          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
   33.12          return xen_api_success(dom.get_memory_dynamic_max())
   33.13 @@ -1441,6 +1444,9 @@ class XendAPI(object):
   33.14          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
   33.15          return xen_api_todo()
   33.16      
   33.17 +    def VM_set_auto_power_on(self, session, vm_ref, val):
   33.18 +        return self.VM_set('auto_power_on', session, vm_ref, val)
   33.19 +    
   33.20      def VM_set_memory_dynamic_max(self, session, vm_ref, mem):
   33.21          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
   33.22          dom.set_memory_dynamic_max(int(mem))
   33.23 @@ -1682,7 +1688,7 @@ class XendAPI(object):
   33.24              'name_description': xeninfo.getName(),
   33.25              'user_version': 1,
   33.26              'is_a_template': xeninfo.info['is_a_template'],
   33.27 -            'auto_power_on': False,
   33.28 +            'auto_power_on': xeninfo.info['auto_power_on'],
   33.29              'resident_on': XendNode.instance().uuid,
   33.30              'memory_static_min': xeninfo.get_memory_static_min(),
   33.31              'memory_static_max': xeninfo.get_memory_static_max(),
    34.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Apr 07 11:29:44 2009 +0900
    34.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Apr 07 11:32:24 2009 +0900
    34.3 @@ -187,6 +187,7 @@ XENAPI_CFG_TYPES = {
    34.4      'name_description': str,
    34.5      'user_version': str,
    34.6      'is_a_template': bool0,
    34.7 +    'auto_power_on': bool0,
    34.8      'resident_on': str,
    34.9      'memory_static_min': int,  # note these are stored in bytes, not KB!
   34.10      'memory_static_max': int,
   34.11 @@ -361,6 +362,7 @@ class XendConfig(dict):
   34.12              'actions_after_crash': 'restart',
   34.13              'actions_after_suspend': '',
   34.14              'is_a_template': False,
   34.15 +            'auto_power_on': False,
   34.16              'is_control_domain': False,
   34.17              'features': '',
   34.18              'PV_bootloader': '',
   34.19 @@ -1410,6 +1412,21 @@ class XendConfig(dict):
   34.20                  if dev_uuid not in target['console_refs']:
   34.21                      target['console_refs'].append(dev_uuid)
   34.22  
   34.23 +		# Cope with old-format save files which say under vfb
   34.24 +		# (type vfb) rather than (vfb 1)
   34.25 +		try:
   34.26 +		    vfb_type = dev_info['type']
   34.27 +		except KeyError:
   34.28 +		    vfb_type = None
   34.29 +		log.debug("iwj dev_type=%s vfb type %s" %
   34.30 +			(dev_type, `vfb_type`))
   34.31 +
   34.32 +		if vfb_type == 'vnc' or vfb_type == 'sdl':
   34.33 +		    dev_info[vfb_type] = 1
   34.34 +		    del dev_info['type']
   34.35 +		    log.debug("iwj dev_type=%s vfb setting dev_info['%s']" %
   34.36 +				(dev_type, vfb_type))
   34.37 +                
   34.38              elif dev_type == 'console':
   34.39                  if 'console_refs' not in target:
   34.40                      target['console_refs'] = []
   34.41 @@ -1895,6 +1912,7 @@ class XendConfig(dict):
   34.42              for key, val in cfg_xenapi.items():
   34.43                  dev_info[key] = val
   34.44              self['devices'][dev_uuid] = (dev_type, dev_info)
   34.45 +            return True
   34.46  
   34.47          return False
   34.48  
    35.1 --- a/tools/python/xen/xend/XendConstants.py	Tue Apr 07 11:29:44 2009 +0900
    35.2 +++ b/tools/python/xen/xend/XendConstants.py	Tue Apr 07 11:32:24 2009 +0900
    35.3 @@ -105,13 +105,15 @@ LAST_SHUTDOWN_REASON = 'xend/last_shutdo
    35.4  TRIGGER_NMI   = 0
    35.5  TRIGGER_RESET = 1
    35.6  TRIGGER_INIT  = 2
    35.7 -TRIGGER_S3RESUME = 3
    35.8 +TRIGGER_POWER = 3
    35.9 +TRIGGER_S3RESUME = 4
   35.10  
   35.11  TRIGGER_TYPE = {
   35.12      "nmi"   : TRIGGER_NMI,
   35.13      "reset" : TRIGGER_RESET,
   35.14      "init"  : TRIGGER_INIT,
   35.15 -    "s3resume": TRIGGER_S3RESUME
   35.16 +    "s3resume": TRIGGER_S3RESUME,
   35.17 +    "power": TRIGGER_POWER
   35.18  }
   35.19  
   35.20  #
    37.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 07 11:29:44 2009 +0900
    37.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 07 11:32:24 2009 +0900
    37.3 @@ -144,6 +144,7 @@ def recreate(info, priv):
    37.4      xeninfo = XendConfig.XendConfig(dominfo = info)
    37.5      xeninfo['is_control_domain'] = priv
    37.6      xeninfo['is_a_template'] = False
    37.7 +    xeninfo['auto_power_on'] = False
    37.8      domid = xeninfo['domid']
    37.9      uuid1 = uuid.fromString(xeninfo['uuid'])
   37.10      needs_reinitialising = False
   37.11 @@ -619,7 +620,7 @@ class XendDomainInfo:
   37.12              pci_devs = pci_conf['devs']
   37.13              for x in pci_devs:
   37.14                  if (int(x['vslt'], 16) == int(new_dev['vslt'], 16) and
   37.15 -                   int(x['vslt'], 16) != 0 ):
   37.16 +                   int(x['vslt'], 16) != AUTO_PHP_SLOT):
   37.17                      raise VmError("vslot %s already have a device." % (new_dev['vslt']))
   37.18  
   37.19                  if (int(x['domain'], 16) == int(new_dev['domain'], 16) and
   37.20 @@ -723,6 +724,13 @@ class XendDomainInfo:
   37.21          dev_config_dict = self.info['devices'][dev_uuid][1]
   37.22          log.debug("XendDomainInfo.device_create: %s" % scrub_password(dev_config_dict))
   37.23  
   37.24 +        if dev_type == 'vif':
   37.25 +            for x in dev_config:
   37.26 +                if x != 'vif' and x[0] == 'mac':
   37.27 +                    if not re.match('^([0-9a-f]{2}:){5}[0-9a-f]{2}$', x[1], re.I):
   37.28 +                        log.error("Virtual network interface creation error - invalid MAC Address entered: %s", x[1])
   37.29 +                        raise VmError("Cannot create a new virtual network interface - MAC address is not valid!");
   37.30 +
   37.31          if self.domid is not None:
   37.32              try:
   37.33                  dev_config_dict['devid'] = devid = \
   37.34 @@ -1045,7 +1053,7 @@ class XendDomainInfo:
   37.35          if devnum >= pci_len:
   37.36              raise VmError("Device @ vslot 0x%x doesn't exist." % (vslot))
   37.37  
   37.38 -        if vslot == 0:
   37.39 +        if vslot == AUTO_PHP_SLOT:
   37.40              raise VmError("Device @ vslot 0x%x do not support hotplug." % (vslot))
   37.41  
   37.42          # Check the co-assignment.
   37.43 @@ -1597,9 +1605,6 @@ class XendDomainInfo:
   37.44          # convert two lists into a python dictionary
   37.45          vm_details = dict(zip(cfg_vm, vm_details))
   37.46  
   37.47 -        if vm_details['rtc/timeoffset'] == None:
   37.48 -            vm_details['rtc/timeoffset'] = "0"
   37.49 -
   37.50          for arg, val in vm_details.items():
   37.51              if arg in XendConfig.LEGACY_CFG_TO_XENAPI_CFG:
   37.52                  xapiarg = XendConfig.LEGACY_CFG_TO_XENAPI_CFG[arg]
   37.53 @@ -1621,10 +1626,10 @@ class XendDomainInfo:
   37.54              self.info.update_with_image_sxp(sxp.from_string(image_sxp))
   37.55              changed = True
   37.56  
   37.57 -        # Check if the rtc offset has changes
   37.58 -        if vm_details.get("rtc/timeoffset", "0") != self.info["platform"].get("rtc_timeoffset", "0"):
   37.59 -            self.info["platform"]["rtc_timeoffset"] = vm_details.get("rtc/timeoffset", 0)
   37.60 -            changed = True
   37.61 +        # Update the rtc_timeoffset to be preserved across reboot.
   37.62 +        # NB. No need to update xenstore domain section.
   37.63 +        val = int(vm_details.get("rtc/timeoffset", 0))
   37.64 +        self.info["platform"]["rtc_timeoffset"] = val
   37.65   
   37.66          if changed:
   37.67              # Update the domain section of the store, as this contains some
   37.68 @@ -2245,8 +2250,9 @@ class XendDomainInfo:
   37.69          # There is an implicit memory overhead for any domain creation. This
   37.70          # overhead is greater for some types of domain than others. For
   37.71          # example, an x86 HVM domain will have a default shadow-pagetable
   37.72 -        # allocation of 1MB. We free up 2MB here to be on the safe side.
   37.73 -        balloon.free(2*1024, self) # 2MB should be plenty
   37.74 +        # allocation of 1MB. We free up 4MB here to be on the safe side.
   37.75 +        # 2MB memory allocation was not enough in some cases, so it's 4MB now
   37.76 +        balloon.free(4*1024, self) # 4MB should be plenty
   37.77  
   37.78          ssidref = 0
   37.79          if security.on() == xsconstants.XS_POLICY_USE:
   37.80 @@ -2305,6 +2311,21 @@ class XendDomainInfo:
   37.81          # Set maximum number of vcpus in domain
   37.82          xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
   37.83  
   37.84 +        # Check for cpu_{cap|weight} validity for credit scheduler
   37.85 +        if XendNode.instance().xenschedinfo() == 'credit':
   37.86 +            cap = self.getCap()
   37.87 +            weight = self.getWeight()
   37.88 +
   37.89 +            assert type(weight) == int
   37.90 +            assert type(cap) == int
   37.91 +
   37.92 +            if weight < 1 or weight > 65535:
   37.93 +                raise VmError("Cpu weight out of range, valid values are within range from 1 to 65535")
   37.94 +
   37.95 +            if cap < 0 or cap > self.getVCpuCount() * 100:
   37.96 +                raise VmError("Cpu cap out of range, valid range is from 0 to %s for specified number of vcpus" %
   37.97 +                              (self.getVCpuCount() * 100))
   37.98 +
   37.99          # Test whether the devices can be assigned with VT-d
  37.100          pci = self.info["platform"].get("pci")
  37.101          pci_str = ''
  37.102 @@ -2416,12 +2437,6 @@ class XendDomainInfo:
  37.103          self._configureBootloader()
  37.104  
  37.105          try:
  37.106 -            if self.info['platform'].get('localtime', 0):
  37.107 -                if time.localtime(time.time())[8]:
  37.108 -                    self.info['platform']['rtc_timeoffset'] = -time.altzone
  37.109 -                else:
  37.110 -                    self.info['platform']['rtc_timeoffset'] = -time.timezone
  37.111 -
  37.112              self.image = image.create(self, self.info)
  37.113  
  37.114              # repin domain vcpus if a restricted cpus list is provided
    38.1 --- a/tools/python/xen/xend/XendNode.py	Tue Apr 07 11:29:44 2009 +0900
    38.2 +++ b/tools/python/xen/xend/XendNode.py	Tue Apr 07 11:32:24 2009 +0900
    38.3 @@ -363,6 +363,8 @@ class XendNode:
    38.4          ppci_uuid = saved_ppci_table.get(pci_dev.name, uuid.createString())
    38.5          XendPPCI(ppci_uuid, ppci_record)
    38.6  
    38.7 +        self.save_PPCIs()
    38.8 +
    38.9  
   38.10      def remove_PPCI(self, pci_name):
   38.11          # Update lspci info
   38.12 @@ -373,15 +375,41 @@ class XendNode:
   38.13          ppci_ref = XendPPCI.get_by_sbdf(domain, bus, slot, func)
   38.14          XendAPIStore.get(ppci_ref, "PPCI").destroy()
   38.15  
   38.16 -
   38.17 -    def add_PSCSI(self):
   38.18 -        # TODO
   38.19 -        log.debug("add_network(): Not implemented.")
   38.20 +        self.save_PPCIs()
   38.21  
   38.22  
   38.23 -    def remove_PSCSI(self):
   38.24 -        # TODO
   38.25 -        log.debug("add_network(): Not implemented.")
   38.26 +    def add_PSCSI(self, add_HCTL):
   38.27 +        saved_pscsis = self.state_store.load_state('pscsi')
   38.28 +        saved_pscsi_table = {}
   38.29 +        if saved_pscsis:
   38.30 +            for saved_uuid, saved_record in saved_pscsis.items():
   38.31 +                try:
   38.32 +                    saved_pscsi_table[saved_record['scsi_id']] = saved_uuid
   38.33 +                except KeyError:
   38.34 +                    pass
   38.35 +
   38.36 +        # Initialise the PSCSI
   38.37 +        pscsi_record = vscsi_util.get_scsi_device(add_HCTL)
   38.38 +        if pscsi_record and pscsi_record['scsi_id']:
   38.39 +            pscsi_uuid = saved_pscsi_table.get(pscsi_record['scsi_id'], None)
   38.40 +            if pscsi_uuid is None:
   38.41 +                pscsi_uuid = uuid.createString()
   38.42 +                XendPSCSI(pscsi_uuid, pscsi_record)
   38.43 +                self.save_PSCSIs()
   38.44 +
   38.45 +
   38.46 +    def remove_PSCSI(self, rem_HCTL):
   38.47 +        saved_pscsis = self.state_store.load_state('pscsi')
   38.48 +        if not saved_pscsis:
   38.49 +            return
   38.50 +
   38.51 +        # Remove the PSCSI
   38.52 +        for pscsi_record in saved_pscsis.values():
   38.53 +            if rem_HCTL == pscsi_record['physical_HCTL']:
   38.54 +                pscsi_ref = XendPSCSI.get_by_HCTL(rem_HCTL)
   38.55 +                XendAPIStore.get(pscsi_ref, "PSCSI").destroy()
   38.56 +                self.save_PSCSIs()
   38.57 +                return
   38.58  
   38.59  
   38.60  ##    def network_destroy(self, net_uuid):
   38.61 @@ -802,6 +830,43 @@ class XendNode:
   38.62  
   38.63          return [[k, info[k]] for k in ITEM_ORDER]
   38.64  
   38.65 +
   38.66 +    def pciinfo(self):
   38.67 +        # Each element of dev_list is a PciDevice
   38.68 +        dev_list = PciUtil.find_all_devices_owned_by_pciback()
   38.69 + 
   38.70 +        # Each element of devs_list is a list of PciDevice
   38.71 +        devs_list = PciUtil.check_FLR_capability(dev_list)
   38.72 + 
   38.73 +        devs_list = PciUtil.check_mmio_bar(devs_list)
   38.74 + 
   38.75 +        # Check if the devices have been assigned to guests.
   38.76 +        final_devs_list = []
   38.77 +        for dev_list in devs_list:
   38.78 +            available = True
   38.79 +            for d in dev_list:
   38.80 +                pci_str = '0x%x,0x%x,0x%x,0x%x' %(d.domain, d.bus, d.slot, d.func)
   38.81 +                # Xen doesn't care what the domid is, so we pass 0 here...
   38.82 +                domid = 0
   38.83 +                bdf = self.xc.test_assign_device(domid, pci_str)
   38.84 +                if bdf != 0:
   38.85 +                    available = False
   38.86 +                    break
   38.87 +            if available:
   38.88 +                final_devs_list = final_devs_list + [dev_list]
   38.89 +
   38.90 +        pci_sxp_list = []
   38.91 +        for dev_list in final_devs_list:
   38.92 +            for d in dev_list:
   38.93 +                pci_sxp = ['dev', ['domain', '0x%04x' % d.domain],
   38.94 +                                  ['bus', '0x%02x' % d.bus],
   38.95 +                                  ['slot', '0x%02x' % d.slot],
   38.96 +                                  ['func', '0x%x' % d.func]]
   38.97 +                pci_sxp_list.append(pci_sxp)
   38.98 +
   38.99 +        return pci_sxp_list
  38.100 + 
  38.101 +
  38.102      def xenschedinfo(self):
  38.103          sched_id = self.xc.sched_id_get()
  38.104          if sched_id == xen.lowlevel.xc.XEN_SCHEDULER_SEDF:
    39.1 --- a/tools/python/xen/xend/image.py	Tue Apr 07 11:29:44 2009 +0900
    39.2 +++ b/tools/python/xen/xend/image.py	Tue Apr 07 11:32:24 2009 +0900
    39.3 @@ -119,9 +119,14 @@ class ImageHandler:
    39.4          self.vncconsole = int(vmConfig['platform'].get('vncconsole', 0))
    39.5          self.dmargs = self.parseDeviceModelArgs(vmConfig)
    39.6          self.pid = None
    39.7 -        rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
    39.8 -        if rtc_timeoffset is not None:
    39.9 -            xc.domain_set_time_offset(self.vm.getDomid(), int(rtc_timeoffset))
   39.10 +        rtc_timeoffset = int(vmConfig['platform'].get('rtc_timeoffset', 0))
   39.11 +        if vmConfig['platform'].get('localtime', 0):
   39.12 +            if time.localtime(time.time())[8]:
   39.13 +                rtc_timeoffset -= time.altzone
   39.14 +            else:
   39.15 +                rtc_timeoffset -= time.timezone
   39.16 +        if rtc_timeoffset != 0:
   39.17 +            xc.domain_set_time_offset(self.vm.getDomid(), rtc_timeoffset)
   39.18  
   39.19          self.cpuid = None
   39.20          self.cpuid_check = None
   39.21 @@ -488,7 +493,10 @@ class ImageHandler:
   39.22  
   39.23      def _dmfailed(self, message):
   39.24          log.warning("domain %s: %s", self.vm.getName(), message)
   39.25 -        xc.domain_shutdown(self.vm.getDomid(), DOMAIN_CRASH)
   39.26 +        try:
   39.27 +            xc.domain_shutdown(self.vm.getDomid(), DOMAIN_CRASH)
   39.28 +        except:
   39.29 +            pass
   39.30  
   39.31      def recreate(self):
   39.32          if self.device_model is None:
   39.33 @@ -526,8 +534,8 @@ class ImageHandler:
   39.34          try: self.sentinel_fifo.read(1)
   39.35          except OSError, e: pass
   39.36          self.sentinel_lock.acquire()
   39.37 -        try:
   39.38 -            if self.pid:
   39.39 +        if self.pid:
   39.40 +            try:
   39.41                  (p,st) = os.waitpid(self.pid, os.WNOHANG)
   39.42                  if p == self.pid:
   39.43                      message = oshelp.waitstatus_description(st)
   39.44 @@ -539,15 +547,15 @@ class ImageHandler:
   39.45                      except:
   39.46                          message = "malfunctioning or died ?"
   39.47                  message = "pid %d: %s" % (self.pid, message)
   39.48 -            else:
   39.49 -                message = "no longer running"
   39.50 -        except Exception, e:
   39.51 -            message = "waitpid failed: %s" % utils.exception_string(e)
   39.52 -        message = "device model failure: %s" % message
   39.53 -        try: message += "; see %s " % self.logfile
   39.54 -        except: pass
   39.55 -        self._dmfailed(message)
   39.56 -        self.pid = None
   39.57 +            except Exception, e:
   39.58 +                message = "waitpid failed: %s" % utils.exception_string(e)
   39.59 +            message = "device model failure: %s" % message
   39.60 +            try: message += "; see %s " % self.logfile
   39.61 +            except: pass
   39.62 +            self._dmfailed(message)
   39.63 +            self.pid = None
   39.64 +        else:
   39.65 +            log.info("%s device model terminated", self.vm.getName())
   39.66          self.sentinel_lock.release()
   39.67  
   39.68      def destroyDeviceModel(self):
   39.69 @@ -778,6 +786,14 @@ class HVMImageHandler(ImageHandler):
   39.70                      if v: ret.append("-%s" % a)
   39.71                  except (ValueError, TypeError):
   39.72                      pass # if we can't convert it to a sane type, ignore it
   39.73 +            elif a == 'serial':
   39.74 +                if v:
   39.75 +                    if type(v) == str:
   39.76 +                        v = [v]
   39.77 +                    for s in v:
   39.78 +                        if s:
   39.79 +                            ret.append("-serial")
   39.80 +                            ret.append("%s" % s)
   39.81              else:
   39.82                  if v:
   39.83                      ret.append("-%s" % a)
    40.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Tue Apr 07 11:29:44 2009 +0900
    40.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Tue Apr 07 11:32:24 2009 +0900
    40.3 @@ -198,7 +198,8 @@ class XMLRPCServer:
    40.4                      self.server.register_function(fn, "xend.domain.%s" % name[7:])
    40.5  
    40.6          # Functions in XendNode and XendDmesg
    40.7 -        for type, lst, n in [(XendNode, ['info', 'send_debug_keys'], 'node'),
    40.8 +        for type, lst, n in [(XendNode, ['info', 'pciinfo', 'send_debug_keys'],
    40.9 +                             'node'),
   40.10                               (XendDmesg, ['info', 'clear'], 'node.dmesg')]:
   40.11              inst = type.instance()
   40.12              for name in lst:
    41.1 --- a/tools/python/xen/xend/server/pciif.py	Tue Apr 07 11:29:44 2009 +0900
    41.2 +++ b/tools/python/xen/xend/server/pciif.py	Tue Apr 07 11:32:24 2009 +0900
    41.3 @@ -90,6 +90,7 @@ class PciController(DevController):
    41.4              back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
    41.5                                          (domain, bus, slot, func)
    41.6              back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
    41.7 +            back['vslot-%i' % pcidevid] = "%02x" % vslot
    41.8              pcidevid += 1
    41.9  
   41.10          if vslots != "":
    42.1 --- a/tools/python/xen/xend/server/udevevent.py	Tue Apr 07 11:29:44 2009 +0900
    42.2 +++ b/tools/python/xen/xend/server/udevevent.py	Tue Apr 07 11:32:24 2009 +0900
    42.3 @@ -40,13 +40,25 @@ class UdevEventProtocol(protocol.Protoco
    42.4                      log.info("Removing pci device %s", pci_name)
    42.5                      XendNode.instance().remove_PPCI(pci_name)
    42.6  
    42.7 -            elif (udev_event.get('SUBSYSTEMS', None) == 'scsi'):
    42.8 +            elif (udev_event.get('SUBSYSTEM', None) == 'scsi'):
    42.9 +                hctl = None
   42.10 +                devpath = udev_event.get('DEVPATH', None)
   42.11 +                if devpath:
   42.12 +                    hctl = devpath.split('/')[-1]
   42.13 +                    if len(hctl.split(':')) != 4:
   42.14 +                        hctl = None
   42.15 +                if hctl is None:
   42.16 +                    # By any possibility, if an HCTL isn't gotten from
   42.17 +                    # the udev event, the udev event is ignored.
   42.18 +                    log.warn("Invalid udev event about scsi received")
   42.19 +                    return
   42.20 +
   42.21                  if (udev_event['ACTION'] == 'add'):
   42.22 -                    log.info("Adding scsi device")
   42.23 -                    XendNode.instance().add_PSCSI()
   42.24 +                    log.info("Adding scsi device %s", hctl)
   42.25 +                    XendNode.instance().add_PSCSI(hctl)
   42.26                  elif (udev_event['ACTION'] == 'remove'):
   42.27 -                    log.info("Removing scci device")
   42.28 -                    XendNode.instance().remove_PSCSI()
   42.29 +                    log.info("Removing scsi device %s", hctl)
   42.30 +                    XendNode.instance().remove_PSCSI(hctl)
   42.31  
   42.32              elif (udev_event.get('SUBSYSTEM', None) == 'net'):
   42.33                  interface = udev_event.get('INTERFACE', None)
    43.1 --- a/tools/python/xen/xend/server/vfbif.py	Tue Apr 07 11:29:44 2009 +0900
    43.2 +++ b/tools/python/xen/xend/server/vfbif.py	Tue Apr 07 11:32:24 2009 +0900
    43.3 @@ -6,7 +6,7 @@ import xen.xend
    43.4  import os
    43.5  
    43.6  CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
    43.7 -                  'videoram', 'display', 'xauthority', 'keymap',
    43.8 +                  'videoram', 'display', 'xauthority', 'keymap', 'vnc', 'sdl',
    43.9                    'uuid', 'location', 'protocol', 'opengl']
   43.10  
   43.11  class VfbifController(DevController):
    44.1 --- a/tools/python/xen/xm/create.py	Tue Apr 07 11:29:44 2009 +0900
    44.2 +++ b/tools/python/xen/xm/create.py	Tue Apr 07 11:32:24 2009 +0900
    44.3 @@ -204,7 +204,7 @@ gopts.var('cpus', val='CPUS',
    44.4            use="CPUS to run the domain on.")
    44.5  
    44.6  gopts.var('rtc_timeoffset', val='RTC_TIMEOFFSET',
    44.7 -          fn=set_value, default="0",
    44.8 +          fn=set_int, default=0,
    44.9            use="Set RTC offset.")
   44.10  
   44.11  gopts.var('pae', val='PAE',
   44.12 @@ -1057,7 +1057,7 @@ def preprocess_pci(vals):
   44.13                  r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + \
   44.14                  r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + \
   44.15                  r"(?P<func>[0-7])" + \
   44.16 -                r"(@(?P<vslot>[0-9a-fA-F]))?" + \
   44.17 +                r"(@(?P<vslot>[01]?[0-9a-fA-F]))?" + \
   44.18                  r"(,(?P<opts>.*))?$", \
   44.19                  pci_dev_str)
   44.20          if pci_match!=None:
   44.21 @@ -1081,7 +1081,7 @@ def preprocess_vscsi(vals):
   44.22      if not vals.vscsi: return
   44.23      scsi = []
   44.24      for scsi_str in vals.vscsi:
   44.25 -        d = scsi_str.split(',')
   44.26 +        d = [tmp.strip() for tmp in scsi_str.split(',')]
   44.27          n = len(d)
   44.28          if n == 2:
   44.29              tmp = d[1].split(':')
    45.1 --- a/tools/python/xen/xm/main.py	Tue Apr 07 11:29:44 2009 +0900
    45.2 +++ b/tools/python/xen/xm/main.py	Tue Apr 07 11:32:24 2009 +0900
    45.3 @@ -58,13 +58,6 @@ from xen.util.acmpolicy import ACM_LABEL
    45.4  
    45.5  import XenAPI
    45.6  
    45.7 -import xen.lowlevel.xc
    45.8 -try:
    45.9 -    xc = xen.lowlevel.xc.xc()
   45.10 -except Exception, ex:
   45.11 -    print >>sys.stderr, ("Is xen kernel running?")
   45.12 -    sys.exit(1)
   45.13 -
   45.14  import inspect
   45.15  from xen.xend import XendOptions
   45.16  xoptions = XendOptions.instance()
   45.17 @@ -158,7 +151,7 @@ SUBCOMMAND_HELP = {
   45.18                       'Get/set credit scheduler parameters.'),
   45.19      'sysrq'       : ('<Domain> <letter>', 'Send a sysrq to a domain.'),
   45.20      'debug-keys'  : ('<Keys>', 'Send debug keys to Xen.'),
   45.21 -    'trigger'     : ('<Domain> <nmi|reset|init|s3resume> [<VCPU>]',
   45.22 +    'trigger'     : ('<Domain> <nmi|reset|init|s3resume|power> [<VCPU>]',
   45.23                       'Send a trigger to a domain.'),
   45.24      'vcpu-list'   : ('[Domain, ...]',
   45.25                       'List the VCPUs for all/some domains.'),
   45.26 @@ -2188,34 +2181,28 @@ def xm_pci_list(args):
   45.27              hdr = 1
   45.28          print ( fmt_str % x )
   45.29  
   45.30 +
   45.31 +def parse_pci_info(info):
   45.32 +    def get_info(n, t, d):
   45.33 +        return t(sxp.child_value(info, n, d))
   45.34 +    return {
   45.35 +        'domain' : get_info('domain', parse_hex, 0),
   45.36 +        'bus'    : get_info('bus', parse_hex, -1),
   45.37 +        'slot'   : get_info('slot', parse_hex, -1),
   45.38 +        'func'   : get_info('func', parse_hex, -1)
   45.39 +        }
   45.40 +
   45.41  def xm_pci_list_assignable_devices(args):
   45.42 -    # Each element of dev_list is a PciDevice
   45.43 -    dev_list = find_all_devices_owned_by_pciback()
   45.44 -
   45.45 -    # Each element of devs_list is a list of PciDevice
   45.46 -    devs_list = check_FLR_capability(dev_list)
   45.47 -
   45.48 -    devs_list = check_mmio_bar(devs_list)
   45.49 -
   45.50 -    # Check if the devices have been assigned to guests.
   45.51 -    final_devs_list = []
   45.52 -    for dev_list in devs_list:
   45.53 -        available = True
   45.54 -        for d in dev_list:
   45.55 -            pci_str = '0x%x,0x%x,0x%x,0x%x' %(d.domain, d.bus, d.slot, d.func)
   45.56 -            # Xen doesn't care what the domid is, so we pass 0 here...
   45.57 -            domid = 0
   45.58 -            bdf = xc.test_assign_device(domid, pci_str)
   45.59 -            if bdf != 0:
   45.60 -                available = False
   45.61 -                break
   45.62 -        if available:
   45.63 -            final_devs_list = final_devs_list + [dev_list]
   45.64 -
   45.65 -    for dev_list in final_devs_list:
   45.66 -        for d in dev_list:
   45.67 -            print d.name,
   45.68 -        print
   45.69 +    xenapi_unsupported()
   45.70 +    arg_check(args, "pci-list-assignable-devices", 0)
   45.71 +
   45.72 +    devs =  server.xend.node.pciinfo()
   45.73 + 
   45.74 +    fmt_str = "%(domain)04x:%(bus)02x:%(slot)02x:%(func)01x"
   45.75 +    for x in devs:
   45.76 +        pci = parse_pci_info(x)
   45.77 +        print fmt_str % pci
   45.78 +
   45.79  
   45.80  def vscsi_sort(devs):
   45.81      def sort_hctl(ds, l):
    46.1 --- a/tools/python/xen/xm/xenapi_create.py	Tue Apr 07 11:29:44 2009 +0900
    46.2 +++ b/tools/python/xen/xm/xenapi_create.py	Tue Apr 07 11:32:24 2009 +0900
    46.3 @@ -218,8 +218,8 @@ class xenapi_create:
    46.4              "SR":               self.DEFAULT_STORAGE_REPOSITORY,  
    46.5              "virtual_size":     vdi.attributes["size"].value,
    46.6              "type":             vdi.attributes["type"].value,
    46.7 -            "sharable":         bool(vdi.attributes["sharable"].value),
    46.8 -            "read_only":        bool(vdi.attributes["read_only"].value),
    46.9 +            "sharable":         vdi.attributes["sharable"].value == "True",
   46.10 +            "read_only":        vdi.attributes["read_only"].value == "True",
   46.11              "other_config":     {"location":
   46.12                  vdi.attributes["src"].value}
   46.13              }
   46.14 @@ -804,6 +804,7 @@ class sxp2xml:
   46.15  
   46.16      def extract_vbd(self, vbd_sxp, document):
   46.17          src = get_child_by_name(vbd_sxp, "uname")
   46.18 +        mode = get_child_by_name(vbd_sxp, "mode")
   46.19          name = str(src.__hash__())
   46.20  
   46.21          vbd = document.createElement("vbd")
   46.22 @@ -811,8 +812,7 @@ class sxp2xml:
   46.23          vbd.attributes["name"] = "vdb" + name
   46.24          vbd.attributes["vdi"] = "vdi" + name
   46.25          vbd.attributes["mode"] \
   46.26 -            = get_child_by_name(vbd_sxp, "mode") != "w" \
   46.27 -              and "RO" or "RW"
   46.28 +            = re.search("^w!{0,1}$", mode) and "RW" or "RO"
   46.29          vbd.attributes["device"] \
   46.30              = re.sub(":cdrom$", "", get_child_by_name(vbd_sxp, "dev"))
   46.31          vbd.attributes["bootable"] = "1"
   46.32 @@ -825,17 +825,18 @@ class sxp2xml:
   46.33  
   46.34      def extract_vdi(self, vbd_sxp, document):
   46.35          src = get_child_by_name(vbd_sxp, "uname")
   46.36 +        mode = get_child_by_name(vbd_sxp, "mode")
   46.37          name = "vdi" + str(src.__hash__())
   46.38  
   46.39          vdi = document.createElement("vdi")
   46.40  
   46.41          vdi.attributes["src"] = src
   46.42          vdi.attributes["read_only"] \
   46.43 -            = (get_child_by_name(vbd_sxp, "mode") != "w") \
   46.44 -               and "True" or "False"
   46.45 +            = re.search("^w!{0,1}$", mode) and "False" or "True"
   46.46          vdi.attributes["size"] = '-1'
   46.47          vdi.attributes["type"] = "system"
   46.48 -        vdi.attributes["sharable"] = "False"
   46.49 +        vdi.attributes["sharable"] \
   46.50 +            = re.search("^w!$", mode) and "True" or "False"
   46.51          vdi.attributes["name"] = name
   46.52  
   46.53          vdi.appendChild(self.make_name_tag(name, document))
    47.1 --- a/tools/xentrace/xenctx.c	Tue Apr 07 11:29:44 2009 +0900
    47.2 +++ b/tools/xentrace/xenctx.c	Tue Apr 07 11:32:24 2009 +0900
    47.3 @@ -42,6 +42,7 @@ typedef unsigned long long guest_word_t;
    47.4  int guest_word_size = sizeof (unsigned long);
    47.5  /* Word-length of the context record we get from xen */
    47.6  int ctxt_word_size = sizeof (unsigned long);
    47.7 +int guest_protected_mode = 1;
    47.8  #elif defined (__ia64__)
    47.9  /* On ia64, we can't translate virtual address to physical address.  */
   47.10  #define NO_TRANSLATION
   47.11 @@ -206,6 +207,7 @@ static void read_symbol_table(const char
   47.12  }
   47.13  
   47.14  #if defined(__i386__) || defined(__x86_64__)
   47.15 +#define CR0_PE  0x1
   47.16  char *flag_values[22][2] =
   47.17  {/*  clear,     set,       bit# */
   47.18      { NULL,     "c"    }, // 0        Carry
   47.19 @@ -371,20 +373,38 @@ static void print_ctx(vcpu_guest_context
   47.20          print_ctx_64(&ctx->x64);
   47.21  }
   47.22  
   47.23 +#define NONPROT_MODE_SEGMENT_SHIFT 4
   47.24 +
   47.25  static guest_word_t instr_pointer(vcpu_guest_context_any_t *ctx)
   47.26  {
   47.27 -    if (ctxt_word_size == 4) 
   47.28 -        return ctx->x32.user_regs.eip;
   47.29 +    guest_word_t r;
   47.30 +    if (ctxt_word_size == 4)
   47.31 +    {
   47.32 +        r = ctx->x32.user_regs.eip;
   47.33 +
   47.34 +        if ( !guest_protected_mode )
   47.35 +            r += ctx->x32.user_regs.cs << NONPROT_MODE_SEGMENT_SHIFT;
   47.36 +    }
   47.37      else 
   47.38 -        return ctx->x64.user_regs.rip;
   47.39 +        r = ctx->x64.user_regs.rip;
   47.40 +
   47.41 +    return r;
   47.42  }
   47.43  
   47.44  static guest_word_t stack_pointer(vcpu_guest_context_any_t *ctx)
   47.45  {
   47.46 -    if (ctxt_word_size == 4) 
   47.47 -        return ctx->x32.user_regs.esp;
   47.48 +    guest_word_t r;
   47.49 +    if (ctxt_word_size == 4)
   47.50 +    {
   47.51 +        r = ctx->x32.user_regs.esp;
   47.52 +
   47.53 +        if ( !guest_protected_mode )
   47.54 +            r += ctx->x32.user_regs.ss << NONPROT_MODE_SEGMENT_SHIFT;
   47.55 +    }
   47.56      else 
   47.57 -        return ctx->x64.user_regs.rsp;
   47.58 +        r = ctx->x64.user_regs.rsp;
   47.59 +    
   47.60 +    return r;
   47.61  }
   47.62  
   47.63  static guest_word_t frame_pointer(vcpu_guest_context_any_t *ctx)
   47.64 @@ -683,12 +703,31 @@ static void print_stack_word(guest_word_
   47.65          printf(FMT_64B_WORD, word);
   47.66  }
   47.67  
   47.68 +static void print_code(vcpu_guest_context_any_t *ctx, int vcpu)
   47.69 +{
   47.70 +    guest_word_t instr;
   47.71 +    int i;
   47.72 +
   47.73 +    instr = instr_pointer(ctx);
   47.74 +    printf("Code (instr addr %08llx)\n", instr);
   47.75 +    instr -= 21;
   47.76 +    for(i=0; i<32; i++) {
   47.77 +        unsigned char *c = map_page(ctx, vcpu, instr+i);
   47.78 +        if (instr+i == instr_pointer(ctx))
   47.79 +            printf("<%02x> ", *c);
   47.80 +        else
   47.81 +            printf("%02x ", *c);
   47.82 +    }
   47.83 +    printf("\n");
   47.84 +
   47.85 +    printf("\n");
   47.86 +}
   47.87 +
   47.88  static void print_stack(vcpu_guest_context_any_t *ctx, int vcpu, int width)
   47.89  {
   47.90      guest_word_t stack = stack_pointer(ctx);
   47.91      guest_word_t stack_limit;
   47.92      guest_word_t frame;
   47.93 -    guest_word_t instr;
   47.94      guest_word_t word;
   47.95      guest_word_t *p;
   47.96      int i;
   47.97 @@ -709,19 +748,6 @@ static void print_stack(vcpu_guest_conte
   47.98      }
   47.99      printf("\n");
  47.100  
  47.101 -    printf("Code:\n");
  47.102 -    instr = instr_pointer(ctx) - 21;
  47.103 -    for(i=0; i<32; i++) {
  47.104 -        unsigned char *c = map_page(ctx, vcpu, instr+i);
  47.105 -        if (instr+i == instr_pointer(ctx))
  47.106 -            printf("<%02x> ", *c);
  47.107 -        else
  47.108 -            printf("%02x ", *c);
  47.109 -    }
  47.110 -    printf("\n");
  47.111 -
  47.112 -    printf("\n");
  47.113 -
  47.114      if(stack_trace)
  47.115          printf("Stack Trace:\n");
  47.116      else
  47.117 @@ -830,6 +856,7 @@ static void dump_ctx(int vcpu)
  47.118                  exit(-1);
  47.119              }
  47.120              guest_word_size = (cpuctx.msr_efer & 0x400) ? 8 : 4;
  47.121 +            guest_protected_mode = (cpuctx.cr0 & CR0_PE);
  47.122              /* HVM guest context records are always host-sized */
  47.123              if (xc_version(xc_handle, XENVER_capabilities, &xen_caps) != 0) {
  47.124                  perror("xc_version");
  47.125 @@ -849,6 +876,7 @@ static void dump_ctx(int vcpu)
  47.126  
  47.127      print_ctx(&ctx);
  47.128  #ifndef NO_TRANSLATION
  47.129 +    print_code(&ctx, vcpu);
  47.130      if (is_kernel_text(instr_pointer(&ctx)))
  47.131          print_stack(&ctx, vcpu, guest_word_size);
  47.132  #endif
    48.1 --- a/xen/arch/ia64/linux-xen/acpi.c	Tue Apr 07 11:29:44 2009 +0900
    48.2 +++ b/xen/arch/ia64/linux-xen/acpi.c	Tue Apr 07 11:32:24 2009 +0900
    48.3 @@ -76,11 +76,7 @@ unsigned int acpi_cpei_phys_cpuid;
    48.4  unsigned long acpi_wakeup_address = 0;
    48.5  
    48.6  #ifdef CONFIG_IA64_GENERIC
    48.7 -#ifndef XEN
    48.8  static unsigned long __init acpi_find_rsdp(void)
    48.9 -#else
   48.10 -unsigned long __init acpi_find_rsdp(void)
   48.11 -#endif
   48.12  {
   48.13  	unsigned long rsdp_phys = 0;
   48.14  
    49.1 --- a/xen/arch/x86/Rules.mk	Tue Apr 07 11:29:44 2009 +0900
    49.2 +++ b/xen/arch/x86/Rules.mk	Tue Apr 07 11:32:24 2009 +0900
    49.3 @@ -42,7 +42,7 @@ x86_64 := n
    49.4  endif
    49.5  
    49.6  ifeq ($(TARGET_SUBARCH),x86_64)
    49.7 -CFLAGS += -mno-red-zone -fpic -fno-reorder-blocks
    49.8 +CFLAGS += -mno-red-zone -fpic
    49.9  CFLAGS += -fno-asynchronous-unwind-tables
   49.10  # -fvisibility=hidden reduces -fpic cost, if it's available
   49.11  ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n)
    50.1 --- a/xen/arch/x86/acpi/boot.c	Tue Apr 07 11:29:44 2009 +0900
    50.2 +++ b/xen/arch/x86/acpi/boot.c	Tue Apr 07 11:32:24 2009 +0900
    50.3 @@ -283,25 +283,6 @@ acpi_parse_nmi_src(struct acpi_subtable_
    50.4  
    50.5  #endif /* CONFIG_X86_IO_APIC */
    50.6  
    50.7 -static unsigned long __init
    50.8 -acpi_scan_rsdp(unsigned long start, unsigned long length)
    50.9 -{
   50.10 -	unsigned long offset = 0;
   50.11 -	unsigned long sig_len = sizeof("RSD PTR ") - 1;
   50.12 -
   50.13 -	/*
   50.14 -	 * Scan all 16-byte boundaries of the physical memory region for the
   50.15 -	 * RSDP signature.
   50.16 -	 */
   50.17 -	for (offset = 0; offset < length; offset += 16) {
   50.18 -		if (strncmp((char *)(start + offset), "RSD PTR ", sig_len))
   50.19 -			continue;
   50.20 -		return (start + offset);
   50.21 -	}
   50.22 -
   50.23 -	return 0;
   50.24 -}
   50.25 -
   50.26  static int __init acpi_parse_sbf(struct acpi_table_header *table)
   50.27  {
   50.28  	struct acpi_table_boot *sb;
   50.29 @@ -371,16 +352,9 @@ extern u32 pmtmr_ioport;
   50.30  static void __init
   50.31  acpi_fadt_parse_sleep_info(struct acpi_table_fadt *fadt)
   50.32  {
   50.33 -	struct acpi_table_rsdp *rsdp;
   50.34 -	unsigned long rsdp_phys;
   50.35  	struct acpi_table_facs *facs = NULL;
   50.36  	uint64_t facs_pa;
   50.37  
   50.38 -	rsdp_phys = acpi_find_rsdp();
   50.39 -	if (!rsdp_phys || acpi_disabled)
   50.40 -		goto bad;
   50.41 -	rsdp = __va(rsdp_phys);
   50.42 -
   50.43  	acpi_fadt_copy_address(pm1a_cnt, pm1a_control, pm1_control);
   50.44  	acpi_fadt_copy_address(pm1b_cnt, pm1b_control, pm1_control);
   50.45  	acpi_fadt_copy_address(pm1a_evt, pm1a_event, pm1_event);
   50.46 @@ -483,29 +457,6 @@ static int __init acpi_parse_fadt(struct
   50.47  	return 0;
   50.48  }
   50.49  
   50.50 -unsigned long __init acpi_find_rsdp(void)
   50.51 -{
   50.52 -	unsigned long rsdp_phys = 0;
   50.53 -
   50.54 -#if 0
   50.55 -	if (efi_enabled) {
   50.56 -		if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
   50.57 -			return efi.acpi20;
   50.58 -		else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
   50.59 -			return efi.acpi;
   50.60 -	}
   50.61 -#endif
   50.62 -	/*
   50.63 -	 * Scan memory looking for the RSDP signature. First search EBDA (low
   50.64 -	 * memory) paragraphs and then search upper memory (E0000-FFFFF).
   50.65 -	 */
   50.66 -	rsdp_phys = acpi_scan_rsdp(0, 0x400);
   50.67 -	if (!rsdp_phys)
   50.68 -		rsdp_phys = acpi_scan_rsdp(0xE0000, 0x20000);
   50.69 -
   50.70 -	return rsdp_phys;
   50.71 -}
   50.72 -
   50.73  #ifdef	CONFIG_X86_LOCAL_APIC
   50.74  /*
   50.75   * Parse LAPIC entries in MADT
    51.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Tue Apr 07 11:29:44 2009 +0900
    51.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Tue Apr 07 11:32:24 2009 +0900
    51.3 @@ -195,6 +195,15 @@ static void acpi_processor_idle(void)
    51.4      int sleep_ticks = 0;
    51.5      u32 t1, t2 = 0;
    51.6  
    51.7 +    sched_tick_suspend();
    51.8 +    /*
    51.9 +     * sched_tick_suspend may raise TIMER_SOFTIRQ by __stop_timer,
   51.10 +     * which will break the later assumption of no sofirq pending,
   51.11 +     * so add do_softirq
   51.12 +     */
   51.13 +    if ( softirq_pending(smp_processor_id()) )
   51.14 +        do_softirq();
   51.15 +
   51.16      /*
   51.17       * Interrupts must be disabled during bus mastering calculations and
   51.18       * for C2/C3 transitions.
   51.19 @@ -204,6 +213,7 @@ static void acpi_processor_idle(void)
   51.20      if ( softirq_pending(smp_processor_id()) )
   51.21      {
   51.22          local_irq_enable();
   51.23 +        sched_tick_resume();
   51.24          return;
   51.25      }
   51.26  
   51.27 @@ -223,6 +233,7 @@ static void acpi_processor_idle(void)
   51.28              pm_idle_save();
   51.29          else
   51.30              acpi_safe_halt();
   51.31 +        sched_tick_resume();
   51.32          return;
   51.33      }
   51.34  
   51.35 @@ -329,6 +340,7 @@ static void acpi_processor_idle(void)
   51.36  
   51.37      default:
   51.38          local_irq_enable();
   51.39 +        sched_tick_resume();
   51.40          return;
   51.41      }
   51.42  
   51.43 @@ -339,6 +351,8 @@ static void acpi_processor_idle(void)
   51.44          cx->time += sleep_ticks;
   51.45      }
   51.46  
   51.47 +    sched_tick_resume();
   51.48 +
   51.49      if ( cpuidle_current_governor->reflect )
   51.50          cpuidle_current_governor->reflect(power);
   51.51  }
    52.1 --- a/xen/arch/x86/acpi/suspend.c	Tue Apr 07 11:29:44 2009 +0900
    52.2 +++ b/xen/arch/x86/acpi/suspend.c	Tue Apr 07 11:32:24 2009 +0900
    52.3 @@ -16,6 +16,7 @@
    52.4  
    52.5  #if defined(CONFIG_X86_64)
    52.6  static unsigned long saved_lstar, saved_cstar;
    52.7 +static unsigned long saved_sysenter_esp, saved_sysenter_eip;
    52.8  #endif
    52.9  
   52.10  void save_rest_processor_state(void)
   52.11 @@ -26,6 +27,11 @@ void save_rest_processor_state(void)
   52.12  #if defined(CONFIG_X86_64)
   52.13      rdmsrl(MSR_CSTAR, saved_cstar);
   52.14      rdmsrl(MSR_LSTAR, saved_lstar);
   52.15 +    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   52.16 +    {
   52.17 +        rdmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp);
   52.18 +        rdmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip);
   52.19 +    }
   52.20  #endif
   52.21  }
   52.22  
   52.23 @@ -41,6 +47,14 @@ void restore_rest_processor_state(void)
   52.24      wrmsrl(MSR_CSTAR, saved_cstar);
   52.25      wrmsr(MSR_STAR, 0, (FLAT_RING3_CS32<<16) | __HYPERVISOR_CS);
   52.26      wrmsr(MSR_SYSCALL_MASK, EF_VM|EF_RF|EF_NT|EF_DF|EF_IE|EF_TF, 0U);    
   52.27 +
   52.28 +    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   52.29 +    {
   52.30 +        /* Recover sysenter MSRs */
   52.31 +        wrmsrl(MSR_IA32_SYSENTER_ESP, saved_sysenter_esp);
   52.32 +        wrmsrl(MSR_IA32_SYSENTER_EIP, saved_sysenter_eip);
   52.33 +        wrmsr(MSR_IA32_SYSENTER_CS, __HYPERVISOR_CS, 0);
   52.34 +    }
   52.35  #else /* !defined(CONFIG_X86_64) */
   52.36      if ( supervisor_mode_kernel && cpu_has_sep )
   52.37          wrmsr(MSR_IA32_SYSENTER_ESP, &init_tss[smp_processor_id()].esp1, 0);
    53.1 --- a/xen/arch/x86/apic.c	Tue Apr 07 11:29:44 2009 +0900
    53.2 +++ b/xen/arch/x86/apic.c	Tue Apr 07 11:32:24 2009 +0900
    53.3 @@ -1303,8 +1303,10 @@ int __init APIC_init_uniprocessor (void)
    53.4      if (enable_local_apic < 0)
    53.5          clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
    53.6  
    53.7 -    if (!smp_found_config && !cpu_has_apic)
    53.8 +    if (!smp_found_config && !cpu_has_apic) {
    53.9 +        skip_ioapic_setup = 1;
   53.10          return -1;
   53.11 +    }
   53.12  
   53.13      /*
   53.14       * Complain if the BIOS pretends there is one.
   53.15 @@ -1313,6 +1315,7 @@ int __init APIC_init_uniprocessor (void)
   53.16          printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
   53.17                 boot_cpu_physical_apicid);
   53.18          clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
   53.19 +        skip_ioapic_setup = 1;
   53.20          return -1;
   53.21      }
   53.22  
    54.1 --- a/xen/arch/x86/cpu/mcheck/mce.c	Tue Apr 07 11:29:44 2009 +0900
    54.2 +++ b/xen/arch/x86/cpu/mcheck/mce.c	Tue Apr 07 11:32:24 2009 +0900
    54.3 @@ -577,6 +577,7 @@ void mcheck_init(struct cpuinfo_x86 *c)
    54.4  		break;
    54.5  	}
    54.6  
    54.7 +    set_poll_bankmask(c);
    54.8  	if (!inited)
    54.9  		printk(XENLOG_INFO "CPU%i: No machine check initialization\n",
   54.10  		    smp_processor_id());
   54.11 @@ -984,14 +985,76 @@ static void x86_mc_mceinject(void *data)
   54.12  #error BITS_PER_LONG definition absent
   54.13  #endif
   54.14  
   54.15 +#ifdef CONFIG_COMPAT
   54.16 +# include <compat/arch-x86/xen-mca.h>
   54.17 +
   54.18 +# define xen_mcinfo_msr              mcinfo_msr
   54.19 +CHECK_mcinfo_msr;
   54.20 +# undef xen_mcinfo_msr
   54.21 +# undef CHECK_mcinfo_msr
   54.22 +# define CHECK_mcinfo_msr            struct mcinfo_msr
   54.23 +
   54.24 +# define xen_mcinfo_common           mcinfo_common
   54.25 +CHECK_mcinfo_common;
   54.26 +# undef xen_mcinfo_common
   54.27 +# undef CHECK_mcinfo_common
   54.28 +# define CHECK_mcinfo_common         struct mcinfo_common
   54.29 +
   54.30 +CHECK_FIELD_(struct, mc_fetch, flags);
   54.31 +CHECK_FIELD_(struct, mc_fetch, fetch_id);
   54.32 +# define CHECK_compat_mc_fetch       struct mc_fetch
   54.33 +
   54.34 +CHECK_FIELD_(struct, mc_physcpuinfo, ncpus);
   54.35 +# define CHECK_compat_mc_physcpuinfo struct mc_physcpuinfo
   54.36 +
   54.37 +CHECK_mc;
   54.38 +# undef CHECK_compat_mc_fetch
   54.39 +# undef CHECK_compat_mc_physcpuinfo
   54.40 +
   54.41 +# define xen_mc_info                 mc_info
   54.42 +CHECK_mc_info;
   54.43 +# undef xen_mc_info
   54.44 +
   54.45 +# define xen_mcinfo_global           mcinfo_global
   54.46 +CHECK_mcinfo_global;
   54.47 +# undef xen_mcinfo_global
   54.48 +
   54.49 +# define xen_mcinfo_bank             mcinfo_bank
   54.50 +CHECK_mcinfo_bank;
   54.51 +# undef xen_mcinfo_bank
   54.52 +
   54.53 +# define xen_mcinfo_extended         mcinfo_extended
   54.54 +CHECK_mcinfo_extended;
   54.55 +# undef xen_mcinfo_extended
   54.56 +
   54.57 +# define xen_mcinfo_recovery         mcinfo_recovery
   54.58 +# define xen_cpu_offline_action      cpu_offline_action
   54.59 +# define xen_page_offline_action     page_offline_action
   54.60 +CHECK_mcinfo_recovery;
   54.61 +# undef xen_cpu_offline_action
   54.62 +# undef xen_page_offline_action
   54.63 +# undef xen_mcinfo_recovery
   54.64 +#else
   54.65 +# define compat_mc_fetch xen_mc_fetch
   54.66 +# define compat_mc_physcpuinfo xen_mc_physcpuinfo
   54.67 +# define compat_handle_is_null guest_handle_is_null
   54.68 +# define copy_to_compat copy_to_guest
   54.69 +#endif
   54.70 +
   54.71  /* Machine Check Architecture Hypercall */
   54.72  long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u_xen_mc)
   54.73  {
   54.74  	long ret = 0;
   54.75  	struct xen_mc curop, *op = &curop;
   54.76  	struct vcpu *v = current;
   54.77 -	struct xen_mc_fetch *mc_fetch;
   54.78 -	struct xen_mc_physcpuinfo *mc_physcpuinfo;
   54.79 +	union {
   54.80 +		struct xen_mc_fetch *nat;
   54.81 +		struct compat_mc_fetch *cmp;
   54.82 +	} mc_fetch;
   54.83 +	union {
   54.84 +		struct xen_mc_physcpuinfo *nat;
   54.85 +		struct compat_mc_physcpuinfo *cmp;
   54.86 +	} mc_physcpuinfo;
   54.87  	uint32_t flags, cmdflags;
   54.88  	int nlcpu;
   54.89  	xen_mc_logical_cpu_t *log_cpus = NULL;
   54.90 @@ -1009,8 +1072,8 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
   54.91  
   54.92  	switch (op->cmd) {
   54.93  	case XEN_MC_fetch:
   54.94 -		mc_fetch = &op->u.mc_fetch;
   54.95 -		cmdflags = mc_fetch->flags;
   54.96 +		mc_fetch.nat = &op->u.mc_fetch;
   54.97 +		cmdflags = mc_fetch.nat->flags;
   54.98  
   54.99  		/* This hypercall is for Dom0 only */
  54.100  		if (!IS_PRIV(v->domain) )
  54.101 @@ -1032,30 +1095,35 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
  54.102  		flags = XEN_MC_OK;
  54.103  
  54.104  		if (cmdflags & XEN_MC_ACK) {
  54.105 -			mctelem_cookie_t cookie = ID2COOKIE(mc_fetch->fetch_id);
  54.106 +			mctelem_cookie_t cookie = ID2COOKIE(mc_fetch.nat->fetch_id);
  54.107  			mctelem_ack(which, cookie);
  54.108  		} else {
  54.109 -			if (guest_handle_is_null(mc_fetch->data))
  54.110 +			if (!is_pv_32on64_vcpu(v)
  54.111 +			    ? guest_handle_is_null(mc_fetch.nat->data)
  54.112 +			    : compat_handle_is_null(mc_fetch.cmp->data))
  54.113  				return x86_mcerr("do_mca fetch: guest buffer "
  54.114  				    "invalid", -EINVAL);
  54.115  
  54.116  			if ((mctc = mctelem_consume_oldest_begin(which))) {
  54.117  				struct mc_info *mcip = mctelem_dataptr(mctc);
  54.118 -				if (copy_to_guest(mc_fetch->data, mcip, 1)) {
  54.119 +				if (!is_pv_32on64_vcpu(v)
  54.120 +				    ? copy_to_guest(mc_fetch.nat->data, mcip, 1)
  54.121 +				    : copy_to_compat(mc_fetch.cmp->data,
  54.122 +						     mcip, 1)) {
  54.123  					ret = -EFAULT;
  54.124  					flags |= XEN_MC_FETCHFAILED;
  54.125 -					mc_fetch->fetch_id = 0;
  54.126 +					mc_fetch.nat->fetch_id = 0;
  54.127  				} else {
  54.128 -					mc_fetch->fetch_id = COOKIE2ID(mctc);
  54.129 +					mc_fetch.nat->fetch_id = COOKIE2ID(mctc);
  54.130  				}
  54.131  				mctelem_consume_oldest_end(mctc);
  54.132  			} else {
  54.133  				/* There is no data */
  54.134  				flags |= XEN_MC_NODATA;
  54.135 -				mc_fetch->fetch_id = 0;
  54.136 +				mc_fetch.nat->fetch_id = 0;
  54.137  			}
  54.138  
  54.139 -			mc_fetch->flags = flags;
  54.140 +			mc_fetch.nat->flags = flags;
  54.141  			if (copy_to_guest(u_xen_mc, op, 1) != 0)
  54.142  				ret = -EFAULT;
  54.143  		}
  54.144 @@ -1069,14 +1137,16 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
  54.145  		if ( !IS_PRIV(v->domain) )
  54.146  			return x86_mcerr("do_mca cpuinfo", -EPERM);
  54.147  
  54.148 -		mc_physcpuinfo = &op->u.mc_physcpuinfo;
  54.149 +		mc_physcpuinfo.nat = &op->u.mc_physcpuinfo;
  54.150  		nlcpu = num_online_cpus();
  54.151  
  54.152 -		if (!guest_handle_is_null(mc_physcpuinfo->info)) {
  54.153 -			if (mc_physcpuinfo->ncpus <= 0)
  54.154 +		if (!is_pv_32on64_vcpu(v)
  54.155 +		    ? !guest_handle_is_null(mc_physcpuinfo.nat->info)
  54.156 +		    : !compat_handle_is_null(mc_physcpuinfo.cmp->info)) {
  54.157 +			if (mc_physcpuinfo.nat->ncpus <= 0)
  54.158  				return x86_mcerr("do_mca cpuinfo: ncpus <= 0",
  54.159  				    -EINVAL);
  54.160 -			nlcpu = min(nlcpu, (int)mc_physcpuinfo->ncpus);
  54.161 +			nlcpu = min(nlcpu, (int)mc_physcpuinfo.nat->ncpus);
  54.162  			log_cpus = xmalloc_array(xen_mc_logical_cpu_t, nlcpu);
  54.163  			if (log_cpus == NULL)
  54.164  				return x86_mcerr("do_mca cpuinfo", -ENOMEM);
  54.165 @@ -1086,22 +1156,20 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
  54.166  				xfree(log_cpus);
  54.167  				return x86_mcerr("do_mca cpuinfo", -EIO);
  54.168  			}
  54.169 -		}
  54.170 -
  54.171 -		mc_physcpuinfo->ncpus = nlcpu;
  54.172 -
  54.173 -		if (copy_to_guest(u_xen_mc, op, 1)) {
  54.174 -			if (log_cpus != NULL)
  54.175 -				xfree(log_cpus);
  54.176 -			return x86_mcerr("do_mca cpuinfo", -EFAULT);
  54.177 -		}
  54.178 -
  54.179 -		if (!guest_handle_is_null(mc_physcpuinfo->info)) {
  54.180 -			if (copy_to_guest(mc_physcpuinfo->info,
  54.181 -			    log_cpus, nlcpu))
  54.182 +			if (!is_pv_32on64_vcpu(v)
  54.183 +			    ? copy_to_guest(mc_physcpuinfo.nat->info,
  54.184 +					    log_cpus, nlcpu)
  54.185 +			    : copy_to_compat(mc_physcpuinfo.cmp->info,
  54.186 +					    log_cpus, nlcpu))
  54.187  				ret = -EFAULT;
  54.188  			xfree(log_cpus);
  54.189  		}
  54.190 +
  54.191 +		mc_physcpuinfo.nat->ncpus = nlcpu;
  54.192 +
  54.193 +		if (copy_to_guest(u_xen_mc, op, 1))
  54.194 +			return x86_mcerr("do_mca cpuinfo", -EFAULT);
  54.195 +
  54.196  		break;
  54.197  
  54.198  	case XEN_MC_msrinject:
  54.199 @@ -1163,7 +1231,19 @@ long do_mca(XEN_GUEST_HANDLE(xen_mc_t) u
  54.200  
  54.201  	return ret;
  54.202  }
  54.203 +void set_poll_bankmask(struct cpuinfo_x86 *c)
  54.204 +{
  54.205  
  54.206 +    if (cmci_support && !mce_disabled) {
  54.207 +        memcpy(&(__get_cpu_var(poll_bankmask)),
  54.208 +                &(__get_cpu_var(no_cmci_banks)), sizeof(cpu_banks_t));
  54.209 +    }
  54.210 +    else {
  54.211 +        memcpy(&(get_cpu_var(poll_bankmask)), &mca_allbanks, sizeof(cpu_banks_t));
  54.212 +        if (mce_firstbank(c))
  54.213 +            clear_bit(0, get_cpu_var(poll_bankmask));
  54.214 +    }
  54.215 +}
  54.216  void mc_panic(char *s)
  54.217  {
  54.218      console_start_sync();
    55.1 --- a/xen/arch/x86/cpu/mcheck/mce.h	Tue Apr 07 11:29:44 2009 +0900
    55.2 +++ b/xen/arch/x86/cpu/mcheck/mce.h	Tue Apr 07 11:32:24 2009 +0900
    55.3 @@ -88,6 +88,10 @@ struct mca_summary {
    55.4  };
    55.5  
    55.6  extern cpu_banks_t mca_allbanks;
    55.7 +void set_poll_bankmask(struct cpuinfo_x86 *c);
    55.8 +DECLARE_PER_CPU(cpu_banks_t, poll_bankmask);
    55.9 +DECLARE_PER_CPU(cpu_banks_t, no_cmci_banks);
   55.10 +extern int cmci_support;
   55.11  
   55.12  extern mctelem_cookie_t mcheck_mca_logout(enum mca_source, cpu_banks_t,
   55.13      struct mca_summary *);
    56.1 --- a/xen/arch/x86/cpu/mcheck/mce_intel.c	Tue Apr 07 11:29:44 2009 +0900
    56.2 +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c	Tue Apr 07 11:32:24 2009 +0900
    56.3 @@ -12,9 +12,10 @@
    56.4  #include "x86_mca.h"
    56.5  
    56.6  DEFINE_PER_CPU(cpu_banks_t, mce_banks_owned);
    56.7 +DEFINE_PER_CPU(cpu_banks_t, no_cmci_banks);
    56.8 +int cmci_support = 0;
    56.9  
   56.10  static int nr_intel_ext_msrs = 0;
   56.11 -static int cmci_support = 0;
   56.12  static int firstbank;
   56.13  
   56.14  #ifdef CONFIG_X86_MCE_THERMAL
   56.15 @@ -117,6 +118,16 @@ static void intel_init_thermal(struct cp
   56.16  }
   56.17  #endif /* CONFIG_X86_MCE_THERMAL */
   56.18  
   56.19 +static inline void intel_get_extended_msr(struct mcinfo_extended *ext, u32 msr)
   56.20 +{
   56.21 +    if ( ext->mc_msrs < ARRAY_SIZE(ext->mc_msr)
   56.22 +         && msr < MSR_IA32_MCG_EAX + nr_intel_ext_msrs ) {
   56.23 +        ext->mc_msr[ext->mc_msrs].reg = msr;
   56.24 +        rdmsrl(msr, ext->mc_msr[ext->mc_msrs].value);
   56.25 +        ++ext->mc_msrs;
   56.26 +    }
   56.27 +}
   56.28 +
   56.29  static enum mca_extinfo
   56.30  intel_get_extended_msrs(struct mc_info *mci, uint16_t bank, uint64_t status)
   56.31  {
   56.32 @@ -129,30 +140,29 @@ intel_get_extended_msrs(struct mc_info *
   56.33      memset(&mc_ext, 0, sizeof(struct mcinfo_extended));
   56.34      mc_ext.common.type = MC_TYPE_EXTENDED;
   56.35      mc_ext.common.size = sizeof(mc_ext);
   56.36 -    mc_ext.mc_msrs = 10;
   56.37 -
   56.38 -    mc_ext.mc_msr[0].reg = MSR_IA32_MCG_EAX;
   56.39 -    rdmsrl(MSR_IA32_MCG_EAX, mc_ext.mc_msr[0].value);
   56.40 -    mc_ext.mc_msr[1].reg = MSR_IA32_MCG_EBX;
   56.41 -    rdmsrl(MSR_IA32_MCG_EBX, mc_ext.mc_msr[1].value);
   56.42 -    mc_ext.mc_msr[2].reg = MSR_IA32_MCG_ECX;
   56.43 -    rdmsrl(MSR_IA32_MCG_ECX, mc_ext.mc_msr[2].value);
   56.44  
   56.45 -    mc_ext.mc_msr[3].reg = MSR_IA32_MCG_EDX;
   56.46 -    rdmsrl(MSR_IA32_MCG_EDX, mc_ext.mc_msr[3].value);
   56.47 -    mc_ext.mc_msr[4].reg = MSR_IA32_MCG_ESI;
   56.48 -    rdmsrl(MSR_IA32_MCG_ESI, mc_ext.mc_msr[4].value);
   56.49 -    mc_ext.mc_msr[5].reg = MSR_IA32_MCG_EDI;
   56.50 -    rdmsrl(MSR_IA32_MCG_EDI, mc_ext.mc_msr[5].value);
   56.51 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EAX);
   56.52 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EBX);
   56.53 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_ECX);
   56.54 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EDX);
   56.55 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_ESI);
   56.56 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EDI);
   56.57 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EBP);
   56.58 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_ESP);
   56.59 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EFLAGS);
   56.60 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_EIP);
   56.61 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_MISC);
   56.62  
   56.63 -    mc_ext.mc_msr[6].reg = MSR_IA32_MCG_EBP;
   56.64 -    rdmsrl(MSR_IA32_MCG_EBP, mc_ext.mc_msr[6].value);
   56.65 -    mc_ext.mc_msr[7].reg = MSR_IA32_MCG_ESP;
   56.66 -    rdmsrl(MSR_IA32_MCG_ESP, mc_ext.mc_msr[7].value);
   56.67 -    mc_ext.mc_msr[8].reg = MSR_IA32_MCG_EFLAGS;
   56.68 -    rdmsrl(MSR_IA32_MCG_EFLAGS, mc_ext.mc_msr[8].value);
   56.69 -    mc_ext.mc_msr[9].reg = MSR_IA32_MCG_EIP;
   56.70 -    rdmsrl(MSR_IA32_MCG_EIP, mc_ext.mc_msr[9].value);
   56.71 +#ifdef __x86_64__
   56.72 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R8);
   56.73 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R9);
   56.74 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R10);
   56.75 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R11);
   56.76 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R12);
   56.77 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R13);
   56.78 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R14);
   56.79 +    intel_get_extended_msr(&mc_ext, MSR_IA32_MCG_R15);
   56.80 +#endif
   56.81  
   56.82      x86_mcinfo_add(mci, &mc_ext);
   56.83  
   56.84 @@ -426,7 +436,7 @@ static void severity_scan(void)
   56.85       * recovered, we need to RESET for avoiding DOM0 LOG missing
   56.86       */
   56.87      for ( i = 0; i < nr_mce_banks; i++) {
   56.88 -        rdmsrl(MSR_IA32_MC0_STATUS + 4 * i , status);
   56.89 +        mca_rdmsrl(MSR_IA32_MC0_STATUS + 4 * i , status);
   56.90          if ( !(status & MCi_STATUS_VAL) )
   56.91              continue;
   56.92          /* MCE handler only handles UC error */
   56.93 @@ -434,7 +444,12 @@ static void severity_scan(void)
   56.94              continue;
   56.95          if ( !(status & MCi_STATUS_EN) )
   56.96              continue;
   56.97 -        if (status & MCi_STATUS_PCC)
   56.98 +        /*
   56.99 +         * If this was an injected error, keep going, since the
  56.100 +         * interposed value will be lost at reboot.
  56.101 +         */
  56.102 +        if (status & MCi_STATUS_PCC && intpose_lookup(smp_processor_id(),
  56.103 +          MSR_IA32_MC0_STATUS + 4 * i, NULL) == NULL)
  56.104              mc_panic("pcc = 1, cpu unable to continue\n");
  56.105      }
  56.106  
  56.107 @@ -519,8 +534,8 @@ static void intel_machine_check(struct c
  56.108  
  56.109      /* Pick one CPU to clear MCIP */
  56.110      if (!test_and_set_bool(mce_process_lock)) {
  56.111 -        rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
  56.112 -        wrmsrl(MSR_IA32_MCG_STATUS, gstatus & ~MCG_STATUS_MCIP);
  56.113 +        mca_rdmsrl(MSR_IA32_MCG_STATUS, gstatus);
  56.114 +        mca_wrmsrl(MSR_IA32_MCG_STATUS, gstatus & ~MCG_STATUS_MCIP);
  56.115  
  56.116          if (worst >= 3) {
  56.117              printk(KERN_WARNING "worst=3 should have caused RESET\n");
  56.118 @@ -534,7 +549,6 @@ static void intel_machine_check(struct c
  56.119  }
  56.120  
  56.121  static DEFINE_SPINLOCK(cmci_discover_lock);
  56.122 -static DEFINE_PER_CPU(cpu_banks_t, no_cmci_banks);
  56.123  
  56.124  /*
  56.125   * Discover bank sharing using the algorithm recommended in the SDM.
  56.126 @@ -728,7 +742,7 @@ void mce_intel_feature_init(struct cpuin
  56.127      intel_init_cmci(c);
  56.128  }
  56.129  
  56.130 -uint64_t g_mcg_cap;
  56.131 +static uint64_t g_mcg_cap;
  56.132  static void mce_cap_init(struct cpuinfo_x86 *c)
  56.133  {
  56.134      u32 l, h;
  56.135 @@ -740,9 +754,12 @@ static void mce_cap_init(struct cpuinfo_
  56.136      if ((l & MCG_CMCI_P) && cpu_has_apic)
  56.137          cmci_support = 1;
  56.138  
  56.139 -    nr_mce_banks = l & 0xff;
  56.140 +    nr_mce_banks = l & MCG_CAP_COUNT;
  56.141      if (nr_mce_banks > MAX_NR_BANKS)
  56.142 +    {
  56.143          printk(KERN_WARNING "MCE: exceed max mce banks\n");
  56.144 +        g_mcg_cap = (g_mcg_cap & ~MCG_CAP_COUNT) | MAX_NR_BANKS;
  56.145 +    }
  56.146      if (l & MCG_EXT_P)
  56.147      {
  56.148          nr_intel_ext_msrs = (l >> MCG_EXT_CNT) & 0xff;
  56.149 @@ -814,11 +831,22 @@ int intel_mcheck_init(struct cpuinfo_x86
  56.150  }
  56.151  
  56.152  /* Guest vMCE# MSRs virtualization ops (rdmsr/wrmsr) */
  56.153 -int intel_mce_wrmsr(u32 msr, u32 lo, u32 hi)
  56.154 +void intel_mce_init_msr(struct domain *d)
  56.155 +{
  56.156 +    d->arch.vmca_msrs.mcg_status = 0x0;
  56.157 +    d->arch.vmca_msrs.mcg_cap = g_mcg_cap;
  56.158 +    d->arch.vmca_msrs.mcg_ctl = (uint64_t)~0x0;
  56.159 +    d->arch.vmca_msrs.nr_injection = 0;
  56.160 +    memset(d->arch.vmca_msrs.mci_ctl, ~0,
  56.161 +           sizeof(d->arch.vmca_msrs.mci_ctl));
  56.162 +    INIT_LIST_HEAD(&d->arch.vmca_msrs.impact_header);
  56.163 +}
  56.164 +
  56.165 +int intel_mce_wrmsr(u32 msr, u64 value)
  56.166  {
  56.167      struct domain *d = current->domain;
  56.168      struct bank_entry *entry = NULL;
  56.169 -    uint64_t value = (u64)hi << 32 | lo;
  56.170 +    unsigned int bank;
  56.171      int ret = 1;
  56.172  
  56.173      spin_lock(&mce_locks);
  56.174 @@ -826,86 +854,71 @@ int intel_mce_wrmsr(u32 msr, u32 lo, u32
  56.175      {
  56.176      case MSR_IA32_MCG_CTL:
  56.177          if (value != (u64)~0x0 && value != 0x0) {
  56.178 -            gdprintk(XENLOG_WARNING, "MCE: value writen to MCG_CTL"
  56.179 +            gdprintk(XENLOG_WARNING, "MCE: value written to MCG_CTL"
  56.180                       "should be all 0s or 1s\n");
  56.181              ret = -1;
  56.182              break;
  56.183          }
  56.184 -        if (!d || is_idle_domain(d)) {
  56.185 -            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
  56.186 -            break;
  56.187 -        }
  56.188          d->arch.vmca_msrs.mcg_ctl = value;
  56.189          break;
  56.190      case MSR_IA32_MCG_STATUS:
  56.191 -        if (!d || is_idle_domain(d)) {
  56.192 -            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
  56.193 -            break;
  56.194 -        }
  56.195          d->arch.vmca_msrs.mcg_status = value;
  56.196          gdprintk(XENLOG_DEBUG, "MCE: wrmsr MCG_CTL %"PRIx64"\n", value);
  56.197          break;
  56.198 -    case MSR_IA32_MC0_CTL2:
  56.199 -    case MSR_IA32_MC1_CTL2:
  56.200 -    case MSR_IA32_MC2_CTL2:
  56.201 -    case MSR_IA32_MC3_CTL2:
  56.202 -    case MSR_IA32_MC4_CTL2:
  56.203 -    case MSR_IA32_MC5_CTL2:
  56.204 -    case MSR_IA32_MC6_CTL2:
  56.205 -    case MSR_IA32_MC7_CTL2:
  56.206 -    case MSR_IA32_MC8_CTL2:
  56.207 +    case MSR_IA32_MCG_CAP:
  56.208 +        gdprintk(XENLOG_WARNING, "MCE: MCG_CAP is read-only\n");
  56.209 +        ret = -1;
  56.210 +        break;
  56.211 +    case MSR_IA32_MC0_CTL2 ... MSR_IA32_MC0_CTL2 + MAX_NR_BANKS - 1:
  56.212          gdprintk(XENLOG_WARNING, "We have disabled CMCI capability, "
  56.213                   "Guest should not write this MSR!\n");
  56.214          break;
  56.215 -    case MSR_IA32_MC0_CTL:
  56.216 -    case MSR_IA32_MC1_CTL:
  56.217 -    case MSR_IA32_MC2_CTL:
  56.218 -    case MSR_IA32_MC3_CTL:
  56.219 -    case MSR_IA32_MC4_CTL:
  56.220 -    case MSR_IA32_MC5_CTL:
  56.221 -    case MSR_IA32_MC6_CTL:
  56.222 -    case MSR_IA32_MC7_CTL:
  56.223 -    case MSR_IA32_MC8_CTL:
  56.224 -        if (value != (u64)~0x0 && value != 0x0) {
  56.225 -            gdprintk(XENLOG_WARNING, "MCE: value writen to MCi_CTL"
  56.226 -                     "should be all 0s or 1s\n");
  56.227 +    case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * MAX_NR_BANKS - 1:
  56.228 +        bank = (msr - MSR_IA32_MC0_CTL) / 4;
  56.229 +        if (bank >= (d->arch.vmca_msrs.mcg_cap & MCG_CAP_COUNT)) {
  56.230 +            gdprintk(XENLOG_WARNING, "MCE: bank %u does not exist\n", bank);
  56.231              ret = -1;
  56.232              break;
  56.233          }
  56.234 -        if (!d || is_idle_domain(d)) {
  56.235 -            gdprintk(XENLOG_WARNING, "MCE: wrmsr not in DOM context, skip\n");
  56.236 +        switch (msr & (MSR_IA32_MC0_CTL | 3))
  56.237 +        {
  56.238 +        case MSR_IA32_MC0_CTL:
  56.239 +            if (value != (u64)~0x0 && value != 0x0) {
  56.240 +                gdprintk(XENLOG_WARNING, "MCE: value written to MC%u_CTL"
  56.241 +                         "should be all 0s or 1s (is %"PRIx64")\n",
  56.242 +                         bank, value);
  56.243 +                ret = -1;
  56.244 +                break;
  56.245 +            }
  56.246 +            d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4] = value;
  56.247 +            break;
  56.248 +        case MSR_IA32_MC0_STATUS:
  56.249 +            /* Give the first entry of the list, it corresponds to current
  56.250 +             * vMCE# injection. When vMCE# is finished processing by the
  56.251 +             * the guest, this node will be deleted.
  56.252 +             * Only error bank is written. Non-error banks simply return.
  56.253 +             */
  56.254 +            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.255 +                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.256 +                                   struct bank_entry, list);
  56.257 +                if ( entry->bank == bank )
  56.258 +                    entry->mci_status = value;
  56.259 +                gdprintk(XENLOG_DEBUG,
  56.260 +                         "MCE: wr MC%u_STATUS %"PRIx64" in vMCE#\n",
  56.261 +                         bank, value);
  56.262 +            } else
  56.263 +                gdprintk(XENLOG_DEBUG,
  56.264 +                         "MCE: wr MC%u_STATUS %"PRIx64"\n", bank, value);
  56.265 +            break;
  56.266 +        case MSR_IA32_MC0_ADDR:
  56.267 +            gdprintk(XENLOG_WARNING, "MCE: MC%u_ADDR is read-only\n", bank);
  56.268 +            ret = -1;
  56.269 +            break;
  56.270 +        case MSR_IA32_MC0_MISC:
  56.271 +            gdprintk(XENLOG_WARNING, "MCE: MC%u_MISC is read-only\n", bank);
  56.272 +            ret = -1;
  56.273              break;
  56.274          }
  56.275 -        d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4] = value;
  56.276 -        break;
  56.277 -    case MSR_IA32_MC0_STATUS:
  56.278 -    case MSR_IA32_MC1_STATUS:
  56.279 -    case MSR_IA32_MC2_STATUS:
  56.280 -    case MSR_IA32_MC3_STATUS:
  56.281 -    case MSR_IA32_MC4_STATUS:
  56.282 -    case MSR_IA32_MC5_STATUS:
  56.283 -    case MSR_IA32_MC6_STATUS:
  56.284 -    case MSR_IA32_MC7_STATUS:
  56.285 -    case MSR_IA32_MC8_STATUS:
  56.286 -        if (!d || is_idle_domain(d)) {
  56.287 -            /* Just skip */
  56.288 -            gdprintk(XENLOG_WARNING, "mce wrmsr: not in domain context!\n");
  56.289 -            break;
  56.290 -        }
  56.291 -        /* Give the first entry of the list, it corresponds to current
  56.292 -         * vMCE# injection. When vMCE# is finished processing by the
  56.293 -         * the guest, this node will be deleted.
  56.294 -         * Only error bank is written. Non-error bank simply return.
  56.295 -         */
  56.296 -        if ( !list_empty(&d->arch.vmca_msrs.impact_header) ) {
  56.297 -            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.298 -                               struct bank_entry, list);
  56.299 -            if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
  56.300 -                entry->mci_status = value;
  56.301 -            }
  56.302 -            gdprintk(XENLOG_DEBUG, "MCE: wmrsr mci_status in vMCE# context\n");
  56.303 -        }
  56.304 -        gdprintk(XENLOG_DEBUG, "MCE: wrmsr mci_status val:%"PRIx64"\n", value);
  56.305          break;
  56.306      default:
  56.307          ret = 0;
  56.308 @@ -919,6 +932,7 @@ int intel_mce_rdmsr(u32 msr, u32 *lo, u3
  56.309  {
  56.310      struct domain *d = current->domain;
  56.311      int ret = 1;
  56.312 +    unsigned int bank;
  56.313      struct bank_entry *entry = NULL;
  56.314  
  56.315      *lo = *hi = 0x0;
  56.316 @@ -926,142 +940,82 @@ int intel_mce_rdmsr(u32 msr, u32 *lo, u3
  56.317      switch(msr)
  56.318      {
  56.319      case MSR_IA32_MCG_STATUS:
  56.320 -        if (!d || is_idle_domain(d)) {
  56.321 -            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
  56.322 -            *lo = *hi = 0x0;
  56.323 -            break;
  56.324 -        }
  56.325          *lo = (u32)d->arch.vmca_msrs.mcg_status;
  56.326          *hi = (u32)(d->arch.vmca_msrs.mcg_status >> 32);
  56.327          gdprintk(XENLOG_DEBUG, "MCE: rd MCG_STATUS lo %x hi %x\n", *lo, *hi);
  56.328          break;
  56.329      case MSR_IA32_MCG_CAP:
  56.330 -        if (!d || is_idle_domain(d)) {
  56.331 -            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
  56.332 -            *lo = *hi = 0x0;
  56.333 -            break;
  56.334 -        }
  56.335          *lo = (u32)d->arch.vmca_msrs.mcg_cap;
  56.336          *hi = (u32)(d->arch.vmca_msrs.mcg_cap >> 32);
  56.337          gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCG_CAP lo %x hi %x\n", *lo, *hi);
  56.338          break;
  56.339      case MSR_IA32_MCG_CTL:
  56.340 -        if (!d || is_idle_domain(d)) {
  56.341 -            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
  56.342 -            *lo = *hi = 0x0;
  56.343 -            break;
  56.344 -        }
  56.345          *lo = (u32)d->arch.vmca_msrs.mcg_ctl;
  56.346          *hi = (u32)(d->arch.vmca_msrs.mcg_ctl >> 32);
  56.347          gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCG_CTL lo %x hi %x\n", *lo, *hi);
  56.348          break;
  56.349 -    case MSR_IA32_MC0_CTL2:
  56.350 -    case MSR_IA32_MC1_CTL2:
  56.351 -    case MSR_IA32_MC2_CTL2:
  56.352 -    case MSR_IA32_MC3_CTL2:
  56.353 -    case MSR_IA32_MC4_CTL2:
  56.354 -    case MSR_IA32_MC5_CTL2:
  56.355 -    case MSR_IA32_MC6_CTL2:
  56.356 -    case MSR_IA32_MC7_CTL2:
  56.357 -    case MSR_IA32_MC8_CTL2:
  56.358 +    case MSR_IA32_MC0_CTL2 ... MSR_IA32_MC0_CTL2 + MAX_NR_BANKS - 1:
  56.359          gdprintk(XENLOG_WARNING, "We have disabled CMCI capability, "
  56.360                   "Guest should not read this MSR!\n");
  56.361          break;
  56.362 -    case MSR_IA32_MC0_CTL:
  56.363 -    case MSR_IA32_MC1_CTL:
  56.364 -    case MSR_IA32_MC2_CTL:
  56.365 -    case MSR_IA32_MC3_CTL:
  56.366 -    case MSR_IA32_MC4_CTL:
  56.367 -    case MSR_IA32_MC5_CTL:
  56.368 -    case MSR_IA32_MC6_CTL:
  56.369 -    case MSR_IA32_MC7_CTL:
  56.370 -    case MSR_IA32_MC8_CTL:
  56.371 -        if (!d || is_idle_domain(d)) {
  56.372 -            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
  56.373 -            *lo = *hi = 0x0;
  56.374 -            break;
  56.375 -        }
  56.376 -        *lo = (u32)d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4];
  56.377 -        *hi =
  56.378 -            (u32)(d->arch.vmca_msrs.mci_ctl[(msr - MSR_IA32_MC0_CTL)/4]
  56.379 -                  >> 32);
  56.380 -        gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_CTL lo %x hi %x\n", *lo, *hi);
  56.381 -        break;
  56.382 -    case MSR_IA32_MC0_STATUS:
  56.383 -    case MSR_IA32_MC1_STATUS:
  56.384 -    case MSR_IA32_MC2_STATUS:
  56.385 -    case MSR_IA32_MC3_STATUS:
  56.386 -    case MSR_IA32_MC4_STATUS:
  56.387 -    case MSR_IA32_MC5_STATUS:
  56.388 -    case MSR_IA32_MC6_STATUS:
  56.389 -    case MSR_IA32_MC7_STATUS:
  56.390 -    case MSR_IA32_MC8_STATUS:
  56.391 -        /* Only error bank is read. Non-error bank simply return */
  56.392 -        *lo = *hi = 0x0;
  56.393 -        gdprintk(XENLOG_DEBUG, "MCE: rdmsr mci_status\n");
  56.394 -        if (!d || is_idle_domain(d)) {
  56.395 -            gdprintk(XENLOG_WARNING, "mce_rdmsr: not in domain context!\n");
  56.396 +    case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * MAX_NR_BANKS - 1:
  56.397 +        bank = (msr - MSR_IA32_MC0_CTL) / 4;
  56.398 +        if (bank >= (d->arch.vmca_msrs.mcg_cap & MCG_CAP_COUNT)) {
  56.399 +            gdprintk(XENLOG_WARNING, "MCE: bank %u does not exist\n", bank);
  56.400 +            ret = -1;
  56.401              break;
  56.402          }
  56.403 -        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.404 -            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.405 -                               struct bank_entry, list);
  56.406 -            if ( entry->bank == (msr - MSR_IA32_MC0_STATUS)/4 ) {
  56.407 -                *lo = entry->mci_status;
  56.408 -                *hi = entry->mci_status >> 32;
  56.409 -                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_STATUS in vmCE# context "
  56.410 -                         "lo %x hi %x\n", *lo, *hi);
  56.411 +        switch (msr & (MSR_IA32_MC0_CTL | 3))
  56.412 +        {
  56.413 +        case MSR_IA32_MC0_CTL:
  56.414 +            *lo = (u32)d->arch.vmca_msrs.mci_ctl[bank];
  56.415 +            *hi = (u32)(d->arch.vmca_msrs.mci_ctl[bank] >> 32);
  56.416 +            gdprintk(XENLOG_DEBUG, "MCE: rd MC%u_CTL lo %x hi %x\n",
  56.417 +                     bank, *lo, *hi);
  56.418 +            break;
  56.419 +        case MSR_IA32_MC0_STATUS:
  56.420 +            /* Only error bank is read. Non-error banks simply return. */
  56.421 +            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.422 +                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.423 +                                   struct bank_entry, list);
  56.424 +                if (entry->bank == bank) {
  56.425 +                    *lo = entry->mci_status;
  56.426 +                    *hi = entry->mci_status >> 32;
  56.427 +                    gdprintk(XENLOG_DEBUG,
  56.428 +                             "MCE: rd MC%u_STATUS in vmCE# context "
  56.429 +                             "lo %x hi %x\n", bank, *lo, *hi);
  56.430 +                } else
  56.431 +                    entry = NULL;
  56.432              }
  56.433 -        }
  56.434 -        break;
  56.435 -    case MSR_IA32_MC0_ADDR:
  56.436 -    case MSR_IA32_MC1_ADDR:
  56.437 -    case MSR_IA32_MC2_ADDR:
  56.438 -    case MSR_IA32_MC3_ADDR:
  56.439 -    case MSR_IA32_MC4_ADDR:
  56.440 -    case MSR_IA32_MC5_ADDR:
  56.441 -    case MSR_IA32_MC6_ADDR:
  56.442 -    case MSR_IA32_MC7_ADDR:
  56.443 -    case MSR_IA32_MC8_ADDR:
  56.444 -        *lo = *hi = 0x0;
  56.445 -        if (!d || is_idle_domain(d)) {
  56.446 -            gdprintk(XENLOG_WARNING, "mce_rdmsr: not in domain context!\n");
  56.447 +            if (!entry)
  56.448 +                gdprintk(XENLOG_DEBUG, "MCE: rd MC%u_STATUS\n", bank);
  56.449              break;
  56.450 -        }
  56.451 -        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.452 -            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.453 -                               struct bank_entry, list);
  56.454 -            if ( entry->bank == (msr - MSR_IA32_MC0_ADDR)/4 ) {
  56.455 -                *lo = entry->mci_addr;
  56.456 -                *hi = entry->mci_addr >> 32;
  56.457 -                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_ADDR in vMCE# context "
  56.458 -                         "lo %x hi %x\n", *lo, *hi);
  56.459 +        case MSR_IA32_MC0_ADDR:
  56.460 +            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.461 +                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.462 +                                   struct bank_entry, list);
  56.463 +                if (entry->bank == bank) {
  56.464 +                    *lo = entry->mci_addr;
  56.465 +                    *hi = entry->mci_addr >> 32;
  56.466 +                    gdprintk(XENLOG_DEBUG,
  56.467 +                             "MCE: rd MC%u_ADDR in vMCE# context lo %x hi %x\n",
  56.468 +                             bank, *lo, *hi);
  56.469 +                }
  56.470              }
  56.471 -        }
  56.472 -        break;
  56.473 -    case MSR_IA32_MC0_MISC:
  56.474 -    case MSR_IA32_MC1_MISC:
  56.475 -    case MSR_IA32_MC2_MISC:
  56.476 -    case MSR_IA32_MC3_MISC:
  56.477 -    case MSR_IA32_MC4_MISC:
  56.478 -    case MSR_IA32_MC5_MISC:
  56.479 -    case MSR_IA32_MC6_MISC:
  56.480 -    case MSR_IA32_MC7_MISC:
  56.481 -    case MSR_IA32_MC8_MISC:
  56.482 -        *lo = *hi = 0x0;
  56.483 -        if (!d || is_idle_domain(d)) {
  56.484 -            gdprintk(XENLOG_WARNING, "MCE: rdmsr not in domain context!\n");
  56.485              break;
  56.486 -        }
  56.487 -        if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.488 -            entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.489 -                               struct bank_entry, list);
  56.490 -            if ( entry->bank == (msr - MSR_IA32_MC0_MISC)/4 ) {
  56.491 -                *lo = entry->mci_misc;
  56.492 -                *hi = entry->mci_misc >> 32;
  56.493 -                gdprintk(XENLOG_DEBUG, "MCE: rdmsr MCi_MISC in vMCE# context "
  56.494 -                         " lo %x hi %x\n", *lo, *hi);
  56.495 +        case MSR_IA32_MC0_MISC:
  56.496 +            if (!list_empty(&d->arch.vmca_msrs.impact_header)) {
  56.497 +                entry = list_entry(d->arch.vmca_msrs.impact_header.next,
  56.498 +                                   struct bank_entry, list);
  56.499 +                if (entry->bank == bank) {
  56.500 +                    *lo = entry->mci_misc;
  56.501 +                    *hi = entry->mci_misc >> 32;
  56.502 +                    gdprintk(XENLOG_DEBUG,
  56.503 +                             "MCE: rd MC%u_MISC in vMCE# context lo %x hi %x\n",
  56.504 +                             bank, *lo, *hi);
  56.505 +                }
  56.506              }
  56.507 +            break;
  56.508          }
  56.509          break;
  56.510      default:
    57.1 --- a/xen/arch/x86/cpu/mcheck/non-fatal.c	Tue Apr 07 11:29:44 2009 +0900
    57.2 +++ b/xen/arch/x86/cpu/mcheck/non-fatal.c	Tue Apr 07 11:32:24 2009 +0900
    57.3 @@ -22,7 +22,7 @@
    57.4  
    57.5  #include "mce.h"
    57.6  
    57.7 -static cpu_banks_t bankmask;
    57.8 +DEFINE_PER_CPU(cpu_banks_t, poll_bankmask);
    57.9  static struct timer mce_timer;
   57.10  
   57.11  #define MCE_PERIOD MILLISECS(8000)
   57.12 @@ -39,7 +39,7 @@ static void mce_checkregs (void *info)
   57.13  	struct mca_summary bs;
   57.14  	static uint64_t dumpcount = 0;
   57.15  
   57.16 -	mctc = mcheck_mca_logout(MCA_POLLER, bankmask, &bs);
   57.17 +	mctc = mcheck_mca_logout(MCA_POLLER, __get_cpu_var(poll_bankmask), &bs);
   57.18  
   57.19  	if (bs.errcnt && mctc != NULL) {
   57.20  		adjust++;
   57.21 @@ -94,10 +94,6 @@ static int __init init_nonfatal_mce_chec
   57.22  	if (!mce_available(c))
   57.23  		return -ENODEV;
   57.24  
   57.25 -	memcpy(&bankmask, &mca_allbanks, sizeof (cpu_banks_t));
   57.26 -	if (mce_firstbank(c) == 1)
   57.27 -		clear_bit(0, bankmask);
   57.28 -
   57.29  	/*
   57.30  	 * Check for non-fatal errors every MCE_RATE s
   57.31  	 */
    58.1 --- a/xen/arch/x86/cpu/mcheck/x86_mca.h	Tue Apr 07 11:29:44 2009 +0900
    58.2 +++ b/xen/arch/x86/cpu/mcheck/x86_mca.h	Tue Apr 07 11:32:24 2009 +0900
    58.3 @@ -18,9 +18,9 @@
    58.4   */
    58.5  
    58.6  #ifndef X86_MCA_H
    58.7 -
    58.8  #define X86_MCA_H
    58.9  
   58.10 +#include <public/arch-x86/xen-mca.h>
   58.11  
   58.12  /* The MCA/MCE MSRs should not be used anywhere else.
   58.13   * They are cpu family/model specific and are only for use
    59.1 --- a/xen/arch/x86/domain.c	Tue Apr 07 11:29:44 2009 +0900
    59.2 +++ b/xen/arch/x86/domain.c	Tue Apr 07 11:32:24 2009 +0900
    59.3 @@ -46,6 +46,7 @@
    59.4  #include <asm/hvm/support.h>
    59.5  #include <asm/debugreg.h>
    59.6  #include <asm/msr.h>
    59.7 +#include <asm/traps.h>
    59.8  #include <asm/nmi.h>
    59.9  #include <xen/numa.h>
   59.10  #include <xen/iommu.h>
   59.11 @@ -373,7 +374,6 @@ void vcpu_destroy(struct vcpu *v)
   59.12          hvm_vcpu_destroy(v);
   59.13  }
   59.14  
   59.15 -extern uint64_t g_mcg_cap;
   59.16  int arch_domain_create(struct domain *d, unsigned int domcr_flags)
   59.17  {
   59.18  #ifdef __x86_64__
   59.19 @@ -458,14 +458,8 @@ int arch_domain_create(struct domain *d,
   59.20              goto fail;
   59.21  
   59.22          /* For Guest vMCE MSRs virtualization */
   59.23 -        d->arch.vmca_msrs.mcg_status = 0x0;
   59.24 -        d->arch.vmca_msrs.mcg_cap = g_mcg_cap;
   59.25 -        d->arch.vmca_msrs.mcg_ctl = (uint64_t)~0x0;
   59.26 -        d->arch.vmca_msrs.nr_injection = 0;
   59.27 -        memset(d->arch.vmca_msrs.mci_ctl, 0x1,
   59.28 -            sizeof(d->arch.vmca_msrs.mci_ctl));
   59.29 -        INIT_LIST_HEAD(&d->arch.vmca_msrs.impact_header);
   59.30 -
   59.31 +        if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   59.32 +            intel_mce_init_msr(d);
   59.33      }
   59.34  
   59.35      if ( is_hvm_domain(d) )
    60.1 --- a/xen/arch/x86/domctl.c	Tue Apr 07 11:29:44 2009 +0900
    60.2 +++ b/xen/arch/x86/domctl.c	Tue Apr 07 11:32:24 2009 +0900
    60.3 @@ -587,6 +587,19 @@ long arch_do_domctl(
    60.4          }
    60.5          break;
    60.6  
    60.7 +        case XEN_DOMCTL_SENDTRIGGER_POWER:
    60.8 +        {
    60.9 +            extern void hvm_acpi_power_button(struct domain *d);
   60.10 +
   60.11 +            ret = -EINVAL;
   60.12 +            if ( is_hvm_domain(d) ) 
   60.13 +            {
   60.14 +                ret = 0;
   60.15 +                hvm_acpi_power_button(d);
   60.16 +            }
   60.17 +        }
   60.18 +        break;
   60.19 +
   60.20          default:
   60.21              ret = -ENOSYS;
   60.22          }
   60.23 @@ -1148,9 +1161,9 @@ void arch_get_info_guest(struct vcpu *v,
   60.24              c.nat->ctrlreg[3] = xen_pfn_to_cr3(
   60.25                  pagetable_get_pfn(v->arch.guest_table));
   60.26  #ifdef __x86_64__
   60.27 -            if ( !pagetable_is_null(v->arch.guest_table_user) )
   60.28 -                c.nat->ctrlreg[1] = xen_pfn_to_cr3(
   60.29 -                    pagetable_get_pfn(v->arch.guest_table_user));
   60.30 +            c.nat->ctrlreg[1] =
   60.31 +                pagetable_is_null(v->arch.guest_table_user) ? 0
   60.32 +                : xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table_user));
   60.33  #endif
   60.34  
   60.35              /* Merge shadow DR7 bits into real DR7. */
    61.1 --- a/xen/arch/x86/hpet.c	Tue Apr 07 11:29:44 2009 +0900
    61.2 +++ b/xen/arch/x86/hpet.c	Tue Apr 07 11:32:24 2009 +0900
    61.3 @@ -45,7 +45,7 @@ static unsigned int num_hpets_used; /* m
    61.4  
    61.5  DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
    61.6  
    61.7 -static int vector_channel[NR_IRQS] = {[0 ... NR_IRQS-1] = -1};
    61.8 +static int vector_channel[NR_VECTORS] = {[0 ... NR_VECTORS-1] = -1};
    61.9  
   61.10  #define vector_to_channel(vector)   vector_channel[vector]
   61.11  
   61.12 @@ -343,20 +343,19 @@ static int hpet_setup_msi_irq(unsigned i
   61.13  
   61.14  static int hpet_assign_irq(struct hpet_event_channel *ch)
   61.15  {
   61.16 -    unsigned int vector;
   61.17 +    int vector;
   61.18  
   61.19 -    vector = assign_irq_vector(AUTO_ASSIGN_IRQ);
   61.20 -    if ( !vector )
   61.21 -        return -EINVAL;
   61.22 +    if ( ch->vector )
   61.23 +        return 0;
   61.24  
   61.25 -    irq_vector[vector] = vector;
   61.26 -    vector_irq[vector] = vector;
   61.27 +    if ( (vector = assign_irq_vector(AUTO_ASSIGN_IRQ)) < 0 )
   61.28 +        return vector;
   61.29 +
   61.30      vector_channel[vector] = ch - &hpet_events[0];
   61.31  
   61.32      if ( hpet_setup_msi_irq(vector) )
   61.33      {
   61.34 -        irq_vector[vector] = 0;
   61.35 -        vector_irq[vector] = FREE_TO_ASSIGN_IRQ;
   61.36 +        free_irq_vector(vector);
   61.37          vector_channel[vector] = -1;
   61.38          return -EINVAL;
   61.39      }
    62.1 --- a/xen/arch/x86/hvm/intercept.c	Tue Apr 07 11:29:44 2009 +0900
    62.2 +++ b/xen/arch/x86/hvm/intercept.c	Tue Apr 07 11:32:24 2009 +0900
    62.3 @@ -100,8 +100,11 @@ static int hvm_mmio_access(struct vcpu *
    62.4          }
    62.5      }
    62.6  
    62.7 -    if ( (p->count = i) != 0 )
    62.8 +    if ( i != 0 )
    62.9 +    {
   62.10 +        p->count = i;
   62.11          rc = X86EMUL_OKAY;
   62.12 +    }
   62.13  
   62.14      return rc;
   62.15  }
   62.16 @@ -165,8 +168,11 @@ static int process_portio_intercept(port
   62.17          }
   62.18      }
   62.19  
   62.20 -    if ( (p->count = i) != 0 )
   62.21 +    if ( i != 0 )
   62.22 +    {
   62.23 +        p->count = i;
   62.24          rc = X86EMUL_OKAY;
   62.25 +    }
   62.26  
   62.27      return rc;
   62.28  }
    63.1 --- a/xen/arch/x86/hvm/pmtimer.c	Tue Apr 07 11:29:44 2009 +0900
    63.2 +++ b/xen/arch/x86/hvm/pmtimer.c	Tue Apr 07 11:32:24 2009 +0900
    63.3 @@ -29,18 +29,15 @@
    63.4  
    63.5  /* The interesting bits of the PM1a_STS register */
    63.6  #define TMR_STS    (1 << 0)
    63.7 -#define PWRBTN_STS (1 << 5)
    63.8 -#define GBL_STS    (1 << 8)
    63.9 +#define GBL_STS    (1 << 5)
   63.10 +#define PWRBTN_STS (1 << 8)
   63.11  
   63.12  /* The same in PM1a_EN */
   63.13  #define TMR_EN     (1 << 0)
   63.14 -#define PWRBTN_EN  (1 << 5)
   63.15 -#define GBL_EN     (1 << 8)
   63.16 +#define GBL_EN     (1 << 5)
   63.17 +#define PWRBTN_EN  (1 << 8)
   63.18  
   63.19 -/* Mask of bits in PM1a_STS that can generate an SCI.  Although the ACPI
   63.20 - * spec lists other bits, the PIIX4, which we are emulating, only
   63.21 - * supports these three.  For now, we only use TMR_STS; in future we
   63.22 - * will let qemu set the other bits */
   63.23 +/* Mask of bits in PM1a_STS that can generate an SCI. */
   63.24  #define SCI_MASK (TMR_STS|PWRBTN_STS|GBL_STS) 
   63.25  
   63.26  /* SCI IRQ number (must match SCI_INT number in ACPI FADT in hvmloader) */
   63.27 @@ -61,6 +58,15 @@ static void pmt_update_sci(PMTState *s)
   63.28          hvm_isa_irq_deassert(s->vcpu->domain, SCI_IRQ);
   63.29  }
   63.30  
   63.31 +void hvm_acpi_power_button(struct domain *d)
   63.32 +{
   63.33 +    PMTState *s = &d->arch.hvm_domain.pl_time.vpmt;
   63.34 +    spin_lock(&s->lock);
   63.35 +    s->pm.pm1a_sts |= PWRBTN_STS;
   63.36 +    pmt_update_sci(s);
   63.37 +    spin_unlock(&s->lock);
   63.38 +}
   63.39 +
   63.40  /* Set the correct value in the timer, accounting for time elapsed
   63.41   * since the last time we did that. */
   63.42  static void pmt_update_time(PMTState *s)
    64.1 --- a/xen/arch/x86/irq.c	Tue Apr 07 11:29:44 2009 +0900
    64.2 +++ b/xen/arch/x86/irq.c	Tue Apr 07 11:32:24 2009 +0900
    64.3 @@ -1069,7 +1069,7 @@ extern void dump_ioapic_irq_info(void);
    64.4  
    64.5  static void dump_irqs(unsigned char key)
    64.6  {
    64.7 -    int i, irq, vector;
    64.8 +    int i, glob_irq, irq, vector;
    64.9      irq_desc_t *desc;
   64.10      irq_guest_action_t *action;
   64.11      struct domain *d;
   64.12 @@ -1077,41 +1077,47 @@ static void dump_irqs(unsigned char key)
   64.13  
   64.14      printk("Guest interrupt information:\n");
   64.15  
   64.16 -    for ( irq = 0; irq < NR_IRQS; irq++ )
   64.17 +    for ( vector = 0; vector < NR_VECTORS; vector++ )
   64.18      {
   64.19 -        vector = irq_to_vector(irq);
   64.20 -        if ( vector == 0 )
   64.21 -            continue;
   64.22 +
   64.23 +        glob_irq = vector_to_irq(vector);
   64.24  
   64.25          desc = &irq_desc[vector];
   64.26 +        if ( desc == NULL || desc->handler == &no_irq_type )
   64.27 +            continue;
   64.28  
   64.29          spin_lock_irqsave(&desc->lock, flags);
   64.30  
   64.31 -        if ( desc->status & IRQ_GUEST )
   64.32 +        if ( !(desc->status & IRQ_GUEST) )
   64.33 +            printk("   Vec%3d IRQ%3d: type=%-15s status=%08x "
   64.34 +                   "mapped, unbound\n",
   64.35 +                   vector, glob_irq, desc->handler->typename, desc->status);
   64.36 +        else
   64.37          {
   64.38              action = (irq_guest_action_t *)desc->action;
   64.39  
   64.40 -            printk("    IRQ%3d Vec%3d: type=%-15s status=%08x "
   64.41 +            printk("   Vec%3d IRQ%3d: type=%-15s status=%08x "
   64.42                     "in-flight=%d domain-list=",
   64.43 -                   irq, vector, desc->handler->typename,
   64.44 +                   vector, glob_irq, desc->handler->typename,
   64.45                     desc->status, action->in_flight);
   64.46  
   64.47              for ( i = 0; i < action->nr_guests; i++ )
   64.48              {
   64.49                  d = action->guest[i];
   64.50 -                printk("%u(%c%c%c%c)",
   64.51 -                       d->domain_id,
   64.52 -                       (test_bit(d->pirq_to_evtchn[irq],
   64.53 +                irq = domain_vector_to_irq(d, vector);
   64.54 +                printk("%u:%3d(%c%c%c%c)",
   64.55 +                       d->domain_id, irq,
   64.56 +                       (test_bit(d->pirq_to_evtchn[glob_irq],
   64.57                                   &shared_info(d, evtchn_pending)) ?
   64.58                          'P' : '-'),
   64.59 -                       (test_bit(d->pirq_to_evtchn[irq] /
   64.60 +                       (test_bit(d->pirq_to_evtchn[glob_irq] /
   64.61                                   BITS_PER_EVTCHN_WORD(d),
   64.62                                   &vcpu_info(d->vcpu[0], evtchn_pending_sel)) ?
   64.63                          'S' : '-'),
   64.64 -                       (test_bit(d->pirq_to_evtchn[irq],
   64.65 +                       (test_bit(d->pirq_to_evtchn[glob_irq],
   64.66                                   &shared_info(d, evtchn_mask)) ?
   64.67                          'M' : '-'),
   64.68 -                       (test_bit(irq, d->pirq_mask) ?
   64.69 +                       (test_bit(glob_irq, d->pirq_mask) ?
   64.70                          'M' : '-'));
   64.71                  if ( i != action->nr_guests )
   64.72                      printk(",");
    65.1 --- a/xen/arch/x86/mm/paging.c	Tue Apr 07 11:29:44 2009 +0900
    65.2 +++ b/xen/arch/x86/mm/paging.c	Tue Apr 07 11:32:24 2009 +0900
    65.3 @@ -385,13 +385,14 @@ int paging_log_dirty_op(struct domain *d
    65.4      }
    65.5  
    65.6      pages = 0;
    65.7 -    l4 = map_domain_page(mfn_x(d->arch.paging.log_dirty.top));
    65.8 +    l4 = (mfn_valid(d->arch.paging.log_dirty.top) ?
    65.9 +          map_domain_page(mfn_x(d->arch.paging.log_dirty.top)) : NULL);
   65.10  
   65.11      for ( i4 = 0;
   65.12            (pages < sc->pages) && (i4 < LOGDIRTY_NODE_ENTRIES);
   65.13            i4++ )
   65.14      {
   65.15 -        l3 = mfn_valid(l4[i4]) ? map_domain_page(mfn_x(l4[i4])) : NULL;
   65.16 +        l3 = (l4 && mfn_valid(l4[i4])) ? map_domain_page(mfn_x(l4[i4])) : NULL;
   65.17          for ( i3 = 0;
   65.18                (pages < sc->pages) && (i3 < LOGDIRTY_NODE_ENTRIES);
   65.19                i3++ )
   65.20 @@ -429,7 +430,8 @@ int paging_log_dirty_op(struct domain *d
   65.21          if ( l3 )
   65.22              unmap_domain_page(l3);
   65.23      }
   65.24 -    unmap_domain_page(l4);
   65.25 +    if ( l4 )
   65.26 +        unmap_domain_page(l4);
   65.27  
   65.28      if ( pages < sc->pages )
   65.29          sc->pages = pages;
    66.1 --- a/xen/arch/x86/time.c	Tue Apr 07 11:29:44 2009 +0900
    66.2 +++ b/xen/arch/x86/time.c	Tue Apr 07 11:32:24 2009 +0900
    66.3 @@ -35,6 +35,13 @@
    66.4  static char opt_clocksource[10];
    66.5  string_param("clocksource", opt_clocksource);
    66.6  
    66.7 +/*
    66.8 + * opt_consistent_tscs: All TSCs tick at the exact same rate, allowing
    66.9 + * simplified system time handling.
   66.10 + */
   66.11 +static int opt_consistent_tscs;
   66.12 +boolean_param("consistent_tscs", opt_consistent_tscs);
   66.13 +
   66.14  unsigned long cpu_khz;  /* CPU clock frequency in kHz. */
   66.15  DEFINE_SPINLOCK(rtc_lock);
   66.16  unsigned long pit0_ticks;
   66.17 @@ -959,7 +966,7 @@ static void local_time_calibration(void)
   66.18      /* The overall calibration scale multiplier. */
   66.19      u32 calibration_mul_frac;
   66.20  
   66.21 -    if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) )
   66.22 +    if ( opt_consistent_tscs )
   66.23      {
   66.24          /* Atomically read cpu_calibration struct and write cpu_time struct. */
   66.25          local_irq_disable();
   66.26 @@ -1087,64 +1094,53 @@ static void local_time_calibration(void)
   66.27   */
   66.28  struct calibration_rendezvous {
   66.29      cpumask_t cpu_calibration_map;
   66.30 -    atomic_t count_start;
   66.31 -    atomic_t count_end;
   66.32 +    atomic_t semaphore;
   66.33      s_time_t master_stime;
   66.34      u64 master_tsc_stamp;
   66.35  };
   66.36  
   66.37 -#define NR_LOOPS 5
   66.38 -
   66.39 -static void time_calibration_rendezvous(void *_r)
   66.40 +static void time_calibration_tsc_rendezvous(void *_r)
   66.41  {
   66.42      int i;
   66.43      struct cpu_calibration *c = &this_cpu(cpu_calibration);
   66.44      struct calibration_rendezvous *r = _r;
   66.45      unsigned int total_cpus = cpus_weight(r->cpu_calibration_map);
   66.46  
   66.47 -    /* 
   66.48 -     * Loop is used here to get rid of the cache's side effect to enlarge
   66.49 -     * the TSC difference among CPUs.
   66.50 -     */
   66.51 -    for ( i = 0; i < NR_LOOPS; i++ )
   66.52 +    /* Loop to get rid of cache effects on TSC skew. */
   66.53 +    for ( i = 4; i >= 0; i-- )
   66.54      {
   66.55          if ( smp_processor_id() == 0 )
   66.56          {
   66.57 -            while ( atomic_read(&r->count_start) != (total_cpus - 1) )
   66.58 +            while ( atomic_read(&r->semaphore) != (total_cpus - 1) )
   66.59                  mb();
   66.60 -   
   66.61 +
   66.62              if ( r->master_stime == 0 )
   66.63              {
   66.64                  r->master_stime = read_platform_stime();
   66.65 -                if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) )
   66.66 -                    rdtscll(r->master_tsc_stamp);
   66.67 +                rdtscll(r->master_tsc_stamp);
   66.68              }
   66.69 -            atomic_set(&r->count_end, 0);
   66.70 -            wmb();
   66.71 -            atomic_inc(&r->count_start);
   66.72 -    
   66.73 -            if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && 
   66.74 -                 i == NR_LOOPS - 1 )
   66.75 -                write_tsc((u32)r->master_tsc_stamp, (u32)(r->master_tsc_stamp >> 32));
   66.76 -    
   66.77 -            while (atomic_read(&r->count_end) != total_cpus - 1)
   66.78 +            atomic_inc(&r->semaphore);
   66.79 +
   66.80 +            if ( i == 0 )
   66.81 +                write_tsc((u32)r->master_tsc_stamp,
   66.82 +                          (u32)(r->master_tsc_stamp >> 32));
   66.83 +
   66.84 +            while ( atomic_read(&r->semaphore) != (2*total_cpus - 1) )
   66.85                  mb();
   66.86 -            atomic_set(&r->count_start, 0);
   66.87 -            wmb();
   66.88 -            atomic_inc(&r->count_end);
   66.89 +            atomic_set(&r->semaphore, 0);
   66.90          }
   66.91          else
   66.92          {
   66.93 -            atomic_inc(&r->count_start);
   66.94 -            while ( atomic_read(&r->count_start) != total_cpus )
   66.95 +            atomic_inc(&r->semaphore);
   66.96 +            while ( atomic_read(&r->semaphore) < total_cpus )
   66.97                  mb();
   66.98 -    
   66.99 -            if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && 
  66.100 -                 i == NR_LOOPS - 1 )
  66.101 -                write_tsc((u32)r->master_tsc_stamp, (u32)(r->master_tsc_stamp >> 32));
  66.102 -    
  66.103 -            atomic_inc(&r->count_end);
  66.104 -            while (atomic_read(&r->count_end) != total_cpus)
  66.105 +
  66.106 +            if ( i == 0 )
  66.107 +                write_tsc((u32)r->master_tsc_stamp,
  66.108 +                          (u32)(r->master_tsc_stamp >> 32));
  66.109 +
  66.110 +            atomic_inc(&r->semaphore);
  66.111 +            while ( atomic_read(&r->semaphore) > total_cpus )
  66.112                  mb();
  66.113          }
  66.114      }
  66.115 @@ -1156,18 +1152,48 @@ static void time_calibration_rendezvous(
  66.116      raise_softirq(TIME_CALIBRATE_SOFTIRQ);
  66.117  }
  66.118  
  66.119 +static void time_calibration_std_rendezvous(void *_r)
  66.120 +{
  66.121 +    struct cpu_calibration *c = &this_cpu(cpu_calibration);
  66.122 +    struct calibration_rendezvous *r = _r;
  66.123 +    unsigned int total_cpus = cpus_weight(r->cpu_calibration_map);
  66.124 +
  66.125 +    if ( smp_processor_id() == 0 )
  66.126 +    {
  66.127 +        while ( atomic_read(&r->semaphore) != (total_cpus - 1) )
  66.128 +            cpu_relax();
  66.129 +        r->master_stime = read_platform_stime();
  66.130 +        mb(); /* write r->master_stime /then/ signal */
  66.131 +        atomic_inc(&r->semaphore);
  66.132 +    }
  66.133 +    else
  66.134 +    {
  66.135 +        atomic_inc(&r->semaphore);
  66.136 +        while ( atomic_read(&r->semaphore) != total_cpus )
  66.137 +            cpu_relax();
  66.138 +        mb(); /* receive signal /then/ read r->master_stime */
  66.139 +    }
  66.140 +
  66.141 +    rdtscll(c->local_tsc_stamp);
  66.142 +    c->stime_local_stamp = get_s_time();
  66.143 +    c->stime_master_stamp = r->master_stime;
  66.144 +
  66.145 +    raise_softirq(TIME_CALIBRATE_SOFTIRQ);
  66.146 +}
  66.147 +
  66.148  static void time_calibration(void *unused)
  66.149  {
  66.150      struct calibration_rendezvous r = {
  66.151          .cpu_calibration_map = cpu_online_map,
  66.152 -        .count_start = ATOMIC_INIT(0),
  66.153 -        .count_end = ATOMIC_INIT(0),
  66.154 -        .master_stime = 0
  66.155 +        .semaphore = ATOMIC_INIT(0)
  66.156      };
  66.157  
  66.158      /* @wait=1 because we must wait for all cpus before freeing @r. */
  66.159      on_selected_cpus(r.cpu_calibration_map,
  66.160 -                     time_calibration_rendezvous, &r, 0, 1);
  66.161 +                     opt_consistent_tscs
  66.162 +                     ? time_calibration_tsc_rendezvous
  66.163 +                     : time_calibration_std_rendezvous,
  66.164 +                     &r, 0, 1);
  66.165  }
  66.166  
  66.167  void init_percpu_time(void)
  66.168 @@ -1194,8 +1220,11 @@ void init_percpu_time(void)
  66.169  /* Late init function (after all CPUs are booted). */
  66.170  int __init init_xen_time(void)
  66.171  {
  66.172 +    if ( !boot_cpu_has(X86_FEATURE_CONSTANT_TSC) )
  66.173 +        opt_consistent_tscs = 0;
  66.174 +
  66.175      /* If we have constant TSCs then scale factor can be shared. */
  66.176 -    if ( boot_cpu_has(X86_FEATURE_CONSTANT_TSC) )
  66.177 +    if ( opt_consistent_tscs )
  66.178      {
  66.179          int cpu;
  66.180          for_each_cpu ( cpu )
    67.1 --- a/xen/arch/x86/traps.c	Tue Apr 07 11:29:44 2009 +0900
    67.2 +++ b/xen/arch/x86/traps.c	Tue Apr 07 11:32:24 2009 +0900
    67.3 @@ -841,7 +841,7 @@ asmlinkage void do_invalid_op(struct cpu
    67.4  {
    67.5      struct bug_frame bug;
    67.6      struct bug_frame_str bug_str;
    67.7 -    char *filename, *predicate, *eip = (char *)regs->eip;
    67.8 +    const char *filename, *predicate, *eip = (char *)regs->eip;
    67.9      unsigned long fixup;
   67.10      int id, lineno;
   67.11  
   67.12 @@ -873,11 +873,13 @@ asmlinkage void do_invalid_op(struct cpu
   67.13      /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
   67.14      if ( !is_kernel(eip) ||
   67.15           __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
   67.16 -         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
   67.17 +         (bug_str.mov != 0xbc) )
   67.18          goto die;
   67.19 +    filename = bug_str(bug_str, eip);
   67.20      eip += sizeof(bug_str);
   67.21  
   67.22 -    filename = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
   67.23 +    if ( !is_kernel(filename) )
   67.24 +        filename = "<unknown>";
   67.25      lineno   = bug.id >> 2;
   67.26  
   67.27      if ( id == BUGFRAME_warn )
   67.28 @@ -900,11 +902,13 @@ asmlinkage void do_invalid_op(struct cpu
   67.29      ASSERT(id == BUGFRAME_assert);
   67.30      if ( !is_kernel(eip) ||
   67.31           __copy_from_user(&bug_str, eip, sizeof(bug_str)) ||
   67.32 -         memcmp(bug_str.mov, BUG_MOV_STR, sizeof(bug_str.mov)) )
   67.33 +         (bug_str.mov != 0xbc) )
   67.34          goto die;
   67.35 +    predicate = bug_str(bug_str, eip);
   67.36      eip += sizeof(bug_str);
   67.37  
   67.38 -    predicate = is_kernel(bug_str.str) ? (char *)bug_str.str : "<unknown>";
   67.39 +    if ( !is_kernel(predicate) )
   67.40 +        predicate = "<unknown>";
   67.41      printk("Assertion '%s' failed at %.50s:%d\n",
   67.42             predicate, filename, lineno);
   67.43      DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
   67.44 @@ -1637,10 +1641,6 @@ static int is_cpufreq_controller(struct 
   67.45              (d->domain_id == 0));
   67.46  }
   67.47  
   67.48 -/*Intel vMCE MSRs virtualization*/
   67.49 -extern int intel_mce_wrmsr(u32 msr, u32 lo,  u32 hi);
   67.50 -extern int intel_mce_rdmsr(u32 msr, u32 *lo,  u32 *hi);
   67.51 -
   67.52  static int emulate_privileged_op(struct cpu_user_regs *regs)
   67.53  {
   67.54      struct vcpu *v = current;
   67.55 @@ -2210,10 +2210,10 @@ static int emulate_privileged_op(struct 
   67.56                  break;
   67.57              if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   67.58              {
   67.59 -                int rc = intel_mce_wrmsr(regs->ecx, eax, edx);
   67.60 -                if ( rc == -1 )
   67.61 +                int rc = intel_mce_wrmsr(regs->ecx, res);
   67.62 +                if ( rc < 0 )
   67.63                      goto fail;
   67.64 -                if ( rc == 0 )
   67.65 +                if ( rc )
   67.66                      break;
   67.67              }
   67.68  
   67.69 @@ -2291,25 +2291,27 @@ static int emulate_privileged_op(struct 
   67.70          default:
   67.71              if ( rdmsr_hypervisor_regs(regs->ecx, &l, &h) )
   67.72              {
   67.73 + rdmsr_writeback:
   67.74                  regs->eax = l;
   67.75                  regs->edx = h;
   67.76                  break;
   67.77              }
   67.78 +
   67.79 +            if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   67.80 +            {
   67.81 +                int rc = intel_mce_rdmsr(regs->ecx, &l, &h);
   67.82 +
   67.83 +                if ( rc < 0 )
   67.84 +                    goto fail;
   67.85 +                if ( rc )
   67.86 +                    goto rdmsr_writeback;
   67.87 +            }
   67.88 +
   67.89              /* Everyone can read the MSR space. */
   67.90              /* gdprintk(XENLOG_WARNING,"Domain attempted RDMSR %p.\n",
   67.91                          _p(regs->ecx));*/
   67.92              if ( rdmsr_safe(regs->ecx, regs->eax, regs->edx) )
   67.93                  goto fail;
   67.94 -
   67.95 -            if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
   67.96 -            {
   67.97 -                int rc = intel_mce_rdmsr(regs->ecx, &eax, &edx);
   67.98 -                if ( rc == -1 )
   67.99 -                    goto fail;
  67.100 -                if ( rc == 0 )
  67.101 -                    break;
  67.102 -            }
  67.103 -
  67.104              break;
  67.105          }
  67.106          break;
  67.107 @@ -3048,8 +3050,8 @@ void load_TR(void)
  67.108  
  67.109      /* Switch to non-compat GDT (which has B bit clear) to execute LTR. */
  67.110      asm volatile (
  67.111 -        "sgdt %1; lgdt %2; ltr %%ax; lgdt %1"
  67.112 -        : : "a" (TSS_ENTRY << 3), "m" (old_gdt), "m" (tss_gdt) : "memory" );
  67.113 +        "sgdt %0; lgdt %2; ltr %w1; lgdt %0"
  67.114 +        : "=m" (old_gdt) : "rm" (TSS_ENTRY << 3), "m" (tss_gdt) : "memory" );
  67.115  }
  67.116  
  67.117  void __devinit percpu_traps_init(void)
    68.1 --- a/xen/common/page_alloc.c	Tue Apr 07 11:29:44 2009 +0900
    68.2 +++ b/xen/common/page_alloc.c	Tue Apr 07 11:32:24 2009 +0900
    68.3 @@ -302,7 +302,8 @@ static unsigned long init_node_heap(int 
    68.4                (mfn + needed) <= (virt_to_mfn(DIRECTMAP_VIRT_END - 1) + 1) )
    68.5      {
    68.6          _heap[node] = mfn_to_virt(mfn);
    68.7 -        avail[node] = mfn_to_virt(mfn + needed) - sizeof(**avail) * NR_ZONES;
    68.8 +        avail[node] = mfn_to_virt(mfn + needed - 1) +
    68.9 +                      PAGE_SIZE - sizeof(**avail) * NR_ZONES;
   68.10      }
   68.11  #endif
   68.12      else if ( get_order_from_bytes(sizeof(**_heap)) ==
    69.1 --- a/xen/common/sched_credit.c	Tue Apr 07 11:29:44 2009 +0900
    69.2 +++ b/xen/common/sched_credit.c	Tue Apr 07 11:32:24 2009 +0900
    69.3 @@ -154,6 +154,7 @@ struct csched_private {
    69.4      spinlock_t lock;
    69.5      struct list_head active_sdom;
    69.6      uint32_t ncpus;
    69.7 +    struct timer  master_ticker;
    69.8      unsigned int master;
    69.9      cpumask_t idlers;
   69.10      uint32_t weight;
   69.11 @@ -325,6 +326,16 @@ static inline void
   69.12  static unsigned int vcpu_migration_delay;
   69.13  integer_param("vcpu_migration_delay", vcpu_migration_delay);
   69.14  
   69.15 +void set_vcpu_migration_delay(unsigned int delay)
   69.16 +{
   69.17 +    vcpu_migration_delay = delay;
   69.18 +}
   69.19 +
   69.20 +unsigned int get_vcpu_migration_delay(void)
   69.21 +{
   69.22 +    return vcpu_migration_delay;
   69.23 +}
   69.24 +
   69.25  static inline int
   69.26  __csched_vcpu_is_cache_hot(struct vcpu *v)
   69.27  {
   69.28 @@ -757,7 +768,7 @@ csched_runq_sort(unsigned int cpu)
   69.29  }
   69.30  
   69.31  static void
   69.32 -csched_acct(void)
   69.33 +csched_acct(void* dummy)
   69.34  {
   69.35      unsigned long flags;
   69.36      struct list_head *iter_vcpu, *next_vcpu;
   69.37 @@ -792,7 +803,7 @@ csched_acct(void)
   69.38          csched_priv.credit_balance = 0;
   69.39          spin_unlock_irqrestore(&csched_priv.lock, flags);
   69.40          CSCHED_STAT_CRANK(acct_no_work);
   69.41 -        return;
   69.42 +        goto out;
   69.43      }
   69.44  
   69.45      CSCHED_STAT_CRANK(acct_run);
   69.46 @@ -950,6 +961,10 @@ csched_acct(void)
   69.47  
   69.48      /* Inform each CPU that its runq needs to be sorted */
   69.49      csched_priv.runq_sort++;
   69.50 +
   69.51 +out:
   69.52 +    set_timer( &csched_priv.master_ticker, NOW() +
   69.53 +            MILLISECS(CSCHED_MSECS_PER_TICK) * CSCHED_TICKS_PER_ACCT );
   69.54  }
   69.55  
   69.56  static void
   69.57 @@ -967,18 +982,6 @@ csched_tick(void *_cpu)
   69.58          csched_vcpu_acct(cpu);
   69.59  
   69.60      /*
   69.61 -     * Host-wide accounting duty
   69.62 -     *
   69.63 -     * Note: Currently, this is always done by the master boot CPU. Eventually,
   69.64 -     * we could distribute or at the very least cycle the duty.
   69.65 -     */
   69.66 -    if ( (csched_priv.master == cpu) &&
   69.67 -         (spc->tick % CSCHED_TICKS_PER_ACCT) == 0 )
   69.68 -    {
   69.69 -        csched_acct();
   69.70 -    }
   69.71 -
   69.72 -    /*
   69.73       * Check if runq needs to be sorted
   69.74       *
   69.75       * Every physical CPU resorts the runq after the accounting master has
   69.76 @@ -1153,7 +1156,8 @@ csched_schedule(s_time_t now)
   69.77      /*
   69.78       * Return task to run next...
   69.79       */
   69.80 -    ret.time = MILLISECS(CSCHED_MSECS_PER_TSLICE);
   69.81 +    ret.time = (is_idle_vcpu(snext->vcpu) ?
   69.82 +                -1 : MILLISECS(CSCHED_MSECS_PER_TSLICE));
   69.83      ret.task = snext->vcpu;
   69.84  
   69.85      CSCHED_VCPU_CHECK(ret.task);
   69.86 @@ -1310,10 +1314,35 @@ static __init int csched_start_tickers(v
   69.87          set_timer(&spc->ticker, NOW() + MILLISECS(CSCHED_MSECS_PER_TICK));
   69.88      }
   69.89  
   69.90 +    init_timer( &csched_priv.master_ticker, csched_acct, NULL,
   69.91 +                    csched_priv.master);
   69.92 +
   69.93 +    set_timer( &csched_priv.master_ticker, NOW() +
   69.94 +            MILLISECS(CSCHED_MSECS_PER_TICK) * CSCHED_TICKS_PER_ACCT );
   69.95 +
   69.96      return 0;
   69.97  }
   69.98  __initcall(csched_start_tickers);
   69.99  
  69.100 +static void csched_tick_suspend(void)
  69.101 +{
  69.102 +    struct csched_pcpu *spc;
  69.103 +
  69.104 +    spc = CSCHED_PCPU(smp_processor_id());
  69.105 +
  69.106 +    stop_timer(&spc->ticker);
  69.107 +}
  69.108 +
  69.109 +static void csched_tick_resume(void)
  69.110 +{
  69.111 +    struct csched_pcpu *spc;
  69.112 +    uint64_t now = NOW();
  69.113 +
  69.114 +    spc = CSCHED_PCPU(smp_processor_id());
  69.115 +
  69.116 +    set_timer(&spc->ticker, now + MILLISECS(CSCHED_MSECS_PER_TICK)
  69.117 +            - now % MILLISECS(CSCHED_MSECS_PER_TICK) );
  69.118 +}
  69.119  
  69.120  struct scheduler sched_credit_def = {
  69.121      .name           = "SMP Credit Scheduler",
  69.122 @@ -1337,4 +1366,7 @@ struct scheduler sched_credit_def = {
  69.123      .dump_cpu_state = csched_dump_pcpu,
  69.124      .dump_settings  = csched_dump,
  69.125      .init           = csched_init,
  69.126 +
  69.127 +    .tick_suspend   = csched_tick_suspend,
  69.128 +    .tick_resume    = csched_tick_resume,
  69.129  };
    70.1 --- a/xen/common/schedule.c	Tue Apr 07 11:29:44 2009 +0900
    70.2 +++ b/xen/common/schedule.c	Tue Apr 07 11:32:24 2009 +0900
    70.3 @@ -798,7 +798,6 @@ static void schedule(void)
    70.4      s_time_t              now = NOW();
    70.5      struct schedule_data *sd;
    70.6      struct task_slice     next_slice;
    70.7 -    s32                   r_time;     /* time for new dom to run */
    70.8  
    70.9      ASSERT(!in_irq());
   70.10      ASSERT(this_cpu(mc_state).flags == 0);
   70.11 @@ -814,12 +813,12 @@ static void schedule(void)
   70.12      /* get policy-specific decision on scheduling... */
   70.13      next_slice = ops.do_schedule(now);
   70.14  
   70.15 -    r_time = next_slice.time;
   70.16      next = next_slice.task;
   70.17  
   70.18      sd->curr = next;
   70.19 -    
   70.20 -    set_timer(&sd->s_timer, now + r_time);
   70.21 +
   70.22 +    if ( next_slice.time >= 0 ) /* -ve means no limit */
   70.23 +        set_timer(&sd->s_timer, now + next_slice.time);
   70.24  
   70.25      if ( unlikely(prev == next) )
   70.26      {
   70.27 @@ -835,7 +834,7 @@ static void schedule(void)
   70.28               next->domain->domain_id,
   70.29               (next->runstate.state == RUNSTATE_runnable) ?
   70.30               (now - next->runstate.state_entry_time) : 0,
   70.31 -             r_time);
   70.32 +             next_slice.time);
   70.33  
   70.34      ASSERT(prev->runstate.state == RUNSTATE_running);
   70.35      vcpu_runstate_change(
   70.36 @@ -964,6 +963,16 @@ void dump_runq(unsigned char key)
   70.37      local_irq_restore(flags);
   70.38  }
   70.39  
   70.40 +void sched_tick_suspend(void)
   70.41 +{
   70.42 +    SCHED_OP(tick_suspend);
   70.43 +}
   70.44 +
   70.45 +void sched_tick_resume(void)
   70.46 +{
   70.47 +    SCHED_OP(tick_resume);
   70.48 +}
   70.49 +
   70.50  #ifdef CONFIG_COMPAT
   70.51  #include "compat/schedule.c"
   70.52  #endif
    71.1 --- a/xen/common/spinlock.c	Tue Apr 07 11:29:44 2009 +0900
    71.2 +++ b/xen/common/spinlock.c	Tue Apr 07 11:32:24 2009 +0900
    71.3 @@ -2,6 +2,7 @@
    71.4  #include <xen/irq.h>
    71.5  #include <xen/smp.h>
    71.6  #include <xen/spinlock.h>
    71.7 +#include <asm/processor.h>
    71.8  
    71.9  #ifndef NDEBUG
   71.10  
   71.11 @@ -43,7 +44,9 @@ void spin_debug_disable(void)
   71.12  void _spin_lock(spinlock_t *lock)
   71.13  {
   71.14      check_lock(&lock->debug);
   71.15 -    _raw_spin_lock(&lock->raw);
   71.16 +    while ( unlikely(!_raw_spin_trylock(&lock->raw)) )
   71.17 +        while ( likely(_raw_spin_is_locked(&lock->raw)) )
   71.18 +            cpu_relax();
   71.19  }
   71.20  
   71.21  void _spin_lock_irq(spinlock_t *lock)
   71.22 @@ -51,7 +54,13 @@ void _spin_lock_irq(spinlock_t *lock)
   71.23      ASSERT(local_irq_is_enabled());
   71.24      local_irq_disable();
   71.25      check_lock(&lock->debug);
   71.26 -    _raw_spin_lock(&lock->raw);
   71.27 +    while ( unlikely(!_raw_spin_trylock(&lock->raw)) )
   71.28 +    {
   71.29 +        local_irq_enable();
   71.30 +        while ( likely(_raw_spin_is_locked(&lock->raw)) )
   71.31 +            cpu_relax();
   71.32 +        local_irq_disable();
   71.33 +    }
   71.34  }
   71.35  
   71.36  unsigned long _spin_lock_irqsave(spinlock_t *lock)
   71.37 @@ -59,7 +68,13 @@ unsigned long _spin_lock_irqsave(spinloc
   71.38      unsigned long flags;
   71.39      local_irq_save(flags);
   71.40      check_lock(&lock->debug);
   71.41 -    _raw_spin_lock(&lock->raw);
   71.42 +    while ( unlikely(!_raw_spin_trylock(&lock->raw)) )
   71.43 +    {
   71.44 +        local_irq_restore(flags);
   71.45 +        while ( likely(_raw_spin_is_locked(&lock->raw)) )
   71.46 +            cpu_relax();
   71.47 +        local_irq_save(flags);
   71.48 +    }
   71.49      return flags;
   71.50  }
   71.51  
    72.1 --- a/xen/common/sysctl.c	Tue Apr 07 11:29:44 2009 +0900
    72.2 +++ b/xen/common/sysctl.c	Tue Apr 07 11:32:24 2009 +0900
    72.3 @@ -206,6 +206,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
    72.4  
    72.5      case XEN_SYSCTL_get_pmstat:
    72.6      {
    72.7 +        ret = xsm_get_pmstat();
    72.8 +        if ( ret )
    72.9 +            break;
   72.10 +
   72.11          ret = do_get_pm_info(&op->u.get_pmstat);
   72.12          if ( ret )
   72.13              break;
   72.14 @@ -220,6 +224,10 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc
   72.15  
   72.16      case XEN_SYSCTL_pm_op:
   72.17      {
   72.18 +        ret = xsm_pm_op();
   72.19 +        if ( ret )
   72.20 +            break;
   72.21 +
   72.22          ret = do_pm_op(&op->u.pm_op);
   72.23          if ( ret && (ret != -EAGAIN) )
   72.24              break;
    73.1 --- a/xen/drivers/acpi/pmstat.c	Tue Apr 07 11:29:44 2009 +0900
    73.2 +++ b/xen/drivers/acpi/pmstat.c	Tue Apr 07 11:32:24 2009 +0900
    73.3 @@ -37,6 +37,7 @@
    73.4  #include <asm/processor.h>
    73.5  #include <xen/percpu.h>
    73.6  #include <xen/domain.h>
    73.7 +#include <xen/acpi.h>
    73.8  
    73.9  #include <public/sysctl.h>
   73.10  #include <acpi/cpufreq/cpufreq.h>
   73.11 @@ -527,6 +528,30 @@ int do_pm_op(struct xen_sysctl_pm_op *op
   73.12          break;
   73.13      }
   73.14  
   73.15 +    case XEN_SYSCTL_pm_op_set_vcpu_migration_delay:
   73.16 +    {
   73.17 +        set_vcpu_migration_delay(op->set_vcpu_migration_delay);
   73.18 +        break;
   73.19 +    }
   73.20 +
   73.21 +    case XEN_SYSCTL_pm_op_get_vcpu_migration_delay:
   73.22 +    {
   73.23 +        op->get_vcpu_migration_delay = get_vcpu_migration_delay();
   73.24 +        break;
   73.25 +    }
   73.26 +
   73.27 +    case XEN_SYSCTL_pm_op_get_max_cstate:
   73.28 +    {
   73.29 +        op->get_max_cstate = acpi_get_cstate_limit();
   73.30 +        break;
   73.31 +    }
   73.32 +
   73.33 +    case XEN_SYSCTL_pm_op_set_max_cstate:
   73.34 +    {
   73.35 +        acpi_set_cstate_limit(op->set_max_cstate);
   73.36 +        break;
   73.37 +    }
   73.38 +
   73.39      default:
   73.40          printk("not defined sub-hypercall @ do_pm_op\n");
   73.41          ret = -ENOSYS;
    74.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Tue Apr 07 11:29:44 2009 +0900
    74.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Tue Apr 07 11:32:24 2009 +0900
    74.3 @@ -911,6 +911,8 @@ static int iommu_alloc(struct acpi_drhd_
    74.4          return -ENOMEM;
    74.5      memset(iommu, 0, sizeof(struct iommu));
    74.6  
    74.7 +    iommu->vector = -1; /* No vector assigned yet. */
    74.8 +
    74.9      iommu->intel = alloc_intel_iommu();
   74.10      if ( iommu->intel == NULL )
   74.11      {
   74.12 @@ -1666,15 +1668,18 @@ static int init_vtd_hw(void)
   74.13              return -EIO;
   74.14          }
   74.15  
   74.16 -        vector = iommu_set_interrupt(iommu);
   74.17 -        if ( vector < 0 )
   74.18 +        if ( iommu->vector < 0 )
   74.19          {
   74.20 -            gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: interrupt setup failed\n");
   74.21 -            return vector;
   74.22 +            vector = iommu_set_interrupt(iommu);
   74.23 +            if ( vector < 0 )
   74.24 +            {
   74.25 +                gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: interrupt setup failed\n");
   74.26 +                return vector;
   74.27 +            }
   74.28 +            iommu->vector = vector;
   74.29          }
   74.30 -        dma_msi_data_init(iommu, vector);
   74.31 +        dma_msi_data_init(iommu, iommu->vector);
   74.32          dma_msi_addr_init(iommu, cpu_physical_id(first_cpu(cpu_online_map)));
   74.33 -        iommu->vector = vector;
   74.34          clear_fault_bits(iommu);
   74.35          dmar_writel(iommu->reg, DMAR_FECTL_REG, 0);
   74.36  
   74.37 @@ -1948,16 +1953,34 @@ void iommu_resume(void)
   74.38  {
   74.39      struct acpi_drhd_unit *drhd;
   74.40      struct iommu *iommu;
   74.41 +    struct iommu_flush *flush;
   74.42      u32 i;
   74.43  
   74.44      if ( !vtd_enabled )
   74.45          return;
   74.46  
   74.47 +    /* Re-initialize the register-based flush functions.
   74.48 +     * In iommu_flush_all(), we invoke iommu_flush_{context,iotlb}_global(),
   74.49 +     * but at this point, on hosts that support QI(Queued Invalidation), QI
   74.50 +     * hasn't been re-enabed yet, so for now let's use the register-based
   74.51 +     * invalidation method before invoking init_vtd_hw().
   74.52 +     */
   74.53 +    if ( iommu_qinval )
   74.54 +    {
   74.55 +        for_each_drhd_unit ( drhd )
   74.56 +        {
   74.57 +            iommu = drhd->iommu;
   74.58 +            flush = iommu_get_flush(iommu);
   74.59 +            flush->context = flush_context_reg;
   74.60 +            flush->iotlb = flush_iotlb_reg;
   74.61 +        }
   74.62 +    }
   74.63 +
   74.64      /* Not sure whether the flush operation is required to meet iommu
   74.65       * specification. Note that BIOS also executes in S3 resume and iommu may
   74.66       * be touched again, so let us do the flush operation for safety.
   74.67       */
   74.68 -    flush_all_cache();
   74.69 +    iommu_flush_all();
   74.70  
   74.71      if ( init_vtd_hw() != 0  && force_iommu )
   74.72           panic("IOMMU setup failed, crash Xen for security purpose!\n");
    75.1 --- a/xen/drivers/passthrough/vtd/qinval.c	Tue Apr 07 11:29:44 2009 +0900
    75.2 +++ b/xen/drivers/passthrough/vtd/qinval.c	Tue Apr 07 11:32:24 2009 +0900
    75.3 @@ -432,10 +432,11 @@ int enable_qinval(struct iommu *iommu)
    75.4                      "Cannot allocate memory for qi_ctrl->qinval_maddr\n");
    75.5              return -ENOMEM;
    75.6          }
    75.7 -        flush->context = flush_context_qi;
    75.8 -        flush->iotlb = flush_iotlb_qi;
    75.9      }
   75.10  
   75.11 +    flush->context = flush_context_qi;
   75.12 +    flush->iotlb = flush_iotlb_qi;
   75.13 +
   75.14      /* Setup Invalidation Queue Address(IQA) register with the
   75.15       * address of the page we just allocated.  QS field at
   75.16       * bits[2:0] to indicate size of queue is one 4KB page.
    76.1 --- a/xen/include/asm-ia64/linux-xen/asm/spinlock.h	Tue Apr 07 11:29:44 2009 +0900
    76.2 +++ b/xen/include/asm-ia64/linux-xen/asm/spinlock.h	Tue Apr 07 11:32:24 2009 +0900
    76.3 @@ -21,111 +21,9 @@
    76.4  
    76.5  typedef struct {
    76.6  	volatile unsigned int lock;
    76.7 -#ifdef CONFIG_PREEMPT
    76.8 -	unsigned int break_lock;
    76.9 -#endif
   76.10 -#ifdef DEBUG_SPINLOCK
   76.11 -	void *locker;
   76.12 -#endif
   76.13  } raw_spinlock_t;
   76.14  
   76.15 -#ifdef XEN
   76.16 -#ifdef DEBUG_SPINLOCK
   76.17 -#define _RAW_SPIN_LOCK_UNLOCKED	/*(raw_spinlock_t)*/ { 0, NULL }
   76.18 -#else
   76.19  #define _RAW_SPIN_LOCK_UNLOCKED	/*(raw_spinlock_t)*/ { 0 }
   76.20 -#endif
   76.21 -#else
   76.22 -#define _RAW_SPIN_LOCK_UNLOCKED	/*(raw_spinlock_t)*/ { 0 }
   76.23 -#endif
   76.24 -
   76.25 -#ifdef ASM_SUPPORTED
   76.26 -/*
   76.27 - * Try to get the lock.  If we fail to get the lock, make a non-standard call to
   76.28 - * ia64_spinlock_contention().  We do not use a normal call because that would force all
   76.29 - * callers of spin_lock() to be non-leaf routines.  Instead, ia64_spinlock_contention() is
   76.30 - * carefully coded to touch only those registers that spin_lock() marks "clobbered".
   76.31 - */
   76.32 -
   76.33 -#define IA64_SPINLOCK_CLOBBERS "ar.ccv", "ar.pfs", "p14", "p15", "r27", "r28", "r29", "r30", "b6", "memory"
   76.34 -
   76.35 -static inline void
   76.36 -_raw_spin_lock_flags (raw_spinlock_t *lock, unsigned long flags)
   76.37 -{
   76.38 -	register volatile unsigned int *ptr asm ("r31") = &lock->lock;
   76.39 -
   76.40 -#if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
   76.41 -# ifdef CONFIG_ITANIUM
   76.42 -	/* don't use brl on Itanium... */
   76.43 -	asm volatile ("{\n\t"
   76.44 -		      "  mov ar.ccv = r0\n\t"
   76.45 -		      "  mov r28 = ip\n\t"
   76.46 -		      "  mov r30 = 1;;\n\t"
   76.47 -		      "}\n\t"
   76.48 -		      "cmpxchg4.acq r30 = [%1], r30, ar.ccv\n\t"
   76.49 -		      "movl r29 = ia64_spinlock_contention_pre3_4;;\n\t"
   76.50 -		      "cmp4.ne p14, p0 = r30, r0\n\t"
   76.51 -		      "mov b6 = r29;;\n\t"
   76.52 -		      "mov r27=%2\n\t"
   76.53 -		      "(p14) br.cond.spnt.many b6"
   76.54 -		      : "=r"(ptr) : "r"(ptr), "r" (flags) : IA64_SPINLOCK_CLOBBERS);
   76.55 -# else
   76.56 -	asm volatile ("{\n\t"
   76.57 -		      "  mov ar.ccv = r0\n\t"
   76.58 -		      "  mov r28 = ip\n\t"
   76.59 -		      "  mov r30 = 1;;\n\t"
   76.60 -		      "}\n\t"
   76.61 -		      "cmpxchg4.acq r30 = [%1], r30, ar.ccv;;\n\t"
   76.62 -		      "cmp4.ne p14, p0 = r30, r0\n\t"
   76.63 -		      "mov r27=%2\n\t"
   76.64 -		      "(p14) brl.cond.spnt.many ia64_spinlock_contention_pre3_4;;"
   76.65 -		      : "=r"(ptr) : "r"(ptr), "r" (flags) : IA64_SPINLOCK_CLOBBERS);
   76.66 -# endif /* CONFIG_MCKINLEY */
   76.67 -#else
   76.68 -# ifdef CONFIG_ITANIUM
   76.69 -	/* don't use brl on Itanium... */
   76.70 -	/* mis-declare, so we get the entry-point, not it's function descriptor: */
   76.71 -	asm volatile ("mov r30 = 1\n\t"
   76.72 -		      "mov r27=%2\n\t"
   76.73 -		      "mov ar.ccv = r0;;\n\t"
   76.74 -		      "cmpxchg4.acq r30 = [%0], r30, ar.ccv\n\t"
   76.75 -		      "movl r29 = ia64_spinlock_contention;;\n\t"
   76.76 -		      "cmp4.ne p14, p0 = r30, r0\n\t"
   76.77 -		      "mov b6 = r29;;\n\t"
   76.78 -		      "(p14) br.call.spnt.many b6 = b6"
   76.79 -		      : "=r"(ptr) : "r"(ptr), "r" (flags) : IA64_SPINLOCK_CLOBBERS);
   76.80 -# else
   76.81 -	asm volatile ("mov r30 = 1\n\t"
   76.82 -		      "mov r27=%2\n\t"
   76.83 -		      "mov ar.ccv = r0;;\n\t"
   76.84 -		      "cmpxchg4.acq r30 = [%0], r30, ar.ccv;;\n\t"
   76.85 -		      "cmp4.ne p14, p0 = r30, r0\n\t"
   76.86 -		      "(p14) brl.call.spnt.many b6=ia64_spinlock_contention;;"
   76.87 -		      : "=r"(ptr) : "r"(ptr), "r" (flags) : IA64_SPINLOCK_CLOBBERS);
   76.88 -# endif /* CONFIG_MCKINLEY */
   76.89 -#endif
   76.90 -
   76.91 -#ifdef DEBUG_SPINLOCK
   76.92 -	asm volatile ("mov %0=ip" : "=r" (lock->locker));
   76.93 -#endif
   76.94 -}
   76.95 -#define _raw_spin_lock(lock) _raw_spin_lock_flags(lock, 0)
   76.96 -#else /* !ASM_SUPPORTED */
   76.97 -#define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
   76.98 -# define _raw_spin_lock(x)								\
   76.99 -do {											\
  76.100 -	__u32 *ia64_spinlock_ptr = (__u32 *) (x);					\
  76.101 -	__u64 ia64_spinlock_val;							\
  76.102 -	ia64_spinlock_val = ia64_cmpxchg4_acq(ia64_spinlock_ptr, 1, 0);			\
  76.103 -	if (unlikely(ia64_spinlock_val)) {						\
  76.104 -		do {									\
  76.105 -			while (*ia64_spinlock_ptr)					\
  76.106 -				ia64_barrier();						\
  76.107 -			ia64_spinlock_val = ia64_cmpxchg4_acq(ia64_spinlock_ptr, 1, 0);	\
  76.108 -		} while (ia64_spinlock_val);						\
  76.109 -	}										\
  76.110 -} while (0)
  76.111 -#endif /* !ASM_SUPPORTED */
  76.112  
  76.113  #define _raw_spin_is_locked(x)	((x)->lock != 0)
  76.114  #define _raw_spin_unlock(x)	do { barrier(); (x)->lock = 0; } while (0)
  76.115 @@ -134,9 +32,6 @@ do {											\
  76.116  typedef struct {
  76.117  	volatile unsigned int read_counter	: 31;
  76.118  	volatile unsigned int write_lock	:  1;
  76.119 -#ifdef CONFIG_PREEMPT
  76.120 -	unsigned int break_lock;
  76.121 -#endif
  76.122  } raw_rwlock_t;
  76.123  #define _RAW_RW_LOCK_UNLOCKED /*(raw_rwlock_t)*/ { 0, 0 }
  76.124  
    77.1 --- a/xen/include/asm-x86/atomic.h	Tue Apr 07 11:29:44 2009 +0900
    77.2 +++ b/xen/include/asm-x86/atomic.h	Tue Apr 07 11:32:24 2009 +0900
    77.3 @@ -23,8 +23,7 @@ typedef struct { int counter; } atomic_t
    77.4   * atomic_read - read atomic variable
    77.5   * @v: pointer of type atomic_t
    77.6   * 
    77.7 - * Atomically reads the value of @v.  Note that the guaranteed
    77.8 - * useful range of an atomic_t is only 24 bits.
    77.9 + * Atomically reads the value of @v.
   77.10   */
   77.11  #define _atomic_read(v)		((v).counter)
   77.12  #define atomic_read(v)		(*(volatile int *)&((v)->counter))
   77.13 @@ -34,8 +33,7 @@ typedef struct { int counter; } atomic_t
   77.14   * @v: pointer of type atomic_t
   77.15   * @i: required value
   77.16   * 
   77.17 - * Atomically sets the value of @v to @i.  Note that the guaranteed
   77.18 - * useful range of an atomic_t is only 24 bits.
   77.19 + * Atomically sets the value of @v to @i.
   77.20   */ 
   77.21  #define _atomic_set(v,i)	(((v).counter) = (i))
   77.22  #define atomic_set(v,i)		(*(volatile int *)&((v)->counter) = (i))
   77.23 @@ -45,12 +43,11 @@ typedef struct { int counter; } atomic_t
   77.24   * @i: integer value to add
   77.25   * @v: pointer of type atomic_t
   77.26   * 
   77.27 - * Atomically adds @i to @v.  Note that the guaranteed useful range
   77.28 - * of an atomic_t is only 24 bits.
   77.29 + * Atomically adds @i to @v.
   77.30   */
   77.31  static __inline__ void atomic_add(int i, atomic_t *v)
   77.32  {
   77.33 -	__asm__ __volatile__(
   77.34 +	asm volatile(
   77.35  		LOCK "addl %1,%0"
   77.36  		:"=m" (*(volatile int *)&v->counter)
   77.37  		:"ir" (i), "m" (*(volatile int *)&v->counter));
   77.38 @@ -61,12 +58,11 @@ static __inline__ void atomic_add(int i,
   77.39   * @i: integer value to subtract
   77.40   * @v: pointer of type atomic_t
   77.41   * 
   77.42 - * Atomically subtracts @i from @v.  Note that the guaranteed
   77.43 - * useful range of an atomic_t is only 24 bits.
   77.44 + * Atomically subtracts @i from @v.
   77.45   */
   77.46  static __inline__ void atomic_sub(int i, atomic_t *v)
   77.47  {
   77.48 -	__asm__ __volatile__(
   77.49 +	asm volatile(
   77.50  		LOCK "subl %1,%0"
   77.51  		:"=m" (*(volatile int *)&v->counter)
   77.52  		:"ir" (i), "m" (*(volatile int *)&v->counter));
   77.53 @@ -79,14 +75,13 @@ static __inline__ void atomic_sub(int i,
   77.54   * 
   77.55   * Atomically subtracts @i from @v and returns
   77.56   * true if the result is zero, or false for all
   77.57 - * other cases.  Note that the guaranteed
   77.58 - * useful range of an atomic_t is only 24 bits.
   77.59 + * other cases.
   77.60   */
   77.61  static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
   77.62  {
   77.63  	unsigned char c;
   77.64  
   77.65 -	__asm__ __volatile__(
   77.66 +	asm volatile(
   77.67  		LOCK "subl %2,%0; sete %1"
   77.68  		:"=m" (*(volatile int *)&v->counter), "=qm" (c)
   77.69  		:"ir" (i), "m" (*(volatile int *)&v->counter) : "memory");
   77.70 @@ -97,12 +92,11 @@ static __inline__ int atomic_sub_and_tes
   77.71   * atomic_inc - increment atomic variable
   77.72   * @v: pointer of type atomic_t
   77.73   * 
   77.74 - * Atomically increments @v by 1.  Note that the guaranteed
   77.75 - * useful range of an atomic_t is only 24 bits.
   77.76 + * Atomically increments @v by 1.
   77.77   */ 
   77.78  static __inline__ void atomic_inc(atomic_t *v)
   77.79  {
   77.80 -	__asm__ __volatile__(
   77.81 +	asm volatile(
   77.82  		LOCK "incl %0"
   77.83  		:"=m" (*(volatile int *)&v->counter)
   77.84  		:"m" (*(volatile int *)&v->counter));
   77.85 @@ -112,12 +106,11 @@ static __inline__ void atomic_inc(atomic
   77.86   * atomic_dec - decrement atomic variable
   77.87   * @v: pointer of type atomic_t
   77.88   * 
   77.89 - * Atomically decrements @v by 1.  Note that the guaranteed
   77.90 - * useful range of an atomic_t is only 24 bits.
   77.91 + * Atomically decrements @v by 1.
   77.92   */ 
   77.93  static __inline__ void atomic_dec(atomic_t *v)
   77.94  {
   77.95 -	__asm__ __volatile__(
   77.96 +	asm volatile(
   77.97  		LOCK "decl %0"
   77.98  		:"=m" (*(volatile int *)&v->counter)
   77.99  		:"m" (*(volatile int *)&v->counter));
  77.100 @@ -129,14 +122,13 @@ static __inline__ void atomic_dec(atomic
  77.101   * 
  77.102   * Atomically decrements @v by 1 and
  77.103   * returns true if the result is 0, or false for all other
  77.104 - * cases.  Note that the guaranteed
  77.105 - * useful range of an atomic_t is only 24 bits.
  77.106 + * cases.
  77.107   */ 
  77.108  static __inline__ int atomic_dec_and_test(atomic_t *v)
  77.109  {
  77.110  	unsigned char c;
  77.111  
  77.112 -	__asm__ __volatile__(
  77.113 +	asm volatile(
  77.114  		LOCK "decl %0; sete %1"
  77.115  		:"=m" (*(volatile int *)&v->counter), "=qm" (c)
  77.116  		:"m" (*(volatile int *)&v->counter) : "memory");
  77.117 @@ -149,14 +141,13 @@ static __inline__ int atomic_dec_and_tes
  77.118   * 
  77.119   * Atomically increments @v by 1
  77.120   * and returns true if the result is zero, or false for all
  77.121 - * other cases.  Note that the guaranteed
  77.122 - * useful range of an atomic_t is only 24 bits.
  77.123 + * other cases.
  77.124   */ 
  77.125  static __inline__ int atomic_inc_and_test(atomic_t *v)
  77.126  {
  77.127  	unsigned char c;
  77.128  
  77.129 -	__asm__ __volatile__(
  77.130 +	asm volatile(
  77.131  		LOCK "incl %0; sete %1"
  77.132  		:"=m" (*(volatile int *)&v->counter), "=qm" (c)
  77.133  		:"m" (*(volatile int *)&v->counter) : "memory");
  77.134 @@ -170,14 +161,13 @@ static __inline__ int atomic_inc_and_tes
  77.135   * 
  77.136   * Atomically adds @i to @v and returns true
  77.137   * if the result is negative, or false when
  77.138 - * result is greater than or equal to zero.  Note that the guaranteed
  77.139 - * useful range of an atomic_t is only 24 bits.
  77.140 + * result is greater than or equal to zero.
  77.141   */ 
  77.142  static __inline__ int atomic_add_negative(int i, atomic_t *v)
  77.143  {
  77.144  	unsigned char c;
  77.145  
  77.146 -	__asm__ __volatile__(
  77.147 +	asm volatile(
  77.148  		LOCK "addl %2,%0; sets %1"
  77.149  		:"=m" (*(volatile int *)&v->counter), "=qm" (c)
  77.150  		:"ir" (i), "m" (*(volatile int *)&v->counter) : "memory");
    78.1 --- a/xen/include/asm-x86/bug.h	Tue Apr 07 11:29:44 2009 +0900
    78.2 +++ b/xen/include/asm-x86/bug.h	Tue Apr 07 11:32:24 2009 +0900
    78.3 @@ -18,4 +18,28 @@ struct bug_frame {
    78.4  #define BUGFRAME_bug    2
    78.5  #define BUGFRAME_assert 3
    78.6  
    78.7 +#define dump_execution_state()                     \
    78.8 +    asm volatile (                                 \
    78.9 +        "ud2 ; ret $0"                             \
   78.10 +        : : "i" (BUGFRAME_dump) )
   78.11 +
   78.12 +#define WARN()                                     \
   78.13 +    asm volatile (                                 \
   78.14 +        "ud2 ; ret %0" BUG_STR(1)                  \
   78.15 +        : : "i" (BUGFRAME_warn | (__LINE__<<2)),   \
   78.16 +            "i" (__FILE__) )
   78.17 +
   78.18 +#define BUG()                                      \
   78.19 +    asm volatile (                                 \
   78.20 +        "ud2 ; ret %0" BUG_STR(1)                  \
   78.21 +        : : "i" (BUGFRAME_bug | (__LINE__<<2)),    \
   78.22 +            "i" (__FILE__) )
   78.23 +
   78.24 +#define assert_failed(p)                           \
   78.25 +    asm volatile (                                 \
   78.26 +        "ud2 ; ret %0" BUG_STR(1) BUG_STR(2)       \
   78.27 +        : : "i" (BUGFRAME_assert | (__LINE__<<2)), \
   78.28 +            "i" (__FILE__), "i" (#p) )
   78.29 +
   78.30 +
   78.31  #endif /* __X86_BUG_H__ */
    79.1 --- a/xen/include/asm-x86/config.h	Tue Apr 07 11:29:44 2009 +0900
    79.2 +++ b/xen/include/asm-x86/config.h	Tue Apr 07 11:32:24 2009 +0900
    79.3 @@ -35,6 +35,7 @@
    79.4  #define CONFIG_ACPI_SLEEP 1
    79.5  #define CONFIG_ACPI_NUMA 1
    79.6  #define CONFIG_ACPI_SRAT 1
    79.7 +#define CONFIG_ACPI_CSTATE 1
    79.8  
    79.9  #define CONFIG_VGA 1
   79.10  
    80.1 --- a/xen/include/asm-x86/msr-index.h	Tue Apr 07 11:29:44 2009 +0900
    80.2 +++ b/xen/include/asm-x86/msr-index.h	Tue Apr 07 11:32:24 2009 +0900
    80.3 @@ -326,7 +326,15 @@
    80.4  #define MSR_IA32_MCG_ESP		0x00000187
    80.5  #define MSR_IA32_MCG_EFLAGS		0x00000188
    80.6  #define MSR_IA32_MCG_EIP		0x00000189
    80.7 -#define MSR_IA32_MCG_RESERVED		0x0000018a
    80.8 +#define MSR_IA32_MCG_MISC		0x0000018a
    80.9 +#define MSR_IA32_MCG_R8			0x00000190
   80.10 +#define MSR_IA32_MCG_R9			0x00000191
   80.11 +#define MSR_IA32_MCG_R10		0x00000192
   80.12 +#define MSR_IA32_MCG_R11		0x00000193
   80.13 +#define MSR_IA32_MCG_R12		0x00000194
   80.14 +#define MSR_IA32_MCG_R13		0x00000195
   80.15 +#define MSR_IA32_MCG_R14		0x00000196
   80.16 +#define MSR_IA32_MCG_R15		0x00000197
   80.17  
   80.18  /* Pentium IV performance counter MSRs */
   80.19  #define MSR_P4_BPU_PERFCTR0		0x00000300
    81.1 --- a/xen/include/asm-x86/spinlock.h	Tue Apr 07 11:29:44 2009 +0900
    81.2 +++ b/xen/include/asm-x86/spinlock.h	Tue Apr 07 11:32:24 2009 +0900
    81.3 @@ -13,19 +13,6 @@ typedef struct {
    81.4  
    81.5  #define _raw_spin_is_locked(x) ((x)->lock <= 0)
    81.6  
    81.7 -static always_inline void _raw_spin_lock(raw_spinlock_t *lock)
    81.8 -{
    81.9 -    asm volatile (
   81.10 -        "1:  lock; decw %0         \n"
   81.11 -        "    jns 3f                \n"
   81.12 -        "2:  rep; nop              \n"
   81.13 -        "    cmpw $0,%0            \n"
   81.14 -        "    jle 2b                \n"
   81.15 -        "    jmp 1b                \n"
   81.16 -        "3:"
   81.17 -        : "=m" (lock->lock) : : "memory" );
   81.18 -}
   81.19 -
   81.20  static always_inline void _raw_spin_unlock(raw_spinlock_t *lock)
   81.21  {
   81.22      ASSERT(_raw_spin_is_locked(lock));
    82.1 --- a/xen/include/asm-x86/traps.h	Tue Apr 07 11:29:44 2009 +0900
    82.2 +++ b/xen/include/asm-x86/traps.h	Tue Apr 07 11:32:24 2009 +0900
    82.3 @@ -47,4 +47,9 @@ extern int guest_has_trap_callback(struc
    82.4  extern int send_guest_trap(struct domain *d, uint16_t vcpuid,
    82.5  				unsigned int trap_nr);
    82.6  
    82.7 +/* Intel vMCE MSRs virtualization */
    82.8 +extern void intel_mce_init_msr(struct domain *d);
    82.9 +extern int intel_mce_wrmsr(u32 msr, u64 value);
   82.10 +extern int intel_mce_rdmsr(u32 msr, u32 *lo, u32 *hi);
   82.11 +
   82.12  #endif /* ASM_TRAP_H */
    83.1 --- a/xen/include/asm-x86/x86_32/bug.h	Tue Apr 07 11:29:44 2009 +0900
    83.2 +++ b/xen/include/asm-x86/x86_32/bug.h	Tue Apr 07 11:32:24 2009 +0900
    83.3 @@ -2,33 +2,10 @@
    83.4  #define __X86_32_BUG_H__
    83.5  
    83.6  struct bug_frame_str {
    83.7 -    unsigned char mov[1];
    83.8 +    unsigned char mov;
    83.9      unsigned long str;
   83.10  } __attribute__((packed));
   83.11 -#define BUG_MOV_STR "\xbc"
   83.12 -
   83.13 -#define dump_execution_state()                          \
   83.14 -    asm volatile (                                      \
   83.15 -        "ud2 ; ret $%c0"                                \
   83.16 -        : : "i" (BUGFRAME_dump) )
   83.17 -
   83.18 -#define WARN()                                          \
   83.19 -    asm volatile (                                      \
   83.20 -        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
   83.21 -        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
   83.22 -            "i" (__FILE__) )
   83.23 -
   83.24 -#define BUG()                                           \
   83.25 -    asm volatile (                                      \
   83.26 -        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
   83.27 -        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
   83.28 -            "i" (__FILE__) )
   83.29 -
   83.30 -#define assert_failed(p)                                \
   83.31 -    asm volatile (                                      \
   83.32 -        "ud2 ; ret $%c0 ; .byte 0xbc ; .long %c1"       \
   83.33 -        " ; .byte 0xbc ; .long %c2"                     \
   83.34 -        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
   83.35 -            "i" (__FILE__), "i" (#p) )
   83.36 +#define bug_str(b, eip) ((const char *)(b).str)
   83.37 +#define BUG_STR(n) "; movl %" #n ", %%esp"
   83.38  
   83.39  #endif /* __X86_32_BUG_H__ */
    84.1 --- a/xen/include/asm-x86/x86_32/page.h	Tue Apr 07 11:29:44 2009 +0900
    84.2 +++ b/xen/include/asm-x86/x86_32/page.h	Tue Apr 07 11:32:24 2009 +0900
    84.3 @@ -27,9 +27,6 @@
    84.4  #define __PAGE_OFFSET           (0xFF000000)
    84.5  #define __XEN_VIRT_START        __PAGE_OFFSET
    84.6  
    84.7 -#define virt_to_maddr(va) ((unsigned long)(va)-DIRECTMAP_VIRT_START)
    84.8 -#define maddr_to_virt(ma) ((void *)((unsigned long)(ma)+DIRECTMAP_VIRT_START))
    84.9 -
   84.10  #define VADDR_BITS              32
   84.11  #define VADDR_MASK              (~0UL)
   84.12  
   84.13 @@ -44,6 +41,22 @@
   84.14  #include <xen/config.h>
   84.15  #include <asm/types.h>
   84.16  
   84.17 +static inline unsigned long __virt_to_maddr(unsigned long va)
   84.18 +{
   84.19 +    ASSERT(va >= DIRECTMAP_VIRT_START && va < DIRECTMAP_VIRT_END);
   84.20 +    return va - DIRECTMAP_VIRT_START;
   84.21 +}
   84.22 +#define virt_to_maddr(va)       \
   84.23 +    (__virt_to_maddr((unsigned long)(va)))
   84.24 +
   84.25 +static inline void *__maddr_to_virt(unsigned long ma)
   84.26 +{
   84.27 +    ASSERT(ma < DIRECTMAP_VIRT_END - DIRECTMAP_VIRT_START);
   84.28 +    return (void *)(ma + DIRECTMAP_VIRT_START);
   84.29 +}
   84.30 +#define maddr_to_virt(ma)       \
   84.31 +    (__maddr_to_virt((unsigned long)(ma)))
   84.32 +
   84.33  /* read access (should only be used for debug printk's) */
   84.34  typedef u64 intpte_t;
   84.35  #define PRIpte "016llx"
    85.1 --- a/xen/include/asm-x86/x86_64/bug.h	Tue Apr 07 11:29:44 2009 +0900
    85.2 +++ b/xen/include/asm-x86/x86_64/bug.h	Tue Apr 07 11:32:24 2009 +0900
    85.3 @@ -2,33 +2,10 @@
    85.4  #define __X86_64_BUG_H__
    85.5  
    85.6  struct bug_frame_str {
    85.7 -    unsigned char mov[2];
    85.8 -    unsigned long str;
    85.9 +    unsigned char mov;
   85.10 +    signed int str_disp;
   85.11  } __attribute__((packed));
   85.12 -#define BUG_MOV_STR "\x48\xbc"
   85.13 -
   85.14 -#define dump_execution_state()                          \
   85.15 -    asm volatile (                                      \
   85.16 -        "ud2 ; ret $%c0"                                \
   85.17 -        : : "i" (BUGFRAME_dump) )
   85.18 -
   85.19 -#define WARN()                                          \
   85.20 -    asm volatile (                                      \
   85.21 -        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
   85.22 -        : : "i" (BUGFRAME_warn | (__LINE__<<2)),        \
   85.23 -            "i" (__FILE__) )
   85.24 -
   85.25 -#define BUG()                                           \
   85.26 -    asm volatile (                                      \
   85.27 -        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
   85.28 -        : : "i" (BUGFRAME_bug | (__LINE__<<2)),         \
   85.29 -            "i" (__FILE__) )
   85.30 -
   85.31 -#define assert_failed(p)                                \
   85.32 -    asm volatile (                                      \
   85.33 -        "ud2 ; ret $%c0 ; .byte 0x48,0xbc ; .quad %c1"  \
   85.34 -        " ; .byte 0x48,0xbc ; .quad %c2"                \
   85.35 -        : : "i" (BUGFRAME_assert | (__LINE__<<2)),      \
   85.36 -            "i" (__FILE__), "i" (#p) )
   85.37 +#define bug_str(b, rip) ((const char *)(rip) + (b).str_disp)
   85.38 +#define BUG_STR(n) "; movl %" #n " - ., %%esp"
   85.39  
   85.40  #endif /* __X86_64_BUG_H__ */
    86.1 --- a/xen/include/asm-x86/x86_64/page.h	Tue Apr 07 11:29:44 2009 +0900
    86.2 +++ b/xen/include/asm-x86/x86_64/page.h	Tue Apr 07 11:32:24 2009 +0900
    86.3 @@ -46,8 +46,14 @@ static inline unsigned long __virt_to_ma
    86.4  }
    86.5  #define virt_to_maddr(va)       \
    86.6      (__virt_to_maddr((unsigned long)(va)))
    86.7 +
    86.8 +static inline void *__maddr_to_virt(unsigned long ma)
    86.9 +{
   86.10 +    ASSERT(ma < DIRECTMAP_VIRT_END - DIRECTMAP_VIRT_START);
   86.11 +    return (void *)(ma + DIRECTMAP_VIRT_START);
   86.12 +}
   86.13  #define maddr_to_virt(ma)       \
   86.14 -    ((void *)((unsigned long)(ma)+DIRECTMAP_VIRT_START))
   86.15 +    (__maddr_to_virt((unsigned long)(ma)))
   86.16  
   86.17  /* read access (should only be used for debug printk's) */
   86.18  typedef u64 intpte_t;
    87.1 --- a/xen/include/public/arch-x86/xen-mca.h	Tue Apr 07 11:29:44 2009 +0900
    87.2 +++ b/xen/include/public/arch-x86/xen-mca.h	Tue Apr 07 11:32:24 2009 +0900
    87.3 @@ -62,7 +62,7 @@
    87.4   * choose a different version number range that is numerically less
    87.5   * than that used in xen-unstable.
    87.6   */
    87.7 -#define XEN_MCA_INTERFACE_VERSION 0x01ecc002
    87.8 +#define XEN_MCA_INTERFACE_VERSION 0x01ecc003
    87.9  
   87.10  /* IN: Dom0 calls hypercall to retrieve nonurgent telemetry */
   87.11  #define XEN_MC_NONURGENT  0x0001
   87.12 @@ -125,13 +125,13 @@ struct mcinfo_global {
   87.13  
   87.14      /* running domain at the time in error (most likely the impacted one) */
   87.15      uint16_t mc_domid;
   87.16 +    uint16_t mc_vcpuid; /* virtual cpu scheduled for mc_domid */
   87.17      uint32_t mc_socketid; /* physical socket of the physical core */
   87.18      uint16_t mc_coreid; /* physical impacted core */
   87.19 +    uint16_t mc_core_threadid; /* core thread of physical core */
   87.20      uint32_t mc_apicid;
   87.21 -    uint16_t mc_core_threadid; /* core thread of physical core */
   87.22 -    uint16_t mc_vcpuid; /* virtual cpu scheduled for mc_domid */
   87.23 +    uint32_t mc_flags;
   87.24      uint64_t mc_gstatus; /* global status */
   87.25 -    uint32_t mc_flags;
   87.26  };
   87.27  
   87.28  /* contains bank local x86 mc information */
   87.29 @@ -166,11 +166,11 @@ struct mcinfo_extended {
   87.30  
   87.31      uint32_t mc_msrs; /* Number of msr with valid values. */
   87.32      /*
   87.33 -     * Currently Intel extended MSR (32/64) including all gp registers
   87.34 -     * and E(R)DI, E(R)BP, E(R)SP, E(R)FLAGS, E(R)IP, E(R)MISC, only 10
   87.35 -     * of them might be useful. So expend this array to 10.
   87.36 -    */
   87.37 -    struct mcinfo_msr mc_msr[10];
   87.38 +     * Currently Intel extended MSR (32/64) include all gp registers
   87.39 +     * and E(R)FLAGS, E(R)IP, E(R)MISC, up to 11/19 of them might be
   87.40 +     * useful at present. So expand this array to 16/32 to leave room.
   87.41 +     */
   87.42 +    struct mcinfo_msr mc_msr[sizeof(void *) * 4];
   87.43  };
   87.44  
   87.45  /* Recovery Action flags. Giving recovery result information to DOM0 */
   87.46 @@ -216,8 +216,9 @@ struct cpu_offline_action
   87.47  };
   87.48  
   87.49  #define MAX_UNION_SIZE 16
   87.50 -struct mc_recovery
   87.51 +struct mcinfo_recovery
   87.52  {
   87.53 +    struct mcinfo_common common;
   87.54      uint16_t mc_bank; /* bank nr */
   87.55      uint8_t action_flags;
   87.56      uint8_t action_types;
   87.57 @@ -228,12 +229,6 @@ struct mc_recovery
   87.58      } action_info;
   87.59  };
   87.60  
   87.61 -struct mcinfo_recovery
   87.62 -{
   87.63 -    struct mcinfo_common common;
   87.64 -    struct mc_recovery mc_action;
   87.65 -};
   87.66 -
   87.67  
   87.68  #define MCINFO_HYPERCALLSIZE	1024
   87.69  #define MCINFO_MAXSIZE		768
   87.70 @@ -241,8 +236,8 @@ struct mcinfo_recovery
   87.71  struct mc_info {
   87.72      /* Number of mcinfo_* entries in mi_data */
   87.73      uint32_t mi_nentries;
   87.74 -
   87.75 -    uint8_t mi_data[MCINFO_MAXSIZE - sizeof(uint32_t)];
   87.76 +    uint32_t _pad0;
   87.77 +    uint64_t mi_data[(MCINFO_MAXSIZE - 1) / 8];
   87.78  };
   87.79  typedef struct mc_info mc_info_t;
   87.80  DEFINE_XEN_GUEST_HANDLE(mc_info_t);
   87.81 @@ -258,7 +253,7 @@ DEFINE_XEN_GUEST_HANDLE(mc_info_t);
   87.82  #define MC_CAPS_VIA	5	/* cpuid level 0xc0000001 */
   87.83  #define MC_CAPS_AMD_ECX	6	/* cpuid level 0x80000001 (%ecx) */
   87.84  
   87.85 -typedef struct mcinfo_logical_cpu {
   87.86 +struct mcinfo_logical_cpu {
   87.87      uint32_t mc_cpunr;          
   87.88      uint32_t mc_chipid; 
   87.89      uint16_t mc_coreid;
   87.90 @@ -280,7 +275,8 @@ typedef struct mcinfo_logical_cpu {
   87.91      uint32_t mc_cache_alignment;
   87.92      int32_t mc_nmsrvals;
   87.93      struct mcinfo_msr mc_msrvalues[__MC_MSR_ARRAYSIZE];
   87.94 -} xen_mc_logical_cpu_t;
   87.95 +};
   87.96 +typedef struct mcinfo_logical_cpu xen_mc_logical_cpu_t;
   87.97  DEFINE_XEN_GUEST_HANDLE(xen_mc_logical_cpu_t);
   87.98  
   87.99  
  87.100 @@ -299,12 +295,12 @@ DEFINE_XEN_GUEST_HANDLE(xen_mc_logical_c
  87.101   *    struct mcinfo_common *x86_mcinfo_first(struct mc_info *mi);
  87.102   */
  87.103  #define x86_mcinfo_first(_mi)       \
  87.104 -    (struct mcinfo_common *)((_mi)->mi_data)
  87.105 +    ((struct mcinfo_common *)(_mi)->mi_data)
  87.106  /* Prototype:
  87.107   *    struct mcinfo_common *x86_mcinfo_next(struct mcinfo_common *mic);
  87.108   */
  87.109  #define x86_mcinfo_next(_mic)       \
  87.110 -    (struct mcinfo_common *)((uint8_t *)(_mic) + (_mic)->size)
  87.111 +    ((struct mcinfo_common *)((uint8_t *)(_mic) + (_mic)->size))
  87.112  
  87.113  /* Prototype:
  87.114   *    void x86_mcinfo_lookup(void *ret, struct mc_info *mi, uint16_t type);
  87.115 @@ -350,6 +346,7 @@ struct xen_mc_fetch {
  87.116                             XEN_MC_ACK if ack'ing an earlier fetch */
  87.117  			/* OUT: XEN_MC_OK, XEN_MC_FETCHFAILED,
  87.118  			   XEN_MC_NODATA, XEN_MC_NOMATCH */
  87.119 +    uint32_t _pad0;
  87.120      uint64_t fetch_id;	/* OUT: id for ack, IN: id we are ack'ing */
  87.121  
  87.122      /* OUT variables. */
  87.123 @@ -382,7 +379,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_mc_notifydom
  87.124  struct xen_mc_physcpuinfo {
  87.125  	/* IN/OUT */
  87.126  	uint32_t ncpus;
  87.127 -	uint32_t pad0;
  87.128 +	uint32_t _pad0;
  87.129  	/* OUT */
  87.130  	XEN_GUEST_HANDLE(xen_mc_logical_cpu_t) info;
  87.131  };
  87.132 @@ -391,10 +388,10 @@ struct xen_mc_physcpuinfo {
  87.133  #define MC_MSRINJ_MAXMSRS       8
  87.134  struct xen_mc_msrinject {
  87.135         /* IN */
  87.136 -	unsigned int mcinj_cpunr;       /* target processor id */
  87.137 +	uint32_t mcinj_cpunr;           /* target processor id */
  87.138  	uint32_t mcinj_flags;           /* see MC_MSRINJ_F_* below */
  87.139  	uint32_t mcinj_count;           /* 0 .. count-1 in array are valid */
  87.140 -	uint32_t mcinj_pad0;
  87.141 +	uint32_t _pad0;
  87.142  	struct mcinfo_msr mcinj_msr[MC_MSRINJ_MAXMSRS];
  87.143  };
  87.144  
  87.145 @@ -406,18 +403,16 @@ struct xen_mc_mceinject {
  87.146  	unsigned int mceinj_cpunr;      /* target processor id */
  87.147  };
  87.148  
  87.149 -typedef union {
  87.150 -    struct xen_mc_fetch        mc_fetch;
  87.151 -    struct xen_mc_notifydomain mc_notifydomain;
  87.152 -    struct xen_mc_physcpuinfo  mc_physcpuinfo;
  87.153 -    struct xen_mc_msrinject    mc_msrinject;
  87.154 -    struct xen_mc_mceinject    mc_mceinject;
  87.155 -} xen_mc_arg_t;
  87.156 -
  87.157  struct xen_mc {
  87.158      uint32_t cmd;
  87.159      uint32_t interface_version; /* XEN_MCA_INTERFACE_VERSION */
  87.160 -    xen_mc_arg_t u;
  87.161 +    union {
  87.162 +        struct xen_mc_fetch        mc_fetch;
  87.163 +        struct xen_mc_notifydomain mc_notifydomain;
  87.164 +        struct xen_mc_physcpuinfo  mc_physcpuinfo;
  87.165 +        struct xen_mc_msrinject    mc_msrinject;
  87.166 +        struct xen_mc_mceinject    mc_mceinject;
  87.167 +    } u;
  87.168  };
  87.169  typedef struct xen_mc xen_mc_t;
  87.170  DEFINE_XEN_GUEST_HANDLE(xen_mc_t);
    88.1 --- a/xen/include/public/arch-x86/xen.h	Tue Apr 07 11:29:44 2009 +0900
    88.2 +++ b/xen/include/public/arch-x86/xen.h	Tue Apr 07 11:32:24 2009 +0900
    88.3 @@ -76,10 +76,6 @@ typedef unsigned long xen_pfn_t;
    88.4  /* Maximum number of virtual CPUs in multi-processor guests. */
    88.5  #define MAX_VIRT_CPUS 32
    88.6  
    88.7 -
    88.8 -/* Machine check support */
    88.9 -#include "xen-mca.h"
   88.10 -
   88.11  #ifndef __ASSEMBLY__
   88.12  
   88.13  typedef unsigned long xen_ulong_t;
    89.1 --- a/xen/include/public/domctl.h	Tue Apr 07 11:29:44 2009 +0900
    89.2 +++ b/xen/include/public/domctl.h	Tue Apr 07 11:32:24 2009 +0900
    89.3 @@ -433,6 +433,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_
    89.4  #define XEN_DOMCTL_SENDTRIGGER_NMI    0
    89.5  #define XEN_DOMCTL_SENDTRIGGER_RESET  1
    89.6  #define XEN_DOMCTL_SENDTRIGGER_INIT   2
    89.7 +#define XEN_DOMCTL_SENDTRIGGER_POWER  3
    89.8  struct xen_domctl_sendtrigger {
    89.9      uint32_t  trigger;  /* IN */
   89.10      uint32_t  vcpu;     /* IN */
    90.1 --- a/xen/include/public/sysctl.h	Tue Apr 07 11:29:44 2009 +0900
    90.2 +++ b/xen/include/public/sysctl.h	Tue Apr 07 11:32:24 2009 +0900
    90.3 @@ -382,6 +382,14 @@ struct xen_sysctl_pm_op {
    90.4      /* set/reset scheduler power saving option */
    90.5      #define XEN_SYSCTL_pm_op_set_sched_opt_smt    0x21
    90.6  
    90.7 +    /* cpuidle max_cstate access command */
    90.8 +    #define XEN_SYSCTL_pm_op_get_max_cstate       0x22
    90.9 +    #define XEN_SYSCTL_pm_op_set_max_cstate       0x23
   90.10 +
   90.11 +    /* set scheduler migration cost value */
   90.12 +    #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay   0x24
   90.13 +    #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay   0x25
   90.14 +
   90.15      uint32_t cmd;
   90.16      uint32_t cpuid;
   90.17      union {
   90.18 @@ -391,6 +399,10 @@ struct xen_sysctl_pm_op {
   90.19          uint64_t get_avgfreq;
   90.20          struct xen_get_cputopo      get_topo;
   90.21          uint32_t                    set_sched_opt_smt;
   90.22 +        uint32_t                    get_max_cstate;
   90.23 +        uint32_t                    set_max_cstate;
   90.24 +        uint32_t                    get_vcpu_migration_delay;
   90.25 +        uint32_t                    set_vcpu_migration_delay;
   90.26      };
   90.27  };
   90.28  
    91.1 --- a/xen/include/xen/acpi.h	Tue Apr 07 11:29:44 2009 +0900
    91.2 +++ b/xen/include/xen/acpi.h	Tue Apr 07 11:32:24 2009 +0900
    91.3 @@ -282,7 +282,6 @@ typedef int (*acpi_table_entry_handler) 
    91.4  
    91.5  unsigned int acpi_get_processor_id (unsigned int cpu);
    91.6  char * __acpi_map_table (unsigned long phys_addr, unsigned long size);
    91.7 -unsigned long acpi_find_rsdp (void);
    91.8  int acpi_boot_init (void);
    91.9  int acpi_boot_table_init (void);
   91.10  int acpi_numa_init (void);
   91.11 @@ -403,9 +402,7 @@ static inline int acpi_blacklisted(void)
   91.12  
   91.13  #endif /*!CONFIG_ACPI_INTERPRETER*/
   91.14  
   91.15 -#define	ACPI_CSTATE_LIMIT_DEFINED	/* for driver builds */
   91.16 -#ifdef	CONFIG_ACPI
   91.17 -
   91.18 +#ifdef	CONFIG_ACPI_CSTATE
   91.19  /*
   91.20   * Set highest legal C-state
   91.21   * 0: C0 okay, but not C1
    92.1 --- a/xen/include/xen/iommu.h	Tue Apr 07 11:29:44 2009 +0900
    92.2 +++ b/xen/include/xen/iommu.h	Tue Apr 07 11:32:24 2009 +0900
    92.3 @@ -55,7 +55,7 @@ struct iommu {
    92.4      spinlock_t lock; /* protect context, domain ids */
    92.5      spinlock_t register_lock; /* protect iommu register handling */
    92.6      u64 root_maddr; /* root entry machine address */
    92.7 -    unsigned int vector;
    92.8 +    int vector;
    92.9      struct intel_iommu *intel;
   92.10  };
   92.11  
    93.1 --- a/xen/include/xen/lib.h	Tue Apr 07 11:29:44 2009 +0900
    93.2 +++ b/xen/include/xen/lib.h	Tue Apr 07 11:32:24 2009 +0900
    93.3 @@ -12,8 +12,8 @@
    93.4  void __bug(char *file, int line) __attribute__((noreturn));
    93.5  void __warn(char *file, int line);
    93.6  
    93.7 -#define BUG_ON(p)  do { if (p) BUG();  } while (0)
    93.8 -#define WARN_ON(p) do { if (p) WARN(); } while (0)
    93.9 +#define BUG_ON(p)  do { if (unlikely(p)) BUG();  } while (0)
   93.10 +#define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0)
   93.11  
   93.12  /* Force a compilation error if condition is true */
   93.13  #define BUILD_BUG_ON(condition) ((void)sizeof(struct { int:-!!(condition); }))
    94.1 --- a/xen/include/xen/sched-if.h	Tue Apr 07 11:29:44 2009 +0900
    94.2 +++ b/xen/include/xen/sched-if.h	Tue Apr 07 11:32:24 2009 +0900
    94.3 @@ -77,6 +77,9 @@ struct scheduler {
    94.4                                      struct xen_domctl_scheduler_op *);
    94.5      void         (*dump_settings)  (void);
    94.6      void         (*dump_cpu_state) (int);
    94.7 +
    94.8 +    void         (*tick_suspend)    (void);
    94.9 +    void         (*tick_resume)     (void);
   94.10  };
   94.11  
   94.12  #endif /* __XEN_SCHED_IF_H__ */
    95.1 --- a/xen/include/xen/sched.h	Tue Apr 07 11:29:44 2009 +0900
    95.2 +++ b/xen/include/xen/sched.h	Tue Apr 07 11:32:24 2009 +0900
    95.3 @@ -428,6 +428,8 @@ int  sched_init_domain(struct domain *d)
    95.4  void sched_destroy_domain(struct domain *d);
    95.5  long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
    95.6  int  sched_id(void);
    95.7 +void sched_tick_suspend(void);
    95.8 +void sched_tick_resume(void);
    95.9  void vcpu_wake(struct vcpu *d);
   95.10  void vcpu_sleep_nosync(struct vcpu *d);
   95.11  void vcpu_sleep_sync(struct vcpu *d);
   95.12 @@ -550,6 +552,9 @@ uint64_t get_cpu_idle_time(unsigned int 
   95.13  #define is_hvm_vcpu(v)   (is_hvm_domain(v->domain))
   95.14  #define need_iommu(d)    ((d)->need_iommu && !(d)->is_hvm)
   95.15  
   95.16 +void set_vcpu_migration_delay(unsigned int delay);
   95.17 +unsigned int get_vcpu_migration_delay(void);
   95.18 +
   95.19  extern int sched_smt_power_savings;
   95.20  
   95.21  extern enum cpufreq_controller {
    96.1 --- a/xen/include/xlat.lst	Tue Apr 07 11:29:44 2009 +0900
    96.2 +++ b/xen/include/xlat.lst	Tue Apr 07 11:32:24 2009 +0900
    96.3 @@ -10,6 +10,22 @@
    96.4  !	cpu_user_regs			arch-x86/xen-@arch@.h
    96.5  !	trap_info			arch-x86/xen.h
    96.6  !	vcpu_guest_context		arch-x86/xen.h
    96.7 +?	cpu_offline_action		arch-x86/xen-mca.h
    96.8 +?	mc				arch-x86/xen-mca.h
    96.9 +?	mcinfo_bank			arch-x86/xen-mca.h
   96.10 +?	mcinfo_common			arch-x86/xen-mca.h
   96.11 +?	mcinfo_extended			arch-x86/xen-mca.h
   96.12 +?	mcinfo_global			arch-x86/xen-mca.h
   96.13 +?	mcinfo_logical_cpu		arch-x86/xen-mca.h
   96.14 +?	mcinfo_msr			arch-x86/xen-mca.h
   96.15 +?	mcinfo_recovery			arch-x86/xen-mca.h
   96.16 +!	mc_fetch			arch-x86/xen-mca.h
   96.17 +?	mc_info				arch-x86/xen-mca.h
   96.18 +?	mc_mceinject			arch-x86/xen-mca.h
   96.19 +?	mc_msrinject			arch-x86/xen-mca.h
   96.20 +?	mc_notifydomain			arch-x86/xen-mca.h
   96.21 +!	mc_physcpuinfo			arch-x86/xen-mca.h
   96.22 +?	page_offline_action		arch-x86/xen-mca.h
   96.23  ?	evtchn_alloc_unbound		event_channel.h
   96.24  ?	evtchn_bind_interdomain		event_channel.h
   96.25  ?	evtchn_bind_ipi			event_channel.h
    97.1 --- a/xen/include/xsm/xsm.h	Tue Apr 07 11:29:44 2009 +0900
    97.2 +++ b/xen/include/xsm/xsm.h	Tue Apr 07 11:32:24 2009 +0900
    97.3 @@ -75,6 +75,8 @@ struct xsm_operations {
    97.4      int (*debug_keys) (void);
    97.5      int (*getcpuinfo) (void);
    97.6      int (*availheap) (void);
    97.7 +    int (*get_pmstat) (void);
    97.8 +    int (*pm_op) (void);
    97.9  
   97.10      int (*evtchn_unbound) (struct domain *d, struct evtchn *chn, domid_t id2);
   97.11      int (*evtchn_interdomain) (struct domain *d1, struct evtchn *chn1,
   97.12 @@ -282,6 +284,16 @@ static inline int xsm_getcpuinfo (void)
   97.13      return xsm_call(getcpuinfo());
   97.14  }
   97.15  
   97.16 +static inline int xsm_get_pmstat(void)
   97.17 +{
   97.18 +    return xsm_call(get_pmstat());
   97.19 +}
   97.20 +
   97.21 +static inline int xsm_pm_op(void)
   97.22 +{
   97.23 +    return xsm_call(pm_op());
   97.24 +}
   97.25 +
   97.26  static inline int xsm_evtchn_unbound (struct domain *d1, struct evtchn *chn,
   97.27                                                                      domid_t id2)
   97.28  {
    98.1 --- a/xen/tools/get-fields.sh	Tue Apr 07 11:29:44 2009 +0900
    98.2 +++ b/xen/tools/get-fields.sh	Tue Apr 07 11:32:24 2009 +0900
    98.3 @@ -328,7 +328,7 @@ check_field ()
    98.4  				struct|union)
    98.5  					;;
    98.6  				[a-zA-Z_]*)
    98.7 -					echo -n "    CHECK_$n"
    98.8 +					echo -n "    CHECK_${n#xen_}"
    98.9  					break
   98.10  					;;
   98.11  				*)
    99.1 --- a/xen/xsm/dummy.c	Tue Apr 07 11:29:44 2009 +0900
    99.2 +++ b/xen/xsm/dummy.c	Tue Apr 07 11:32:24 2009 +0900
    99.3 @@ -134,6 +134,16 @@ static int dummy_getcpuinfo (void)
    99.4      return 0;
    99.5  }
    99.6  
    99.7 +static int dummy_get_pmstat (void)
    99.8 +{
    99.9 +    return 0;
   99.10 +}
   99.11 +
   99.12 +static int dummy_pm_op (void)
   99.13 +{
   99.14 +    return 0;
   99.15 +}
   99.16 +
   99.17  static int dummy_availheap (void)
   99.18  {
   99.19      return 0;