WARNING - OLD ARCHIVES

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

xen-changelog

[Xen-changelog] [xen-unstable] x86: Adapt 32b guest os to 64b hypervisor

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Oct 2008 07:50:50 -0700
Delivery-date: Wed, 22 Oct 2008 07:53:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1224578853 -3600
# Node ID a9f299b11b7fd381cc2391687a8367d74eea5bd0
# Parent  1eba0c88655f21ab723b36224b28f04ad58da3ad
x86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility

Changeset 18552 (19b0a4f91712) move px transfer logic from
platform_hypercall.c to a common file to support both x86 and
ia64. However, it involves 32b guest os to 64b hypervisor (x86)
compatible issue. This patch fix the compatible issue, and make
set_px_pminfo() re-used by ia64 and x86 (32b guest os to 64b
hypervisor, and 64b guest os to 64b hypervisor).

Signed-off-by: Liu Jinsong <jinsong.liu@xxxxxxxxx>
---
 xen/arch/x86/platform_hypercall.c         |   22 ++-----
 xen/arch/x86/x86_64/Makefile              |    2 
 xen/arch/x86/x86_64/cpu_idle.c            |    2 
 xen/arch/x86/x86_64/cpufreq.c             |   91 ++++++++++++++++++++++++++++++
 xen/arch/x86/x86_64/platform_hypercall.c  |    4 -
 xen/drivers/cpufreq/cpufreq.c             |   17 +----
 xen/include/acpi/cpufreq/processor_perf.h |    3 
 xen/include/xlat.lst                      |    4 +
 8 files changed, 111 insertions(+), 34 deletions(-)

diff -r 1eba0c88655f -r a9f299b11b7f xen/arch/x86/platform_hypercall.c
--- a/xen/arch/x86/platform_hypercall.c Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/arch/x86/platform_hypercall.c Tue Oct 21 09:47:33 2008 +0100
@@ -53,15 +53,6 @@ static long cpu_frequency_change_helper(
     return cpu_frequency_change(this_cpu(freq));
 }
 
-int xenpf_copy_px_states(struct processor_performance *pxpt,
-        struct xen_processor_performance *dom0_px_info)
-{
-    if (!pxpt || !dom0_px_info)
-        return -EINVAL;
-    return  copy_from_compat(pxpt->states, dom0_px_info->states, 
-                    dom0_px_info->state_count);
-}
-
 ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
 {
     ret_t ret = 0;
@@ -372,12 +363,13 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
         switch ( op->u.set_pminfo.type )
         {
         case XEN_PM_PX:
-        {
-
-            ret = set_px_pminfo(op->u.set_pminfo.id,
-                                &op->u.set_pminfo.perf);
-            break;
-        }
+            if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
+            {
+                ret = -ENOSYS;
+                break;
+            }
+            ret = set_px_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.perf);
+            break;
  
         case XEN_PM_CX:
             if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_CX) )
diff -r 1eba0c88655f -r a9f299b11b7f xen/arch/x86/x86_64/Makefile
--- a/xen/arch/x86/x86_64/Makefile      Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/arch/x86/x86_64/Makefile      Tue Oct 21 09:47:33 2008 +0100
@@ -13,6 +13,7 @@ obj-$(CONFIG_COMPAT) += physdev.o
 obj-$(CONFIG_COMPAT) += physdev.o
 obj-$(CONFIG_COMPAT) += platform_hypercall.o
 obj-$(CONFIG_COMPAT) += cpu_idle.o
+obj-$(CONFIG_COMPAT) += cpufreq.o
 
 ifeq ($(CONFIG_COMPAT),y)
 # extra dependencies
@@ -24,4 +25,5 @@ sysctl.o:     ../sysctl.c
 sysctl.o:      ../sysctl.c
 traps.o:       compat/traps.c
 cpu_idle.o:    ../acpi/cpu_idle.c
+cpufreq.o:     ../../../drivers/cpufreq/cpufreq.c
 endif
