]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
fadump: Add PT_NOTE program header for vmcoreinfo
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Thu, 16 Feb 2012 01:14:53 +0000 (01:14 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 22 Feb 2012 23:50:02 +0000 (10:50 +1100)
Introduce a PT_NOTE program header that points to physical address of
vmcoreinfo_note buffer declared in kernel/kexec.c. The vmcoreinfo
note buffer is populated during crash_fadump() at the time of system
crash.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/kernel/fadump.c

index da68bdad194af52a059cc5459bac7097f2976124..a83bc9015c64edca35f30444aa31d5bb4c19dcb5 100644 (file)
@@ -814,6 +814,19 @@ static void fadump_setup_crash_memory_ranges(void)
        }
 }
 
+/*
+ * If the given physical address falls within the boot memory region then
+ * return the relocated address that points to the dump region reserved
+ * for saving initial boot memory contents.
+ */
+static inline unsigned long fadump_relocate(unsigned long paddr)
+{
+       if (paddr > RMA_START && paddr < fw_dump.boot_memory_size)
+               return fdm.rmr_region.destination_address + paddr;
+       else
+               return paddr;
+}
+
 static int fadump_create_elfcore_headers(char *bufp)
 {
        struct elfhdr *elf;
@@ -845,6 +858,22 @@ static int fadump_create_elfcore_headers(char *bufp)
 
        (elf->e_phnum)++;
 
+       /* setup ELF PT_NOTE for vmcoreinfo */
+       phdr = (struct elf_phdr *)bufp;
+       bufp += sizeof(struct elf_phdr);
+       phdr->p_type    = PT_NOTE;
+       phdr->p_flags   = 0;
+       phdr->p_vaddr   = 0;
+       phdr->p_align   = 0;
+
+       phdr->p_paddr   = fadump_relocate(paddr_vmcoreinfo_note());
+       phdr->p_offset  = phdr->p_paddr;
+       phdr->p_memsz   = vmcoreinfo_max_size;
+       phdr->p_filesz  = vmcoreinfo_max_size;
+
+       /* Increment number of program headers. */
+       (elf->e_phnum)++;
+
        /* setup PT_LOAD sections. */
 
        for (i = 0; i < crash_mem_ranges; i++) {