ia64/xen-unstable

changeset 13805:0a4cbad6752c

Allocate Xen kexec/kdump elfnote sections of the correct size.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Feb 01 14:15:37 2007 +0000 (2007-02-01)
parents f45de0fe8a15
children f73e71aa0a90
files xen/common/kexec.c
line diff
     1.1 --- a/xen/common/kexec.c	Thu Feb 01 13:44:35 2007 +0000
     1.2 +++ b/xen/common/kexec.c	Thu Feb 01 14:15:37 2007 +0000
     1.3 @@ -131,12 +131,20 @@ static __init int register_crashdump_tri
     1.4  
     1.5  static void setup_note(Elf_Note *n, const char *name, int type, int descsz)
     1.6  {
     1.7 -    strlcpy(ELFNOTE_NAME(n), name, INT_MAX);
     1.8 -    n->namesz = strlen(name);
     1.9 +    int l = strlen(name) + 1;
    1.10 +    strlcpy(ELFNOTE_NAME(n), name, l);
    1.11 +    n->namesz = l;
    1.12      n->descsz = descsz;
    1.13      n->type = type;
    1.14  }
    1.15  
    1.16 +static int sizeof_note(const char *name, int descsz)
    1.17 +{
    1.18 +    return (sizeof(Elf_Note) +
    1.19 +            ELFNOTE_ALIGN(sizeof(name)) +
    1.20 +            ELFNOTE_ALIGN(descsz));
    1.21 +}
    1.22 +
    1.23  #define kexec_get(x)      kexec_get_##x
    1.24  
    1.25  #endif
    1.26 @@ -162,16 +170,17 @@ static int kexec_get(xen)(xen_kexec_rang
    1.27  static int kexec_get(cpu)(xen_kexec_range_t *range)
    1.28  {
    1.29      int nr = range->nr;
    1.30 -    int nr_bytes = sizeof(Elf_Note) * 2
    1.31 -        + ELFNOTE_ALIGN(sizeof(ELF_Prstatus))
    1.32 -        + ELFNOTE_ALIGN(sizeof(crash_xen_core_t));
    1.33 +    int nr_bytes = 0;
    1.34  
    1.35      if ( nr < 0 || nr >= num_present_cpus() )
    1.36          return -EINVAL;
    1.37  
    1.38 +    nr_bytes += sizeof_note("CORE", sizeof(ELF_Prstatus));
    1.39 +    nr_bytes += sizeof_note("Xen", sizeof(crash_xen_core_t));
    1.40 +
    1.41      /* The Xen info note is included in CPU0's range. */
    1.42      if ( nr == 0 )
    1.43 -        nr_bytes += sizeof(Elf_Note) + ELFNOTE_ALIGN(sizeof(crash_xen_info_t));
    1.44 +        nr_bytes += sizeof_note("Xen", sizeof(crash_xen_info_t));
    1.45  
    1.46      if ( per_cpu(crash_notes, nr) == NULL )
    1.47      {