aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2007-12-12 10:50:03 -0700
committerAlex Williamson <alex.williamson@hp.com>2007-12-12 10:50:03 -0700
commit26817e1c743126b426034999d1b32b047086fb14 (patch)
treeb198cd41c6b99aea59458a3d9b33080a709cc0b4
parent9294e55c34a7410445b7801d016ec528bb0477f2 (diff)
parent77f9359c57fc54bdf92bb35294de573f78814166 (diff)
downloadxen-26817e1c743126b426034999d1b32b047086fb14.tar.gz
xen-26817e1c743126b426034999d1b32b047086fb14.tar.bz2
xen-26817e1c743126b426034999d1b32b047086fb14.zip
merge with xen-unstable.hg (staging)
-rw-r--r--docs/misc/crashdb.txt67
-rw-r--r--docs/misc/vtd.txt14
-rw-r--r--docs/xen-api/revision-history.tex20
-rw-r--r--docs/xen-api/xenapi-coversheet.tex4
-rw-r--r--docs/xen-api/xenapi-datamodel.tex39
-rw-r--r--docs/xen-api/xenapi.tex3
-rw-r--r--tools/ioemu/hw/pass-through.c12
-rw-r--r--tools/ioemu/hw/vga.c16
-rw-r--r--tools/libxc/xc_domain.c16
-rw-r--r--tools/libxc/xenctrl.h4
-rw-r--r--tools/libxen/include/xen/api/xen_xspolicy.h13
-rw-r--r--tools/libxen/src/xen_xspolicy.c18
-rw-r--r--tools/python/xen/lowlevel/xc/xc.c14
-rw-r--r--tools/python/xen/util/acmpolicy.py15
-rw-r--r--tools/python/xen/util/xsm/acm/acm.py15
-rw-r--r--tools/python/xen/util/xsm/dummy/dummy.py4
-rw-r--r--tools/python/xen/xend/XendDevices.py3
-rw-r--r--tools/python/xen/xend/XendDomain.py20
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py7
-rw-r--r--tools/python/xen/xend/XendXSPolicy.py32
-rw-r--r--tools/python/xen/xend/XendXSPolicyAdmin.py17
-rw-r--r--tools/python/xen/xend/server/usbif.py42
-rw-r--r--tools/python/xen/xm/create.py11
-rw-r--r--tools/python/xen/xm/main.py2
-rw-r--r--tools/python/xen/xm/resetpolicy.py60
-rw-r--r--tools/python/xen/xsview/__init__.py0
-rw-r--r--xen/arch/x86/domctl.c26
-rw-r--r--xen/arch/x86/gdbstub.c10
-rw-r--r--xen/arch/x86/hvm/i8254.c2
-rw-r--r--xen/arch/x86/hvm/irq.c24
-rw-r--r--xen/arch/x86/hvm/mtrr.c80
-rw-r--r--xen/arch/x86/hvm/rtc.c10
-rw-r--r--xen/arch/x86/hvm/vioapic.c2
-rw-r--r--xen/arch/x86/hvm/vlapic.c20
-rw-r--r--xen/arch/x86/hvm/vmx/vtd/dmar.c1
-rw-r--r--xen/arch/x86/hvm/vmx/vtd/intel-iommu.c26
-rw-r--r--xen/arch/x86/hvm/vmx/vtd/io.c7
-rw-r--r--xen/arch/x86/hvm/vmx/vtd/utils.c1
-rw-r--r--xen/arch/x86/hvm/vpt.c105
-rw-r--r--xen/arch/x86/traps.c8
-rw-r--r--xen/common/gdbstub.c19
-rw-r--r--xen/common/keyhandler.c1
-rw-r--r--xen/include/asm-x86/hvm/irq.h3
-rw-r--r--xen/include/asm-x86/hvm/vlapic.h3
-rw-r--r--xen/include/asm-x86/hvm/vpt.h26
-rw-r--r--xen/include/asm-x86/iommu.h1
-rw-r--r--xen/include/asm-x86/mtrr.h1
-rw-r--r--xen/include/public/arch-x86/hvm/save.h19
-rw-r--r--xen/include/public/domctl.h12
-rw-r--r--xen/include/xen/gdbstub.h1
50 files changed, 576 insertions, 300 deletions
diff --git a/docs/misc/crashdb.txt b/docs/misc/crashdb.txt
index a366f72f5d..b41a538adb 100644
--- a/docs/misc/crashdb.txt
+++ b/docs/misc/crashdb.txt
@@ -5,31 +5,46 @@ Xen has a simple gdb stub for doing post-mortem debugging i.e. once
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.
-
-The next step depends on your individual setup. This is how to do
-it for a normal test box in the SRG:
-
--- 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.
-
-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.
+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.
+
+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.
+
+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:
+
+ * 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 debugger:
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 --git a/docs/misc/vtd.txt b/docs/misc/vtd.txt
index c33074b84a..1d4e68ce5a 100644
--- a/docs/misc/vtd.txt
+++ b/docs/misc/vtd.txt
@@ -2,7 +2,7 @@ Title : How to do PCI Passthrough with VT-d
Authors : Allen Kay <allen.m.kay@intel.com>
Weidong Han <weidong.han@intel.com>
Created : October-24-2007
-Updated : October-24-2007
+Updated : December-11-2007
How to turn on VT-d in Xen
--------------------------
@@ -22,7 +22,7 @@ How to turn on VT-d in 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
@@ -32,6 +32,15 @@ title Xen-Fedora Core (2.6.18-xen)
"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/category.aspx/optix?c=us&cs=555&l=en&s=biz
- HP Compaq: DC7800
http://h10010.www1.hp.com/wwpc/us/en/en/WF04a/12454-12454-64287-321860-3328898.html
+
diff --git a/docs/xen-api/revision-history.tex b/docs/xen-api/revision-history.tex
new file mode 100644
index 0000000000..9ccac18cc4
--- /dev/null
+++ b/docs/xen-api/revision-history.tex
@@ -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 --git a/docs/xen-api/xenapi-coversheet.tex b/docs/xen-api/xenapi-coversheet.tex
index d9ca120be7..0edcd3e26b 100644
--- a/docs/xen-api/xenapi-coversheet.tex
+++ b/docs/xen-api/xenapi-coversheet.tex
@@ -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 --git a/docs/xen-api/xenapi-datamodel.tex b/docs/xen-api/xenapi-datamodel.tex
index 29a2c30b99..c6a95883a5 100644
--- a/docs/xen-api/xenapi-datamodel.tex
+++ b/docs/xen-api/xenapi-datamodel.tex
@@ -14735,6 +14735,45 @@ 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}
+\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 --git a/docs/xen-api/xenapi.tex b/docs/xen-api/xenapi.tex
index bc1abfee9d..f71689e377 100644
--- a/docs/xen-api/xenapi.tex
+++ b/docs/xen-api/xenapi.tex
@@ -32,6 +32,9 @@
% The coversheet itself
\include{coversheet}
+% The revision history
+\include{revision-history}
+
% ... and off we go!
\chapter{Introduction}
diff --git a/tools/ioemu/hw/pass-through.c b/tools/ioemu/hw/pass-through.c
index 304ae3add0..5415019ed5 100644
--- a/tools/ioemu/hw/pass-through.c
+++ b/tools/ioemu/hw/pass-through.c
@@ -327,6 +327,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
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(PCIBus *e_bus,
/* 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 --git a/tools/ioemu/hw/vga.c b/tools/ioemu/hw/vga.c
index cb34f289fb..17538bbddc 100644
--- a/tools/ioemu/hw/vga.c
+++ b/tools/ioemu/hw/vga.c
@@ -1742,6 +1742,7 @@ static CPUWriteMemoryFunc *vga_mem_write[3] = {
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 *opaque)
#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 *opaque, int version_id)
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 --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 9157871742..e6eac869a8 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -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 --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 61f7fc558f..d9c6bace54 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -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 --git a/tools/libxen/include/xen/api/xen_xspolicy.h b/tools/libxen/include/xen/api/xen_xspolicy.h
index 3ecdc4b54d..b0808f4d57 100644
--- a/tools/libxen/include/xen/api/xen_xspolicy.h
+++ b/tools/libxen/include/xen/api/xen_xspolicy.h
@@ -240,6 +240,19 @@ xen_xspolicy_set_xspolicy(xen_session *session, xen_xs_policystate **result,
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 --git a/tools/libxen/src/xen_xspolicy.c b/tools/libxen/src/xen_xspolicy.c
index ccafe1f4e8..e5f290c1a1 100644
--- a/tools/libxen/src/xen_xspolicy.c
+++ b/tools/libxen/src/xen_xspolicy.c
@@ -225,6 +225,24 @@ xen_xspolicy_set_xspolicy(xen_session *session, xen_xs_policystate **result,
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 --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index f899edceeb..1f1421e487 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -560,9 +560,9 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
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(XcObject *self,
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 --git a/tools/python/xen/util/acmpolicy.py b/tools/python/xen/util/acmpolicy.py
index a89acb34dd..48e044d318 100644
--- a/tools/python/xen/util/acmpolicy.py
+++ b/tools/python/xen/util/acmpolicy.py
@@ -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 --git a/tools/python/xen/util/xsm/acm/acm.py b/tools/python/xen/util/xsm/acm/acm.py
index ebaddbb922..7973a5b704 100644
--- a/tools/python/xen/util/xsm/acm/acm.py
+++ b/tools/python/xen/util/xsm/acm/acm.py
@@ -86,6 +86,7 @@ xmlrpc_exports = [
'list_labels',
'get_labeled_resources',
'set_policy',
+ 'reset_policy',
'get_policy',
'activate_policy',
'rm_bootpolicy',
@@ -567,6 +568,20 @@ def set_policy(xs_type, xml, flags, overwrite):
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))
+
+
def get_policy():
"""
Xend exports this function via XML-RPC
diff --git a/tools/python/xen/util/xsm/dummy/dummy.py b/tools/python/xen/util/xsm/dummy/dummy.py
index 7a07e906d0..66fc8c2bd2 100644
--- a/tools/python/xen/util/xsm/dummy/dummy.py
+++ b/tools/python/xen/util/xsm/dummy/dummy.py
@@ -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 get_labeled_resources():
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 --git a/tools/python/xen/xend/XendDevices.py b/tools/python/xen/xend/XendDevices.py
index 70557855a1..635ff923f8 100644
--- a/tools/python/xen/xend/XendDevices.py
+++ b/tools/python/xen/xend/XendDevices.py
@@ -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 --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py
index 5af454afd0..553a22d2c7 100644
--- a/tools/python/xen/xend/XendDomain.py
+++ b/tools/python/xen/xend/XendDomain.py
@@ -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 --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 4558a9cec6..418b09ccaf 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -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 --git a/tools/python/xen/xend/XendXSPolicy.py b/tools/python/xen/xend/XendXSPolicy.py
index 834857e40f..dff029ddde 100644
--- a/tools/python/xen/xend/XendXSPolicy.py
+++ b/tools/python/xen/xend/XendXSPolicy.py
@@ -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 --git a/tools/python/xen/xend/XendXSPolicyAdmin.py b/tools/python/xen/xend/XendXSPolicyAdmin.py
index cc861fda80..cf10ef2df4 100644
--- a/tools/python/xen/xend/XendXSPolicyAdmin.py
+++ b/tools/python/xen/xend/XendXSPolicyAdmin.py
@@ -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 --git a/tools/python/xen/xend/server/usbif.py b/tools/python/xen/xend/server/usbif.py
deleted file mode 100644
index ccc212f885..0000000000
--- a/tools/python/xen/xend/server/usbif.py
+++ /dev/null
@@ -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@hp.com>
-# Copyright (C) 2004 Intel Research Cambridge
-# Copyright (C) 2004 Mark Williamson <mark.williamson@cl.cam.ac.uk>
-# 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 --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py
index 5159eb1ee8..297b819fdb 100644
--- a/tools/python/xen/xm/create.py
+++ b/tools/python/xen/xm/create.py
@@ -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.
@@ -617,11 +612,6 @@ def configure_irq(config_devs, vals):
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:
d = comma_sep_kv_to_dict(f)
@@ -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 --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index 59105a8f86..a736247f2e 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -1833,7 +1833,7 @@ def xm_debug_keys(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 --git a/tools/python/xen/xm/resetpolicy.py b/tools/python/xen/xm/resetpolicy.py
index bc37760d2c..c88b427f2a 100644
--- a/tools/python/xen/xm/resetpolicy.py
+++ b/tools/python/xen/xm/resetpolicy.py
@@ -26,40 +26,6 @@ from xen.xm.main import server
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 --git a/tools/python/xen/xsview/__init__.py b/tools/python/xen/xsview/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tools/python/xen/xsview/__init__.py
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 09633cba14..1460f8e620 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -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 --git a/xen/arch/x86/gdbstub.c b/xen/arch/x86/gdbstub.c
index a3af473ee2..3d0d0d0429 100644
--- a/xen/arch/x86/gdbstub.c
+++ b/xen/arch/x86/gdbstub.c
@@ -71,18 +71,20 @@ gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
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 --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c
index 5ca76f1276..8814d4b1e1 100644
--- a/xen/arch/x86/hvm/i8254.c
+++ b/xen/arch/x86/hvm/i8254.c
@@ -501,6 +501,8 @@ void pit_init(struct vcpu *v, unsigned long cpu_khz)
/* 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 --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index de21d0f357..dc35eda989 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -347,30 +347,6 @@ struct hvm_intack hvm_vcpu_ack_pending_irq(
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)
{
struct hvm_intack intack;
diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
index a817bd9021..cfa8f90389 100644
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -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 --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c
index c4b082a322..ece6f29ad9 100644
--- a/xen/arch/x86/hvm/rtc.c
+++ b/xen/arch/x86/hvm/rtc.c
@@ -42,14 +42,6 @@ static void rtc_periodic_cb(struct vcpu *v, void *opaque)
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
* RTC_RATE_SELECT settings */
static void rtc_timer_update(RTCState *s)
@@ -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 --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index 670cdf5979..cfc80c5aa1 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -300,7 +300,7 @@ static uint32_t ioapic_get_delivery_bitmask(
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 --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 5ac455b1fe..059b64538d 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -68,9 +68,6 @@ static unsigned int vlapic_lvt_mask[VLAPIC_LVT_NUM] =
#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 --git a/xen/arch/x86/hvm/vmx/vtd/dmar.c b/xen/arch/x86/hvm/vmx/vtd/dmar.c
index 49aa994a49..786186966f 100644
--- a/xen/arch/x86/hvm/vmx/vtd/dmar.c
+++ b/xen/arch/x86/hvm/vmx/vtd/dmar.c
@@ -30,7 +30,6 @@
#include "pci-direct.h"
#include "pci_regs.h"
-#define VTDPREFIX
int vtd_enabled;
boolean_param("vtd", vtd_enabled);
diff --git a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c
index 8a773c559e..239239ed8e 100644
--- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c
+++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c
@@ -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 --git a/xen/arch/x86/hvm/vmx/vtd/io.c b/xen/arch/x86/hvm/vmx/vtd/io.c
index d3500da5da..39029fab9f 100644
--- a/xen/arch/x86/hvm/vmx/vtd/io.c
+++ b/xen/arch/x86/hvm/vmx/vtd/io.c
@@ -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 domain *d, unsigned int isairq)
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, unsigned int guest_gsi,
{
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 --git a/xen/arch/x86/hvm/vmx/vtd/utils.c b/xen/arch/x86/hvm/vmx/vtd/utils.c
index b15af311c7..55a7149a7e 100644
--- a/xen/arch/x86/hvm/vmx/vtd/utils.c
+++ b/xen/arch/x86/hvm/vmx/vtd/utils.c
@@ -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 --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c
index 0a780298b8..45c9350226 100644
--- a/xen/arch/x86/hvm/vpt.c
+++ b/xen/arch/x86/hvm/vpt.c
@@ -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>
@@ -26,6 +25,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)
{
struct vcpu *v;
@@ -144,29 +183,39 @@ static void pt_timer_fn(void *data)
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;
+ int irq, is_lapic;
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 &&
+ 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;
}
}
+ 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_lvtt(v, irq) )
+ 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;
+ 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 hvm_intack intack)
}
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 --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 9cc1669116..970796e045 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -912,6 +912,14 @@ static int __spurious_page_fault(
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 )
return 0;
diff --git a/xen/common/gdbstub.c b/xen/common/gdbstub.c
index 51a2d6cb7d..c0b2f4c474 100644
--- a/xen/common/gdbstub.c
+++ b/xen/common/gdbstub.c
@@ -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 @@ void
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, int int_size, struct gdb_context *ctx)
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, int int_size, struct gdb_context *ctx)
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, unsigned long cookie)
if ( gdb_ctx->serhnd < 0 )
{
- dbg_printk("Debugger not ready yet.\n");
+ printk("Debugging connection not set up.\n");
return -EBUSY;
}
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index f7756cd324..14ed246703 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -275,6 +275,7 @@ extern void perfc_reset(unsigned char key);
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 --git a/xen/include/asm-x86/hvm/irq.h b/xen/include/asm-x86/hvm/irq.h
index d270685caf..5fd0db3b7d 100644
--- a/xen/include/asm-x86/hvm/irq.h
+++ b/xen/include/asm-x86/hvm/irq.h
@@ -160,7 +160,4 @@ struct hvm_intack hvm_vcpu_has_pending_irq(struct vcpu *v);
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 --git a/xen/include/asm-x86/hvm/vlapic.h b/xen/include/asm-x86/hvm/vlapic.h
index 856b532637..d20a627882 100644
--- a/xen/include/asm-x86/hvm/vlapic.h
+++ b/xen/include/asm-x86/hvm/vlapic.h
@@ -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 --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h
index 9f69024340..df54f66268 100644
--- a/xen/include/asm-x86/hvm/vpt.h
+++ b/xen/include/asm-x86/hvm/vpt.h
@@ -72,12 +72,16 @@ typedef void time_cb(struct vcpu *v, void *opaque);
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_update_irq(struct vcpu *v);
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 pit_deinit(struct domain *d);
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 --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h
index e2ceffc7de..1894335bab 100644
--- a/xen/include/asm-x86/iommu.h
+++ b/xen/include/asm-x86/iommu.h
@@ -79,5 +79,6 @@ int pt_irq_create_bind_vtd(struct domain *d,
xen_domctl_bind_pt_irq_t *pt_irq_bind);
#define PT_IRQ_TIME_OUT MILLISECS(8)
+#define VTDPREFIX "[VT-D]"
#endif /* _IOMMU_H_ */
diff --git a/xen/include/asm-x86/mtrr.h b/xen/include/asm-x86/mtrr.h
index c0a52a0a26..5ad34f1650 100644
--- a/xen/include/asm-x86/mtrr.h
+++ b/xen/include/asm-x86/mtrr.h
@@ -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 --git a/xen/include/public/arch-x86/hvm/save.h b/xen/include/public/arch-x86/hvm/save.h
index fd77d04e9f..a2b41f03b3 100644
--- a/xen/include/public/arch-x86/hvm/save.h
+++ b/xen/include/public/arch-x86/hvm/save.h
@@ -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 --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 5d9a44c3ee..5e50053610 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -435,9 +435,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendtrigger_t);
/* 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_pt_irq_t);
/* 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_vcpucontext_t);
*/
#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 --git a/xen/include/xen/gdbstub.h b/xen/include/xen/gdbstub.h
index 46e4815e44..09af6f3642 100644
--- a/xen/include/xen/gdbstub.h
+++ b/xen/include/xen/gdbstub.h
@@ -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);