aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/xmexample.vti13
-rw-r--r--tools/libxc/ia64/xc_ia64_hvm_build.c72
-rw-r--r--tools/libxc/xenctrl.h3
-rw-r--r--tools/python/xen/lowlevel/xc/xc.c20
-rw-r--r--tools/python/xen/xend/image.py2
5 files changed, 110 insertions, 0 deletions
diff --git a/tools/examples/xmexample.vti b/tools/examples/xmexample.vti
index f38d363918..92e29c76c9 100644
--- a/tools/examples/xmexample.vti
+++ b/tools/examples/xmexample.vti
@@ -147,3 +147,16 @@ serial='pty'
#-----------------------------------------------------------------------------
# Set keyboard layout, default is en-us keyboard.
#keymap='ja'
+
+#-----------------------------------------------------------------------------
+# Enable optimization features for the specified OS type. (Specific to the
+# OS running in the guest domain. Other OSes may not run correctly
+# if the wrong OS type is specified.)
+#
+# Default is "default", which should work for all supported guest OSes.
+#
+# Known values:
+# 'linux' - All Linux variants
+# 'windows' - All Windows variants (Windows Server 2003/2008)
+#
+#guest_os_type='default'
diff --git a/tools/libxc/ia64/xc_ia64_hvm_build.c b/tools/libxc/ia64/xc_ia64_hvm_build.c
index 5fc0d58fa9..3a9c0e16ba 100644
--- a/tools/libxc/ia64/xc_ia64_hvm_build.c
+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c
@@ -1094,6 +1094,78 @@ error_out:
}
/*
+ * From asm/pgtable.h
+ */
+#define _PAGE_P_BIT 0
+#define _PAGE_A_BIT 5
+#define _PAGE_D_BIT 6
+
+#define _PAGE_P (1 << _PAGE_P_BIT) /* page present bit */
+#define _PAGE_A (1 << _PAGE_A_BIT) /* page accessed bit */
+#define _PAGE_D (1 << _PAGE_D_BIT) /* page dirty bit */
+
+#define _PAGE_MA_WB (0x0 << 2) /* write back memory attribute */
+#define _PAGE_MA_UC (0x4 << 2) /* uncacheable memory attribute */
+#define _PAGE_AR_RW (2 << 9) /* read & write */
+
+int
+xc_ia64_set_os_type(int xc_handle, char *guest_os_type, uint32_t dom)
+{
+ DECLARE_DOMCTL;
+
+ domctl.cmd = XEN_DOMCTL_set_opt_feature;
+ domctl.domain = (domid_t)dom;
+
+ if (!guest_os_type || !strlen(guest_os_type) ||
+ !strcmp("default", guest_os_type)) {
+
+ /* Nothing */
+ return 0;
+
+ } else if (!strcmp("windows", guest_os_type)) {
+ DPRINTF("Enabling Windows guest OS optimizations\n");
+
+ /* Windows identity maps regions 4 & 5 */
+ domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG4;
+ domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON;
+ domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D |
+ _PAGE_MA_WB | _PAGE_AR_RW);
+ domctl.u.set_opt_feature.optf.key = 0;
+ if (xc_domctl(xc_handle, &domctl))
+ PERROR("Failed to set region 4 identity mapping for Windows "
+ "guest OS type.\n");
+
+ domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG5;
+ domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON;
+ domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D |
+ _PAGE_MA_UC | _PAGE_AR_RW);
+ domctl.u.set_opt_feature.optf.key = 0;
+ if (xc_domctl(xc_handle, &domctl))
+ PERROR("Failed to set region 5 identity mapping for Windows "
+ "guest OS type.\n");
+ return 0;
+
+ } else if (!strcmp("linux", guest_os_type)) {
+ DPRINTF("Enabling Linux guest OS optimizations\n");
+
+ /* Linux identity maps regions 7 */
+ domctl.u.set_opt_feature.optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;
+ domctl.u.set_opt_feature.optf.on = XEN_IA64_OPTF_ON;
+ domctl.u.set_opt_feature.optf.pgprot = (_PAGE_P | _PAGE_A | _PAGE_D |
+ _PAGE_MA_WB | _PAGE_AR_RW);
+ domctl.u.set_opt_feature.optf.key = 0;
+ if (xc_domctl(xc_handle, &domctl))
+ PERROR("Failed to set region 7 identity mapping for Linux "
+ "guest OS type.\n");
+ return 0;
+ }
+
+ DPRINTF("Unknown guest_os_type (%s), using defaults\n", guest_os_type);
+
+ return 0;
+}
+
+/*
* Local variables:
* mode: C
* c-set-style: "BSD"
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 0e82a5fbd3..61f7fc558f 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -906,6 +906,9 @@ int xc_ia64_save_to_nvram(int xc_handle, uint32_t dom);
/* IA64 specific, nvram init */
int xc_ia64_nvram_init(int xc_handle, char *dom_name, uint32_t dom);
+/* IA64 specific, set guest OS type optimizations */
+int xc_ia64_set_os_type(int xc_handle, char *guest_os_type, uint32_t dom);
+
/* HVM guest pass-through */
int xc_assign_device(int xc_handle,
uint32_t domid,
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 2a09947be3..f899edceeb 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -604,6 +604,21 @@ static PyObject *pyxc_nvram_init(XcObject *self,
Py_INCREF(zero);
return zero;
}
+
+static PyObject *pyxc_set_os_type(XcObject *self,
+ PyObject *args)
+{
+ char *os_type;
+ uint32_t dom;
+
+ if ( !PyArg_ParseTuple(args, "si", &os_type, &dom) )
+ return NULL;
+
+ xc_ia64_set_os_type(self->xc_handle, os_type, dom);
+
+ Py_INCREF(zero);
+ return zero;
+}
#endif /* __ia64__ */
static PyObject *pyxc_hvm_build(XcObject *self,
@@ -1558,6 +1573,11 @@ static PyMethodDef pyxc_methods[] = {
METH_VARARGS, "\n"
"Init nvram in IA64 platform\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "set_os_type",
+ (PyCFunction)pyxc_set_os_type,
+ METH_VARARGS, "\n"
+ "Set guest OS type on IA64 platform\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
#endif /* __ia64__ */
{ "domain_ioport_permission",
(PyCFunction)pyxc_domain_ioport_permission,
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index a660e9faec..85e7e4fa08 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -541,6 +541,8 @@ class IA64_HVM_ImageHandler(HVMImageHandler):
def buildDomain(self):
xc.nvram_init(self.vm.getName(), self.vm.getDomid())
xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_VHPT_SIZE, self.vhpt)
+ if self.guest_os_type is not None:
+ xc.set_os_type(self.guest_os_type.lower(), self.vm.getDomid())
return HVMImageHandler.buildDomain(self)
def getRequiredAvailableMemory(self, mem_kb):