aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/kexec.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-02-01 14:15:37 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-02-01 14:15:37 +0000
commitd0a7aa6a33391fccc6ef4eedd1b54a4cc1171356 (patch)
treeb41a917bc452ce3fa4ea18d6d2e73839085aed6f /xen/common/kexec.c
parent6552100e95eff8719a53ed1d1710a149e756aa05 (diff)
downloadxen-d0a7aa6a33391fccc6ef4eedd1b54a4cc1171356.tar.gz
xen-d0a7aa6a33391fccc6ef4eedd1b54a4cc1171356.tar.bz2
xen-d0a7aa6a33391fccc6ef4eedd1b54a4cc1171356.zip
Allocate Xen kexec/kdump elfnote sections of the correct size.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/kexec.c')
-rw-r--r--xen/common/kexec.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/xen/common/kexec.c b/xen/common/kexec.c
index 9e6e1858a4..ca729d10c1 100644
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -131,12 +131,20 @@ __initcall(register_crashdump_trigger);
static void setup_note(Elf_Note *n, const char *name, int type, int descsz)
{
- strlcpy(ELFNOTE_NAME(n), name, INT_MAX);
- n->namesz = strlen(name);
+ int l = strlen(name) + 1;
+ strlcpy(ELFNOTE_NAME(n), name, l);
+ n->namesz = l;
n->descsz = descsz;
n->type = type;
}
+static int sizeof_note(const char *name, int descsz)
+{
+ return (sizeof(Elf_Note) +
+ ELFNOTE_ALIGN(sizeof(name)) +
+ ELFNOTE_ALIGN(descsz));
+}
+
#define kexec_get(x) kexec_get_##x
#endif
@@ -162,16 +170,17 @@ static int kexec_get(xen)(xen_kexec_range_t *range)
static int kexec_get(cpu)(xen_kexec_range_t *range)
{
int nr = range->nr;
- int nr_bytes = sizeof(Elf_Note) * 2
- + ELFNOTE_ALIGN(sizeof(ELF_Prstatus))
- + ELFNOTE_ALIGN(sizeof(crash_xen_core_t));
+ int nr_bytes = 0;
if ( nr < 0 || nr >= num_present_cpus() )
return -EINVAL;
+ nr_bytes += sizeof_note("CORE", sizeof(ELF_Prstatus));
+ nr_bytes += sizeof_note("Xen", sizeof(crash_xen_core_t));
+
/* The Xen info note is included in CPU0's range. */
if ( nr == 0 )
- nr_bytes += sizeof(Elf_Note) + ELFNOTE_ALIGN(sizeof(crash_xen_info_t));
+ nr_bytes += sizeof_note("Xen", sizeof(crash_xen_info_t));
if ( per_cpu(crash_notes, nr) == NULL )
{