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>
---
Fri, 29 Feb 2008 16:44:34 +0900
- Make sure that kexec_range_compat() and kexec_load_unload_compat()
return 0 when CONFIG_COMPAT is not defined
xen/common/compat/kexec.c | 3 --
xen/common/kexec.c | 51 ++++++++++++++++++++++++++++-----------------
2 files changed, 32 insertions(+), 22 deletions(-)
Index: xen-unstable.hg/xen/common/kexec.c
===================================================================
--- xen-unstable.hg.orig/xen/common/kexec.c 2008-02-29 16:19:27.000000000
+0900
+++ xen-unstable.hg/xen/common/kexec.c 2008-02-29 16:26:04.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,10 @@ static int kexec_get_range_compat(XEN_GU
}
return ret;
-}
+#else /* CONFIG_COMPAT */
+ return 0;
#endif /* CONFIG_COMPAT */
+}
static int kexec_load_get_bits(int type, int *base, int *bit)
{
@@ -343,10 +343,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 +364,10 @@ static int kexec_load_unload_compat(unsi
XLAT_kexec_image(&load.image, &compat_load.image);
return kexec_load_unload_internal(op, &load);
+#else /* CONFIG_COMPAT */
+ return 0;
+#endif /* CONFIG_COMPAT */
}
-#endif
static int kexec_exec(XEN_GUEST_HANDLE(void) uarg)
{
@@ -400,9 +402,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 +418,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 +443,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
16:19:27.000000000 +0900
+++ xen-unstable.hg/xen/common/compat/kexec.c 2008-02-29 16:19:36.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;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|