From: Alex Williamson Date: Mon, 22 Oct 2007 18:19:42 +0000 (-0600) Subject: [IA64] Kdump: 64-bit aligned access to elf-note data X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14850 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=de5d56f31dd18fde2297e6f7ea1a1bc2e809ffe5;p=xen.git [IA64] Kdump: 64-bit aligned access to elf-note data xen_core_regs, as passed by kexec_crash_save_info(), is 32-bit aligned as it is the data section of an ELF-note. In order to ensure 64-bit aligned access when xen_core_regs is filled in, shift it a bit and then memmove() the data back into the 32-bit aligned location after the values have been written. Without this change kdump panics on an unaligned-access. Signed-off-by: Simon Horman --- diff --git a/xen/include/asm-ia64/elf.h b/xen/include/asm-ia64/elf.h index 52bc433df1..f8c1e74287 100644 --- a/xen/include/asm-ia64/elf.h +++ b/xen/include/asm-ia64/elf.h @@ -31,6 +31,8 @@ typedef struct { #define ELF_NGREG 128 /* we really need just 72, * but let's leave some headroom */ +#define ALIGN_UP(addr, size) (((addr) + ((size) - 1)) & (~((size) - 1))) + typedef unsigned long elf_greg_t; typedef elf_greg_t elf_gregset_t[ELF_NGREG]; typedef elf_gregset_t crash_xen_core_t; @@ -40,7 +42,17 @@ extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst); static inline void elf_core_save_regs(ELF_Gregset *core_regs, crash_xen_core_t *xen_core_regs) { - ia64_elf_core_copy_regs(NULL, *xen_core_regs); + elf_greg_t *aligned_xen_core_regs; + + /* + * Re-align xen_core_regs to 64bit for access to avoid unaligned faults, + * then memmove back in place. + * xen_core_regs has headroom, so this is ok + */ + aligned_xen_core_regs = (elf_greg_t *)ALIGN_UP((unsigned long) + *xen_core_regs, 8); + ia64_elf_core_copy_regs(NULL, aligned_xen_core_regs); + memmove(*xen_core_regs, aligned_xen_core_regs, sizeof(crash_xen_core_t)); } #endif /* __IA64_ELF_H__ */