WARNING - OLD ARCHIVES

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

xen-ia64-devel

RE: [Xen-ia64-devel] [PATCH 5/5] Implement guest_os_type for ia64

To: "Alex Williamson" <alex.williamson@xxxxxx>, "xen-ia64-devel" <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Subject: RE: [Xen-ia64-devel] [PATCH 5/5] Implement guest_os_type for ia64
From: "Zhang, Xing Z" <xing.z.zhang@xxxxxxxxx>
Date: Thu, 29 Nov 2007 12:09:00 +0800
Delivery-date: Wed, 28 Nov 2007 20:11:18 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <1196292048.7687.49.camel@lappy>
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1196223655.19478.48.camel@lappy> <1196292048.7687.49.camel@lappy>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcgyFpT/++4JeQFGRBu767P70mXa6gAJndtw
Thread-topic: [Xen-ia64-devel] [PATCH 5/5] Implement guest_os_type for ia64
This is really great!!!
In the beginning I want this way, but give up because I think add a new 
function in XC lib will not be accepted. Thanks Keir.

Good good study,day day up ! ^_^
-Wing(zhang xin)

OTC,Intel Corporation

>-----Original Message-----
>From: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
>[mailto:xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx] On
>Behalf Of Alex Williamson
>Sent: 2007?11?29? 7:21
>To: xen-ia64-devel
>Subject: Re: [Xen-ia64-devel] [PATCH 5/5] Implement
>guest_os_type for ia64
>
>
>  Here's a new version of this patch that doesn't make use of
>hvm
>parameters.  As outlined in the discussion with Keir, we make
>a new ia64
>specific pyxc binding to set the guest OS type.  This can then
>make
>direct use of the XEN_DOMCTL_set_opt_feature calls without
>mangling the
>OS type string or unnecessarily storing the OS type in a Xen
>visible
>API.  This should also more elegantly address Wing's concern
>over only
>having an 8 character string.  The only string manipulation done
>versus
>what the user specifies in the domain config file is converting
>it to
>lower case to avoid simple comparison errors.  Let me know if
>you have
>comments/concerns.  Thanks,
>
>       Alex
>
>Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
>---
>
>diff -r 98defc4f3bf9 tools/examples/xmexample.vti
>--- a/tools/examples/xmexample.vti     Mon Nov 26 10:07:30 2007
>-0700
>+++ b/tools/examples/xmexample.vti     Tue Nov 27 12:25:09 2007
>-0700
>@@ -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 -r 98defc4f3bf9 tools/libxc/ia64/xc_ia64_hvm_build.c
>--- a/tools/libxc/ia64/xc_ia64_hvm_build.c     Mon Nov 26
>10:07:30 2007 -0700
>+++ b/tools/libxc/ia64/xc_ia64_hvm_build.c     Wed Nov 28
>16:08:10 2007 -0700
>@@ -1094,6 +1094,76 @@ 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 (!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 -r 98defc4f3bf9 tools/libxc/xenctrl.h
>--- a/tools/libxc/xenctrl.h    Mon Nov 26 10:07:30 2007 -0700
>+++ b/tools/libxc/xenctrl.h    Wed Nov 28 11:02:33 2007 -0700
>@@ -906,6 +906,9 @@ int xc_ia64_save_to_nvram(int xc_handle,
> /* 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 -r 98defc4f3bf9 tools/python/xen/lowlevel/xc/xc.c
>--- a/tools/python/xen/lowlevel/xc/xc.c        Mon Nov 26
>10:07:30 2007 -0700
>+++ b/tools/python/xen/lowlevel/xc/xc.c        Wed Nov 28
>11:08:20 2007 -0700
>@@ -604,6 +604,21 @@ static PyObject *pyxc_nvram_init(XcObjec
>     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,
>@@ -1557,6 +1572,11 @@ static PyMethodDef pyxc_methods[] = {
>       (PyCFunction)pyxc_nvram_init,
>       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",
>diff -r 98defc4f3bf9 tools/python/xen/xend/image.py
>--- a/tools/python/xen/xend/image.py   Mon Nov 26 10:07:30
>2007 -0700
>+++ b/tools/python/xen/xend/image.py   Wed Nov 28 15:58:15
>2007 -0700
>@@ -540,6 +541,8 @@ class IA64_HVM_ImageHandler(HVMImageHand
>     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):
>diff -r 98defc4f3bf9 xen/arch/ia64/vmx/mmio.c
>--- a/xen/arch/ia64/vmx/mmio.c Mon Nov 26 10:07:30 2007 -0700
>+++ b/xen/arch/ia64/vmx/mmio.c Tue Nov 27 09:21:20 2007 -0700
>@@ -234,35 +234,6 @@ static int vmx_ide_pio_intercept(ioreq_t
>
> #define TO_LEGACY_IO(pa)  (((pa)>>12<<2)|((pa)&0x3))
>
>-static const char * const guest_os_name[] = {
>-    "Unknown",
>-    "Windows 2003 server",
>-    "Linux",
>-};
>-
>-static inline void set_os_type(VCPU *v, u64 type)
>-{
>-    if (type > OS_BASE && type < OS_END) {
>-        v->domain->arch.vmx_platform.gos_type = type;
>-        gdprintk(XENLOG_INFO, "Guest OS : %s\n",
>guest_os_name[type - OS_BASE]);
>-
>-        if (GOS_WINDOWS(v)) {
>-            struct xen_ia64_opt_feature optf;
>-
>-            /* Windows identity maps regions 4 & 5 */
>-            optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG4;
>-            optf.on = XEN_IA64_OPTF_ON;
>-            optf.pgprot =
>(_PAGE_P|_PAGE_A|_PAGE_D|_PAGE_MA_WB|_PAGE_AR_RW);
>-            optf.key = 0;
>-            domain_opt_feature(v->domain, &optf);
>-
>-            optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG5;
>-            optf.pgprot =
>(_PAGE_P|_PAGE_A|_PAGE_D|_PAGE_MA_UC|_PAGE_AR_RW);
>-            domain_opt_feature(v->domain, &optf);
>-        }
>-    }
>-}
>-
> static void __vmx_identity_mapping_save(int on,
>         const struct identity_mapping* im,
>         struct hvm_hw_ia64_identity_mapping *im_save)
>@@ -359,11 +330,6 @@ static void legacy_io_access(VCPU *vcpu,
>
>     p->io_count++;
>
>-    if (dir == IOREQ_WRITE && p->addr == OS_TYPE_PORT) {
>-        set_os_type(v, *val);
>-        return;
>-    }
>-
>     if (vmx_ide_pio_intercept(p, val))
>         return;
>
>diff -r 98defc4f3bf9 xen/arch/ia64/vmx/vmx_init.c
>--- a/xen/arch/ia64/vmx/vmx_init.c     Mon Nov 26 10:07:30 2007
>-0700
>+++ b/xen/arch/ia64/vmx/vmx_init.c     Tue Nov 27 11:24:02 2007
>-0700
>@@ -396,7 +396,6 @@ vmx_final_setup_guest(struct vcpu *v)
>       v->arch.privregs = (mapped_regs_t *)vpd;
>       vpd->vpd_low.virt_env_vaddr = vm_buffer;
>
>-      v->domain->arch.vmx_platform.gos_type = OS_UNKNOWN;
>       /* Per-domain vTLB and vhpt implementation. Now vmx domain
>will stick
>        * to this solution. Maybe it can be deferred until we know
>created
>        * one as vmx domain */
>diff -r 98defc4f3bf9 xen/include/asm-ia64/domain.h
>--- a/xen/include/asm-ia64/domain.h    Mon Nov 26 10:07:30
>2007 -0700
>+++ b/xen/include/asm-ia64/domain.h    Tue Nov 27 20:02:22
>2007 -0700
>@@ -75,11 +75,11 @@ struct xen_sal_data {
> };
>
> /*
>- * Optimization features
>- * are used by the hypervisor to do some optimizations for
>guests.
>- * By default the optimizations are switched off and the guest
>has to activate
>- * the feature. On PV the guest must do this via the hypercall
>- * __HYPERVISOR_opt_feature, on HVM it's done within xen in
>set_os_type().
>+ * Optimization features are used by the hypervisor to do some
>optimizations
>+ * for guests.  By default the optimizations are switched off
>and the guest
>+ * may activate the feature. The guest may do this via the
>hypercall
>+ * __HYPERVISOR_opt_feature.  Domain builder code can also
>enable these
>+ * via XEN_DOMCTL_set_opt_feature.
>  */
>
> /*
>@@ -100,20 +100,6 @@ struct opt_feature {
>     struct identity_mapping im_reg5;  /* Region 5 identity
>mapping */
>     struct identity_mapping im_reg7;  /* Region 7 identity
>mapping */
> };
>-
>-/*
>- * The base XEN_IA64_OPTF_IDENT_MAP_REG7 is defined in
>public/arch-ia64.h.
>- * Identity mapping of region 4 addresses in HVM.
>- */
>-#define XEN_IA64_OPTF_IDENT_MAP_REG4_BIT        \
>-    (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 1)
>-#define XEN_IA64_OPTF_IDENT_MAP_REG4            \
>-    (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_BIT)
>-/* Identity mapping of region 5 addresses in HVM. */
>-#define XEN_IA64_OPTF_IDENT_MAP_REG5_BIT        \
>-    (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 2)
>-#define XEN_IA64_OPTF_IDENT_MAP_REG5            \
>-    (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_BIT)
>
> /* Set an optimization feature in the struct arch_domain. */
> extern int domain_opt_feature(struct domain *, struct
>xen_ia64_opt_feature*);
>diff -r 98defc4f3bf9 xen/include/asm-ia64/vmx_platform.h
>--- a/xen/include/asm-ia64/vmx_platform.h      Mon Nov 26
>10:07:30 2007 -0700
>+++ b/xen/include/asm-ia64/vmx_platform.h      Tue Nov 27
>09:21:20 2007 -0700
>@@ -24,25 +24,6 @@
> #include <asm/viosapic.h>
> #include <asm/hvm/vacpi.h>
>
>-
>-/* Value of guest os type */
>-#define OS_BASE     0xB0
>-#define OS_UNKNOWN  0xB0
>-#define OS_WINDOWS  0xB1
>-#define OS_LINUX    0xB2
>-#define OS_END      0xB3
>-
>-#define GOS_WINDOWS(_v) \
>-    ((_v)->domain->arch.vmx_platform.gos_type ==
>OS_WINDOWS)
>-
>-#define GOS_LINUX(_v) \
>-    ((_v)->domain->arch.vmx_platform.gos_type == OS_LINUX)
>-
>-/* port guest Firmware use to indicate os type
>- * this port is used to trigger SMI on x86,
>- * it is not used on ia64 */
>-#define OS_TYPE_PORT    0xB2
>-
> struct vmx_ioreq_page {
>     spinlock_t          lock;
>     struct page_info   *page;
>@@ -52,7 +33,6 @@ int vmx_set_ioreq_page(struct domain *d,
>                        struct vmx_ioreq_page *iorp, unsigned
>long gmfn);
>
> typedef struct virtual_platform_def {
>-    unsigned long               gos_type;
>     struct vmx_ioreq_page       ioreq;
>     struct vmx_ioreq_page       buf_ioreq;
>     struct vmx_ioreq_page       buf_pioreq;
>diff -r 98defc4f3bf9 xen/include/public/arch-ia64.h
>--- a/xen/include/public/arch-ia64.h   Mon Nov 26 10:07:30
>2007 -0700
>+++ b/xen/include/public/arch-ia64.h   Tue Nov 27 10:57:20
>2007 -0700
>@@ -605,6 +605,20 @@ struct xen_ia64_boot_param {
> #define XEN_IA64_OPTF_IDENT_MAP_REG7          \
>       (1UL << XEN_IA64_OPTF_IDENT_MAP_REG7_BIT)
>
>+/* Identity mapping of region 4 addresses in HVM. */
>+#define XEN_IA64_OPTF_IDENT_MAP_REG4_BIT        \
>+        (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 1)
>+#define XEN_IA64_OPTF_IDENT_MAP_REG4            \
>+        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG4_BIT)
>+
>+/* Identity mapping of region 5 addresses in HVM. */
>+#define XEN_IA64_OPTF_IDENT_MAP_REG5_BIT        \
>+        (XEN_IA64_OPTF_IDENT_MAP_REG7_BIT + 2)
>+#define XEN_IA64_OPTF_IDENT_MAP_REG5            \
>+        (1UL << XEN_IA64_OPTF_IDENT_MAP_REG5_BIT)
>+
>+#define XEN_IA64_OPTF_IDENT_MAP_NOT_SET  (0)
>+
> struct xen_ia64_opt_feature {
>       unsigned long cmd;              /* Which feature */
>       unsigned char on;               /* Switch feature on/off */
>
>
>
>_______________________________________________
>Xen-ia64-devel mailing list
>Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
>http://lists.xensource.com/xen-ia64-devel

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

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