WARNING - OLD ARCHIVES

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

xen-changelog

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] merge with xen-unstable.hg (staging)
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Dec 2007 08:40:11 -0800
Delivery-date: Thu, 13 Dec 2007 08:40:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1197481803 25200
# Node ID d90dbf72049c8a93fb868b392963e42b33b919b0
# Parent  be02461e981045b550b6ff2e27a56e74a564bf71
# Parent  4553bc1087d9f73e5c27f5511c1d4c724b4dbccf
merge with xen-unstable.hg (staging)
---
 tools/python/xen/xend/server/usbif.py       |   42 ---------
 docs/misc/crashdb.txt                       |   54 ++++++++----
 docs/misc/vtd.txt                           |   14 ++-
 docs/xen-api/revision-history.tex           |   20 ++++
 docs/xen-api/xenapi-coversheet.tex          |    4 
 docs/xen-api/xenapi-datamodel.tex           |   39 ++++++++
 docs/xen-api/xenapi.tex                     |    3 
 tools/ioemu/hw/pass-through.c               |   12 ++
 tools/ioemu/hw/vga.c                        |   16 +++
 tools/libxc/xc_domain.c                     |   16 +++
 tools/libxc/xenctrl.h                       |    4 
 tools/libxen/include/xen/api/xen_xspolicy.h |   13 ++
 tools/libxen/src/xen_xspolicy.c             |   18 ++++
 tools/python/xen/lowlevel/xc/xc.c           |   14 +--
 tools/python/xen/util/acmpolicy.py          |   15 ++-
 tools/python/xen/util/xsm/acm/acm.py        |   15 +++
 tools/python/xen/util/xsm/dummy/dummy.py    |    4 
 tools/python/xen/xend/XendDevices.py        |    3 
 tools/python/xen/xend/XendDomain.py         |   20 ++--
 tools/python/xen/xend/XendDomainInfo.py     |    7 -
 tools/python/xen/xend/XendXSPolicy.py       |   32 +++++++
 tools/python/xen/xend/XendXSPolicyAdmin.py  |   17 +++
 tools/python/xen/xm/create.py               |   11 --
 tools/python/xen/xm/main.py                 |    2 
 tools/python/xen/xm/resetpolicy.py          |   60 -------------
 xen/arch/x86/domctl.c                       |   26 +++++
 xen/arch/x86/gdbstub.c                      |   10 +-
 xen/arch/x86/hvm/i8254.c                    |    2 
 xen/arch/x86/hvm/irq.c                      |   24 -----
 xen/arch/x86/hvm/mtrr.c                     |   80 +++++++++++++++++
 xen/arch/x86/hvm/rtc.c                      |   10 --
 xen/arch/x86/hvm/vioapic.c                  |    2 
 xen/arch/x86/hvm/vlapic.c                   |   20 ----
 xen/arch/x86/hvm/vmx/vtd/dmar.c             |    1 
 xen/arch/x86/hvm/vmx/vtd/intel-iommu.c      |   26 ++---
 xen/arch/x86/hvm/vmx/vtd/io.c               |    7 -
 xen/arch/x86/hvm/vmx/vtd/utils.c            |    1 
 xen/arch/x86/hvm/vpt.c                      |  125 ++++++++++++++++++----------
 xen/arch/x86/traps.c                        |    8 +
 xen/common/gdbstub.c                        |   19 +++-
 xen/common/keyhandler.c                     |    1 
 xen/include/asm-x86/hvm/irq.h               |    3 
 xen/include/asm-x86/hvm/vlapic.h            |    3 
 xen/include/asm-x86/hvm/vpt.h               |   26 ++++-
 xen/include/asm-x86/iommu.h                 |    1 
 xen/include/asm-x86/mtrr.h                  |    1 
 xen/include/public/arch-x86/hvm/save.h      |   19 ++++
 xen/include/public/domctl.h                 |   12 +-
 xen/include/xen/gdbstub.h                   |    1 
 49 files changed, 583 insertions(+), 300 deletions(-)

diff -r be02461e9810 -r d90dbf72049c docs/misc/crashdb.txt
--- a/docs/misc/crashdb.txt     Wed Dec 12 10:47:54 2007 -0700
+++ b/docs/misc/crashdb.txt     Wed Dec 12 10:50:03 2007 -0700
@@ -5,31 +5,46 @@ you've crashed it, you get to poke aroun
 you've crashed it, you get to poke around and find out why.  There's
 also a special key handler for making it crash, which is handy.
 
-You need to have crash_debug=y set when compiling to enable the crash
-debugger (so go ``export crash_debug=y; make'', or ``crash_debug=y
-make'' or ``make crash_debug=y''), and you also need to enable it on
-the Xen command line, by going e.g. cdb=com1.  If you need to have a
-serial port shared between cdb and the console, try cdb=com1H.  CDB
-will then set the high bit on every byte it sends, and only respond to
-bytes with the high bit set.  Similarly for com2.
+You need to have crash_debug=y set when compiling , and you also need
+to enable it on the Xen command line, eg by gdb=com1.
 
-The next step depends on your individual setup.  This is how to do
-it for a normal test box in the SRG:
+If you need to have a serial port shared between gdb and the console,
+you can use gdb=com1H.  CDB will then set the high bit on every byte
+it sends, and only respond to bytes with the high bit set.  Similarly
+for com2.  If you do this you will need a demultiplexing program on
+the debugging workstation, such as perhaps tools/misc/nsplitd.
 
--- Make your test machine crash.  Either a normal panic or hitting
-   'C-A C-A C-A %' on the serial console will do.
--- Start gdb as ``gdb ./xen-syms''
--- Go ``target remote serial.srg:12331'', where 12331 is the second port
-   reported for that machine by xenuse. (In this case, the machine is
-   bombjack)
--- Go ``add-symbol-file vmlinux''
--- Debug as if you had a core file
--- When you're finished, go and reboot your test box.  Hitting 'R' on the
-   serial console won't work.
+The next step depends on your individual setup.  This is how to do it
+if you have a simple null modem connection between the test box and
+the workstation, and aren't using a H/L split console:
 
