xen/32on64-kexec.patch

227 lines
6.6 KiB
Diff

Enable compatibility mode operation for kexec.
Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S
===================================================================
--- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:50:12.000000000 +0100
+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:52:27.000000000 +0100
@@ -316,6 +316,7 @@ ENTRY(compat_hypercall_table)
.quad compat_ni_hypercall
.quad compat_sysctl /* 35 */
.quad compat_domctl
+ .quad compat_kexec_op
.rept NR_hypercalls-((.-compat_hypercall_table)/8)
.quad compat_ni_hypercall
.endr
@@ -358,6 +359,7 @@ ENTRY(compat_hypercall_args_table)
.byte 0 /* compat_ni_hypercall */
.byte 1 /* compat_sysctl */ /* 35 */
.byte 1 /* compat_domctl */
+ .byte 2 /* compat_kexec_op */
.rept NR_hypercalls-(.-compat_hypercall_args_table)
.byte 0 /* compat_ni_hypercall */
.endr
Index: 2006-12-18/xen/common/Makefile
===================================================================
--- 2006-12-18.orig/xen/common/Makefile 2006-12-18 09:50:08.000000000 +0100
+++ 2006-12-18/xen/common/Makefile 2006-12-18 09:52:27.000000000 +0100
@@ -44,6 +44,7 @@ ifeq ($(CONFIG_COMPAT),y)
# extra dependencies
acm_ops.o: compat/acm_ops.c
grant_table.o: compat/grant_table.c
+kexec.o: compat/kexec.c
schedule.o: compat/schedule.c
xenoprof.o: compat/xenoprof.c
endif
Index: 2006-12-18/xen/common/compat/kexec.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ 2006-12-18/xen/common/compat/kexec.c 2006-12-18 09:52:27.000000000 +0100
@@ -0,0 +1,33 @@
+/*
+ * compat/kexec.c
+ */
+
+#include <compat/kexec.h>
+
+#define COMPAT
+#define ret_t int
+
+#define do_kexec_op compat_kexec_op
+
+#undef kexec_get
+#define kexec_get(x) compat_kexec_get_##x
+#define xen_kexec_range compat_kexec_range
+#define xen_kexec_range_t compat_kexec_range_t
+
+#define kexec_load_unload compat_kexec_load_unload
+#define xen_kexec_load compat_kexec_load
+#define xen_kexec_load_t compat_kexec_load_t
+
+CHECK_kexec_exec;
+
+#include "../kexec.c"
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Index: 2006-12-18/xen/common/kexec.c
===================================================================
--- 2006-12-18.orig/xen/common/kexec.c 2006-12-15 16:33:59.000000000 +0100
+++ 2006-12-18/xen/common/kexec.c 2006-12-18 09:52:27.000000000 +0100
@@ -22,6 +22,10 @@
#include <xen/version.h>
#include <public/elfnote.h>
+#ifndef COMPAT
+
+typedef long ret_t;
+
DEFINE_PER_CPU (crash_note_t, crash_notes);
cpumask_t crash_saved_cpus;
@@ -143,7 +147,11 @@ static __init int register_crashdump_tri
}
__initcall(register_crashdump_trigger);
-static int kexec_get_reserve(xen_kexec_range_t *range)
+#define kexec_get(x) kexec_get_##x
+
+#endif
+
+static int kexec_get(reserve)(xen_kexec_range_t *range)
{
range->start = kexec_crash_area.start;
range->size = kexec_crash_area.size;
@@ -152,14 +160,14 @@ static int kexec_get_reserve(xen_kexec_r
extern unsigned long _text;
-static int kexec_get_xen(xen_kexec_range_t *range)
+static int kexec_get(xen)(xen_kexec_range_t *range)
{
range->start = virt_to_maddr(&_text);
range->size = (unsigned long)&_end - (unsigned long)&_text;
return 0;
}
-static int kexec_get_cpu(xen_kexec_range_t *range)
+static int kexec_get(cpu)(xen_kexec_range_t *range)
{
if ( range->nr < 0 || range->nr >= num_present_cpus() )
return -EINVAL;
@@ -169,7 +177,7 @@ static int kexec_get_cpu(xen_kexec_range
return 0;
}
-static int kexec_get_range(XEN_GUEST_HANDLE(void) uarg)
+static int kexec_get(range)(XEN_GUEST_HANDLE(void) uarg)
{
xen_kexec_range_t range;
int ret = -EINVAL;
@@ -180,13 +188,13 @@ static int kexec_get_range(XEN_GUEST_HAN
switch ( range.range )
{
case KEXEC_RANGE_MA_CRASH:
- ret = kexec_get_reserve(&range);
+ ret = kexec_get(reserve)(&range);
break;
case KEXEC_RANGE_MA_XEN:
- ret = kexec_get_xen(&range);
+ ret = kexec_get(xen)(&range);
break;
case KEXEC_RANGE_MA_CPU:
- ret = kexec_get_cpu(&range);
+ ret = kexec_get(cpu)(&range);
break;
}
@@ -196,6 +204,8 @@ static int kexec_get_range(XEN_GUEST_HAN
return ret;
}
+#ifndef COMPAT
+
static int kexec_load_get_bits(int type, int *base, int *bit)
{
switch ( type )
@@ -214,6 +224,8 @@ static int kexec_load_get_bits(int type,
return 0;
}
+#endif
+
static int kexec_load_unload(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
{
xen_kexec_load_t load;
@@ -236,7 +248,11 @@ static int kexec_load_unload(unsigned lo
BUG_ON(test_bit((base + !pos), &kexec_flags)); /* must be free */
+#ifndef COMPAT
memcpy(image, &load.image, sizeof(*image));
+#else
+ XLAT_kexec_image(image, &load.image);
+#endif
if ( !(ret = machine_kexec_load(load.type, base + !pos, image)) )
{
@@ -261,6 +277,8 @@ static int kexec_load_unload(unsigned lo
return ret;
}
+#ifndef COMPAT
+
static int kexec_exec(XEN_GUEST_HANDLE(void) uarg)
{
xen_kexec_exec_t exec;
@@ -294,7 +312,9 @@ static int kexec_exec(XEN_GUEST_HANDLE(v
return -EINVAL; /* never reached */
}
-long do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
+#endif
+
+ret_t do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg)
{
unsigned long flags;
int ret = -EINVAL;
@@ -305,7 +325,7 @@ long do_kexec_op(unsigned long op, XEN_G
switch ( op )
{
case KEXEC_CMD_kexec_get_range:
- ret = kexec_get_range(uarg);
+ ret = kexec_get(range)(uarg);
break;
case KEXEC_CMD_kexec_load:
case KEXEC_CMD_kexec_unload:
@@ -324,6 +344,10 @@ long do_kexec_op(unsigned long op, XEN_G
return ret;
}
+#if defined(CONFIG_COMPAT) && !defined(COMPAT)
+#include "compat/kexec.c"
+#endif
+
/*
* Local variables:
* mode: C
Index: 2006-12-18/xen/include/xlat.lst
===================================================================
--- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:52:23.000000000 +0100
+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:52:27.000000000 +0100
@@ -32,6 +32,8 @@
! gnttab_transfer grant_table.h
? gnttab_unmap_grant_ref grant_table.h
? grant_entry grant_table.h
+? kexec_exec kexec.h
+! kexec_image kexec.h
! add_to_physmap memory.h
! foreign_memory_map memory.h
! memory_exchange memory.h