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-devel

[Xen-devel] [patch 4/5] kexec: Add explicit compat_kexec_op()

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch 4/5] kexec: Add explicit compat_kexec_op()
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Fri, 29 Feb 2008 15:28:58 +0900
Cc: Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Delivery-date: Thu, 28 Feb 2008 22:34:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20080229062854.370669317@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
Add an explicit compat_kexec_op() using a method similar to
that was used to create kexec_range_compat() and kexec_load_unload_compat()

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

 xen/common/compat/kexec.c |    3 --
 xen/common/kexec.c        |   47 ++++++++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 22 deletions(-)


Index: xen-unstable.hg/xen/common/kexec.c
===================================================================
--- xen-unstable.hg.orig/xen/common/kexec.c     2008-02-29 14:56:46.000000000 
+0900
+++ xen-unstable.hg/xen/common/kexec.c  2008-02-29 15:07:57.000000000 +0900
@@ -29,8 +29,6 @@
 
 #ifndef COMPAT
 
-typedef long ret_t;
-
 static DEFINE_PER_CPU(void *, crash_notes);
 
 static Elf_Note *xen_crash_note;
@@ -248,9 +246,9 @@ static int kexec_get_range(XEN_GUEST_HAN
     return ret;
 }
 
-#ifdef CONFIG_COMPAT
 static int kexec_get_range_compat(XEN_GUEST_HANDLE(void) uarg)
 {
+#ifdef CONFIG_COMPAT
     xen_kexec_range_t range;
     compat_kexec_range_t compat_range;
     int ret = -EINVAL;
@@ -269,8 +267,8 @@ static int kexec_get_range_compat(XEN_GU
     }
 
     return ret;
-}
 #endif /* CONFIG_COMPAT */
+}
 
 static int kexec_load_get_bits(int type, int *base, int *bit)
 {
@@ -343,10 +341,10 @@ static int kexec_load_unload(unsigned lo
     return kexec_load_unload_internal(op, &load);
 }
 
-#ifdef CONFIG_COMPAT
 static int kexec_load_unload_compat(unsigned long op,
                                     XEN_GUEST_HANDLE(void) uarg)
 {
+#ifdef CONFIG_COMPAT
     compat_kexec_load_t compat_load;
     xen_kexec_load_t load;
 
@@ -364,8 +362,8 @@ static int kexec_load_unload_compat(unsi
     XLAT_kexec_image(&load.image, &compat_load.image);
 
     return kexec_load_unload_internal(op, &load);
-}
 #endif
+}
 
 static int kexec_exec(XEN_GUEST_HANDLE(void) uarg)
 {
@@ -400,9 +398,8 @@ static int kexec_exec(XEN_GUEST_HANDLE(v
     return -EINVAL; /* never reached */
 }
 
-#endif
-
-ret_t do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
+int do_kexec_op_internal(unsigned long op, XEN_GUEST_HANDLE(void) uarg,
+                           int compat)
 {
     unsigned long flags;
     int ret = -EINVAL;
@@ -417,22 +414,20 @@ ret_t do_kexec_op(unsigned long op, XEN_
     switch ( op )
     {
     case KEXEC_CMD_kexec_get_range:
-#ifndef COMPAT
-        ret = kexec_get_range(uarg);
-#else
-        ret = kexec_get_range_compat(uarg);
-#endif
+        if (compat)
+                ret = kexec_get_range_compat(uarg);
+        else
+                ret = kexec_get_range(uarg);
         break;
     case KEXEC_CMD_kexec_load:
     case KEXEC_CMD_kexec_unload:
         spin_lock_irqsave(&kexec_lock, flags);
         if (!test_bit(KEXEC_FLAG_IN_PROGRESS, &kexec_flags))
         {
-#ifndef COMPAT
-            ret = kexec_load_unload(op, uarg);
-#else
-            ret = kexec_load_unload_compat(op, uarg);
-#endif
+                if (compat)
+                        ret = kexec_load_unload_compat(op, uarg);
+                else
+                        ret = kexec_load_unload(op, uarg);
         }
         spin_unlock_irqrestore(&kexec_lock, flags);
         break;
@@ -444,6 +439,20 @@ ret_t do_kexec_op(unsigned long op, XEN_
     return ret;
 }
 
+long do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
+{
+    return do_kexec_op_internal(op, uarg, 0);
+}
+
+#ifdef CONFIG_COMPAT
+int compat_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
+{
+    return do_kexec_op_internal(op, uarg, 1);
+}
+#endif
+
+#endif /* COMPAT */
+
 #if defined(CONFIG_COMPAT) && !defined(COMPAT)
 #include "compat/kexec.c"
 #endif
Index: xen-unstable.hg/xen/common/compat/kexec.c
===================================================================
--- xen-unstable.hg.orig/xen/common/compat/kexec.c      2008-02-29 
15:00:53.000000000 +0900
+++ xen-unstable.hg/xen/common/compat/kexec.c   2008-02-29 15:07:57.000000000 
+0900
@@ -5,9 +5,6 @@
 #include <compat/kexec.h>
 
 #define COMPAT
-#define ret_t int
-
-#define do_kexec_op compat_kexec_op
 
 CHECK_kexec_exec;
 

-- 

-- 
Horms


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