ia64/xen-unstable

changeset 13558:66cc1685d957

[XEN] Avoid void* arithmetic in kexec ELF note manipulations.

From: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Mon Jan 22 15:29:04 2007 +0000 (2007-01-22)
parents 207523704fb1
children de6c4f72b65b
files xen/common/kexec.c
line diff
     1.1 --- a/xen/common/kexec.c	Mon Jan 22 15:15:32 2007 +0000
     1.2 +++ b/xen/common/kexec.c	Mon Jan 22 15:29:04 2007 +0000
     1.3 @@ -27,9 +27,9 @@
     1.4  typedef long ret_t;
     1.5  
     1.6  #define ELFNOTE_ALIGN(_n_) (((_n_)+3)&~3)
     1.7 -#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_)))
     1.8 +#define ELFNOTE_NAME(_n_) ((char*)(_n_) + sizeof(*(_n_)))
     1.9  #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + ELFNOTE_ALIGN((_n_)->namesz))
    1.10 -#define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + ELFNOTE_ALIGN((_n_)->descsz))
    1.11 +#define ELFNOTE_NEXT(_n_) ((Elf_Note *)(ELFNOTE_DESC(_n_) + ELFNOTE_ALIGN((_n_)->descsz)))
    1.12  
    1.13  static DEFINE_PER_CPU(void *, crash_notes);
    1.14  
    1.15 @@ -75,10 +75,10 @@ void kexec_crash_save_cpu(void)
    1.16      if ( cpu_test_and_set(cpu, crash_saved_cpus) )
    1.17          return;
    1.18  
    1.19 -    prstatus = ELFNOTE_DESC(note);
    1.20 +    prstatus = (ELF_Prstatus *)ELFNOTE_DESC(note);
    1.21  
    1.22      note = ELFNOTE_NEXT(note);
    1.23 -    xencore = ELFNOTE_DESC(note);
    1.24 +    xencore = (crash_xen_core_t *)ELFNOTE_DESC(note);
    1.25  
    1.26      elf_core_save_regs(&prstatus->pr_reg, xencore);
    1.27  }
    1.28 @@ -87,7 +87,7 @@ void kexec_crash_save_cpu(void)
    1.29  crash_xen_info_t *kexec_crash_save_info(void)
    1.30  {
    1.31      int cpu = smp_processor_id();
    1.32 -    crash_xen_info_t *info = ELFNOTE_DESC(xen_crash_note);
    1.33 +    crash_xen_info_t *info = (crash_xen_info_t *)ELFNOTE_DESC(xen_crash_note);
    1.34  
    1.35      BUG_ON(!cpu_test_and_set(cpu, crash_saved_cpus));
    1.36