diff -r 1eba0c88655f -r a9f299b11b7f xen/arch/x86/x86_64/cpu_idle.c
--- a/xen/arch/x86/x86_64/cpu_idle.c    Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/arch/x86/x86_64/cpu_idle.c    Tue Oct 21 09:47:33 2008 +0100
@@ -44,7 +44,7 @@ DEFINE_XEN_GUEST_HANDLE(compat_processor
     xlat_page_current = xlat_page_start; \
 } while (0)
 
-static void *xlat_malloc(unsigned long *xlat_page_current, size_t size)
+void *xlat_malloc(unsigned long *xlat_page_current, size_t size)
 {
     void *ret;
 
diff -r 1eba0c88655f -r a9f299b11b7f xen/arch/x86/x86_64/cpufreq.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/x86/x86_64/cpufreq.c     Tue Oct 21 09:47:33 2008 +0100
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * cpufreq.c -- adapt 32b compat guest to 64b hypervisor.
+ *
+ *  Copyright (C) 2008, Liu Jinsong <jinsong.liu@xxxxxxxxx>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at
+ *  your option) any later version.
+ *
+ *  This program 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
+ *  General Public License for more details.
+ *
+ *  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/config.h>
+#include <xen/types.h>
+#include <xen/xmalloc.h>
+#include <xen/guest_access.h>
+#include <compat/platform.h>
+
+DEFINE_XEN_GUEST_HANDLE(compat_processor_px_t);
+
+#define xlat_page_start ((unsigned long)COMPAT_ARG_XLAT_VIRT_BASE)
+
+#define xlat_malloc_init(xlat_page_current)    do { \
+    xlat_page_current = xlat_page_start; \
+} while (0)
+
+extern void *xlat_malloc(unsigned long *xlat_page_current, size_t size);
+
+#define xlat_malloc_array(_p, _t, _c) ((_t *) xlat_malloc(&_p, sizeof(_t) * 
_c))
+
+extern int 
+set_px_pminfo(uint32_t cpu, struct xen_processor_performance *perf);
+
+int 
+compat_set_px_pminfo(uint32_t cpu, struct compat_processor_performance *perf)
+{
+    struct xen_processor_performance *xen_perf;
+    unsigned long xlat_page_current;
+
+    xlat_malloc_init(xlat_page_current);
+
+    xen_perf = xlat_malloc_array(xlat_page_current,
+                                  struct xen_processor_performance, 1);
+    if ( unlikely(xen_perf == NULL) )
+       return -EFAULT;
+
+#define XLAT_processor_performance_HNDL_states(_d_, _s_) do { \
+    xen_processor_px_t *xen_states = NULL; \
+\
+    if ( likely((_s_)->state_count > 0) ) \
+    { \
+        XEN_GUEST_HANDLE(compat_processor_px_t) states; \
+        compat_processor_px_t state; \
+        int i; \
+\
+        xen_states = xlat_malloc_array(xlat_page_current, \
+                               xen_processor_px_t, (_s_)->state_count); \
+        if ( unlikely(xen_states == NULL) ) \
+            return -EFAULT; \
+\
+        if ( unlikely(!compat_handle_okay((_s_)->states, \
+                                (_s_)->state_count)) ) \
+            return -EFAULT; \
+        guest_from_compat_handle(states, (_s_)->states); \
+\
+        for ( i = 0; i < _s_->state_count; i++ ) \
+        { \
+           if ( unlikely(copy_from_guest_offset(&state, states, i, 1)) ) \
+               return -EFAULT; \
+           XLAT_processor_px(&xen_states[i], &state); \
+        } \
+    } \
+\
+    set_xen_guest_handle((_d_)->states, xen_states); \
+} while (0)
+    XLAT_processor_performance(xen_perf, perf);
+#undef XLAT_processor_performance_HNDL_states
+
+    return set_px_pminfo(cpu, xen_perf);
+}
diff -r 1eba0c88655f -r a9f299b11b7f xen/arch/x86/x86_64/platform_hypercall.c
--- a/xen/arch/x86/x86_64/platform_hypercall.c  Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/arch/x86/x86_64/platform_hypercall.c  Tue Oct 21 09:47:33 2008 +0100
@@ -11,13 +11,13 @@ DEFINE_XEN_GUEST_HANDLE(compat_platform_
 #define xen_platform_op_t   compat_platform_op_t
 #define do_platform_op(x)   compat_platform_op(_##x)
 
-#define xenpf_copy_px_states compat_xenpf_copy_px_states
-
 #define xen_processor_px    compat_processor_px
 #define xen_processor_px_t  compat_processor_px_t
 #define xen_processor_performance    compat_processor_performance
 #define xen_processor_performance_t  compat_processor_performance_t
 #define xenpf_set_processor_pminfo   compat_pf_set_processor_pminfo
+
+#define set_px_pminfo          compat_set_px_pminfo
 
 #define xen_processor_power     compat_processor_power
 #define xen_processor_power_t   compat_processor_power_t
diff -r 1eba0c88655f -r a9f299b11b7f xen/drivers/cpufreq/cpufreq.c
--- a/xen/drivers/cpufreq/cpufreq.c     Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/drivers/cpufreq/cpufreq.c     Tue Oct 21 09:47:33 2008 +0100
@@ -34,6 +34,7 @@
 #include <xen/sched.h>
 #include <xen/timer.h>
 #include <xen/xmalloc.h>
+#include <xen/guest_access.h>
 #include <xen/domain.h>
 #include <asm/bug.h>
 #include <asm/io.h>
@@ -217,14 +218,8 @@ int set_px_pminfo(uint32_t acpi_id, stru
     struct processor_pminfo *pmpt;
     struct processor_performance *pxpt;
 
-    if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
-    {
-        ret = -ENOSYS;
-        goto out;
-    }
-
     cpuid = get_cpu_id(acpi_id);
-    if ( cpuid < 0 )
+    if ( cpuid < 0 || !dom0_px_info)
     {
         ret = -EINVAL;
         goto out;
@@ -265,12 +260,8 @@ int set_px_pminfo(uint32_t acpi_id, stru
             ret = -ENOMEM;
             goto out;
         }
-        if ( xenpf_copy_px_states(pxpt, dom0_px_info) )
-        {
-            xfree(pxpt->states);
-            ret = -EFAULT;
-            goto out;
-        }
+        copy_from_guest(pxpt->states, dom0_px_info->states, 
+                                      dom0_px_info->state_count);
         pxpt->state_count = dom0_px_info->state_count;
         print_PSS(pxpt->states,pxpt->state_count);
     }
diff -r 1eba0c88655f -r a9f299b11b7f xen/include/acpi/cpufreq/processor_perf.h
--- a/xen/include/acpi/cpufreq/processor_perf.h Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/include/acpi/cpufreq/processor_perf.h Tue Oct 21 09:47:33 2008 +0100
@@ -60,8 +60,5 @@ struct pm_px {
 
 extern struct pm_px *cpufreq_statistic_data[NR_CPUS];
 
-int xenpf_copy_px_states(struct processor_performance *pxpt,
-        struct xen_processor_performance *dom0_px_info);
-
 int cpufreq_cpu_init(unsigned int cpuid);
 #endif /* __XEN_PROCESSOR_PM_H__ */
diff -r 1eba0c88655f -r a9f299b11b7f xen/include/xlat.lst
--- a/xen/include/xlat.lst      Mon Oct 20 17:45:36 2008 +0100
+++ b/xen/include/xlat.lst      Tue Oct 21 09:47:33 2008 +0100
@@ -55,3 +55,7 @@
 !      processor_cx                    platform.h
 !      processor_flags                 platform.h
 !      processor_power                 platform.h
+!      pct_register                    platform.h
+!      processor_px                    platform.h
+!      psd_package                     platform.h
+!      processor_performance           platform.h

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility, Xen patchbot-unstable <=