-At one stage, it was sometimes possible to resume after entering the
-debugger from the serial console.  This seems to have rotted, however,
-and I'm not terribly interested in putting it back.
+  * Set debug=y in Config.mk
+  * Set crash_debug=y in xen/Rules.mk
+  * Make the changes in the attached patch, and build.
+  * Arrange to pass gdb=com1 as a hypervisor command line argument
+    (I already have com1=38400,8n1 console=com1,vga sync_console)
+    
+  * Boot the system with minicom (or your favourite terminal program)
+    connected from your workstation via a null modem cable in the
+    usual way.
+  * In minicom, give the escape character (^A by default) three times
+    to talk to Xen (Xen prints `(XEN) *** Serial input -> Xen...').
+  * Press % and observe the messages
+     (XEN) '%' pressed -> trapping into debugger
+     (XEN) GDB connection activated.
+     (XEN) Waiting for GDB to attach...
+  * Disconnect from minicom without allowing minicom to send any
+    modem control sequences.
+  * Start gdb with   gdb /path/to/build/tree/xen/xen-syms  and then
+      (gdb) set remotebaud 38400
+      Remote debugging using /dev/ttyS0
+      0xff124d61 in idle_loop () at domain.c:78
+      78              safe_halt();
+      (gdb)
+
+There is code which was once intended to make it possible to resume
+after entering the debugger.  However this does not presently work; it
+has been nonfunctional for quite some time.
 
 As soon as you reach the debugger, we disable interrupts, the
 watchdog, and every other CPU, so the state of the world shouldn't
@@ -44,7 +59,5 @@ Reasons why we might fail to reach the d
    you're screwed.
 -- If the page tables are wrong, you're screwed
 -- If the serial port setup is wrong, badness happens
--- We acquire the console lock at one stage XXX this is unnecessary and
-   stupid
 -- Obviously, the low level processor state can be screwed in any
    number of wonderful ways
diff -r be02461e9810 -r d90dbf72049c docs/misc/vtd.txt
--- a/docs/misc/vtd.txt Wed Dec 12 10:47:54 2007 -0700
+++ b/docs/misc/vtd.txt Wed Dec 12 10:50:03 2007 -0700
@@ -2,7 +2,7 @@ Authors : Allen Kay    <allen.m.kay@inte
 Authors : Allen Kay    <allen.m.kay@xxxxxxxxx>
           Weidong Han  <weidong.han@xxxxxxxxx>
 Created : October-24-2007
-Updated : October-24-2007
+Updated : December-11-2007
 
 How to turn on VT-d in Xen
 --------------------------
@@ -22,7 +22,7 @@ title Xen-Fedora Core (2.6.18-xen)
 title Xen-Fedora Core (2.6.18-xen)
         root (hd0,0)
         kernel /boot/xen.gz com1=115200,8n1 console=com1 vtd=1
-        module /boot/vmlinuz-2.6.18.8-xen root=LABEL=/ ro console=tty0 
console=ttyS0,115200,8n1 pciback.hide=(01:00.0)(03:00.0) 
pciback.verbose_request=1 apic=debug maxcpus=1
+        module /boot/vmlinuz-2.6.18.8-xen root=LABEL=/ ro console=tty0 
console=ttyS0,115200,8n1 pciback.hide=(01:00.0)(03:00.0) 
pciback.verbose_request=1 apic=debug
         module /boot/initrd-2.6.18-xen.img
 
 12) reboot system
@@ -30,6 +30,15 @@ 13) add "pci" line in /etc/xen/hvm.conf 
         pci = [ '01:00.0', '03:00.0' ]
 15) start hvm guest and use "lspci" to see the passthru device and
     "ifconfig" to see if IP address has been assigned to NIC devices.
+
+
+Caveat on Conventional PCI Device Passthrough
+---------------------------------------------
+
+VT-d spec specifies that all conventional PCI devices behind a
+PCIe-to-PCI bridge have to be assigned to the same domain.
+
+PCIe devices do not have this restriction.
 
 
 VT-d Enabled Systems
@@ -48,3 +57,4 @@ http://www.dell.com/content/products/cat
 
 - HP Compaq:  DC7800
 
http://h10010.www1.hp.com/wwpc/us/en/en/WF04a/12454-12454-64287-321860-3328898.html
+
diff -r be02461e9810 -r d90dbf72049c docs/xen-api/revision-history.tex
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/xen-api/revision-history.tex Wed Dec 12 10:50:03 2007 -0700
@@ -0,0 +1,20 @@
+{ \bf Revision History}
+
+\begin{center}
+ \begin{tabular}{|l|l|l|l|}
+  \hline
+  1.0.0 & 27th April 07 & Xensource et al. &
+   \begin{minipage}[t][.7cm]{7cm}
+     Initial Revision
+   \end{minipage}\\
+  \hline
+  1.0.1 & 10th Dec. 07 & S. Berger &
+   \begin{minipage}[t]{7cm}
+    \begin{flushleft}
+     Added XSPolicy.reset\_xspolicy, VTPM.get\_other\_config,
+     VTPM.set\_otherconfig. ACMPolicy.get\_enforced\_binary methods.
+    \end{flushleft}
+   \end{minipage}\\
+  \hline
+ \end{tabular}
+\end{center}
\ No newline at end of file
diff -r be02461e9810 -r d90dbf72049c docs/xen-api/xenapi-coversheet.tex
--- a/docs/xen-api/xenapi-coversheet.tex        Wed Dec 12 10:47:54 2007 -0700
+++ b/docs/xen-api/xenapi-coversheet.tex        Wed Dec 12 10:50:03 2007 -0700
@@ -17,12 +17,12 @@
 \newcommand{\coversheetlogo}{xen.eps}
 
 %% Document date
-\newcommand{\datestring}{27th April 2007}
+\newcommand{\datestring}{10th December 2007}
 
 \newcommand{\releasestatement}{Stable Release}
 
 %% Document revision
-\newcommand{\revstring}{API Revision 1.0.0}
+\newcommand{\revstring}{API Revision 1.0.1}
 
 %% Document authors
 \newcommand{\docauthors}{
diff -r be02461e9810 -r d90dbf72049c docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Wed Dec 12 10:47:54 2007 -0700
+++ b/docs/xen-api/xenapi-datamodel.tex Wed Dec 12 10:50:03 2007 -0700
@@ -14735,6 +14735,45 @@ State information about the policy. In c
 State information about the policy. In case an error occurred, the 'xs\_err'
 field contains the error code. The 'errors' may contain further information
 about the error.
+ \vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~reset\_xspolicy}
+
+{\bf Overview:}
+Attempt to reset the system's policy by installing the default policy.
+Since this function is implemented as an update to the current policy, it
+underlies the same restrictions. This function may fail if for example
+other domains than Domain-0 are running and use a different label than
+Domain-0
+
+\noindent {\bf Signature:}
+\begin{verbatim} xs_policystate reset_xspolicy (session_id s, xs_type type)
+\end{verbatim}
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt xs\_type } & type & the type of policy \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+
+ \noindent {\bf Return Type:}
+{\tt
+xs\_policystate
+}
+
+
+State information about the policy. In case an error occurred, the 'xs\_err'
+field contains the error code. The 'errors' may contain further information
+about the error.
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
diff -r be02461e9810 -r d90dbf72049c docs/xen-api/xenapi.tex
--- a/docs/xen-api/xenapi.tex   Wed Dec 12 10:47:54 2007 -0700
+++ b/docs/xen-api/xenapi.tex   Wed Dec 12 10:50:03 2007 -0700
@@ -32,6 +32,9 @@
 % The coversheet itself
 \include{coversheet}
 
+% The revision history
+\include{revision-history}
+
 % ... and off we go!
 
 \chapter{Introduction}
diff -r be02461e9810 -r d90dbf72049c tools/ioemu/hw/pass-through.c
--- a/tools/ioemu/hw/pass-through.c     Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/ioemu/hw/pass-through.c     Wed Dec 12 10:50:03 2007 -0700
@@ -327,6 +327,7 @@ struct pt_dev * register_real_device(PCI
     struct pt_dev *assigned_device = NULL;
     struct pci_dev *pci_dev;
     uint8_t e_device, e_intx;
+    struct pci_config_cf8 machine_bdf;
 
     PT_LOG("Assigning real physical device %02x:%02x.%x ...\n",
         r_bus, r_dev, r_func);
@@ -360,13 +361,22 @@ struct pt_dev * register_real_device(PCI
     /* Issue PCIe FLR */
     pdev_flr(pci_dev);
 
+    /* Assign device */
+    machine_bdf.reg = 0;
+    machine_bdf.bus = r_bus;
+    machine_bdf.dev = r_dev;
+    machine_bdf.func = r_func;
+    rc = xc_assign_device(xc_handle, domid, machine_bdf.value);
+    if ( rc < 0 )
+        PT_LOG("Error: xc_assign_device error %d\n", rc);
+
     /* Initialize virtualized PCI configuration (Extended 256 Bytes) */
     for ( i = 0; i < PCI_CONFIG_SIZE; i++ )
         assigned_device->dev.config[i] = pci_read_byte(pci_dev, i);
 
     /* Handle real device's MMIO/PIO BARs */
     pt_register_regions(assigned_device);
-    
+
     /* Bind interrupt */
     e_device = (assigned_device->dev.devfn >> 3) & 0x1f;
     e_intx = assigned_device->dev.config[0x3d]-1;
diff -r be02461e9810 -r d90dbf72049c tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c      Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/ioemu/hw/vga.c      Wed Dec 12 10:50:03 2007 -0700
@@ -1742,6 +1742,7 @@ static void vga_save(QEMUFile *f, void *
 static void vga_save(QEMUFile *f, void *opaque)
 {
     VGAState *s = opaque;
+    uint32_t vram_size;
 #ifdef CONFIG_BOCHS_VBE
     int i;
 #endif
@@ -1783,17 +1784,21 @@ static void vga_save(QEMUFile *f, void *
 #else
     qemu_put_byte(f, 0);
 #endif
+    vram_size = s->vram_size;
+    qemu_put_be32s(f, &vram_size); 
+    qemu_put_buffer(f, s->vram_ptr, s->vram_size); 
 }
 
 static int vga_load(QEMUFile *f, void *opaque, int version_id)
 {
     VGAState *s = opaque;
     int is_vbe, ret;
+    uint32_t vram_size;
 #ifdef CONFIG_BOCHS_VBE
     int i;
 #endif
 
-    if (version_id > 2)
+    if (version_id > 3)
         return -EINVAL;
 
     if (s->pci_dev && version_id >= 2) {
@@ -1839,6 +1844,13 @@ static int vga_load(QEMUFile *f, void *o
     if (is_vbe)
         return -EINVAL;
 #endif
+    if (version_id >= 3) {
+       /* people who restore old images may be lucky ... */
+       qemu_get_be32s(f, &vram_size);
+       if (vram_size != s->vram_size)
+           return -EINVAL;
+       qemu_get_buffer(f, s->vram_ptr, s->vram_size); 
+    }
 
     /* force refresh */
     s->graphic_mode = -1;
@@ -2052,7 +2064,7 @@ static void vga_init(VGAState *s)
 {
     int vga_io_memory;
 
-    register_savevm("vga", 0, 2, vga_save, vga_load, s);
+    register_savevm("vga", 0, 3, vga_save, vga_load, s);
 
     register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
 
diff -r be02461e9810 -r d90dbf72049c tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/libxc/xc_domain.c   Wed Dec 12 10:50:03 2007 -0700
@@ -759,7 +759,21 @@ int xc_assign_device(
     domctl.cmd = XEN_DOMCTL_assign_device;
     domctl.domain = domid;
     domctl.u.assign_device.machine_bdf = machine_bdf;
- 
+
+    return do_domctl(xc_handle, &domctl);
+}
+
+int xc_test_assign_device(
+    int xc_handle,
+    uint32_t domid,
+    uint32_t machine_bdf)
+{
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_test_assign_device;
+    domctl.domain = domid;
+    domctl.u.assign_device.machine_bdf = machine_bdf;
+
     return do_domctl(xc_handle, &domctl);
 }
 
diff -r be02461e9810 -r d90dbf72049c tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/libxc/xenctrl.h     Wed Dec 12 10:50:03 2007 -0700
@@ -914,6 +914,10 @@ int xc_assign_device(int xc_handle,
                      uint32_t domid,
                      uint32_t machine_bdf);
 
+int xc_test_assign_device(int xc_handle,
+                          uint32_t domid,
+                          uint32_t machine_bdf);
+
 int xc_domain_memory_mapping(int xc_handle,
                              uint32_t domid,
                              unsigned long first_gfn,
diff -r be02461e9810 -r d90dbf72049c tools/libxen/include/xen/api/xen_xspolicy.h
--- a/tools/libxen/include/xen/api/xen_xspolicy.h       Wed Dec 12 10:47:54 
2007 -0700
+++ b/tools/libxen/include/xen/api/xen_xspolicy.h       Wed Dec 12 10:50:03 
2007 -0700
@@ -240,6 +240,19 @@ xen_xspolicy_set_xspolicy(xen_session *s
                           bool overwrite);
 
 
+
+/**
+ * Attempt to reset the system's policy to the DEFAULT policy for the
+ * respective policy type. This is done by updating the system and therefore
+ * underlies the same restrictions of a policy update. This operation may
+ * for example fail if other domains than Domain-0 are running and have
+ * different labels than Domain-0.
+ */
+bool
+xen_xspolicy_reset_xspolicy(xen_session *session, xen_xs_policystate **result,
+                            xs_type type);
+
+
 /**
  * Remove any policy from having the system booted with.
  */
diff -r be02461e9810 -r d90dbf72049c tools/libxen/src/xen_xspolicy.c
--- a/tools/libxen/src/xen_xspolicy.c   Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/libxen/src/xen_xspolicy.c   Wed Dec 12 10:50:03 2007 -0700
@@ -225,6 +225,24 @@ xen_xspolicy_set_xspolicy(xen_session *s
 
 
 bool
+xen_xspolicy_reset_xspolicy(xen_session *session, xen_xs_policystate **result,
+                            xs_type type)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_int,
+              .u.int_val = type },
+        };
+
+    abstract_type result_type = xen_xs_policystate_abstract_type_;
+
+    *result = NULL;
+    XEN_CALL_("XSPolicy.reset_xspolicy");
+    return session->ok;
+}
+
+
+bool
 xen_xspolicy_get_xspolicy(xen_session *session, xen_xs_policystate **result)
 {
     abstract_value param_values[] =
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/lowlevel/xc/xc.c Wed Dec 12 10:50:03 2007 -0700
@@ -560,9 +560,9 @@ static int next_bdf(char **str, int *seg
     return 1;
 }
 
-static PyObject *pyxc_assign_device(XcObject *self,
-                                    PyObject *args,
-                                    PyObject *kwds)
+static PyObject *pyxc_test_assign_device(XcObject *self,
+                                         PyObject *args,
+                                         PyObject *kwds)
 {
     uint32_t dom;
     char *pci_str;
@@ -580,7 +580,7 @@ static PyObject *pyxc_assign_device(XcOb
         bdf |= (dev & 0x1f) << 11;
         bdf |= (func & 0x7) << 8;
 
-        if ( xc_assign_device(self->xc_handle, dom, bdf) != 0 )
+        if ( xc_test_assign_device(self->xc_handle, dom, bdf) != 0 )
             break;
 
         bdf = 0;
@@ -1426,10 +1426,10 @@ static PyMethodDef pyxc_methods[] = {
       " value   [long]:     Value of param.\n"
       "Returns: [int] 0 on success.\n" },
 
-     { "assign_device",
-       (PyCFunction)pyxc_assign_device,
+     { "test_assign_device",
+       (PyCFunction)pyxc_test_assign_device,
        METH_VARARGS | METH_KEYWORDS, "\n"
-       "assign device with VT-d.\n"
+       "test device assignment with VT-d.\n"
        " dom     [int]:      Identifier of domain to build into.\n"
        " pci_str [str]:      PCI devices.\n"
        "Returns: [int] 0 on success, or device bdf that can't be assigned.\n" 
},
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/util/acmpolicy.py
--- a/tools/python/xen/util/acmpolicy.py        Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/util/acmpolicy.py        Wed Dec 12 10:50:03 2007 -0700
@@ -86,7 +86,7 @@ DEFAULT_policy = \
 "  <SecurityLabelTemplate>\n" +\
 "    <SubjectLabels bootstrap=\"SystemManagement\">\n" +\
 "      <VirtualMachineLabel>\n" +\
-"        <Name>SystemManagement</Name>\n" +\
+"        <Name%s>SystemManagement</Name>\n" +\
 "        <SimpleTypeEnforcementTypes>\n" +\
 "          <Type>SystemManagement</Type>\n" +\
 "        </SimpleTypeEnforcementTypes>\n" +\
@@ -99,8 +99,11 @@ DEFAULT_policy = \
 "</SecurityPolicyDefinition>\n"
 
 
-def get_DEFAULT_policy():
-    return DEFAULT_policy
+def get_DEFAULT_policy(dom0label=""):
+    fromnode = ""
+    if dom0label != "":
+        fromnode = " from=\"%s\"" % dom0label
+    return DEFAULT_policy % fromnode
 
 def initialize():
     xoptions = XendOptions.instance()
@@ -375,6 +378,12 @@ class ACMPolicy(XSPolicy):
 
     force_default_policy = classmethod(force_default_policy)
 
+    def get_reset_policy_xml(klass):
+        dom0_label = security.get_ssid(0)[1]
+        return get_DEFAULT_policy(dom0_label)
+
+    get_reset_policy_xml = classmethod(get_reset_policy_xml)
+
     def __do_update_version_check(self, acmpol_new):
         acmpol_old = self
 
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/util/xsm/acm/acm.py
--- a/tools/python/xen/util/xsm/acm/acm.py      Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/util/xsm/acm/acm.py      Wed Dec 12 10:50:03 2007 -0700
@@ -86,6 +86,7 @@ xmlrpc_exports = [
   'list_labels',
   'get_labeled_resources',
   'set_policy',
+  'reset_policy',
   'get_policy',
   'activate_policy',
   'rm_bootpolicy',
@@ -562,6 +563,20 @@ def set_policy(xs_type, xml, flags, over
              xspoladmin.add_acmpolicy_to_system(xml,
                                                 int(flags),
                                                 True)
+        return rc, base64.b64encode(errors)
+    except Exception, e:
+        err(str(e))
+
+
+def reset_policy():
+    """
+       Xend exports this function via XML-RPC
+    """
+    from xen.xend import XendXSPolicyAdmin
+    xspoladmin = XendXSPolicyAdmin.XSPolicyAdminInstance()
+    try:
+        acmpol, rc, errors = \
+             xspoladmin.reset_acmpolicy()
         return rc, base64.b64encode(errors)
     except Exception, e:
         err(str(e))
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/util/xsm/dummy/dummy.py
--- a/tools/python/xen/util/xsm/dummy/dummy.py  Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/util/xsm/dummy/dummy.py  Wed Dec 12 10:50:03 2007 -0700
@@ -21,6 +21,7 @@ xmlrpc_exports = [
   'list_labels',
   'get_labeled_resources',
   'set_policy',
+  'reset_policy',
   'get_policy',
   'activate_policy',
   'rm_bootpolicy',
@@ -102,6 +103,9 @@ def set_policy(xs_type, xml, flags, over
 def set_policy(xs_type, xml, flags, overwrite):
     err("Command not supported under xsm 'dummy' module.")
 
+def reset_policy():
+    err("Command not supported under xsm 'dummy' module.")
+
 def get_policy():
     return "", 0
 
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/XendDevices.py
--- a/tools/python/xen/xend/XendDevices.py      Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xend/XendDevices.py      Wed Dec 12 10:50:03 2007 -0700
@@ -19,7 +19,7 @@
 # A collection of DevControllers 
 #
 
-from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif, 
vfbif
+from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, vfbif
 from xen.xend.server.BlktapController import BlktapController
 from xen.xend.server.ConsoleController import ConsoleController
 
@@ -41,7 +41,6 @@ class XendDevices:
         'pci': pciif.PciController,
         'ioports': iopif.IOPortsController,
         'irq': irqif.IRQController,
-        'usb': usbif.UsbifController,
         'tap': BlktapController,
         'vfb': vfbif.VfbifController,
         'vkbd': vfbif.VkbdifController,
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xend/XendDomain.py       Wed Dec 12 10:50:03 2007 -0700
@@ -613,13 +613,19 @@ class XendDomain:
                 if dom.getName() == DOM0_NAME:
                     continue
                 
-                if dom._stateGet() == DOM_STATE_RUNNING:
-                    shutdownAction = dom.info.get('on_xend_stop', 'ignore')
-                    if shutdownAction == 'shutdown':
-                        log.debug('Shutting down domain: %s' % dom.getName())
-                        dom.shutdown("poweroff")
-                    elif shutdownAction == 'suspend':
-                        self.domain_suspend(dom.getName())
+                try:
+                    if dom._stateGet() == DOM_STATE_RUNNING:
+                        shutdownAction = dom.info.get('on_xend_stop', 'ignore')
+                        if shutdownAction == 'shutdown':
+                            log.debug('Shutting down domain: %s' % 
dom.getName())
+                            dom.shutdown("poweroff")
+                        elif shutdownAction == 'suspend':
+                            self.domain_suspend(dom.getName())
+                        else:
+                            log.debug('Domain %s continues to run.' % 
dom.getName())
+                except:
+                    log.exception('Domain %s failed to %s.' % \
+                                  (dom.getName(), shutdownAction))
         finally:
             self.domains_lock.release()
 
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Dec 12 10:50:03 2007 -0700
@@ -1653,10 +1653,10 @@ class XendDomainInfo:
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max']))
 
-        # Assign devices with VT-d
+        # Test whether the devices can be assigned with VT-d
         pci_str = str(self.info["platform"].get("pci"))
         if hvm and pci_str:
-            bdf = xc.assign_device(self.domid, pci_str)
+            bdf = xc.test_assign_device(self.domid, pci_str)
             if bdf != 0:
                 bus = (bdf >> 16) & 0xff
                 devfn = (bdf >> 8) & 0xff
@@ -1880,8 +1880,6 @@ class XendDomainInfo:
 
         self._cleanupVm()
         if self.dompath is not None:
-            if self.domid is not None:
-                xc.domain_destroy_hook(self.domid)
             self.destroyDomain()
 
         self._cleanup_phantom_devs(paths)
@@ -1899,6 +1897,7 @@ class XendDomainInfo:
 
         try:
             if self.domid is not None:
+                xc.domain_destroy_hook(self.domid)
                 xc.domain_destroy(self.domid)
                 for state in DOM_STATES_OLD:
                     self.info[state] = 0
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/XendXSPolicy.py
--- a/tools/python/xen/xend/XendXSPolicy.py     Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xend/XendXSPolicy.py     Wed Dec 12 10:50:03 2007 -0700
@@ -43,6 +43,7 @@ class XendXSPolicy(XendBase):
     def getFuncs(self):
         funcs = [ 'get_xstype',
                   'set_xspolicy',
+                  'reset_xspolicy',
                   'get_xspolicy',
                   'rm_xsbootpolicy',
                   'get_resource_label',
@@ -104,6 +105,36 @@ class XendXSPolicy(XendBase):
             raise SecurityError(-xsconstants.XSERR_POLICY_TYPE_UNSUPPORTED)
         return polstate
 
+
+    def reset_xspolicy(self, xstype):
+        xstype = int(xstype)
+        polstate = { 'xs_ref': "", 'repr'   : "", 'type'   : 0,
+                     'flags' : 0 , 'version': 0 , 'errors' : "", 'xserr' : 0 }
+        if xstype == xsconstants.XS_POLICY_ACM:
+            poladmin = XSPolicyAdminInstance()
+            try:
+                (xspol, rc, errors) = poladmin.reset_acmpolicy()
+                if rc != 0:
+                    polstate.update( { 'xserr' : rc,
+                                       'errors': base64.b64encode(errors) } )
+                else:
+                    ref = xspol.get_ref()
+                    polstate = {
+                      'xs_ref' : ref,
+                      'flags'  : poladmin.get_policy_flags(xspol),
+                      'type'   : xstype,
+                      'repr'   : "",
+                      'version': xspol.get_version(),
+                      'errors' : base64.b64encode(errors),
+                      'xserr'  : rc,
+                    }
+            except Exception, e:
+                raise
+        else:
+            raise SecurityError(-xsconstants.XSERR_POLICY_TYPE_UNSUPPORTED)
+        return polstate
+
+
     def activate_xspolicy(self, flags):
         flags = int(flags)
         rc = -xsconstants.XSERR_GENERAL_FAILURE
@@ -162,6 +193,7 @@ class XendXSPolicy(XendBase):
     get_xstype      = classmethod(get_xstype)
     get_xspolicy    = classmethod(get_xspolicy)
     set_xspolicy    = classmethod(set_xspolicy)
+    reset_xspolicy  = classmethod(reset_xspolicy)
     rm_xsbootpolicy = classmethod(rm_xsbootpolicy)
     set_resource_label = classmethod(set_resource_label)
     get_resource_label = classmethod(get_resource_label)
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/XendXSPolicyAdmin.py
--- a/tools/python/xen/xend/XendXSPolicyAdmin.py        Wed Dec 12 10:47:54 
2007 -0700
+++ b/tools/python/xen/xend/XendXSPolicyAdmin.py        Wed Dec 12 10:50:03 
2007 -0700
@@ -179,6 +179,23 @@ class XSPolicyAdmin:
             self.xsobjs[ref]  = acmpol
         return (acmpol, xsconstants.XSERR_SUCCESS, errors)
 
+
+    def reset_acmpolicy(self):
+        """
+           Attempt to reset the system's policy by udating it with
+           the DEFAULT policy.
+        """
+        from xen.xend import XendDomain
+        domains = XendDomain.instance()
+        try:
+            domains.domains_lock.acquire()
+            xml = ACMPolicy.get_reset_policy_xml()
+            flags = xsconstants.XS_INST_BOOT | xsconstants.XS_INST_LOAD
+            return self.__add_acmpolicy_to_system(xml, flags, True)
+        finally:
+            domains.domains_lock.release()
+
+
     def make_boot_policy(self, acmpol):
         if acmpol.is_default_policy():
             return xsconstants.XSERR_SUCCESS
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xend/server/usbif.py
--- a/tools/python/xen/xend/server/usbif.py     Wed Dec 12 10:47:54 2007 -0700
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#============================================================================
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of version 2.1 of the GNU Lesser General Public
-# License as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-#============================================================================
-# Copyright (C) 2004 Mike Wray <mike.wray@xxxxxx>
-# Copyright (C) 2004 Intel Research Cambridge
-# Copyright (C) 2004 Mark Williamson <mark.williamson@xxxxxxxxxxxx>
-# Copyright (C) 2005 XenSource Ltd
-#============================================================================
-
-
-"""Support for virtual USB hubs.
-"""
-
-from xen.xend.server.DevController import DevController
-
-
-class UsbifController(DevController):
-    """USB device interface controller. Handles all USB devices
-    for a domain.
-    """
-    
-    def __init__(self, vm):
-        """Create a USB device controller.
-        """
-        DevController.__init__(self, vm)
-
-
-    def getDeviceDetails(self, _):
-        """@see DevController.getDeviceDetails"""
-
-        return (self.allocateDeviceID(), {}, {})
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xm/create.py     Wed Dec 12 10:50:03 2007 -0700
@@ -309,11 +309,6 @@ gopts.var('irq', val='IRQ',
          For example 'irq=7'.
          This option may be repeated to add more than one IRQ.""")
 
-gopts.var('usbport', val='PATH',
-          fn=append_value, default=[],
-          use="""Add a physical USB port to a domain, as specified by the path
-          to that port.  This option may be repeated to add more than one 
port.""")
-
 gopts.var('vfb', 
val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD",
           fn=append_value, default=[],
           use="""Make the domain a framebuffer backend.
@@ -616,11 +611,6 @@ def configure_irq(config_devs, vals):
     for irq in vals.irq:
         config_irq = ['irq', ['irq', irq]]
         config_devs.append(['device', config_irq])
-
-def configure_usb(config_devs, vals):
-    for path in vals.usbport:
-        config_usb = ['usbport', ['path', path]]
-        config_devs.append(['device', config_usb])
 
 def configure_vfbs(config_devs, vals):
     for f in vals.vfb:
@@ -800,7 +790,6 @@ def make_config(vals):
     configure_ioports(config_devs, vals)
     configure_irq(config_devs, vals)
     configure_vifs(config_devs, vals)
-    configure_usb(config_devs, vals)
     configure_vtpm(config_devs, vals)
     configure_vfbs(config_devs, vals)
     configure_security(config, vals)
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xm/main.py       Wed Dec 12 10:50:03 2007 -0700
@@ -1833,7 +1833,7 @@ def xm_top(args):
 def xm_top(args):
     arg_check(args, "top", 0)
 
-    os.execvp('xentop', ['xentop'])
+    os.system('xentop')
 
 def xm_dmesg(args):
     arg_check(args, "dmesg", 0, 1)
diff -r be02461e9810 -r d90dbf72049c tools/python/xen/xm/resetpolicy.py
--- a/tools/python/xen/xm/resetpolicy.py        Wed Dec 12 10:47:54 2007 -0700
+++ b/tools/python/xen/xm/resetpolicy.py        Wed Dec 12 10:50:03 2007 -0700
@@ -26,40 +26,6 @@ from xen.util import xsconstants
 from xen.util import xsconstants
 from xen.util.acmpolicy import ACMPolicy
 
-DOM0_UUID = "00000000-0000-0000-0000-000000000000"
-
-DEFAULT_policy_template = \
-"<?xml version=\"1.0\" ?>" +\
-"<SecurityPolicyDefinition xmlns=\"http://www.ibm.com\"; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; 
xsi:schemaLocation=\"http://www.ibm.com ../../security_policy.xsd\">" +\
-"  <PolicyHeader>" +\
-"    <PolicyName>DEFAULT</PolicyName>" +\
-"    <Version>1.0</Version>" +\
-"  </PolicyHeader>" +\
-"  <SimpleTypeEnforcement>" +\
-"    <SimpleTypeEnforcementTypes>" +\
-"      <Type>SystemManagement</Type>" +\
-"    </SimpleTypeEnforcementTypes>" +\
-"  </SimpleTypeEnforcement>" +\
-"  <ChineseWall>" +\
-"    <ChineseWallTypes>" +\
-"      <Type>SystemManagement</Type>" +\
-"    </ChineseWallTypes>" +\
-"  </ChineseWall>" +\
-"  <SecurityLabelTemplate>" +\
-"    <SubjectLabels bootstrap=\"SystemManagement\">" +\
-"      <VirtualMachineLabel>" +\
-"        <Name%s>SystemManagement</Name>" +\
-"        <SimpleTypeEnforcementTypes>" +\
-"          <Type>SystemManagement</Type>" +\
-"        </SimpleTypeEnforcementTypes>" +\
-"        <ChineseWallTypes>" +\
-"          <Type/>" +\
-"        </ChineseWallTypes>" +\
-"      </VirtualMachineLabel>" +\
-"    </SubjectLabels>" +\
-"  </SecurityLabelTemplate>" +\
-"</SecurityPolicyDefinition>"
-
 
 def help():
     return """
@@ -69,16 +35,6 @@ def help():
     since otherwise this operation will fail.
     """
 
-def get_reset_policy_xml(dom0_seclab):
-    if dom0_seclab == "":
-        return DEFAULT_policy_template % ""
-    else:
-        poltyp, policy, label = dom0_seclab.split(":")
-        if label != "SystemManagement":
-            return DEFAULT_policy_template % \
-                   (" from=\"%s\"" % label)
-        else:
-            return DEFAULT_policy_template % ""
 
 def resetpolicy():
     msg = None
@@ -99,13 +55,8 @@ def resetpolicy():
            not acmpol.is_default_policy():
             msg = "Old policy not found in bootloader file."
 
-        seclab = server.xenapi.VM.get_security_label(DOM0_UUID)
-        xml = get_reset_policy_xml(seclab)
         try:
-            policystate = server.xenapi.XSPolicy.set_xspolicy(xs_type,
-                                                              xml,
-                                                              flags,
-                                                              True)
+            policystate = server.xenapi.XSPolicy.reset_xspolicy(xs_type)
         except Exception, e:
             raise security.XSMError("An error occurred resetting the "
                                     "policy: %s" % str(e))
@@ -130,14 +81,7 @@ def resetpolicy():
            not acmpol.is_default_policy():
             msg = "Old policy not found in bootloader file."
 
-        seclab = server.xend.security.get_domain_label(0)
-        if seclab[0] == '\'':
-            seclab =  seclab[1:]
-        xml = get_reset_policy_xml(seclab)
-        rc, errors = server.xend.security.set_policy(xs_type,
-                                                     xml,
-                                                     flags,
-                                                     True)
+        rc, errors = server.xend.security.reset_policy()
         if rc != xsconstants.XSERR_SUCCESS:
             raise security.XSMError("Could not reset the system's policy. "
                                     "Try to halt all guests.")
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c     Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/domctl.c     Wed Dec 12 10:50:03 2007 -0700
@@ -525,10 +525,31 @@ long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_test_assign_device:
+    {
+        u8 bus, devfn;
+
+        ret = -EINVAL;
+        if ( !vtd_enabled )
+            break;
+
+        bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff;
+        devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff;
+
+        if ( device_assigned(bus, devfn) )
+        {
+            gdprintk(XENLOG_ERR, "XEN_DOMCTL_test_assign_device: "
+                     "%x:%x:%x already assigned\n",
+                     bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+            break;
+        }
+        ret = 0;
+    }
+    break;
+
     case XEN_DOMCTL_assign_device:
     {
         struct domain *d;
-        struct hvm_iommu *hd;
         u8 bus, devfn;
 
         ret = -EINVAL;
@@ -541,7 +562,6 @@ long arch_do_domctl(
                 "XEN_DOMCTL_assign_device: get_domain_by_id() failed\n");
             break;
         }
-        hd = domain_hvm_iommu(d);
         bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff;
         devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff;
 
@@ -549,7 +569,7 @@ long arch_do_domctl(
         {
             gdprintk(XENLOG_ERR, "XEN_DOMCTL_assign_device: "
                      "%x:%x:%x already assigned\n",
-                     bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 
+                     bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
             break;
         }
 
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/gdbstub.c
--- a/xen/arch/x86/gdbstub.c    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/gdbstub.c    Wed Dec 12 10:50:03 2007 -0700
@@ -71,18 +71,20 @@ gdb_arch_read_reg(unsigned long regnum, 
     gdb_send_reply("", ctx);
 }
 
-/* Like copy_from_user, but safe to call with interrupts disabled.
-   Trust me, and don't look behind the curtain. */
+/*
+ * Use __copy_*_user to make us page-fault safe, but not otherwise restrict
+ * our access to the full virtual address space.
+ */
 unsigned int
 gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
 {
-    return copy_from_user(dest, src, len);
+    return __copy_from_user(dest, src, len);
 }
 
 unsigned int 
 gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
 {
-    return copy_to_user(dest, src, len);
+    return __copy_to_user(dest, src, len);
 }
 
 void 
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/i8254.c
--- a/xen/arch/x86/hvm/i8254.c  Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/i8254.c  Wed Dec 12 10:50:03 2007 -0700
@@ -501,6 +501,8 @@ void pit_init(struct vcpu *v, unsigned l
     /* Some sub-functions assert that they are called with the lock held. */
     spin_lock(&pit->lock);
 
+    pit->pt0.source = PTSRC_isa;
+
     register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
     register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);
     ticks_per_sec(v) = cpu_khz * (int64_t)1000;
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/irq.c
--- a/xen/arch/x86/hvm/irq.c    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/irq.c    Wed Dec 12 10:50:03 2007 -0700
@@ -345,30 +345,6 @@ struct hvm_intack hvm_vcpu_ack_pending_i
     }
 
     return intack;
-}
-
-int get_isa_irq_vector(struct vcpu *v, int isa_irq, enum hvm_intsrc src)
-{
-    unsigned int gsi = hvm_isa_irq_to_gsi(isa_irq);
-
-    if ( src == hvm_intsrc_pic )
-        return (v->domain->arch.hvm_domain.vpic[isa_irq >> 3].irq_base
-                + (isa_irq & 7));
-
-    ASSERT(src == hvm_intsrc_lapic);
-    return domain_vioapic(v->domain)->redirtbl[gsi].fields.vector;
-}
-
-int is_isa_irq_masked(struct vcpu *v, int isa_irq)
-{
-    unsigned int gsi = hvm_isa_irq_to_gsi(isa_irq);
-
-    if ( is_lvtt(v, isa_irq) )
-        return !is_lvtt_enabled(v);
-
-    return ((v->domain->arch.hvm_domain.vpic[isa_irq >> 3].imr &
-             (1 << (isa_irq & 7))) &&
-            domain_vioapic(v->domain)->redirtbl[gsi].fields.mask);
 }
 
 int hvm_local_events_need_delivery(struct vcpu *v)
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/mtrr.c
--- a/xen/arch/x86/hvm/mtrr.c   Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/mtrr.c   Wed Dec 12 10:50:03 2007 -0700
@@ -769,3 +769,83 @@ int32_t hvm_set_mem_pinned_cacheattr(
 
     return 0;
 }
+
+static int hvm_save_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
+{
+    int i;
+    struct vcpu *v;
+    struct hvm_hw_mtrr hw_mtrr;
+    struct mtrr_state *mtrr_state;
+    /* save mtrr&pat */
+    for_each_vcpu(d, v)
+    {
+        mtrr_state = &v->arch.hvm_vcpu.mtrr;
+
+        hw_mtrr.msr_pat_cr = v->arch.hvm_vcpu.pat_cr;
+
+        hw_mtrr.msr_mtrr_def_type = mtrr_state->def_type
+                                | (mtrr_state->enabled << 10);
+        hw_mtrr.msr_mtrr_cap = mtrr_state->mtrr_cap;
+
+        for ( i = 0; i < MTRR_VCNT; i++ )
+        {
+            /* save physbase */
+            hw_mtrr.msr_mtrr_var[i*2] =
+                ((uint64_t*)mtrr_state->var_ranges)[i*2];
+            /* save physmask */
+            hw_mtrr.msr_mtrr_var[i*2+1] =
+                ((uint64_t*)mtrr_state->var_ranges)[i*2+1];
+        }
+
+        for ( i = 0; i < NUM_FIXED_MSR; i++ )
+            hw_mtrr.msr_mtrr_fixed[i] =
+                ((uint64_t*)mtrr_state->fixed_ranges)[i];
+
+        if ( hvm_save_entry(MTRR, v->vcpu_id, h, &hw_mtrr) != 0 )
+            return 1;
+    }
+    return 0;
+}
+
+static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
+{
+    int vcpuid, i;
+    struct vcpu *v;
+    struct mtrr_state *mtrr_state;
+    struct hvm_hw_mtrr hw_mtrr;
+
+    vcpuid = hvm_load_instance(h);
+    if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL )
+    {
+        gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid);
+        return -EINVAL;
+    }
+
+    if ( hvm_load_entry(MTRR, h, &hw_mtrr) != 0 )
+        return -EINVAL;
+
+    mtrr_state = &v->arch.hvm_vcpu.mtrr;
+
+    pat_msr_set(&v->arch.hvm_vcpu.pat_cr, hw_mtrr.msr_pat_cr);
+
+    mtrr_state->mtrr_cap = hw_mtrr.msr_mtrr_cap;
+
+    for ( i = 0; i < NUM_FIXED_MSR; i++ )
+        mtrr_fix_range_msr_set(mtrr_state, i, hw_mtrr.msr_mtrr_fixed[i]);
+
+    for ( i = 0; i < MTRR_VCNT; i++ )
+    {
+        mtrr_var_range_msr_set(mtrr_state,
+                MTRRphysBase_MSR(i), hw_mtrr.msr_mtrr_var[i*2]);
+        mtrr_var_range_msr_set(mtrr_state,
+                MTRRphysMask_MSR(i), hw_mtrr.msr_mtrr_var[i*2+1]);
+    }
+
+    mtrr_def_type_msr_set(mtrr_state, hw_mtrr.msr_mtrr_def_type);
+
+    v->arch.hvm_vcpu.mtrr.is_initialized = 1;
+    return 0;
+}
+
+HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, hvm_load_mtrr_msr,
+                          1, HVMSR_PER_VCPU);
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/rtc.c
--- a/xen/arch/x86/hvm/rtc.c    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/rtc.c    Wed Dec 12 10:50:03 2007 -0700
@@ -40,14 +40,6 @@ static void rtc_periodic_cb(struct vcpu 
     spin_lock(&s->lock);
     s->hw.cmos_data[RTC_REG_C] |= 0xc0;
     spin_unlock(&s->lock);
-}
-
-int is_rtc_periodic_irq(void *opaque)
-{
-    RTCState *s = opaque;
-
-    return !(s->hw.cmos_data[RTC_REG_C] & RTC_AF || 
-             s->hw.cmos_data[RTC_REG_C] & RTC_UF);
 }
 
 /* Enable/configure/disable the periodic timer based on the RTC_PIE and
@@ -488,6 +480,8 @@ void rtc_init(struct vcpu *v, int base)
 
     spin_lock_init(&s->lock);
 
+    s->pt.source = PTSRC_isa;
+
     s->hw.cmos_data[RTC_REG_A] = RTC_REF_CLCK_32KHZ | 6; /* ~1kHz */
     s->hw.cmos_data[RTC_REG_B] = RTC_24H;
     s->hw.cmos_data[RTC_REG_C] = 0;
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vioapic.c
--- a/xen/arch/x86/hvm/vioapic.c        Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vioapic.c        Wed Dec 12 10:50:03 2007 -0700
@@ -300,7 +300,7 @@ static inline int pit_channel0_enabled(v
 static inline int pit_channel0_enabled(void)
 {
     PITState *pit = &current->domain->arch.hvm_domain.pl_time.vpit;
-    return pit->pt0.enabled;
+    return pt_active(&pit->pt0);
 }
 
 static void vioapic_deliver(struct hvm_hw_vioapic *vioapic, int irq)
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vlapic.c
--- a/xen/arch/x86/hvm/vlapic.c Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vlapic.c Wed Dec 12 10:50:03 2007 -0700
@@ -68,9 +68,6 @@ static unsigned int vlapic_lvt_mask[VLAP
 #define APIC_DEST_NOSHORT                0x0
 #define APIC_DEST_MASK                   0x800
 
-#define vlapic_lvt_enabled(vlapic, lvt_type)                    \
-    (!(vlapic_get_reg(vlapic, lvt_type) & APIC_LVT_MASKED))
-
 #define vlapic_lvt_vector(vlapic, lvt_type)                     \
     (vlapic_get_reg(vlapic, lvt_type) & APIC_VECTOR_MASK)
 
@@ -932,6 +929,8 @@ int vlapic_init(struct vcpu *v)
 
     HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "%d", v->vcpu_id);
 
+    vlapic->pt.source = PTSRC_lapic;
+
 #ifdef __i386__
     /* 32-bit VMX may be limited to 32-bit physical addresses. */
     if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
@@ -974,18 +973,3 @@ void vlapic_destroy(struct vcpu *v)
     unmap_domain_page_global(vlapic->regs);
     free_domheap_page(vlapic->regs_page);
 }
-
-int is_lvtt(struct vcpu *v, int vector)
-{
-    return vcpu_vlapic(v)->pt.enabled &&
-           vector == vlapic_lvt_vector(vcpu_vlapic(v), APIC_LVTT);
-}
-
-int is_lvtt_enabled(struct vcpu *v)
-{
-    if ( unlikely(!vlapic_enabled(vcpu_vlapic(v))) ||
-            !vlapic_lvt_enabled(vcpu_vlapic(v), APIC_LVTT)) 
-        return 0;
-
-    return 1;
-}
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vmx/vtd/dmar.c
--- a/xen/arch/x86/hvm/vmx/vtd/dmar.c   Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/dmar.c   Wed Dec 12 10:50:03 2007 -0700
@@ -30,7 +30,6 @@
 #include "pci-direct.h"
 #include "pci_regs.h"
 
-#define VTDPREFIX
 int vtd_enabled;
 boolean_param("vtd", vtd_enabled);
 
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vmx/vtd/intel-iommu.c
--- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c    Wed Dec 12 10:50:03 2007 -0700
@@ -37,7 +37,6 @@
 
 #define domain_iommu_domid(d) ((d)->arch.hvm_domain.hvm_iommu.iommu_domid)
 
-#define VTDPREFIX
 extern void print_iommu_regs(struct acpi_drhd_unit *drhd);
 extern void print_vtd_entries(struct domain *d, int bus, int devfn,
                               unsigned long gmfn);
@@ -954,7 +953,7 @@ struct iommu *iommu_alloc(void *hw_data)
 
     set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, drhd->address);
     iommu->reg = (void *) fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
-    dprintk(XENLOG_ERR VTDPREFIX,
+    dprintk(XENLOG_INFO VTDPREFIX,
             "iommu_alloc: iommu->reg = %p drhd->address = %lx\n",
             iommu->reg, drhd->address);
     nr_iommus++;
@@ -1058,7 +1057,7 @@ static int domain_context_mapping_one(
 
     if ( context_present(*context) )
     {
-        gdprintk(XENLOG_INFO VTDPREFIX,
+        gdprintk(XENLOG_WARNING VTDPREFIX,
                  "domain_context_mapping_one:context present:bdf=%x:%x:%x\n",
                  bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
         return 0;
@@ -1097,7 +1096,7 @@ static int domain_context_mapping_one(
     iommu_flush_cache_entry(iommu, context);
 
     gdprintk(XENLOG_INFO VTDPREFIX,
-             "context_mapping_one-%x:%x:%x-*context=%"PRIx64":%"PRIx64
+             "domain_context_mapping_one-%x:%x:%x-*context=%"PRIx64":%"PRIx64
              " hd->pgd=%p\n",
              bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
              context->hi, context->lo, hd->pgd);
@@ -1198,14 +1197,11 @@ static int domain_context_mapping(
             PCI_FUNC(pdev->devfn), PCI_SUBORDINATE_BUS);
 
         if ( sec_bus != sub_bus )
-        {
-            dprintk(XENLOG_INFO VTDPREFIX,
-                    "context_mapping: nested PCI bridge not supported\n");
-            dprintk(XENLOG_INFO VTDPREFIX,
-                    "    bdf = %x:%x:%x sec_bus = %x sub_bus = %x\n",
-                    pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
-                    sec_bus, sub_bus);
-        }
+            gdprintk(XENLOG_WARNING VTDPREFIX,
+                     "context_context_mapping: nested PCI bridge not "
+                     "supported: bdf = %x:%x:%x sec_bus = %x sub_bus = %x\n",
+                     pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
+                     sec_bus, sub_bus);
         break;
     case DEV_TYPE_PCIe_ENDPOINT:
         gdprintk(XENLOG_INFO VTDPREFIX,
@@ -1227,7 +1223,7 @@ static int domain_context_mapping(
             if ( bus2bridge[pdev->bus].bus != 0 )
                 gdprintk(XENLOG_WARNING VTDPREFIX,
                          "domain_context_mapping:bus2bridge"
-                         "[pdev->bus].bus != 0\n");
+                         "[%d].bus != 0\n", pdev->bus);
 
             ret = domain_context_mapping_one(
                 domain, iommu,
@@ -1345,8 +1341,8 @@ static int domain_context_unmap(
         {
             if ( bus2bridge[pdev->bus].bus != 0 )
                 gdprintk(XENLOG_WARNING VTDPREFIX,
-                         "domain_context_mapping:"
-                         "bus2bridge[pdev->bus].bus != 0\n");
+                         "domain_context_unmap:"
+                         "bus2bridge[%d].bus != 0\n", pdev->bus);
 
             ret = domain_context_unmap_one(domain, iommu,
                                            (u8)(bus2bridge[pdev->bus].bus),
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vmx/vtd/io.c
--- a/xen/arch/x86/hvm/vmx/vtd/io.c     Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/io.c     Wed Dec 12 10:50:03 2007 -0700
@@ -131,7 +131,7 @@ int pt_irq_create_bind_vtd(
         pirq_guest_bind(d->vcpu[0], machine_gsi, BIND_PIRQ__WILL_SHARE);
     }
 
-    gdprintk(XENLOG_INFO,
+    gdprintk(XENLOG_INFO VTDPREFIX,
              "VT-d irq bind: m_irq = %x device = %x intx = %x\n",
              machine_gsi, device, intx);
     return 0;
@@ -187,7 +187,7 @@ static void hvm_dpci_isairq_eoi(struct d
                 if ( --dpci->mirq[i].pending == 0 )
                 {
                     spin_unlock(&dpci->dirq_lock);
-                    gdprintk(XENLOG_INFO,
+                    gdprintk(XENLOG_INFO VTDPREFIX,
                              "hvm_dpci_isairq_eoi:: mirq = %x\n", i);
                     stop_timer(&dpci->hvm_timer[irq_to_vector(i)]);
                     pirq_guest_eoi(d, i);
@@ -226,7 +226,8 @@ void hvm_dpci_eoi(struct domain *d, unsi
     {
         spin_unlock(&hvm_irq_dpci->dirq_lock);
 
-        gdprintk(XENLOG_INFO, "hvm_dpci_eoi:: mirq = %x\n", machine_gsi);
+        gdprintk(XENLOG_INFO VTDPREFIX,
+                 "hvm_dpci_eoi:: mirq = %x\n", machine_gsi);
         stop_timer(&hvm_irq_dpci->hvm_timer[irq_to_vector(machine_gsi)]);
         if ( (ent == NULL) || !ent->fields.mask )
             pirq_guest_eoi(d, machine_gsi);
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vmx/vtd/utils.c
--- a/xen/arch/x86/hvm/vmx/vtd/utils.c  Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vmx/vtd/utils.c  Wed Dec 12 10:50:03 2007 -0700
@@ -34,7 +34,6 @@
 #include <xen/xmalloc.h>
 #include <xen/inttypes.h>
 
-#define VTDPREFIX "[VT-D]"
 #define INTEL   0x8086
 #define SEABURG 0x4000
 #define C_STEP  2
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/hvm/vpt.c    Wed Dec 12 10:50:03 2007 -0700
@@ -15,7 +15,6 @@
  * You should have received a copy of the GNU General Public License along with
  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
  */
 
 #include <xen/time.h>
@@ -25,6 +24,46 @@
 
 #define mode_is(d, name) \
     ((d)->arch.hvm_domain.params[HVM_PARAM_TIMER_MODE] == HVMPTM_##name)
+
+static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src)
+{
+    struct vcpu *v = pt->vcpu;
+    unsigned int gsi, isa_irq;
+
+    if ( pt->source == PTSRC_lapic )
+        return pt->irq;
+
+    isa_irq = pt->irq;
+    gsi = hvm_isa_irq_to_gsi(isa_irq);
+
+    if ( src == hvm_intsrc_pic )
+        return (v->domain->arch.hvm_domain.vpic[isa_irq >> 3].irq_base
+                + (isa_irq & 7));
+
+    ASSERT(src == hvm_intsrc_lapic);
+    return domain_vioapic(v->domain)->redirtbl[gsi].fields.vector;
+}
+
+static int pt_irq_masked(struct periodic_time *pt)
+{
+    struct vcpu *v = pt->vcpu;
+    unsigned int gsi, isa_irq;
+    uint8_t pic_imr;
+
+    if ( pt->source == PTSRC_lapic )
+    {
+        struct vlapic *vlapic = vcpu_vlapic(v);
+        return (vlapic_enabled(vlapic) &&
+                !(vlapic_get_reg(vlapic, APIC_LVTT) & APIC_LVT_MASKED));
+    }
+
+    isa_irq = pt->irq;
+    gsi = hvm_isa_irq_to_gsi(isa_irq);
+    pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >> 3].imr;
+
+    return (((pic_imr & (1 << (isa_irq & 7))) || !vlapic_accept_pic_intr(v)) &&
+            domain_vioapic(v->domain)->redirtbl[gsi].fields.mask);
+}
 
 static void pt_lock(struct periodic_time *pt)
 {
@@ -144,29 +183,39 @@ void pt_update_irq(struct vcpu *v)
 void pt_update_irq(struct vcpu *v)
 {
     struct list_head *head = &v->arch.hvm_vcpu.tm_list;
-    struct periodic_time *pt;
+    struct periodic_time *pt, *earliest_pt = NULL;
     uint64_t max_lag = -1ULL;
-    int irq = -1;
-
-    spin_lock(&v->arch.hvm_vcpu.tm_lock);
-
-    list_for_each_entry ( pt, head, list )
-    {
-        if ( !is_isa_irq_masked(v, pt->irq) && pt->pending_intr_nr &&
+    int irq, is_lapic;
+
+    spin_lock(&v->arch.hvm_vcpu.tm_lock);
+
+    list_for_each_entry ( pt, head, list )
+    {
+        if ( !pt_irq_masked(pt) && pt->pending_intr_nr &&
              ((pt->last_plt_gtime + pt->period_cycles) < max_lag) )
         {
             max_lag = pt->last_plt_gtime + pt->period_cycles;
-            irq = pt->irq;
+            earliest_pt = pt;
         }
     }
 
-    spin_unlock(&v->arch.hvm_vcpu.tm_lock);
-
-    if ( is_lvtt(v, irq) )
+    if ( earliest_pt == NULL )
+    {
+        spin_unlock(&v->arch.hvm_vcpu.tm_lock);
+        return;
+    }
+
+    earliest_pt->irq_issued = 1;
+    irq = earliest_pt->irq;
+    is_lapic = (earliest_pt->source == PTSRC_lapic);
+
+    spin_unlock(&v->arch.hvm_vcpu.tm_lock);
+
+    if ( is_lapic )
     {
         vlapic_set_irq(vcpu_vlapic(v), irq, 0);
     }
-    else if ( irq >= 0 )
+    else
     {
         hvm_isa_irq_deassert(v->domain, irq);
         hvm_isa_irq_assert(v->domain, irq);
@@ -178,29 +227,12 @@ static struct periodic_time *is_pt_irq(
 {
     struct list_head *head = &v->arch.hvm_vcpu.tm_list;
     struct periodic_time *pt;
-    struct RTCState *rtc = &v->domain->arch.hvm_domain.pl_time.vrtc;
-    int vector;
-
-    list_for_each_entry ( pt, head, list )
-    {
-        if ( !pt->pending_intr_nr )
-            continue;
-
-        if ( is_lvtt(v, pt->irq) )
-        {
-            if ( pt->irq != intack.vector )
-                continue;
+
+    list_for_each_entry ( pt, head, list )
+    {
+        if ( pt->pending_intr_nr && pt->irq_issued &&
+             (intack.vector == pt_irq_vector(pt, intack.source)) )
             return pt;
-        }
-
-        vector = get_isa_irq_vector(v, pt->irq, intack.source);
-
-        /* RTC irq need special care */
-        if ( (intack.vector != vector) ||
-             ((pt->irq == 8) && !is_rtc_periodic_irq(rtc)) )
-            continue;
-
-        return pt;
     }
 
     return NULL;
@@ -222,11 +254,13 @@ void pt_intr_post(struct vcpu *v, struct
     }
 
     pt->do_not_freeze = 0;
+    pt->irq_issued = 0;
 
     if ( pt->one_shot )
     {
-        pt->enabled = 0;
-        list_del(&pt->list);
+        if ( pt->on_list )
+            list_del(&pt->list);
+        pt->on_list = 0;
     }
     else
     {
@@ -290,13 +324,15 @@ void create_periodic_time(
     struct vcpu *v, struct periodic_time *pt, uint64_t period,
     uint8_t irq, char one_shot, time_cb *cb, void *data)
 {
+    ASSERT(pt->source != 0);
+
     destroy_periodic_time(pt);
 
     spin_lock(&v->arch.hvm_vcpu.tm_lock);
 
-    pt->enabled = 1;
     pt->pending_intr_nr = 0;
     pt->do_not_freeze = 0;
+    pt->irq_issued = 0;
 
     /* Periodic timer must be at least 0.9ms. */
     if ( (period < 900000) && !one_shot )
@@ -319,11 +355,12 @@ void create_periodic_time(
      * LAPIC ticks for process accounting can see long sequences of process
      * ticks incorrectly accounted to interrupt processing.
      */
-    if ( is_lvtt(v, irq) )
+    if ( pt->source == PTSRC_lapic )
         pt->scheduled += period >> 1;
     pt->cb = cb;
     pt->priv = data;
 
+    pt->on_list = 1;
     list_add(&pt->list, &v->arch.hvm_vcpu.tm_list);
 
     init_timer(&pt->timer, pt_timer_fn, pt, v->processor);
@@ -334,12 +371,14 @@ void create_periodic_time(
 
 void destroy_periodic_time(struct periodic_time *pt)
 {
-    if ( !pt->enabled )
+    /* Was this structure previously initialised by create_periodic_time()? */
+    if ( pt->vcpu == NULL )
         return;
 
     pt_lock(pt);
-    pt->enabled = 0;
-    list_del(&pt->list);
+    if ( pt->on_list )
+        list_del(&pt->list);
+    pt->on_list = 0;
     pt_unlock(pt);
 
     /*
diff -r be02461e9810 -r d90dbf72049c xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c      Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/arch/x86/traps.c      Wed Dec 12 10:50:03 2007 -0700
@@ -911,6 +911,14 @@ static int __spurious_page_fault(
     l2_pgentry_t l2e, *l2t;
     l1_pgentry_t l1e, *l1t;
     unsigned int required_flags, disallowed_flags;
+
+    /*
+     * We do not take spurious page faults in IRQ handlers as we do not
+     * modify page tables in IRQ context. We therefore bail here because
+     * map_domain_page() is not IRQ-safe.
+     */
+    if ( in_irq() )
+        return 0;
 
     /* Reserved bit violations are never spurious faults. */
     if ( regs->error_code & PFEC_reserved_bit )
diff -r be02461e9810 -r d90dbf72049c xen/common/gdbstub.c
--- a/xen/common/gdbstub.c      Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/common/gdbstub.c      Wed Dec 12 10:50:03 2007 -0700
@@ -43,6 +43,7 @@
 #include <xen/smp.h>
 #include <xen/console.h>
 #include <xen/errno.h>
+#include <asm/byteorder.h>
 
 /* Printk isn't particularly safe just after we've trapped to the
    debugger. so avoid it. */
@@ -215,8 +216,7 @@ gdb_write_to_packet_hex(unsigned long x,
 gdb_write_to_packet_hex(unsigned long x, int int_size, struct gdb_context *ctx)
 {
     char buf[sizeof(unsigned long) * 2 + 1];
-    int i = sizeof(unsigned long) * 2;
-    int width = int_size * 2;
+    int i, width = int_size * 2;
 
     buf[sizeof(unsigned long) * 2] = 0;
 
@@ -233,6 +233,8 @@ gdb_write_to_packet_hex(unsigned long x,
         break;
     }
 
+#ifdef __BIG_ENDIAN
+       i = sizeof(unsigned long) * 2
     do {
         buf[--i] = hex2char(x & 15);
         x >>= 4;
@@ -242,6 +244,17 @@ gdb_write_to_packet_hex(unsigned long x,
         buf[--i] = '0';
 
     gdb_write_to_packet(&buf[i], width, ctx);
+#elif defined(__LITTLE_ENDIAN)
+       i = 0;
+       while (i < width) {
+               buf[i++] = hex2char(x>>4);
+               buf[i++] = hex2char(x);
+               x >>= 8;
+       }
+       gdb_write_to_packet(buf, width, ctx);
+#else
+# error unknown endian
+#endif
 }
 
 static int
@@ -512,7 +525,7 @@ __trap_to_gdb(struct cpu_user_regs *regs
 
     if ( gdb_ctx->serhnd < 0 )
     {
-        dbg_printk("Debugger not ready yet.\n");
+        printk("Debugging connection not set up.\n");
         return -EBUSY;
     }
 
diff -r be02461e9810 -r d90dbf72049c xen/common/keyhandler.c
--- a/xen/common/keyhandler.c   Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/common/keyhandler.c   Wed Dec 12 10:50:03 2007 -0700
@@ -275,6 +275,7 @@ extern void perfc_reset(unsigned char ke
 
 static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
 {
+    printk("'%c' pressed -> trapping into debugger\n", key);
     (void)debugger_trap_fatal(0xf001, regs);
     nop(); /* Prevent the compiler doing tail call
                              optimisation, as that confuses xendbg a
diff -r be02461e9810 -r d90dbf72049c xen/include/asm-x86/hvm/irq.h
--- a/xen/include/asm-x86/hvm/irq.h     Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/asm-x86/hvm/irq.h     Wed Dec 12 10:50:03 2007 -0700
@@ -160,7 +160,4 @@ struct hvm_intack hvm_vcpu_ack_pending_i
 struct hvm_intack hvm_vcpu_ack_pending_irq(struct vcpu *v,
                                            struct hvm_intack intack);
 
-int get_isa_irq_vector(struct vcpu *vcpu, int irq, enum hvm_intsrc src);
-int is_isa_irq_masked(struct vcpu *v, int isa_irq);
-
 #endif /* __ASM_X86_HVM_IRQ_H__ */
diff -r be02461e9810 -r d90dbf72049c xen/include/asm-x86/hvm/vlapic.h
--- a/xen/include/asm-x86/hvm/vlapic.h  Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/asm-x86/hvm/vlapic.h  Wed Dec 12 10:50:03 2007 -0700
@@ -92,7 +92,4 @@ struct vlapic *apic_round_robin(
 
 int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda);
 
-int is_lvtt(struct vcpu *v, int vector);
-int is_lvtt_enabled(struct vcpu *v);
-
 #endif /* __ASM_X86_HVM_VLAPIC_H__ */
diff -r be02461e9810 -r d90dbf72049c xen/include/asm-x86/hvm/vpt.h
--- a/xen/include/asm-x86/hvm/vpt.h     Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/asm-x86/hvm/vpt.h     Wed Dec 12 10:50:03 2007 -0700
@@ -72,12 +72,16 @@ typedef void time_cb(struct vcpu *v, voi
 
 struct periodic_time {
     struct list_head list;
-    char enabled;
-    char one_shot;              /* one shot time */
-    char do_not_freeze;
+    bool_t on_list;
+    bool_t one_shot;
+    bool_t do_not_freeze;
+    bool_t irq_issued;
+#define PTSRC_isa    1 /* ISA time source */
+#define PTSRC_lapic  2 /* LAPIC time source */
+    u8 source;                  /* PTSRC_ */
     u8 irq;
     struct vcpu *vcpu;          /* vcpu timer interrupt delivers to */
-    u32 pending_intr_nr;        /* the couner for pending timer interrupts */
+    u32 pending_intr_nr;        /* pending timer interrupts */
     u64 period;                 /* frequency in ns */
     u64 period_cycles;          /* frequency in cpu cycles */
     s_time_t scheduled;         /* scheduled timer interrupt */
@@ -140,6 +144,19 @@ void pt_intr_post(struct vcpu *v, struct
 void pt_intr_post(struct vcpu *v, struct hvm_intack intack);
 void pt_reset(struct vcpu *v);
 void pt_migrate(struct vcpu *v);
+
+/* Is given periodic timer active? */
+#define pt_active(pt) ((pt)->on_list)
+
+/*
+ * Create/destroy a periodic (or one-shot!) timer.
+ * The given periodic timer structure must be initialised with zero bytes,
+ * except for the 'source' field which must be initialised with the
+ * correct PTSRC_ value. The initialised timer structure can then be passed
+ * to {create,destroy}_periodic_time() and number of times and in any order.
+ * Note that, for a given periodic timer, invocations of these functions MUST
+ * be serialised.
+ */
 void create_periodic_time(
     struct vcpu *v, struct periodic_time *pt, uint64_t period,
     uint8_t irq, char one_shot, time_cb *cb, void *data);
@@ -152,7 +169,6 @@ void rtc_init(struct vcpu *v, int base);
 void rtc_init(struct vcpu *v, int base);
 void rtc_migrate_timers(struct vcpu *v);
 void rtc_deinit(struct domain *d);
-int is_rtc_periodic_irq(void *opaque);
 void pmtimer_init(struct vcpu *v);
 void pmtimer_deinit(struct domain *d);
 
diff -r be02461e9810 -r d90dbf72049c xen/include/asm-x86/iommu.h
--- a/xen/include/asm-x86/iommu.h       Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/asm-x86/iommu.h       Wed Dec 12 10:50:03 2007 -0700
@@ -79,5 +79,6 @@ int pt_irq_create_bind_vtd(struct domain
                            xen_domctl_bind_pt_irq_t *pt_irq_bind);
 
 #define PT_IRQ_TIME_OUT MILLISECS(8)
+#define VTDPREFIX "[VT-D]"
 
 #endif /* _IOMMU_H_ */
diff -r be02461e9810 -r d90dbf72049c xen/include/asm-x86/mtrr.h
--- a/xen/include/asm-x86/mtrr.h        Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/asm-x86/mtrr.h        Wed Dec 12 10:50:03 2007 -0700
@@ -47,6 +47,7 @@ struct mtrr_var_range {
 };
 
 #define NUM_FIXED_RANGES 88
+#define NUM_FIXED_MSR 11
 struct mtrr_state {
        struct mtrr_var_range *var_ranges;
        mtrr_type fixed_ranges[NUM_FIXED_RANGES];
diff -r be02461e9810 -r d90dbf72049c xen/include/public/arch-x86/hvm/save.h
--- a/xen/include/public/arch-x86/hvm/save.h    Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/public/arch-x86/hvm/save.h    Wed Dec 12 10:50:03 2007 -0700
@@ -405,9 +405,26 @@ struct hvm_hw_pmtimer {
 
 DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer);
 
+/*
+ * MTRR MSRs
+ */
+
+struct hvm_hw_mtrr {
+#define MTRR_VCNT 8
+#define NUM_FIXED_MSR 11
+    uint64_t msr_pat_cr;
+    /* mtrr physbase & physmask msr pair*/
+    uint64_t msr_mtrr_var[MTRR_VCNT*2];
+    uint64_t msr_mtrr_fixed[NUM_FIXED_MSR];
+    uint64_t msr_mtrr_cap;
+    uint64_t msr_mtrr_def_type;
+};
+
+DECLARE_HVM_SAVE_TYPE(MTRR, 14, struct hvm_hw_mtrr);
+
 /* 
  * Largest type-code in use
  */
-#define HVM_SAVE_CODE_MAX 13
+#define HVM_SAVE_CODE_MAX 14
 
 #endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */
diff -r be02461e9810 -r d90dbf72049c xen/include/public/domctl.h
--- a/xen/include/public/domctl.h       Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/public/domctl.h       Wed Dec 12 10:50:03 2007 -0700
@@ -435,9 +435,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendt
 
 
 /* Assign PCI device to HVM guest. Sets up IOMMU structures. */
-#define XEN_DOMCTL_assign_device     37
-#define DPCI_ADD_MAPPING         1
-#define DPCI_REMOVE_MAPPING      0 
+#define XEN_DOMCTL_assign_device      37
+#define XEN_DOMCTL_test_assign_device 45
 struct xen_domctl_assign_device {
     uint32_t  machine_bdf;   /* machine PCI ID of assigned device */
 };
@@ -473,6 +472,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_bind_
 
 /* Bind machine I/O address range -> HVM address range. */
 #define XEN_DOMCTL_memory_mapping    39
+#define DPCI_ADD_MAPPING         1
+#define DPCI_REMOVE_MAPPING      0
 struct xen_domctl_memory_mapping {
     uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */
     uint64_aligned_t first_mfn; /* first page (machine page) in range */
@@ -544,8 +545,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_ext_v
  */
 #define XEN_DOMCTL_set_opt_feature    44
 struct xen_domctl_set_opt_feature {
-#ifdef __ia64__
+#if defined(__ia64__)
     struct xen_ia64_opt_feature optf;
+#else
+    /* Make struct non-empty: do not depend on this field name! */
+    uint64_t dummy;
 #endif
 };
 typedef struct xen_domctl_set_opt_feature xen_domctl_set_opt_feature_t;
diff -r be02461e9810 -r d90dbf72049c xen/include/xen/gdbstub.h
--- a/xen/include/xen/gdbstub.h Wed Dec 12 10:47:54 2007 -0700
+++ b/xen/include/xen/gdbstub.h Wed Dec 12 10:50:03 2007 -0700
@@ -53,6 +53,7 @@ void gdb_write_to_packet(
     const char *buf, int count, struct gdb_context *ctx);
 void gdb_write_to_packet_hex(
     unsigned long x, int int_size, struct gdb_context *ctx);
+    /* ... writes in target native byte order as required by gdb spec. */
 void gdb_send_packet(struct gdb_context *ctx);
 void gdb_send_reply(const char *buf, struct gdb_context *ctx);
 

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

<Prev in Thread] Current Thread [Next in Thread>