int xen_build_id_check(const Elf_Note *n, unsigned int n_sz, const void **p, unsigned int *len) { /* Check if we really have a build-id. */ ASSERT(n_sz > sizeof(*n)); if ( NT_GNU_BUILD_ID != n->type ) return -ENODATA; if ( n->namesz + n->descsz < n->namesz ) return -EINVAL; if ( n->namesz < 4 /* GNU\0 */) return -EINVAL; if ( n->namesz + n->descsz > n_sz - sizeof(*n) ) return -EINVAL; /* Sanity check, name should be "GNU" for ld-generated build-id. */ if ( strncmp(ELFNOTE_NAME(n), "GNU", n->namesz) != 0 ) return -ENODATA; if ( len ) *len = n->descsz; if ( p ) *p = ELFNOTE_DESC(n); return 0; }
/* Save the registers in the per-cpu crash note buffer. */ void kexec_crash_save_cpu(void) { int cpu = smp_processor_id(); Elf_Note *note = per_cpu(crash_notes, cpu); ELF_Prstatus *prstatus; crash_xen_core_t *xencore; if ( cpu_test_and_set(cpu, crash_saved_cpus) ) return; prstatus = (ELF_Prstatus *)ELFNOTE_DESC(note); note = ELFNOTE_NEXT(note); xencore = (crash_xen_core_t *)ELFNOTE_DESC(note); elf_core_save_regs(&prstatus->pr_reg, xencore); }
/* Set up the single Xen-specific-info crash note. */ crash_xen_info_t *kexec_crash_save_info(void) { int cpu = smp_processor_id(); 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(info)); 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; /* Copy from guaranteed-aligned local copy to possibly-unaligned dest. */ memcpy(out, &info, sizeof(info)); return out; }