debuggers.hg
changeset 16643:d90dbf72049c
merge with xen-unstable.hg (staging)
author | Alex Williamson <alex.williamson@hp.com> |
---|---|
date | Wed Dec 12 10:50:03 2007 -0700 (2007-12-12) |
parents | be02461e9810 4553bc1087d9 |
children | 8f0cbfc478d6 |
files | tools/python/xen/xend/server/usbif.py |
line diff
1.1 --- a/docs/misc/crashdb.txt Wed Dec 12 10:47:54 2007 -0700 1.2 +++ b/docs/misc/crashdb.txt Wed Dec 12 10:50:03 2007 -0700 1.3 @@ -5,31 +5,46 @@ Xen has a simple gdb stub for doing post 1.4 you've crashed it, you get to poke around and find out why. There's 1.5 also a special key handler for making it crash, which is handy. 1.6 1.7 -You need to have crash_debug=y set when compiling to enable the crash 1.8 -debugger (so go ``export crash_debug=y; make'', or ``crash_debug=y 1.9 -make'' or ``make crash_debug=y''), and you also need to enable it on 1.10 -the Xen command line, by going e.g. cdb=com1. If you need to have a 1.11 -serial port shared between cdb and the console, try cdb=com1H. CDB 1.12 -will then set the high bit on every byte it sends, and only respond to 1.13 -bytes with the high bit set. Similarly for com2. 1.14 +You need to have crash_debug=y set when compiling , and you also need 1.15 +to enable it on the Xen command line, eg by gdb=com1. 1.16 1.17 -The next step depends on your individual setup. This is how to do 1.18 -it for a normal test box in the SRG: 1.19 +If you need to have a serial port shared between gdb and the console, 1.20 +you can use gdb=com1H. CDB will then set the high bit on every byte 1.21 +it sends, and only respond to bytes with the high bit set. Similarly 1.22 +for com2. If you do this you will need a demultiplexing program on 1.23 +the debugging workstation, such as perhaps tools/misc/nsplitd. 1.24 + 1.25 +The next step depends on your individual setup. This is how to do it 1.26 +if you have a simple null modem connection between the test box and 1.27 +the workstation, and aren't using a H/L split console: 1.28 1.29 --- Make your test machine crash. Either a normal panic or hitting 1.30 - 'C-A C-A C-A %' on the serial console will do. 1.31 --- Start gdb as ``gdb ./xen-syms'' 1.32 --- Go ``target remote serial.srg:12331'', where 12331 is the second port 1.33 - reported for that machine by xenuse. (In this case, the machine is 1.34 - bombjack) 1.35 --- Go ``add-symbol-file vmlinux'' 1.36 --- Debug as if you had a core file 1.37 --- When you're finished, go and reboot your test box. Hitting 'R' on the 1.38 - serial console won't work. 1.39 + * Set debug=y in Config.mk 1.40 + * Set crash_debug=y in xen/Rules.mk 1.41 + * Make the changes in the attached patch, and build. 1.42 + * Arrange to pass gdb=com1 as a hypervisor command line argument 1.43 + (I already have com1=38400,8n1 console=com1,vga sync_console) 1.44 + 1.45 + * Boot the system with minicom (or your favourite terminal program) 1.46 + connected from your workstation via a null modem cable in the 1.47 + usual way. 1.48 + * In minicom, give the escape character (^A by default) three times 1.49 + to talk to Xen (Xen prints `(XEN) *** Serial input -> Xen...'). 1.50 + * Press % and observe the messages 1.51 + (XEN) '%' pressed -> trapping into debugger 1.52 + (XEN) GDB connection activated. 1.53 + (XEN) Waiting for GDB to attach... 1.54 + * Disconnect from minicom without allowing minicom to send any 1.55 + modem control sequences. 1.56 + * Start gdb with gdb /path/to/build/tree/xen/xen-syms and then 1.57 + (gdb) set remotebaud 38400 1.58 + Remote debugging using /dev/ttyS0 1.59 + 0xff124d61 in idle_loop () at domain.c:78 1.60 + 78 safe_halt(); 1.61 + (gdb) 1.62 1.63 -At one stage, it was sometimes possible to resume after entering the 1.64 -debugger from the serial console. This seems to have rotted, however, 1.65 -and I'm not terribly interested in putting it back. 1.66 +There is code which was once intended to make it possible to resume 1.67 +after entering the debugger. However this does not presently work; it 1.68 +has been nonfunctional for quite some time. 1.69 1.70 As soon as you reach the debugger, we disable interrupts, the 1.71 watchdog, and every other CPU, so the state of the world shouldn't 1.72 @@ -44,7 +59,5 @@ Reasons why we might fail to reach the d 1.73 you're screwed. 1.74 -- If the page tables are wrong, you're screwed 1.75 -- If the serial port setup is wrong, badness happens 1.76 --- We acquire the console lock at one stage XXX this is unnecessary and 1.77 - stupid 1.78 -- Obviously, the low level processor state can be screwed in any 1.79 number of wonderful ways
2.1 --- a/docs/misc/vtd.txt Wed Dec 12 10:47:54 2007 -0700 2.2 +++ b/docs/misc/vtd.txt Wed Dec 12 10:50:03 2007 -0700 2.3 @@ -2,7 +2,7 @@ Title : How to do PCI Passthrough with 2.4 Authors : Allen Kay <allen.m.kay@intel.com> 2.5 Weidong Han <weidong.han@intel.com> 2.6 Created : October-24-2007 2.7 -Updated : October-24-2007 2.8 +Updated : December-11-2007 2.9 2.10 How to turn on VT-d in Xen 2.11 -------------------------- 2.12 @@ -22,7 +22,7 @@ 11) "hide" pci device from dom0 as follo 2.13 title Xen-Fedora Core (2.6.18-xen) 2.14 root (hd0,0) 2.15 kernel /boot/xen.gz com1=115200,8n1 console=com1 vtd=1 2.16 - 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 2.17 + 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 2.18 module /boot/initrd-2.6.18-xen.img 2.19 2.20 12) reboot system 2.21 @@ -32,6 +32,15 @@ 15) start hvm guest and use "lspci" to s 2.22 "ifconfig" to see if IP address has been assigned to NIC devices. 2.23 2.24 2.25 +Caveat on Conventional PCI Device Passthrough 2.26 +--------------------------------------------- 2.27 + 2.28 +VT-d spec specifies that all conventional PCI devices behind a 2.29 +PCIe-to-PCI bridge have to be assigned to the same domain. 2.30 + 2.31 +PCIe devices do not have this restriction. 2.32 + 2.33 + 2.34 VT-d Enabled Systems 2.35 -------------------- 2.36 2.37 @@ -48,3 +57,4 @@ http://www.dell.com/content/products/cat 2.38 2.39 - HP Compaq: DC7800 2.40 http://h10010.www1.hp.com/wwpc/us/en/en/WF04a/12454-12454-64287-321860-3328898.html 2.41 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/docs/xen-api/revision-history.tex Wed Dec 12 10:50:03 2007 -0700 3.3 @@ -0,0 +1,20 @@ 3.4 +{ \bf Revision History} 3.5 + 3.6 +\begin{center} 3.7 + \begin{tabular}{|l|l|l|l|} 3.8 + \hline 3.9 + 1.0.0 & 27th April 07 & Xensource et al. & 3.10 + \begin{minipage}[t][.7cm]{7cm} 3.11 + Initial Revision 3.12 + \end{minipage}\\ 3.13 + \hline 3.14 + 1.0.1 & 10th Dec. 07 & S. Berger & 3.15 + \begin{minipage}[t]{7cm} 3.16 + \begin{flushleft} 3.17 + Added XSPolicy.reset\_xspolicy, VTPM.get\_other\_config, 3.18 + VTPM.set\_otherconfig. ACMPolicy.get\_enforced\_binary methods. 3.19 + \end{flushleft} 3.20 + \end{minipage}\\ 3.21 + \hline 3.22 + \end{tabular} 3.23 +\end{center} 3.24 \ No newline at end of file
4.1 --- a/docs/xen-api/xenapi-coversheet.tex Wed Dec 12 10:47:54 2007 -0700 4.2 +++ b/docs/xen-api/xenapi-coversheet.tex Wed Dec 12 10:50:03 2007 -0700 4.3 @@ -17,12 +17,12 @@ 4.4 \newcommand{\coversheetlogo}{xen.eps} 4.5 4.6 %% Document date 4.7 -\newcommand{\datestring}{27th April 2007} 4.8 +\newcommand{\datestring}{10th December 2007} 4.9 4.10 \newcommand{\releasestatement}{Stable Release} 4.11 4.12 %% Document revision 4.13 -\newcommand{\revstring}{API Revision 1.0.0} 4.14 +\newcommand{\revstring}{API Revision 1.0.1} 4.15 4.16 %% Document authors 4.17 \newcommand{\docauthors}{
5.1 --- a/docs/xen-api/xenapi-datamodel.tex Wed Dec 12 10:47:54 2007 -0700 5.2 +++ b/docs/xen-api/xenapi-datamodel.tex Wed Dec 12 10:50:03 2007 -0700 5.3 @@ -14735,6 +14735,45 @@ xs\_policystate 5.4 State information about the policy. In case an error occurred, the 'xs\_err' 5.5 field contains the error code. The 'errors' may contain further information 5.6 about the error. 5.7 + \vspace{0.3cm} 5.8 +\vspace{0.3cm} 5.9 +\vspace{0.3cm} 5.10 +\subsubsection{RPC name:~reset\_xspolicy} 5.11 + 5.12 +{\bf Overview:} 5.13 +Attempt to reset the system's policy by installing the default policy. 5.14 +Since this function is implemented as an update to the current policy, it 5.15 +underlies the same restrictions. This function may fail if for example 5.16 +other domains than Domain-0 are running and use a different label than 5.17 +Domain-0 5.18 + 5.19 +\noindent {\bf Signature:} 5.20 +\begin{verbatim} xs_policystate reset_xspolicy (session_id s, xs_type type) 5.21 +\end{verbatim} 5.22 + 5.23 +\noindent{\bf Arguments:} 5.24 + 5.25 +\vspace{0.3cm} 5.26 + 5.27 +\begin{tabular}{|c|c|p{7cm}|} 5.28 + \hline 5.29 +{\bf type} & {\bf name} & {\bf description} \\ \hline 5.30 +{\tt xs\_type } & type & the type of policy \\ \hline 5.31 + 5.32 +\end{tabular} 5.33 + 5.34 +\vspace{0.3cm} 5.35 + 5.36 + 5.37 + \noindent {\bf Return Type:} 5.38 +{\tt 5.39 +xs\_policystate 5.40 +} 5.41 + 5.42 + 5.43 +State information about the policy. In case an error occurred, the 'xs\_err' 5.44 +field contains the error code. The 'errors' may contain further information 5.45 +about the error. 5.46 \vspace{0.3cm} 5.47 \vspace{0.3cm} 5.48 \vspace{0.3cm}
6.1 --- a/docs/xen-api/xenapi.tex Wed Dec 12 10:47:54 2007 -0700 6.2 +++ b/docs/xen-api/xenapi.tex Wed Dec 12 10:50:03 2007 -0700 6.3 @@ -32,6 +32,9 @@ 6.4 % The coversheet itself 6.5 \include{coversheet} 6.6 6.7 +% The revision history 6.8 +\include{revision-history} 6.9 + 6.10 % ... and off we go! 6.11 6.12 \chapter{Introduction}
7.1 --- a/tools/ioemu/hw/pass-through.c Wed Dec 12 10:47:54 2007 -0700 7.2 +++ b/tools/ioemu/hw/pass-through.c Wed Dec 12 10:50:03 2007 -0700 7.3 @@ -327,6 +327,7 @@ struct pt_dev * register_real_device(PCI 7.4 struct pt_dev *assigned_device = NULL; 7.5 struct pci_dev *pci_dev; 7.6 uint8_t e_device, e_intx; 7.7 + struct pci_config_cf8 machine_bdf; 7.8 7.9 PT_LOG("Assigning real physical device %02x:%02x.%x ...\n", 7.10 r_bus, r_dev, r_func); 7.11 @@ -360,13 +361,22 @@ struct pt_dev * register_real_device(PCI 7.12 /* Issue PCIe FLR */ 7.13 pdev_flr(pci_dev); 7.14 7.15 + /* Assign device */ 7.16 + machine_bdf.reg = 0; 7.17 + machine_bdf.bus = r_bus; 7.18 + machine_bdf.dev = r_dev; 7.19 + machine_bdf.func = r_func; 7.20 + rc = xc_assign_device(xc_handle, domid, machine_bdf.value); 7.21 + if ( rc < 0 ) 7.22 + PT_LOG("Error: xc_assign_device error %d\n", rc); 7.23 + 7.24 /* Initialize virtualized PCI configuration (Extended 256 Bytes) */ 7.25 for ( i = 0; i < PCI_CONFIG_SIZE; i++ ) 7.26 assigned_device->dev.config[i] = pci_read_byte(pci_dev, i); 7.27 7.28 /* Handle real device's MMIO/PIO BARs */ 7.29 pt_register_regions(assigned_device); 7.30 - 7.31 + 7.32 /* Bind interrupt */ 7.33 e_device = (assigned_device->dev.devfn >> 3) & 0x1f; 7.34 e_intx = assigned_device->dev.config[0x3d]-1;
8.1 --- a/tools/ioemu/hw/vga.c Wed Dec 12 10:47:54 2007 -0700 8.2 +++ b/tools/ioemu/hw/vga.c Wed Dec 12 10:50:03 2007 -0700 8.3 @@ -1742,6 +1742,7 @@ static CPUWriteMemoryFunc *vga_mem_write 8.4 static void vga_save(QEMUFile *f, void *opaque) 8.5 { 8.6 VGAState *s = opaque; 8.7 + uint32_t vram_size; 8.8 #ifdef CONFIG_BOCHS_VBE 8.9 int i; 8.10 #endif 8.11 @@ -1783,17 +1784,21 @@ static void vga_save(QEMUFile *f, void * 8.12 #else 8.13 qemu_put_byte(f, 0); 8.14 #endif 8.15 + vram_size = s->vram_size; 8.16 + qemu_put_be32s(f, &vram_size); 8.17 + qemu_put_buffer(f, s->vram_ptr, s->vram_size); 8.18 } 8.19 8.20 static int vga_load(QEMUFile *f, void *opaque, int version_id) 8.21 { 8.22 VGAState *s = opaque; 8.23 int is_vbe, ret; 8.24 + uint32_t vram_size; 8.25 #ifdef CONFIG_BOCHS_VBE 8.26 int i; 8.27 #endif 8.28 8.29 - if (version_id > 2) 8.30 + if (version_id > 3) 8.31 return -EINVAL; 8.32 8.33 if (s->pci_dev && version_id >= 2) { 8.34 @@ -1839,6 +1844,13 @@ static int vga_load(QEMUFile *f, void *o 8.35 if (is_vbe) 8.36 return -EINVAL; 8.37 #endif 8.38 + if (version_id >= 3) { 8.39 + /* people who restore old images may be lucky ... */ 8.40 + qemu_get_be32s(f, &vram_size); 8.41 + if (vram_size != s->vram_size) 8.42 + return -EINVAL; 8.43 + qemu_get_buffer(f, s->vram_ptr, s->vram_size); 8.44 + } 8.45 8.46 /* force refresh */ 8.47 s->graphic_mode = -1; 8.48 @@ -2052,7 +2064,7 @@ static void vga_init(VGAState *s) 8.49 { 8.50 int vga_io_memory; 8.51 8.52 - register_savevm("vga", 0, 2, vga_save, vga_load, s); 8.53 + register_savevm("vga", 0, 3, vga_save, vga_load, s); 8.54 8.55 register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s); 8.56
9.1 --- a/tools/libxc/xc_domain.c Wed Dec 12 10:47:54 2007 -0700 9.2 +++ b/tools/libxc/xc_domain.c Wed Dec 12 10:50:03 2007 -0700 9.3 @@ -759,7 +759,21 @@ int xc_assign_device( 9.4 domctl.cmd = XEN_DOMCTL_assign_device; 9.5 domctl.domain = domid; 9.6 domctl.u.assign_device.machine_bdf = machine_bdf; 9.7 - 9.8 + 9.9 + return do_domctl(xc_handle, &domctl); 9.10 +} 9.11 + 9.12 +int xc_test_assign_device( 9.13 + int xc_handle, 9.14 + uint32_t domid, 9.15 + uint32_t machine_bdf) 9.16 +{ 9.17 + DECLARE_DOMCTL; 9.18 + 9.19 + domctl.cmd = XEN_DOMCTL_test_assign_device; 9.20 + domctl.domain = domid; 9.21 + domctl.u.assign_device.machine_bdf = machine_bdf; 9.22 + 9.23 return do_domctl(xc_handle, &domctl); 9.24 } 9.25
10.1 --- a/tools/libxc/xenctrl.h Wed Dec 12 10:47:54 2007 -0700 10.2 +++ b/tools/libxc/xenctrl.h Wed Dec 12 10:50:03 2007 -0700 10.3 @@ -914,6 +914,10 @@ int xc_assign_device(int xc_handle, 10.4 uint32_t domid, 10.5 uint32_t machine_bdf); 10.6 10.7 +int xc_test_assign_device(int xc_handle, 10.8 + uint32_t domid, 10.9 + uint32_t machine_bdf); 10.10 + 10.11 int xc_domain_memory_mapping(int xc_handle, 10.12 uint32_t domid, 10.13 unsigned long first_gfn,
11.1 --- a/tools/libxen/include/xen/api/xen_xspolicy.h Wed Dec 12 10:47:54 2007 -0700 11.2 +++ b/tools/libxen/include/xen/api/xen_xspolicy.h Wed Dec 12 10:50:03 2007 -0700 11.3 @@ -240,6 +240,19 @@ xen_xspolicy_set_xspolicy(xen_session *s 11.4 bool overwrite); 11.5 11.6 11.7 + 11.8 +/** 11.9 + * Attempt to reset the system's policy to the DEFAULT policy for the 11.10 + * respective policy type. This is done by updating the system and therefore 11.11 + * underlies the same restrictions of a policy update. This operation may 11.12 + * for example fail if other domains than Domain-0 are running and have 11.13 + * different labels than Domain-0. 11.14 + */ 11.15 +bool 11.16 +xen_xspolicy_reset_xspolicy(xen_session *session, xen_xs_policystate **result, 11.17 + xs_type type); 11.18 + 11.19 + 11.20 /** 11.21 * Remove any policy from having the system booted with. 11.22 */
12.1 --- a/tools/libxen/src/xen_xspolicy.c Wed Dec 12 10:47:54 2007 -0700 12.2 +++ b/tools/libxen/src/xen_xspolicy.c Wed Dec 12 10:50:03 2007 -0700 12.3 @@ -225,6 +225,24 @@ xen_xspolicy_set_xspolicy(xen_session *s 12.4 12.5 12.6 bool 12.7 +xen_xspolicy_reset_xspolicy(xen_session *session, xen_xs_policystate **result, 12.8 + xs_type type) 12.9 +{ 12.10 + abstract_value param_values[] = 12.11 + { 12.12 + { .type = &abstract_type_int, 12.13 + .u.int_val = type }, 12.14 + }; 12.15 + 12.16 + abstract_type result_type = xen_xs_policystate_abstract_type_; 12.17 + 12.18 + *result = NULL; 12.19 + XEN_CALL_("XSPolicy.reset_xspolicy"); 12.20 + return session->ok; 12.21 +} 12.22 + 12.23 + 12.24 +bool 12.25 xen_xspolicy_get_xspolicy(xen_session *session, xen_xs_policystate **result) 12.26 { 12.27 abstract_value param_values[] =
13.1 --- a/tools/python/xen/lowlevel/xc/xc.c Wed Dec 12 10:47:54 2007 -0700 13.2 +++ b/tools/python/xen/lowlevel/xc/xc.c Wed Dec 12 10:50:03 2007 -0700 13.3 @@ -560,9 +560,9 @@ static int next_bdf(char **str, int *seg 13.4 return 1; 13.5 } 13.6 13.7 -static PyObject *pyxc_assign_device(XcObject *self, 13.8 - PyObject *args, 13.9 - PyObject *kwds) 13.10 +static PyObject *pyxc_test_assign_device(XcObject *self, 13.11 + PyObject *args, 13.12 + PyObject *kwds) 13.13 { 13.14 uint32_t dom; 13.15 char *pci_str; 13.16 @@ -580,7 +580,7 @@ static PyObject *pyxc_assign_device(XcOb 13.17 bdf |= (dev & 0x1f) << 11; 13.18 bdf |= (func & 0x7) << 8; 13.19 13.20 - if ( xc_assign_device(self->xc_handle, dom, bdf) != 0 ) 13.21 + if ( xc_test_assign_device(self->xc_handle, dom, bdf) != 0 ) 13.22 break; 13.23 13.24 bdf = 0; 13.25 @@ -1426,10 +1426,10 @@ static PyMethodDef pyxc_methods[] = { 13.26 " value [long]: Value of param.\n" 13.27 "Returns: [int] 0 on success.\n" }, 13.28 13.29 - { "assign_device", 13.30 - (PyCFunction)pyxc_assign_device, 13.31 + { "test_assign_device", 13.32 + (PyCFunction)pyxc_test_assign_device, 13.33 METH_VARARGS | METH_KEYWORDS, "\n" 13.34 - "assign device with VT-d.\n" 13.35 + "test device assignment with VT-d.\n" 13.36 " dom [int]: Identifier of domain to build into.\n" 13.37 " pci_str [str]: PCI devices.\n" 13.38 "Returns: [int] 0 on success, or device bdf that can't be assigned.\n" },
14.1 --- a/tools/python/xen/util/acmpolicy.py Wed Dec 12 10:47:54 2007 -0700 14.2 +++ b/tools/python/xen/util/acmpolicy.py Wed Dec 12 10:50:03 2007 -0700 14.3 @@ -86,7 +86,7 @@ DEFAULT_policy = \ 14.4 " <SecurityLabelTemplate>\n" +\ 14.5 " <SubjectLabels bootstrap=\"SystemManagement\">\n" +\ 14.6 " <VirtualMachineLabel>\n" +\ 14.7 -" <Name>SystemManagement</Name>\n" +\ 14.8 +" <Name%s>SystemManagement</Name>\n" +\ 14.9 " <SimpleTypeEnforcementTypes>\n" +\ 14.10 " <Type>SystemManagement</Type>\n" +\ 14.11 " </SimpleTypeEnforcementTypes>\n" +\ 14.12 @@ -99,8 +99,11 @@ DEFAULT_policy = \ 14.13 "</SecurityPolicyDefinition>\n" 14.14 14.15 14.16 -def get_DEFAULT_policy(): 14.17 - return DEFAULT_policy 14.18 +def get_DEFAULT_policy(dom0label=""): 14.19 + fromnode = "" 14.20 + if dom0label != "": 14.21 + fromnode = " from=\"%s\"" % dom0label 14.22 + return DEFAULT_policy % fromnode 14.23 14.24 def initialize(): 14.25 xoptions = XendOptions.instance() 14.26 @@ -375,6 +378,12 @@ class ACMPolicy(XSPolicy): 14.27 14.28 force_default_policy = classmethod(force_default_policy) 14.29 14.30 + def get_reset_policy_xml(klass): 14.31 + dom0_label = security.get_ssid(0)[1] 14.32 + return get_DEFAULT_policy(dom0_label) 14.33 + 14.34 + get_reset_policy_xml = classmethod(get_reset_policy_xml) 14.35 + 14.36 def __do_update_version_check(self, acmpol_new): 14.37 acmpol_old = self 14.38
15.1 --- a/tools/python/xen/util/xsm/acm/acm.py Wed Dec 12 10:47:54 2007 -0700 15.2 +++ b/tools/python/xen/util/xsm/acm/acm.py Wed Dec 12 10:50:03 2007 -0700 15.3 @@ -86,6 +86,7 @@ xmlrpc_exports = [ 15.4 'list_labels', 15.5 'get_labeled_resources', 15.6 'set_policy', 15.7 + 'reset_policy', 15.8 'get_policy', 15.9 'activate_policy', 15.10 'rm_bootpolicy', 15.11 @@ -567,6 +568,20 @@ def set_policy(xs_type, xml, flags, over 15.12 err(str(e)) 15.13 15.14 15.15 +def reset_policy(): 15.16 + """ 15.17 + Xend exports this function via XML-RPC 15.18 + """ 15.19 + from xen.xend import XendXSPolicyAdmin 15.20 + xspoladmin = XendXSPolicyAdmin.XSPolicyAdminInstance() 15.21 + try: 15.22 + acmpol, rc, errors = \ 15.23 + xspoladmin.reset_acmpolicy() 15.24 + return rc, base64.b64encode(errors) 15.25 + except Exception, e: 15.26 + err(str(e)) 15.27 + 15.28 + 15.29 def get_policy(): 15.30 """ 15.31 Xend exports this function via XML-RPC
16.1 --- a/tools/python/xen/util/xsm/dummy/dummy.py Wed Dec 12 10:47:54 2007 -0700 16.2 +++ b/tools/python/xen/util/xsm/dummy/dummy.py Wed Dec 12 10:50:03 2007 -0700 16.3 @@ -21,6 +21,7 @@ xmlrpc_exports = [ 16.4 'list_labels', 16.5 'get_labeled_resources', 16.6 'set_policy', 16.7 + 'reset_policy', 16.8 'get_policy', 16.9 'activate_policy', 16.10 'rm_bootpolicy', 16.11 @@ -102,6 +103,9 @@ def get_labeled_resources(): 16.12 def set_policy(xs_type, xml, flags, overwrite): 16.13 err("Command not supported under xsm 'dummy' module.") 16.14 16.15 +def reset_policy(): 16.16 + err("Command not supported under xsm 'dummy' module.") 16.17 + 16.18 def get_policy(): 16.19 return "", 0 16.20
17.1 --- a/tools/python/xen/xend/XendDevices.py Wed Dec 12 10:47:54 2007 -0700 17.2 +++ b/tools/python/xen/xend/XendDevices.py Wed Dec 12 10:50:03 2007 -0700 17.3 @@ -19,7 +19,7 @@ 17.4 # A collection of DevControllers 17.5 # 17.6 17.7 -from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif, vfbif 17.8 +from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, vfbif 17.9 from xen.xend.server.BlktapController import BlktapController 17.10 from xen.xend.server.ConsoleController import ConsoleController 17.11 17.12 @@ -41,7 +41,6 @@ class XendDevices: 17.13 'pci': pciif.PciController, 17.14 'ioports': iopif.IOPortsController, 17.15 'irq': irqif.IRQController, 17.16 - 'usb': usbif.UsbifController, 17.17 'tap': BlktapController, 17.18 'vfb': vfbif.VfbifController, 17.19 'vkbd': vfbif.VkbdifController,
18.1 --- a/tools/python/xen/xend/XendDomain.py Wed Dec 12 10:47:54 2007 -0700 18.2 +++ b/tools/python/xen/xend/XendDomain.py Wed Dec 12 10:50:03 2007 -0700 18.3 @@ -613,13 +613,19 @@ class XendDomain: 18.4 if dom.getName() == DOM0_NAME: 18.5 continue 18.6 18.7 - if dom._stateGet() == DOM_STATE_RUNNING: 18.8 - shutdownAction = dom.info.get('on_xend_stop', 'ignore') 18.9 - if shutdownAction == 'shutdown': 18.10 - log.debug('Shutting down domain: %s' % dom.getName()) 18.11 - dom.shutdown("poweroff") 18.12 - elif shutdownAction == 'suspend': 18.13 - self.domain_suspend(dom.getName()) 18.14 + try: 18.15 + if dom._stateGet() == DOM_STATE_RUNNING: 18.16 + shutdownAction = dom.info.get('on_xend_stop', 'ignore') 18.17 + if shutdownAction == 'shutdown': 18.18 + log.debug('Shutting down domain: %s' % dom.getName()) 18.19 + dom.shutdown("poweroff") 18.20 + elif shutdownAction == 'suspend': 18.21 + self.domain_suspend(dom.getName()) 18.22 + else: 18.23 + log.debug('Domain %s continues to run.' % dom.getName()) 18.24 + except: 18.25 + log.exception('Domain %s failed to %s.' % \ 18.26 + (dom.getName(), shutdownAction)) 18.27 finally: 18.28 self.domains_lock.release() 18.29
19.1 --- a/tools/python/xen/xend/XendDomainInfo.py Wed Dec 12 10:47:54 2007 -0700 19.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Dec 12 10:50:03 2007 -0700 19.3 @@ -1653,10 +1653,10 @@ class XendDomainInfo: 19.4 # Set maximum number of vcpus in domain 19.5 xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max'])) 19.6 19.7 - # Assign devices with VT-d 19.8 + # Test whether the devices can be assigned with VT-d 19.9 pci_str = str(self.info["platform"].get("pci")) 19.10 if hvm and pci_str: 19.11 - bdf = xc.assign_device(self.domid, pci_str) 19.12 + bdf = xc.test_assign_device(self.domid, pci_str) 19.13 if bdf != 0: 19.14 bus = (bdf >> 16) & 0xff 19.15 devfn = (bdf >> 8) & 0xff 19.16 @@ -1880,8 +1880,6 @@ class XendDomainInfo: 19.17 19.18 self._cleanupVm() 19.19 if self.dompath is not None: 19.20 - if self.domid is not None: 19.21 - xc.domain_destroy_hook(self.domid) 19.22 self.destroyDomain() 19.23 19.24 self._cleanup_phantom_devs(paths) 19.25 @@ -1899,6 +1897,7 @@ class XendDomainInfo: 19.26 19.27 try: 19.28 if self.domid is not None: 19.29 + xc.domain_destroy_hook(self.domid) 19.30 xc.domain_destroy(self.domid) 19.31 for state in DOM_STATES_OLD: 19.32 self.info[state] = 0
20.1 --- a/tools/python/xen/xend/XendXSPolicy.py Wed Dec 12 10:47:54 2007 -0700 20.2 +++ b/tools/python/xen/xend/XendXSPolicy.py Wed Dec 12 10:50:03 2007 -0700 20.3 @@ -43,6 +43,7 @@ class XendXSPolicy(XendBase): 20.4 def getFuncs(self): 20.5 funcs = [ 'get_xstype', 20.6 'set_xspolicy', 20.7 + 'reset_xspolicy', 20.8 'get_xspolicy', 20.9 'rm_xsbootpolicy', 20.10 'get_resource_label', 20.11 @@ -104,6 +105,36 @@ class XendXSPolicy(XendBase): 20.12 raise SecurityError(-xsconstants.XSERR_POLICY_TYPE_UNSUPPORTED) 20.13 return polstate 20.14 20.15 + 20.16 + def reset_xspolicy(self, xstype): 20.17 + xstype = int(xstype) 20.18 + polstate = { 'xs_ref': "", 'repr' : "", 'type' : 0, 20.19 + 'flags' : 0 , 'version': 0 , 'errors' : "", 'xserr' : 0 } 20.20 + if xstype == xsconstants.XS_POLICY_ACM: 20.21 + poladmin = XSPolicyAdminInstance() 20.22 + try: 20.23 + (xspol, rc, errors) = poladmin.reset_acmpolicy() 20.24 + if rc != 0: 20.25 + polstate.update( { 'xserr' : rc, 20.26 + 'errors': base64.b64encode(errors) } ) 20.27 + else: 20.28 + ref = xspol.get_ref() 20.29 + polstate = { 20.30 + 'xs_ref' : ref, 20.31 + 'flags' : poladmin.get_policy_flags(xspol), 20.32 + 'type' : xstype, 20.33 + 'repr' : "", 20.34 + 'version': xspol.get_version(), 20.35 + 'errors' : base64.b64encode(errors), 20.36 + 'xserr' : rc, 20.37 + } 20.38 + except Exception, e: 20.39 + raise 20.40 + else: 20.41 + raise SecurityError(-xsconstants.XSERR_POLICY_TYPE_UNSUPPORTED) 20.42 + return polstate 20.43 + 20.44 + 20.45 def activate_xspolicy(self, flags): 20.46 flags = int(flags) 20.47 rc = -xsconstants.XSERR_GENERAL_FAILURE 20.48 @@ -162,6 +193,7 @@ class XendXSPolicy(XendBase): 20.49 get_xstype = classmethod(get_xstype) 20.50 get_xspolicy = classmethod(get_xspolicy) 20.51 set_xspolicy = classmethod(set_xspolicy) 20.52 + reset_xspolicy = classmethod(reset_xspolicy) 20.53 rm_xsbootpolicy = classmethod(rm_xsbootpolicy) 20.54 set_resource_label = classmethod(set_resource_label) 20.55 get_resource_label = classmethod(get_resource_label)
21.1 --- a/tools/python/xen/xend/XendXSPolicyAdmin.py Wed Dec 12 10:47:54 2007 -0700 21.2 +++ b/tools/python/xen/xend/XendXSPolicyAdmin.py Wed Dec 12 10:50:03 2007 -0700 21.3 @@ -179,6 +179,23 @@ class XSPolicyAdmin: 21.4 self.xsobjs[ref] = acmpol 21.5 return (acmpol, xsconstants.XSERR_SUCCESS, errors) 21.6 21.7 + 21.8 + def reset_acmpolicy(self): 21.9 + """ 21.10 + Attempt to reset the system's policy by udating it with 21.11 + the DEFAULT policy. 21.12 + """ 21.13 + from xen.xend import XendDomain 21.14 + domains = XendDomain.instance() 21.15 + try: 21.16 + domains.domains_lock.acquire() 21.17 + xml = ACMPolicy.get_reset_policy_xml() 21.18 + flags = xsconstants.XS_INST_BOOT | xsconstants.XS_INST_LOAD 21.19 + return self.__add_acmpolicy_to_system(xml, flags, True) 21.20 + finally: 21.21 + domains.domains_lock.release() 21.22 + 21.23 + 21.24 def make_boot_policy(self, acmpol): 21.25 if acmpol.is_default_policy(): 21.26 return xsconstants.XSERR_SUCCESS
22.1 --- a/tools/python/xen/xend/server/usbif.py Wed Dec 12 10:47:54 2007 -0700 22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 22.3 @@ -1,42 +0,0 @@ 22.4 -#============================================================================ 22.5 -# This library is free software; you can redistribute it and/or 22.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public 22.7 -# License as published by the Free Software Foundation. 22.8 -# 22.9 -# This library is distributed in the hope that it will be useful, 22.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of 22.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22.12 -# Lesser General Public License for more details. 22.13 -# 22.14 -# You should have received a copy of the GNU Lesser General Public 22.15 -# License along with this library; if not, write to the Free Software 22.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22.17 -#============================================================================ 22.18 -# Copyright (C) 2004 Mike Wray <mike.wray@hp.com> 22.19 -# Copyright (C) 2004 Intel Research Cambridge 22.20 -# Copyright (C) 2004 Mark Williamson <mark.williamson@cl.cam.ac.uk> 22.21 -# Copyright (C) 2005 XenSource Ltd 22.22 -#============================================================================ 22.23 - 22.24 - 22.25 -"""Support for virtual USB hubs. 22.26 -""" 22.27 - 22.28 -from xen.xend.server.DevController import DevController 22.29 - 22.30 - 22.31 -class UsbifController(DevController): 22.32 - """USB device interface controller. Handles all USB devices 22.33 - for a domain. 22.34 - """ 22.35 - 22.36 - def __init__(self, vm): 22.37 - """Create a USB device controller. 22.38 - """ 22.39 - DevController.__init__(self, vm) 22.40 - 22.41 - 22.42 - def getDeviceDetails(self, _): 22.43 - """@see DevController.getDeviceDetails""" 22.44 - 22.45 - return (self.allocateDeviceID(), {}, {})
23.1 --- a/tools/python/xen/xm/create.py Wed Dec 12 10:47:54 2007 -0700 23.2 +++ b/tools/python/xen/xm/create.py Wed Dec 12 10:50:03 2007 -0700 23.3 @@ -309,11 +309,6 @@ gopts.var('irq', val='IRQ', 23.4 For example 'irq=7'. 23.5 This option may be repeated to add more than one IRQ.""") 23.6 23.7 -gopts.var('usbport', val='PATH', 23.8 - fn=append_value, default=[], 23.9 - use="""Add a physical USB port to a domain, as specified by the path 23.10 - to that port. This option may be repeated to add more than one port.""") 23.11 - 23.12 gopts.var('vfb', val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD", 23.13 fn=append_value, default=[], 23.14 use="""Make the domain a framebuffer backend. 23.15 @@ -617,11 +612,6 @@ def configure_irq(config_devs, vals): 23.16 config_irq = ['irq', ['irq', irq]] 23.17 config_devs.append(['device', config_irq]) 23.18 23.19 -def configure_usb(config_devs, vals): 23.20 - for path in vals.usbport: 23.21 - config_usb = ['usbport', ['path', path]] 23.22 - config_devs.append(['device', config_usb]) 23.23 - 23.24 def configure_vfbs(config_devs, vals): 23.25 for f in vals.vfb: 23.26 d = comma_sep_kv_to_dict(f) 23.27 @@ -800,7 +790,6 @@ def make_config(vals): 23.28 configure_ioports(config_devs, vals) 23.29 configure_irq(config_devs, vals) 23.30 configure_vifs(config_devs, vals) 23.31 - configure_usb(config_devs, vals) 23.32 configure_vtpm(config_devs, vals) 23.33 configure_vfbs(config_devs, vals) 23.34 configure_security(config, vals)
24.1 --- a/tools/python/xen/xm/main.py Wed Dec 12 10:47:54 2007 -0700 24.2 +++ b/tools/python/xen/xm/main.py Wed Dec 12 10:50:03 2007 -0700 24.3 @@ -1833,7 +1833,7 @@ def xm_debug_keys(args): 24.4 def xm_top(args): 24.5 arg_check(args, "top", 0) 24.6 24.7 - os.execvp('xentop', ['xentop']) 24.8 + os.system('xentop') 24.9 24.10 def xm_dmesg(args): 24.11 arg_check(args, "dmesg", 0, 1)
25.1 --- a/tools/python/xen/xm/resetpolicy.py Wed Dec 12 10:47:54 2007 -0700 25.2 +++ b/tools/python/xen/xm/resetpolicy.py Wed Dec 12 10:50:03 2007 -0700 25.3 @@ -26,40 +26,6 @@ from xen.xm.main import server 25.4 from xen.util import xsconstants 25.5 from xen.util.acmpolicy import ACMPolicy 25.6 25.7 -DOM0_UUID = "00000000-0000-0000-0000-000000000000" 25.8 - 25.9 -DEFAULT_policy_template = \ 25.10 -"<?xml version=\"1.0\" ?>" +\ 25.11 -"<SecurityPolicyDefinition xmlns=\"http://www.ibm.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.ibm.com ../../security_policy.xsd\">" +\ 25.12 -" <PolicyHeader>" +\ 25.13 -" <PolicyName>DEFAULT</PolicyName>" +\ 25.14 -" <Version>1.0</Version>" +\ 25.15 -" </PolicyHeader>" +\ 25.16 -" <SimpleTypeEnforcement>" +\ 25.17 -" <SimpleTypeEnforcementTypes>" +\ 25.18 -" <Type>SystemManagement</Type>" +\ 25.19 -" </SimpleTypeEnforcementTypes>" +\ 25.20 -" </SimpleTypeEnforcement>" +\ 25.21 -" <ChineseWall>" +\ 25.22 -" <ChineseWallTypes>" +\ 25.23 -" <Type>SystemManagement</Type>" +\ 25.24 -" </ChineseWallTypes>" +\ 25.25 -" </ChineseWall>" +\ 25.26 -" <SecurityLabelTemplate>" +\ 25.27 -" <SubjectLabels bootstrap=\"SystemManagement\">" +\ 25.28 -" <VirtualMachineLabel>" +\ 25.29 -" <Name%s>SystemManagement</Name>" +\ 25.30 -" <SimpleTypeEnforcementTypes>" +\ 25.31 -" <Type>SystemManagement</Type>" +\ 25.32 -" </SimpleTypeEnforcementTypes>" +\ 25.33 -" <ChineseWallTypes>" +\ 25.34 -" <Type/>" +\ 25.35 -" </ChineseWallTypes>" +\ 25.36 -" </VirtualMachineLabel>" +\ 25.37 -" </SubjectLabels>" +\ 25.38 -" </SecurityLabelTemplate>" +\ 25.39 -"</SecurityPolicyDefinition>" 25.40 - 25.41 25.42 def help(): 25.43 return """ 25.44 @@ -69,16 +35,6 @@ def help(): 25.45 since otherwise this operation will fail. 25.46 """ 25.47 25.48 -def get_reset_policy_xml(dom0_seclab): 25.49 - if dom0_seclab == "": 25.50 - return DEFAULT_policy_template % "" 25.51 - else: 25.52 - poltyp, policy, label = dom0_seclab.split(":") 25.53 - if label != "SystemManagement": 25.54 - return DEFAULT_policy_template % \ 25.55 - (" from=\"%s\"" % label) 25.56 - else: 25.57 - return DEFAULT_policy_template % "" 25.58 25.59 def resetpolicy(): 25.60 msg = None 25.61 @@ -99,13 +55,8 @@ def resetpolicy(): 25.62 not acmpol.is_default_policy(): 25.63 msg = "Old policy not found in bootloader file." 25.64 25.65 - seclab = server.xenapi.VM.get_security_label(DOM0_UUID) 25.66 - xml = get_reset_policy_xml(seclab) 25.67 try: 25.68 - policystate = server.xenapi.XSPolicy.set_xspolicy(xs_type, 25.69 - xml, 25.70 - flags, 25.71 - True) 25.72 + policystate = server.xenapi.XSPolicy.reset_xspolicy(xs_type) 25.73 except Exception, e: 25.74 raise security.XSMError("An error occurred resetting the " 25.75 "policy: %s" % str(e)) 25.76 @@ -130,14 +81,7 @@ def resetpolicy(): 25.77 not acmpol.is_default_policy(): 25.78 msg = "Old policy not found in bootloader file." 25.79 25.80 - seclab = server.xend.security.get_domain_label(0) 25.81 - if seclab[0] == '\'': 25.82 - seclab = seclab[1:] 25.83 - xml = get_reset_policy_xml(seclab) 25.84 - rc, errors = server.xend.security.set_policy(xs_type, 25.85 - xml, 25.86 - flags, 25.87 - True) 25.88 + rc, errors = server.xend.security.reset_policy() 25.89 if rc != xsconstants.XSERR_SUCCESS: 25.90 raise security.XSMError("Could not reset the system's policy. " 25.91 "Try to halt all guests.")
27.1 --- a/xen/arch/x86/domctl.c Wed Dec 12 10:47:54 2007 -0700 27.2 +++ b/xen/arch/x86/domctl.c Wed Dec 12 10:50:03 2007 -0700 27.3 @@ -525,10 +525,31 @@ long arch_do_domctl( 27.4 } 27.5 break; 27.6 27.7 + case XEN_DOMCTL_test_assign_device: 27.8 + { 27.9 + u8 bus, devfn; 27.10 + 27.11 + ret = -EINVAL; 27.12 + if ( !vtd_enabled ) 27.13 + break; 27.14 + 27.15 + bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff; 27.16 + devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff; 27.17 + 27.18 + if ( device_assigned(bus, devfn) ) 27.19 + { 27.20 + gdprintk(XENLOG_ERR, "XEN_DOMCTL_test_assign_device: " 27.21 + "%x:%x:%x already assigned\n", 27.22 + bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 27.23 + break; 27.24 + } 27.25 + ret = 0; 27.26 + } 27.27 + break; 27.28 + 27.29 case XEN_DOMCTL_assign_device: 27.30 { 27.31 struct domain *d; 27.32 - struct hvm_iommu *hd; 27.33 u8 bus, devfn; 27.34 27.35 ret = -EINVAL; 27.36 @@ -541,7 +562,6 @@ long arch_do_domctl( 27.37 "XEN_DOMCTL_assign_device: get_domain_by_id() failed\n"); 27.38 break; 27.39 } 27.40 - hd = domain_hvm_iommu(d); 27.41 bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff; 27.42 devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff; 27.43 27.44 @@ -549,7 +569,7 @@ long arch_do_domctl( 27.45 { 27.46 gdprintk(XENLOG_ERR, "XEN_DOMCTL_assign_device: " 27.47 "%x:%x:%x already assigned\n", 27.48 - bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 27.49 + bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 27.50 break; 27.51 } 27.52
28.1 --- a/xen/arch/x86/gdbstub.c Wed Dec 12 10:47:54 2007 -0700 28.2 +++ b/xen/arch/x86/gdbstub.c Wed Dec 12 10:50:03 2007 -0700 28.3 @@ -71,18 +71,20 @@ gdb_arch_read_reg(unsigned long regnum, 28.4 gdb_send_reply("", ctx); 28.5 } 28.6 28.7 -/* Like copy_from_user, but safe to call with interrupts disabled. 28.8 - Trust me, and don't look behind the curtain. */ 28.9 +/* 28.10 + * Use __copy_*_user to make us page-fault safe, but not otherwise restrict 28.11 + * our access to the full virtual address space. 28.12 + */ 28.13 unsigned int 28.14 gdb_arch_copy_from_user(void *dest, const void *src, unsigned len) 28.15 { 28.16 - return copy_from_user(dest, src, len); 28.17 + return __copy_from_user(dest, src, len); 28.18 } 28.19 28.20 unsigned int 28.21 gdb_arch_copy_to_user(void *dest, const void *src, unsigned len) 28.22 { 28.23 - return copy_to_user(dest, src, len); 28.24 + return __copy_to_user(dest, src, len); 28.25 } 28.26 28.27 void
29.1 --- a/xen/arch/x86/hvm/i8254.c Wed Dec 12 10:47:54 2007 -0700 29.2 +++ b/xen/arch/x86/hvm/i8254.c Wed Dec 12 10:50:03 2007 -0700 29.3 @@ -501,6 +501,8 @@ void pit_init(struct vcpu *v, unsigned l 29.4 /* Some sub-functions assert that they are called with the lock held. */ 29.5 spin_lock(&pit->lock); 29.6 29.7 + pit->pt0.source = PTSRC_isa; 29.8 + 29.9 register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io); 29.10 register_portio_handler(v->domain, 0x61, 1, handle_speaker_io); 29.11 ticks_per_sec(v) = cpu_khz * (int64_t)1000;
30.1 --- a/xen/arch/x86/hvm/irq.c Wed Dec 12 10:47:54 2007 -0700 30.2 +++ b/xen/arch/x86/hvm/irq.c Wed Dec 12 10:50:03 2007 -0700 30.3 @@ -347,30 +347,6 @@ struct hvm_intack hvm_vcpu_ack_pending_i 30.4 return intack; 30.5 } 30.6 30.7 -int get_isa_irq_vector(struct vcpu *v, int isa_irq, enum hvm_intsrc src) 30.8 -{ 30.9 - unsigned int gsi = hvm_isa_irq_to_gsi(isa_irq); 30.10 - 30.11 - if ( src == hvm_intsrc_pic ) 30.12 - return (v->domain->arch.hvm_domain.vpic[isa_irq >> 3].irq_base 30.13 - + (isa_irq & 7)); 30.14 - 30.15 - ASSERT(src == hvm_intsrc_lapic); 30.16 - return domain_vioapic(v->domain)->redirtbl[gsi].fields.vector; 30.17 -} 30.18 - 30.19 -int is_isa_irq_masked(struct vcpu *v, int isa_irq) 30.20 -{ 30.21 - unsigned int gsi = hvm_isa_irq_to_gsi(isa_irq); 30.22 - 30.23 - if ( is_lvtt(v, isa_irq) ) 30.24 - return !is_lvtt_enabled(v); 30.25 - 30.26 - return ((v->domain->arch.hvm_domain.vpic[isa_irq >> 3].imr & 30.27 - (1 << (isa_irq & 7))) && 30.28 - domain_vioapic(v->domain)->redirtbl[gsi].fields.mask); 30.29 -} 30.30 - 30.31 int hvm_local_events_need_delivery(struct vcpu *v) 30.32 { 30.33 struct hvm_intack intack;
31.1 --- a/xen/arch/x86/hvm/mtrr.c Wed Dec 12 10:47:54 2007 -0700 31.2 +++ b/xen/arch/x86/hvm/mtrr.c Wed Dec 12 10:50:03 2007 -0700 31.3 @@ -769,3 +769,83 @@ int32_t hvm_set_mem_pinned_cacheattr( 31.4 31.5 return 0; 31.6 } 31.7 + 31.8 +static int hvm_save_mtrr_msr(struct domain *d, hvm_domain_context_t *h) 31.9 +{ 31.10 + int i; 31.11 + struct vcpu *v; 31.12 + struct hvm_hw_mtrr hw_mtrr; 31.13 + struct mtrr_state *mtrr_state; 31.14 + /* save mtrr&pat */ 31.15 + for_each_vcpu(d, v) 31.16 + { 31.17 + mtrr_state = &v->arch.hvm_vcpu.mtrr; 31.18 + 31.19 + hw_mtrr.msr_pat_cr = v->arch.hvm_vcpu.pat_cr; 31.20 + 31.21 + hw_mtrr.msr_mtrr_def_type = mtrr_state->def_type 31.22 + | (mtrr_state->enabled << 10); 31.23 + hw_mtrr.msr_mtrr_cap = mtrr_state->mtrr_cap; 31.24 + 31.25 + for ( i = 0; i < MTRR_VCNT; i++ ) 31.26 + { 31.27 + /* save physbase */ 31.28 + hw_mtrr.msr_mtrr_var[i*2] = 31.29 + ((uint64_t*)mtrr_state->var_ranges)[i*2]; 31.30 + /* save physmask */ 31.31 + hw_mtrr.msr_mtrr_var[i*2+1] = 31.32 + ((uint64_t*)mtrr_state->var_ranges)[i*2+1]; 31.33 + } 31.34 + 31.35 + for ( i = 0; i < NUM_FIXED_MSR; i++ ) 31.36 + hw_mtrr.msr_mtrr_fixed[i] = 31.37 + ((uint64_t*)mtrr_state->fixed_ranges)[i]; 31.38 + 31.39 + if ( hvm_save_entry(MTRR, v->vcpu_id, h, &hw_mtrr) != 0 ) 31.40 + return 1; 31.41 + } 31.42 + return 0; 31.43 +} 31.44 + 31.45 +static int hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h) 31.46 +{ 31.47 + int vcpuid, i; 31.48 + struct vcpu *v; 31.49 + struct mtrr_state *mtrr_state; 31.50 + struct hvm_hw_mtrr hw_mtrr; 31.51 + 31.52 + vcpuid = hvm_load_instance(h); 31.53 + if ( vcpuid > MAX_VIRT_CPUS || (v = d->vcpu[vcpuid]) == NULL ) 31.54 + { 31.55 + gdprintk(XENLOG_ERR, "HVM restore: domain has no vcpu %u\n", vcpuid); 31.56 + return -EINVAL; 31.57 + } 31.58 + 31.59 + if ( hvm_load_entry(MTRR, h, &hw_mtrr) != 0 ) 31.60 + return -EINVAL; 31.61 + 31.62 + mtrr_state = &v->arch.hvm_vcpu.mtrr; 31.63 + 31.64 + pat_msr_set(&v->arch.hvm_vcpu.pat_cr, hw_mtrr.msr_pat_cr); 31.65 + 31.66 + mtrr_state->mtrr_cap = hw_mtrr.msr_mtrr_cap; 31.67 + 31.68 + for ( i = 0; i < NUM_FIXED_MSR; i++ ) 31.69 + mtrr_fix_range_msr_set(mtrr_state, i, hw_mtrr.msr_mtrr_fixed[i]); 31.70 + 31.71 + for ( i = 0; i < MTRR_VCNT; i++ ) 31.72 + { 31.73 + mtrr_var_range_msr_set(mtrr_state, 31.74 + MTRRphysBase_MSR(i), hw_mtrr.msr_mtrr_var[i*2]); 31.75 + mtrr_var_range_msr_set(mtrr_state, 31.76 + MTRRphysMask_MSR(i), hw_mtrr.msr_mtrr_var[i*2+1]); 31.77 + } 31.78 + 31.79 + mtrr_def_type_msr_set(mtrr_state, hw_mtrr.msr_mtrr_def_type); 31.80 + 31.81 + v->arch.hvm_vcpu.mtrr.is_initialized = 1; 31.82 + return 0; 31.83 +} 31.84 + 31.85 +HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, hvm_load_mtrr_msr, 31.86 + 1, HVMSR_PER_VCPU);
32.1 --- a/xen/arch/x86/hvm/rtc.c Wed Dec 12 10:47:54 2007 -0700 32.2 +++ b/xen/arch/x86/hvm/rtc.c Wed Dec 12 10:50:03 2007 -0700 32.3 @@ -42,14 +42,6 @@ static void rtc_periodic_cb(struct vcpu 32.4 spin_unlock(&s->lock); 32.5 } 32.6 32.7 -int is_rtc_periodic_irq(void *opaque) 32.8 -{ 32.9 - RTCState *s = opaque; 32.10 - 32.11 - return !(s->hw.cmos_data[RTC_REG_C] & RTC_AF || 32.12 - s->hw.cmos_data[RTC_REG_C] & RTC_UF); 32.13 -} 32.14 - 32.15 /* Enable/configure/disable the periodic timer based on the RTC_PIE and 32.16 * RTC_RATE_SELECT settings */ 32.17 static void rtc_timer_update(RTCState *s) 32.18 @@ -488,6 +480,8 @@ void rtc_init(struct vcpu *v, int base) 32.19 32.20 spin_lock_init(&s->lock); 32.21 32.22 + s->pt.source = PTSRC_isa; 32.23 + 32.24 s->hw.cmos_data[RTC_REG_A] = RTC_REF_CLCK_32KHZ | 6; /* ~1kHz */ 32.25 s->hw.cmos_data[RTC_REG_B] = RTC_24H; 32.26 s->hw.cmos_data[RTC_REG_C] = 0;
33.1 --- a/xen/arch/x86/hvm/vioapic.c Wed Dec 12 10:47:54 2007 -0700 33.2 +++ b/xen/arch/x86/hvm/vioapic.c Wed Dec 12 10:50:03 2007 -0700 33.3 @@ -300,7 +300,7 @@ static uint32_t ioapic_get_delivery_bitm 33.4 static inline int pit_channel0_enabled(void) 33.5 { 33.6 PITState *pit = ¤t->domain->arch.hvm_domain.pl_time.vpit; 33.7 - return pit->pt0.enabled; 33.8 + return pt_active(&pit->pt0); 33.9 } 33.10 33.11 static void vioapic_deliver(struct hvm_hw_vioapic *vioapic, int irq)
34.1 --- a/xen/arch/x86/hvm/vlapic.c Wed Dec 12 10:47:54 2007 -0700 34.2 +++ b/xen/arch/x86/hvm/vlapic.c Wed Dec 12 10:50:03 2007 -0700 34.3 @@ -68,9 +68,6 @@ static unsigned int vlapic_lvt_mask[VLAP 34.4 #define APIC_DEST_NOSHORT 0x0 34.5 #define APIC_DEST_MASK 0x800 34.6 34.7 -#define vlapic_lvt_enabled(vlapic, lvt_type) \ 34.8 - (!(vlapic_get_reg(vlapic, lvt_type) & APIC_LVT_MASKED)) 34.9 - 34.10 #define vlapic_lvt_vector(vlapic, lvt_type) \ 34.11 (vlapic_get_reg(vlapic, lvt_type) & APIC_VECTOR_MASK) 34.12 34.13 @@ -932,6 +929,8 @@ int vlapic_init(struct vcpu *v) 34.14 34.15 HVM_DBG_LOG(DBG_LEVEL_VLAPIC, "%d", v->vcpu_id); 34.16 34.17 + vlapic->pt.source = PTSRC_lapic; 34.18 + 34.19 #ifdef __i386__ 34.20 /* 32-bit VMX may be limited to 32-bit physical addresses. */ 34.21 if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ) 34.22 @@ -974,18 +973,3 @@ void vlapic_destroy(struct vcpu *v) 34.23 unmap_domain_page_global(vlapic->regs); 34.24 free_domheap_page(vlapic->regs_page); 34.25 } 34.26 - 34.27 -int is_lvtt(struct vcpu *v, int vector) 34.28 -{ 34.29 - return vcpu_vlapic(v)->pt.enabled && 34.30 - vector == vlapic_lvt_vector(vcpu_vlapic(v), APIC_LVTT); 34.31 -} 34.32 - 34.33 -int is_lvtt_enabled(struct vcpu *v) 34.34 -{ 34.35 - if ( unlikely(!vlapic_enabled(vcpu_vlapic(v))) || 34.36 - !vlapic_lvt_enabled(vcpu_vlapic(v), APIC_LVTT)) 34.37 - return 0; 34.38 - 34.39 - return 1; 34.40 -}
35.1 --- a/xen/arch/x86/hvm/vmx/vtd/dmar.c Wed Dec 12 10:47:54 2007 -0700 35.2 +++ b/xen/arch/x86/hvm/vmx/vtd/dmar.c Wed Dec 12 10:50:03 2007 -0700 35.3 @@ -30,7 +30,6 @@ 35.4 #include "pci-direct.h" 35.5 #include "pci_regs.h" 35.6 35.7 -#define VTDPREFIX 35.8 int vtd_enabled; 35.9 boolean_param("vtd", vtd_enabled); 35.10
36.1 --- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c Wed Dec 12 10:47:54 2007 -0700 36.2 +++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c Wed Dec 12 10:50:03 2007 -0700 36.3 @@ -37,7 +37,6 @@ 36.4 36.5 #define domain_iommu_domid(d) ((d)->arch.hvm_domain.hvm_iommu.iommu_domid) 36.6 36.7 -#define VTDPREFIX 36.8 extern void print_iommu_regs(struct acpi_drhd_unit *drhd); 36.9 extern void print_vtd_entries(struct domain *d, int bus, int devfn, 36.10 unsigned long gmfn); 36.11 @@ -954,7 +953,7 @@ struct iommu *iommu_alloc(void *hw_data) 36.12 36.13 set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, drhd->address); 36.14 iommu->reg = (void *) fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus); 36.15 - dprintk(XENLOG_ERR VTDPREFIX, 36.16 + dprintk(XENLOG_INFO VTDPREFIX, 36.17 "iommu_alloc: iommu->reg = %p drhd->address = %lx\n", 36.18 iommu->reg, drhd->address); 36.19 nr_iommus++; 36.20 @@ -1058,7 +1057,7 @@ static int domain_context_mapping_one( 36.21 36.22 if ( context_present(*context) ) 36.23 { 36.24 - gdprintk(XENLOG_INFO VTDPREFIX, 36.25 + gdprintk(XENLOG_WARNING VTDPREFIX, 36.26 "domain_context_mapping_one:context present:bdf=%x:%x:%x\n", 36.27 bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); 36.28 return 0; 36.29 @@ -1097,7 +1096,7 @@ static int domain_context_mapping_one( 36.30 iommu_flush_cache_entry(iommu, context); 36.31 36.32 gdprintk(XENLOG_INFO VTDPREFIX, 36.33 - "context_mapping_one-%x:%x:%x-*context=%"PRIx64":%"PRIx64 36.34 + "domain_context_mapping_one-%x:%x:%x-*context=%"PRIx64":%"PRIx64 36.35 " hd->pgd=%p\n", 36.36 bus, PCI_SLOT(devfn), PCI_FUNC(devfn), 36.37 context->hi, context->lo, hd->pgd); 36.38 @@ -1198,14 +1197,11 @@ static int domain_context_mapping( 36.39 PCI_FUNC(pdev->devfn), PCI_SUBORDINATE_BUS); 36.40 36.41 if ( sec_bus != sub_bus ) 36.42 - { 36.43 - dprintk(XENLOG_INFO VTDPREFIX, 36.44 - "context_mapping: nested PCI bridge not supported\n"); 36.45 - dprintk(XENLOG_INFO VTDPREFIX, 36.46 - " bdf = %x:%x:%x sec_bus = %x sub_bus = %x\n", 36.47 - pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), 36.48 - sec_bus, sub_bus); 36.49 - } 36.50 + gdprintk(XENLOG_WARNING VTDPREFIX, 36.51 + "context_context_mapping: nested PCI bridge not " 36.52 + "supported: bdf = %x:%x:%x sec_bus = %x sub_bus = %x\n", 36.53 + pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), 36.54 + sec_bus, sub_bus); 36.55 break; 36.56 case DEV_TYPE_PCIe_ENDPOINT: 36.57 gdprintk(XENLOG_INFO VTDPREFIX, 36.58 @@ -1227,7 +1223,7 @@ static int domain_context_mapping( 36.59 if ( bus2bridge[pdev->bus].bus != 0 ) 36.60 gdprintk(XENLOG_WARNING VTDPREFIX, 36.61 "domain_context_mapping:bus2bridge" 36.62 - "[pdev->bus].bus != 0\n"); 36.63 + "[%d].bus != 0\n", pdev->bus); 36.64 36.65 ret = domain_context_mapping_one( 36.66 domain, iommu, 36.67 @@ -1345,8 +1341,8 @@ static int domain_context_unmap( 36.68 { 36.69 if ( bus2bridge[pdev->bus].bus != 0 ) 36.70 gdprintk(XENLOG_WARNING VTDPREFIX, 36.71 - "domain_context_mapping:" 36.72 - "bus2bridge[pdev->bus].bus != 0\n"); 36.73 + "domain_context_unmap:" 36.74 + "bus2bridge[%d].bus != 0\n", pdev->bus); 36.75 36.76 ret = domain_context_unmap_one(domain, iommu, 36.77 (u8)(bus2bridge[pdev->bus].bus),
37.1 --- a/xen/arch/x86/hvm/vmx/vtd/io.c Wed Dec 12 10:47:54 2007 -0700 37.2 +++ b/xen/arch/x86/hvm/vmx/vtd/io.c Wed Dec 12 10:50:03 2007 -0700 37.3 @@ -131,7 +131,7 @@ int pt_irq_create_bind_vtd( 37.4 pirq_guest_bind(d->vcpu[0], machine_gsi, BIND_PIRQ__WILL_SHARE); 37.5 } 37.6 37.7 - gdprintk(XENLOG_INFO, 37.8 + gdprintk(XENLOG_INFO VTDPREFIX, 37.9 "VT-d irq bind: m_irq = %x device = %x intx = %x\n", 37.10 machine_gsi, device, intx); 37.11 return 0; 37.12 @@ -187,7 +187,7 @@ static void hvm_dpci_isairq_eoi(struct d 37.13 if ( --dpci->mirq[i].pending == 0 ) 37.14 { 37.15 spin_unlock(&dpci->dirq_lock); 37.16 - gdprintk(XENLOG_INFO, 37.17 + gdprintk(XENLOG_INFO VTDPREFIX, 37.18 "hvm_dpci_isairq_eoi:: mirq = %x\n", i); 37.19 stop_timer(&dpci->hvm_timer[irq_to_vector(i)]); 37.20 pirq_guest_eoi(d, i); 37.21 @@ -226,7 +226,8 @@ void hvm_dpci_eoi(struct domain *d, unsi 37.22 { 37.23 spin_unlock(&hvm_irq_dpci->dirq_lock); 37.24 37.25 - gdprintk(XENLOG_INFO, "hvm_dpci_eoi:: mirq = %x\n", machine_gsi); 37.26 + gdprintk(XENLOG_INFO VTDPREFIX, 37.27 + "hvm_dpci_eoi:: mirq = %x\n", machine_gsi); 37.28 stop_timer(&hvm_irq_dpci->hvm_timer[irq_to_vector(machine_gsi)]); 37.29 if ( (ent == NULL) || !ent->fields.mask ) 37.30 pirq_guest_eoi(d, machine_gsi);
38.1 --- a/xen/arch/x86/hvm/vmx/vtd/utils.c Wed Dec 12 10:47:54 2007 -0700 38.2 +++ b/xen/arch/x86/hvm/vmx/vtd/utils.c Wed Dec 12 10:50:03 2007 -0700 38.3 @@ -34,7 +34,6 @@ 38.4 #include <xen/xmalloc.h> 38.5 #include <xen/inttypes.h> 38.6 38.7 -#define VTDPREFIX "[VT-D]" 38.8 #define INTEL 0x8086 38.9 #define SEABURG 0x4000 38.10 #define C_STEP 2
39.1 --- a/xen/arch/x86/hvm/vpt.c Wed Dec 12 10:47:54 2007 -0700 39.2 +++ b/xen/arch/x86/hvm/vpt.c Wed Dec 12 10:50:03 2007 -0700 39.3 @@ -15,7 +15,6 @@ 39.4 * You should have received a copy of the GNU General Public License along with 39.5 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 39.6 * Place - Suite 330, Boston, MA 02111-1307 USA. 39.7 - * 39.8 */ 39.9 39.10 #include <xen/time.h> 39.11 @@ -26,6 +25,46 @@ 39.12 #define mode_is(d, name) \ 39.13 ((d)->arch.hvm_domain.params[HVM_PARAM_TIMER_MODE] == HVMPTM_##name) 39.14 39.15 +static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) 39.16 +{ 39.17 + struct vcpu *v = pt->vcpu; 39.18 + unsigned int gsi, isa_irq; 39.19 + 39.20 + if ( pt->source == PTSRC_lapic ) 39.21 + return pt->irq; 39.22 + 39.23 + isa_irq = pt->irq; 39.24 + gsi = hvm_isa_irq_to_gsi(isa_irq); 39.25 + 39.26 + if ( src == hvm_intsrc_pic ) 39.27 + return (v->domain->arch.hvm_domain.vpic[isa_irq >> 3].irq_base 39.28 + + (isa_irq & 7)); 39.29 + 39.30 + ASSERT(src == hvm_intsrc_lapic); 39.31 + return domain_vioapic(v->domain)->redirtbl[gsi].fields.vector; 39.32 +} 39.33 + 39.34 +static int pt_irq_masked(struct periodic_time *pt) 39.35 +{ 39.36 + struct vcpu *v = pt->vcpu; 39.37 + unsigned int gsi, isa_irq; 39.38 + uint8_t pic_imr; 39.39 + 39.40 + if ( pt->source == PTSRC_lapic ) 39.41 + { 39.42 + struct vlapic *vlapic = vcpu_vlapic(v); 39.43 + return (vlapic_enabled(vlapic) && 39.44 + !(vlapic_get_reg(vlapic, APIC_LVTT) & APIC_LVT_MASKED)); 39.45 + } 39.46 + 39.47 + isa_irq = pt->irq; 39.48 + gsi = hvm_isa_irq_to_gsi(isa_irq); 39.49 + pic_imr = v->domain->arch.hvm_domain.vpic[isa_irq >> 3].imr; 39.50 + 39.51 + return (((pic_imr & (1 << (isa_irq & 7))) || !vlapic_accept_pic_intr(v)) && 39.52 + domain_vioapic(v->domain)->redirtbl[gsi].fields.mask); 39.53 +} 39.54 + 39.55 static void pt_lock(struct periodic_time *pt) 39.56 { 39.57 struct vcpu *v; 39.58 @@ -144,29 +183,39 @@ static void pt_timer_fn(void *data) 39.59 void pt_update_irq(struct vcpu *v) 39.60 { 39.61 struct list_head *head = &v->arch.hvm_vcpu.tm_list; 39.62 - struct periodic_time *pt; 39.63 + struct periodic_time *pt, *earliest_pt = NULL; 39.64 uint64_t max_lag = -1ULL; 39.65 - int irq = -1; 39.66 + int irq, is_lapic; 39.67 39.68 spin_lock(&v->arch.hvm_vcpu.tm_lock); 39.69 39.70 list_for_each_entry ( pt, head, list ) 39.71 { 39.72 - if ( !is_isa_irq_masked(v, pt->irq) && pt->pending_intr_nr && 39.73 + if ( !pt_irq_masked(pt) && pt->pending_intr_nr && 39.74 ((pt->last_plt_gtime + pt->period_cycles) < max_lag) ) 39.75 { 39.76 max_lag = pt->last_plt_gtime + pt->period_cycles; 39.77 - irq = pt->irq; 39.78 + earliest_pt = pt; 39.79 } 39.80 } 39.81 39.82 + if ( earliest_pt == NULL ) 39.83 + { 39.84 + spin_unlock(&v->arch.hvm_vcpu.tm_lock); 39.85 + return; 39.86 + } 39.87 + 39.88 + earliest_pt->irq_issued = 1; 39.89 + irq = earliest_pt->irq; 39.90 + is_lapic = (earliest_pt->source == PTSRC_lapic); 39.91 + 39.92 spin_unlock(&v->arch.hvm_vcpu.tm_lock); 39.93 39.94 - if ( is_lvtt(v, irq) ) 39.95 + if ( is_lapic ) 39.96 { 39.97 vlapic_set_irq(vcpu_vlapic(v), irq, 0); 39.98 } 39.99 - else if ( irq >= 0 ) 39.100 + else 39.101 { 39.102 hvm_isa_irq_deassert(v->domain, irq); 39.103 hvm_isa_irq_assert(v->domain, irq); 39.104 @@ -178,29 +227,12 @@ static struct periodic_time *is_pt_irq( 39.105 { 39.106 struct list_head *head = &v->arch.hvm_vcpu.tm_list; 39.107 struct periodic_time *pt; 39.108 - struct RTCState *rtc = &v->domain->arch.hvm_domain.pl_time.vrtc; 39.109 - int vector; 39.110 39.111 list_for_each_entry ( pt, head, list ) 39.112 { 39.113 - if ( !pt->pending_intr_nr ) 39.114 - continue; 39.115 - 39.116 - if ( is_lvtt(v, pt->irq) ) 39.117 - { 39.118 - if ( pt->irq != intack.vector ) 39.119 - continue; 39.120 + if ( pt->pending_intr_nr && pt->irq_issued && 39.121 + (intack.vector == pt_irq_vector(pt, intack.source)) ) 39.122 return pt; 39.123 - } 39.124 - 39.125 - vector = get_isa_irq_vector(v, pt->irq, intack.source); 39.126 - 39.127 - /* RTC irq need special care */ 39.128 - if ( (intack.vector != vector) || 39.129 - ((pt->irq == 8) && !is_rtc_periodic_irq(rtc)) ) 39.130 - continue; 39.131 - 39.132 - return pt; 39.133 } 39.134 39.135 return NULL; 39.136 @@ -222,11 +254,13 @@ void pt_intr_post(struct vcpu *v, struct 39.137 } 39.138 39.139 pt->do_not_freeze = 0; 39.140 + pt->irq_issued = 0; 39.141 39.142 if ( pt->one_shot ) 39.143 { 39.144 - pt->enabled = 0; 39.145 - list_del(&pt->list); 39.146 + if ( pt->on_list ) 39.147 + list_del(&pt->list); 39.148 + pt->on_list = 0; 39.149 } 39.150 else 39.151 { 39.152 @@ -290,13 +324,15 @@ void create_periodic_time( 39.153 struct vcpu *v, struct periodic_time *pt, uint64_t period, 39.154 uint8_t irq, char one_shot, time_cb *cb, void *data) 39.155 { 39.156 + ASSERT(pt->source != 0); 39.157 + 39.158 destroy_periodic_time(pt); 39.159 39.160 spin_lock(&v->arch.hvm_vcpu.tm_lock); 39.161 39.162 - pt->enabled = 1; 39.163 pt->pending_intr_nr = 0; 39.164 pt->do_not_freeze = 0; 39.165 + pt->irq_issued = 0; 39.166 39.167 /* Periodic timer must be at least 0.9ms. */ 39.168 if ( (period < 900000) && !one_shot ) 39.169 @@ -319,11 +355,12 @@ void create_periodic_time( 39.170 * LAPIC ticks for process accounting can see long sequences of process 39.171 * ticks incorrectly accounted to interrupt processing. 39.172 */ 39.173 - if ( is_lvtt(v, irq) ) 39.174 + if ( pt->source == PTSRC_lapic ) 39.175 pt->scheduled += period >> 1; 39.176 pt->cb = cb; 39.177 pt->priv = data; 39.178 39.179 + pt->on_list = 1; 39.180 list_add(&pt->list, &v->arch.hvm_vcpu.tm_list); 39.181 39.182 init_timer(&pt->timer, pt_timer_fn, pt, v->processor); 39.183 @@ -334,12 +371,14 @@ void create_periodic_time( 39.184 39.185 void destroy_periodic_time(struct periodic_time *pt) 39.186 { 39.187 - if ( !pt->enabled ) 39.188 + /* Was this structure previously initialised by create_periodic_time()? */ 39.189 + if ( pt->vcpu == NULL ) 39.190 return; 39.191 39.192 pt_lock(pt); 39.193 - pt->enabled = 0; 39.194 - list_del(&pt->list); 39.195 + if ( pt->on_list ) 39.196 + list_del(&pt->list); 39.197 + pt->on_list = 0; 39.198 pt_unlock(pt); 39.199 39.200 /*
40.1 --- a/xen/arch/x86/traps.c Wed Dec 12 10:47:54 2007 -0700 40.2 +++ b/xen/arch/x86/traps.c Wed Dec 12 10:50:03 2007 -0700 40.3 @@ -912,6 +912,14 @@ static int __spurious_page_fault( 40.4 l1_pgentry_t l1e, *l1t; 40.5 unsigned int required_flags, disallowed_flags; 40.6 40.7 + /* 40.8 + * We do not take spurious page faults in IRQ handlers as we do not 40.9 + * modify page tables in IRQ context. We therefore bail here because 40.10 + * map_domain_page() is not IRQ-safe. 40.11 + */ 40.12 + if ( in_irq() ) 40.13 + return 0; 40.14 + 40.15 /* Reserved bit violations are never spurious faults. */ 40.16 if ( regs->error_code & PFEC_reserved_bit ) 40.17 return 0;
41.1 --- a/xen/common/gdbstub.c Wed Dec 12 10:47:54 2007 -0700 41.2 +++ b/xen/common/gdbstub.c Wed Dec 12 10:50:03 2007 -0700 41.3 @@ -43,6 +43,7 @@ 41.4 #include <xen/smp.h> 41.5 #include <xen/console.h> 41.6 #include <xen/errno.h> 41.7 +#include <asm/byteorder.h> 41.8 41.9 /* Printk isn't particularly safe just after we've trapped to the 41.10 debugger. so avoid it. */ 41.11 @@ -215,8 +216,7 @@ void 41.12 gdb_write_to_packet_hex(unsigned long x, int int_size, struct gdb_context *ctx) 41.13 { 41.14 char buf[sizeof(unsigned long) * 2 + 1]; 41.15 - int i = sizeof(unsigned long) * 2; 41.16 - int width = int_size * 2; 41.17 + int i, width = int_size * 2; 41.18 41.19 buf[sizeof(unsigned long) * 2] = 0; 41.20 41.21 @@ -233,6 +233,8 @@ gdb_write_to_packet_hex(unsigned long x, 41.22 break; 41.23 } 41.24 41.25 +#ifdef __BIG_ENDIAN 41.26 + i = sizeof(unsigned long) * 2 41.27 do { 41.28 buf[--i] = hex2char(x & 15); 41.29 x >>= 4; 41.30 @@ -242,6 +244,17 @@ gdb_write_to_packet_hex(unsigned long x, 41.31 buf[--i] = '0'; 41.32 41.33 gdb_write_to_packet(&buf[i], width, ctx); 41.34 +#elif defined(__LITTLE_ENDIAN) 41.35 + i = 0; 41.36 + while (i < width) { 41.37 + buf[i++] = hex2char(x>>4); 41.38 + buf[i++] = hex2char(x); 41.39 + x >>= 8; 41.40 + } 41.41 + gdb_write_to_packet(buf, width, ctx); 41.42 +#else 41.43 +# error unknown endian 41.44 +#endif 41.45 } 41.46 41.47 static int 41.48 @@ -512,7 +525,7 @@ int 41.49 41.50 if ( gdb_ctx->serhnd < 0 ) 41.51 { 41.52 - dbg_printk("Debugger not ready yet.\n"); 41.53 + printk("Debugging connection not set up.\n"); 41.54 return -EBUSY; 41.55 } 41.56
42.1 --- a/xen/common/keyhandler.c Wed Dec 12 10:47:54 2007 -0700 42.2 +++ b/xen/common/keyhandler.c Wed Dec 12 10:50:03 2007 -0700 42.3 @@ -275,6 +275,7 @@ extern void perfc_reset(unsigned char ke 42.4 42.5 static void do_debug_key(unsigned char key, struct cpu_user_regs *regs) 42.6 { 42.7 + printk("'%c' pressed -> trapping into debugger\n", key); 42.8 (void)debugger_trap_fatal(0xf001, regs); 42.9 nop(); /* Prevent the compiler doing tail call 42.10 optimisation, as that confuses xendbg a
43.1 --- a/xen/include/asm-x86/hvm/irq.h Wed Dec 12 10:47:54 2007 -0700 43.2 +++ b/xen/include/asm-x86/hvm/irq.h Wed Dec 12 10:50:03 2007 -0700 43.3 @@ -160,7 +160,4 @@ struct hvm_intack hvm_vcpu_has_pending_i 43.4 struct hvm_intack hvm_vcpu_ack_pending_irq(struct vcpu *v, 43.5 struct hvm_intack intack); 43.6 43.7 -int get_isa_irq_vector(struct vcpu *vcpu, int irq, enum hvm_intsrc src); 43.8 -int is_isa_irq_masked(struct vcpu *v, int isa_irq); 43.9 - 43.10 #endif /* __ASM_X86_HVM_IRQ_H__ */
44.1 --- a/xen/include/asm-x86/hvm/vlapic.h Wed Dec 12 10:47:54 2007 -0700 44.2 +++ b/xen/include/asm-x86/hvm/vlapic.h Wed Dec 12 10:50:03 2007 -0700 44.3 @@ -92,7 +92,4 @@ struct vlapic *apic_round_robin( 44.4 44.5 int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda); 44.6 44.7 -int is_lvtt(struct vcpu *v, int vector); 44.8 -int is_lvtt_enabled(struct vcpu *v); 44.9 - 44.10 #endif /* __ASM_X86_HVM_VLAPIC_H__ */
45.1 --- a/xen/include/asm-x86/hvm/vpt.h Wed Dec 12 10:47:54 2007 -0700 45.2 +++ b/xen/include/asm-x86/hvm/vpt.h Wed Dec 12 10:50:03 2007 -0700 45.3 @@ -72,12 +72,16 @@ typedef void time_cb(struct vcpu *v, voi 45.4 45.5 struct periodic_time { 45.6 struct list_head list; 45.7 - char enabled; 45.8 - char one_shot; /* one shot time */ 45.9 - char do_not_freeze; 45.10 + bool_t on_list; 45.11 + bool_t one_shot; 45.12 + bool_t do_not_freeze; 45.13 + bool_t irq_issued; 45.14 +#define PTSRC_isa 1 /* ISA time source */ 45.15 +#define PTSRC_lapic 2 /* LAPIC time source */ 45.16 + u8 source; /* PTSRC_ */ 45.17 u8 irq; 45.18 struct vcpu *vcpu; /* vcpu timer interrupt delivers to */ 45.19 - u32 pending_intr_nr; /* the couner for pending timer interrupts */ 45.20 + u32 pending_intr_nr; /* pending timer interrupts */ 45.21 u64 period; /* frequency in ns */ 45.22 u64 period_cycles; /* frequency in cpu cycles */ 45.23 s_time_t scheduled; /* scheduled timer interrupt */ 45.24 @@ -140,6 +144,19 @@ void pt_update_irq(struct vcpu *v); 45.25 void pt_intr_post(struct vcpu *v, struct hvm_intack intack); 45.26 void pt_reset(struct vcpu *v); 45.27 void pt_migrate(struct vcpu *v); 45.28 + 45.29 +/* Is given periodic timer active? */ 45.30 +#define pt_active(pt) ((pt)->on_list) 45.31 + 45.32 +/* 45.33 + * Create/destroy a periodic (or one-shot!) timer. 45.34 + * The given periodic timer structure must be initialised with zero bytes, 45.35 + * except for the 'source' field which must be initialised with the 45.36 + * correct PTSRC_ value. The initialised timer structure can then be passed 45.37 + * to {create,destroy}_periodic_time() and number of times and in any order. 45.38 + * Note that, for a given periodic timer, invocations of these functions MUST 45.39 + * be serialised. 45.40 + */ 45.41 void create_periodic_time( 45.42 struct vcpu *v, struct periodic_time *pt, uint64_t period, 45.43 uint8_t irq, char one_shot, time_cb *cb, void *data); 45.44 @@ -152,7 +169,6 @@ void pit_deinit(struct domain *d); 45.45 void rtc_init(struct vcpu *v, int base); 45.46 void rtc_migrate_timers(struct vcpu *v); 45.47 void rtc_deinit(struct domain *d); 45.48 -int is_rtc_periodic_irq(void *opaque); 45.49 void pmtimer_init(struct vcpu *v); 45.50 void pmtimer_deinit(struct domain *d); 45.51
46.1 --- a/xen/include/asm-x86/iommu.h Wed Dec 12 10:47:54 2007 -0700 46.2 +++ b/xen/include/asm-x86/iommu.h Wed Dec 12 10:50:03 2007 -0700 46.3 @@ -79,5 +79,6 @@ int pt_irq_create_bind_vtd(struct domain 46.4 xen_domctl_bind_pt_irq_t *pt_irq_bind); 46.5 46.6 #define PT_IRQ_TIME_OUT MILLISECS(8) 46.7 +#define VTDPREFIX "[VT-D]" 46.8 46.9 #endif /* _IOMMU_H_ */
47.1 --- a/xen/include/asm-x86/mtrr.h Wed Dec 12 10:47:54 2007 -0700 47.2 +++ b/xen/include/asm-x86/mtrr.h Wed Dec 12 10:50:03 2007 -0700 47.3 @@ -47,6 +47,7 @@ struct mtrr_var_range { 47.4 }; 47.5 47.6 #define NUM_FIXED_RANGES 88 47.7 +#define NUM_FIXED_MSR 11 47.8 struct mtrr_state { 47.9 struct mtrr_var_range *var_ranges; 47.10 mtrr_type fixed_ranges[NUM_FIXED_RANGES];
48.1 --- a/xen/include/public/arch-x86/hvm/save.h Wed Dec 12 10:47:54 2007 -0700 48.2 +++ b/xen/include/public/arch-x86/hvm/save.h Wed Dec 12 10:50:03 2007 -0700 48.3 @@ -405,9 +405,26 @@ struct hvm_hw_pmtimer { 48.4 48.5 DECLARE_HVM_SAVE_TYPE(PMTIMER, 13, struct hvm_hw_pmtimer); 48.6 48.7 +/* 48.8 + * MTRR MSRs 48.9 + */ 48.10 + 48.11 +struct hvm_hw_mtrr { 48.12 +#define MTRR_VCNT 8 48.13 +#define NUM_FIXED_MSR 11 48.14 + uint64_t msr_pat_cr; 48.15 + /* mtrr physbase & physmask msr pair*/ 48.16 + uint64_t msr_mtrr_var[MTRR_VCNT*2]; 48.17 + uint64_t msr_mtrr_fixed[NUM_FIXED_MSR]; 48.18 + uint64_t msr_mtrr_cap; 48.19 + uint64_t msr_mtrr_def_type; 48.20 +}; 48.21 + 48.22 +DECLARE_HVM_SAVE_TYPE(MTRR, 14, struct hvm_hw_mtrr); 48.23 + 48.24 /* 48.25 * Largest type-code in use 48.26 */ 48.27 -#define HVM_SAVE_CODE_MAX 13 48.28 +#define HVM_SAVE_CODE_MAX 14 48.29 48.30 #endif /* __XEN_PUBLIC_HVM_SAVE_X86_H__ */
49.1 --- a/xen/include/public/domctl.h Wed Dec 12 10:47:54 2007 -0700 49.2 +++ b/xen/include/public/domctl.h Wed Dec 12 10:50:03 2007 -0700 49.3 @@ -435,9 +435,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_sendt 49.4 49.5 49.6 /* Assign PCI device to HVM guest. Sets up IOMMU structures. */ 49.7 -#define XEN_DOMCTL_assign_device 37 49.8 -#define DPCI_ADD_MAPPING 1 49.9 -#define DPCI_REMOVE_MAPPING 0 49.10 +#define XEN_DOMCTL_assign_device 37 49.11 +#define XEN_DOMCTL_test_assign_device 45 49.12 struct xen_domctl_assign_device { 49.13 uint32_t machine_bdf; /* machine PCI ID of assigned device */ 49.14 }; 49.15 @@ -473,6 +472,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_bind_ 49.16 49.17 /* Bind machine I/O address range -> HVM address range. */ 49.18 #define XEN_DOMCTL_memory_mapping 39 49.19 +#define DPCI_ADD_MAPPING 1 49.20 +#define DPCI_REMOVE_MAPPING 0 49.21 struct xen_domctl_memory_mapping { 49.22 uint64_aligned_t first_gfn; /* first page (hvm guest phys page) in range */ 49.23 uint64_aligned_t first_mfn; /* first page (machine page) in range */ 49.24 @@ -544,8 +545,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_ext_v 49.25 */ 49.26 #define XEN_DOMCTL_set_opt_feature 44 49.27 struct xen_domctl_set_opt_feature { 49.28 -#ifdef __ia64__ 49.29 +#if defined(__ia64__) 49.30 struct xen_ia64_opt_feature optf; 49.31 +#else 49.32 + /* Make struct non-empty: do not depend on this field name! */ 49.33 + uint64_t dummy; 49.34 #endif 49.35 }; 49.36 typedef struct xen_domctl_set_opt_feature xen_domctl_set_opt_feature_t;
50.1 --- a/xen/include/xen/gdbstub.h Wed Dec 12 10:47:54 2007 -0700 50.2 +++ b/xen/include/xen/gdbstub.h Wed Dec 12 10:50:03 2007 -0700 50.3 @@ -53,6 +53,7 @@ void gdb_write_to_packet( 50.4 const char *buf, int count, struct gdb_context *ctx); 50.5 void gdb_write_to_packet_hex( 50.6 unsigned long x, int int_size, struct gdb_context *ctx); 50.7 + /* ... writes in target native byte order as required by gdb spec. */ 50.8 void gdb_send_packet(struct gdb_context *ctx); 50.9 void gdb_send_reply(const char *buf, struct gdb_context *ctx); 50.10