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] Unaligned access in kexec_crash_save_cpu()

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Unaligned access in kexec_crash_save_cpu()
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Mon, 23 Apr 2007 16:40:11 +0900
Cc: Itsuro ODA <oda@xxxxxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Delivery-date: Mon, 23 Apr 2007 00:38:53 -0700
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: mutt-ng/devel-r804 (Debian)
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>

--- 
Tested on xen-ia64-unstable 14854:039daabebad5

Index: xen-ia64-unstable-14854/xen/common/kexec.c
===================================================================
--- xen-ia64-unstable-14854.orig/xen/common/kexec.c     2007-04-23 
15:55:34.000000000 +0900
+++ xen-ia64-unstable-14854/xen/common/kexec.c  2007-04-23 15:56:14.000000000 
+0900
@@ -81,20 +81,25 @@ void kexec_crash_save_cpu(void)
 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));
+    memset(&info, 0, sizeof(crash_xen_info_t));
 
-    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;
+    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;
+    /* Info is not be word aligned on 64 bit architectures */
+    memcpy(out, &info, sizeof(crash_xen_info_t));
+
+    return out;
 }
 
 void kexec_crash(void)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Unaligned access in kexec_crash_save_cpu(), Simon Horman <=