From 7c78356e8f45ded79ceb9625e4990f61298113ba Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 14 Mar 2016 22:29:08 +0000 Subject: remaining TI changes --- kdump/kdump.c | 30 +++++++++++++++--------------- kexec/crashdump-elf.c | 4 +++- kexec/kexec.c | 2 ++ kexec/kexec.h | 6 ++++++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/kdump/kdump.c b/kdump/kdump.c index de46d28..e7a0252 100644 --- a/kdump/kdump.c +++ b/kdump/kdump.c @@ -74,7 +74,7 @@ static void *xmalloc(size_t size) } static void *collect_notes( - int fd, Elf64_Ehdr *ehdr, Elf64_Phdr *phdr, size_t *note_bytes) + int fd, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, size_t *note_bytes) { int i; size_t bytes, result_bytes; @@ -94,7 +94,7 @@ static void *collect_notes( /* Walk through and capture the notes */ for(i = 0; i < ehdr->e_phnum; i++) { - Elf64_Nhdr *hdr, *lhdr, *nhdr; + Elf32_Nhdr *hdr, *lhdr, *nhdr; void *pnotes; if (phdr[i].p_type != PT_NOTE) { continue; @@ -105,8 +105,8 @@ static void *collect_notes( unmap_addr(pnotes, phdr[i].p_filesz); /* Walk through the new notes and find the real length */ - hdr = (Elf64_Nhdr *)(notes + result_bytes); - lhdr = (Elf64_Nhdr *)(notes + result_bytes + phdr[i].p_filesz); + hdr = (Elf32_Nhdr *)(notes + result_bytes); + lhdr = (Elf32_Nhdr *)(notes + result_bytes + phdr[i].p_filesz); for(; hdr < lhdr; hdr = nhdr) { size_t hdr_size; /* If there is not a name this is a invalid/reserved note @@ -120,7 +120,7 @@ static void *collect_notes( ((hdr->n_namesz + 3) & ~3) + ((hdr->n_descsz + 3) & ~3); - nhdr = (Elf64_Nhdr *)(((char *)hdr) + hdr_size); + nhdr = (Elf32_Nhdr *)(((char *)hdr) + hdr_size); /* if the note does not fit in the segment stop here */ if (nhdr > lhdr) { break; @@ -134,13 +134,13 @@ static void *collect_notes( } static void *generate_new_headers( - Elf64_Ehdr *ehdr, Elf64_Phdr *phdr, size_t note_bytes, size_t *header_bytes) + Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, size_t note_bytes, size_t *header_bytes) { unsigned phnum; size_t bytes; char *headers; - Elf64_Ehdr *nehdr; - Elf64_Phdr *nphdr; + Elf32_Ehdr *nehdr; + Elf32_Phdr *nphdr; unsigned long long offset; int i; /* Count the number of program headers. @@ -161,8 +161,8 @@ static void *generate_new_headers( headers = xmalloc(bytes); /* Setup pointers to the new headers */ - nehdr = (Elf64_Ehdr *)headers; - nphdr = (Elf64_Phdr *)(headers + sizeof(*nehdr)); + nehdr = (Elf32_Ehdr *)headers; + nphdr = (Elf32_Phdr *)(headers + sizeof(*nehdr)); /* Copy and adjust the Elf header */ memcpy(nehdr, ehdr, sizeof(*nehdr)); @@ -227,8 +227,8 @@ int main(int argc, char **argv) { char *start_addr_str, *end; unsigned long long start_addr; - Elf64_Ehdr *ehdr; - Elf64_Phdr *phdr; + Elf32_Ehdr *ehdr; + Elf32_Phdr *phdr; void *notes, *headers; size_t note_bytes, header_bytes; int fd; @@ -270,13 +270,13 @@ int main(int argc, char **argv) (ehdr->e_ident[EI_MAG1] != ELFMAG1) || (ehdr->e_ident[EI_MAG2] != ELFMAG2) || (ehdr->e_ident[EI_MAG3] != ELFMAG3) || - (ehdr->e_ident[EI_CLASS] != ELFCLASS64) || + (ehdr->e_ident[EI_CLASS] != ELFCLASS32) || (ehdr->e_ident[EI_DATA] != ELFDATALOCAL) || (ehdr->e_ident[EI_VERSION] != EV_CURRENT) || (ehdr->e_type != ET_CORE) || (ehdr->e_version != EV_CURRENT) || - (ehdr->e_ehsize != sizeof(Elf64_Ehdr)) || - (ehdr->e_phentsize != sizeof(Elf64_Phdr)) || + (ehdr->e_ehsize != sizeof(Elf32_Ehdr)) || + (ehdr->e_phentsize != sizeof(Elf32_Phdr)) || (ehdr->e_phnum == 0)) { fprintf(stderr, "Invalid Elf header\n"); diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c index b8bb686..045f6b5 100644 --- a/kexec/crashdump-elf.c +++ b/kexec/crashdump-elf.c @@ -152,7 +152,7 @@ int FUNC(struct kexec_info *info, bufp += sizeof(PHDR); phdr->p_type = PT_NOTE; phdr->p_flags = 0; - phdr->p_offset = phdr->p_paddr = notes_addr; + phdr->p_offset = phdr->p_paddr = notes_addr - K2_ALIAS_OFFSET; phdr->p_vaddr = 0; phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ @@ -203,6 +203,8 @@ int FUNC(struct kexec_info *info, continue; mstart = range->start; mend = range->end; + if (mend >= 0x100000000ULL) + continue; if (!mstart && !mend) continue; phdr = (PHDR *) bufp; diff --git a/kexec/kexec.c b/kexec/kexec.c index cfd837c..2c696c6 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -883,10 +883,12 @@ static int my_shutdown(void) */ static int my_exec(void) { +if (1) { if (xen_present()) xen_kexec_exec(); else reboot(LINUX_REBOOT_CMD_KEXEC); +} /* I have failed if I make it here */ fprintf(stderr, "kexec failed: %s\n", strerror(errno)); diff --git a/kexec/kexec.h b/kexec/kexec.h index 26225d2..cd2e4b0 100644 --- a/kexec/kexec.h +++ b/kexec/kexec.h @@ -319,4 +319,10 @@ int xen_kexec_status(uint64_t kexec_flags); extern unsigned long long get_kernel_sym(const char *text); +/* Keystone2 definitions */ + +#define K2_MEM_START 0x800000000ULL +#define K2_MEM_2G_END 0x880000000ULL +#define K2_ALIAS_OFFSET 0x780000000ULL + #endif /* KEXEC_H */ -- cgit