[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] kexec: Avoid unaligned writes when producing crash info.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1177404488 -3600
# Node ID 7493bb48d89f6b01c5281d360523a713323850ac
# Parent  5607a3afedb0f0859dde85f2f98c629373cf8b7c
kexec: Avoid unaligned writes when producing crash info.

The alignment of info is 32bits in line with the elf specification.
This means that on 64 bit architectures accessing it directly may
result unaligned access and a panic. I have been experiencing
this on IA64.

It seems that a simple approach of having an crash_xen_info_t on
the stack and simply memcopying it into info at the end alleviates
the problem.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
---
 xen/common/kexec.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff -r 5607a3afedb0 -r 7493bb48d89f xen/common/kexec.c
--- a/xen/common/kexec.c        Tue Apr 24 09:44:51 2007 +0100
+++ b/xen/common/kexec.c        Tue Apr 24 09:48:08 2007 +0100
@@ -81,20 +81,25 @@ crash_xen_info_t *kexec_crash_save_info(
 crash_xen_info_t *kexec_crash_save_info(void)
 {
     int cpu = smp_processor_id();
-    crash_xen_info_t *info = (crash_xen_info_t *)ELFNOTE_DESC(xen_crash_note);
+    crash_xen_info_t info;
+    crash_xen_info_t *out = (crash_xen_info_t *)ELFNOTE_DESC(xen_crash_note);
 
     BUG_ON(!cpu_test_and_set(cpu, crash_saved_cpus));
 
-    info->xen_major_version = xen_major_version();
-    info->xen_minor_version = xen_minor_version();
-    info->xen_extra_version = __pa(xen_extra_version());
-    info->xen_changeset = __pa(xen_changeset());
-    info->xen_compiler = __pa(xen_compiler());
-    info->xen_compile_date = __pa(xen_compile_date());
-    info->xen_compile_time = __pa(xen_compile_time());
-    info->tainted = tainted;
-
-    return info;
+    memset(&info, 0, sizeof(info));
+    info.xen_major_version = xen_major_version();
+    info.xen_minor_version = xen_minor_version();
+    info.xen_extra_version = __pa(xen_extra_version());
+    info.xen_changeset = __pa(xen_changeset());
+    info.xen_compiler = __pa(xen_compiler());
+    info.xen_compile_date = __pa(xen_compile_date());
+    info.xen_compile_time = __pa(xen_compile_time());
+    info.tainted = tainted;
+
+    /* Copy from guaranteed-aligned local copy to possibly-unaligned dest. */
+    memcpy(out, &info, sizeof(info));
+
+    return out;
 }
 
 void kexec_crash(void)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.