All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1] X86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility
@ 2008-10-21  2:49 Liu, Jinsong
  2008-10-21  9:23 ` [PATCH 1] X86: Adapt 32b guest os to 64b hypervisorplatform_hypercall compatibility Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Liu, Jinsong @ 2008-10-21  2:49 UTC (permalink / raw)
  To: xen-devel, xen-ia64-devel; +Cc: Isaku Yamahata, Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

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@intel.com>

[-- Attachment #2: px-xen-1-setpxinfo-update.patch --]
[-- Type: application/octet-stream, Size: 9562 bytes --]

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@intel.com>

diff -r 4a50bfca7c4f xen/arch/x86/platform_hypercall.c
--- a/xen/arch/x86/platform_hypercall.c	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/arch/x86/platform_hypercall.c	Tue Oct 14 18:41:53 2008 +0800
@@ -51,15 +51,6 @@ static long cpu_frequency_change_helper(
 static long cpu_frequency_change_helper(void *data)
 {
     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)
@@ -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);
+            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 4a50bfca7c4f xen/arch/x86/x86_64/Makefile
--- a/xen/arch/x86/x86_64/Makefile	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/arch/x86/x86_64/Makefile	Tue Oct 14 18:41:53 2008 +0800
@@ -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 4a50bfca7c4f xen/arch/x86/x86_64/cpu_idle.c
--- a/xen/arch/x86/x86_64/cpu_idle.c	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/arch/x86/x86_64/cpu_idle.c	Tue Oct 14 18:41:53 2008 +0800
@@ -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 4a50bfca7c4f 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 14 18:41:53 2008 +0800
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * cpufreq.c -- adapt 32b compat guest to 64b hypervisor.
+ *
+ *  Copyright (C) 2008, Liu Jinsong <jinsong.liu@intel.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  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 4a50bfca7c4f xen/arch/x86/x86_64/platform_hypercall.c
--- a/xen/arch/x86/x86_64/platform_hypercall.c	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/arch/x86/x86_64/platform_hypercall.c	Tue Oct 14 18:41:53 2008 +0800
@@ -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 4a50bfca7c4f xen/drivers/cpufreq/cpufreq.c
--- a/xen/drivers/cpufreq/cpufreq.c	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/drivers/cpufreq/cpufreq.c	Tue Oct 14 18:41:53 2008 +0800
@@ -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 4a50bfca7c4f xen/include/acpi/cpufreq/processor_perf.h
--- a/xen/include/acpi/cpufreq/processor_perf.h	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/include/acpi/cpufreq/processor_perf.h	Tue Oct 14 18:41:53 2008 +0800
@@ -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 4a50bfca7c4f xen/include/xlat.lst
--- a/xen/include/xlat.lst	Tue Oct 07 17:23:04 2008 +0800
+++ b/xen/include/xlat.lst	Tue Oct 14 18:41:53 2008 +0800
@@ -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

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-22  7:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21  2:49 [PATCH 1] X86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility Liu, Jinsong
2008-10-21  9:23 ` [PATCH 1] X86: Adapt 32b guest os to 64b hypervisorplatform_hypercall compatibility Jan Beulich
2008-10-22  7:02   ` Liu, Jinsong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.