FYI: x86_64 bug when using gdb with vmcore
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 539140123.1108061265388145735.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com
The kexec/arch/x86_64/crashdump-x86_64.h file contains a stale PAGE_OFFSET value. In 2.6.27 it was changed from 0xffff810000000000UL to 0xffff880000000000UL. This is only a problem when using gdb with the vmlinux/vmcore pair, because gdb relies upon the PT_LOAD segment's p_vaddr values in the ELF header to be correct.
Anyway, in the RHEL6 kexec-tools, this simple patch was made:
-#define PAGE_OFFSET 0xffff810000000000UL
+#define PAGE_OFFSET 0xffff880000000000UL
which is OK since the RHEL6 version of kexec-tools will only be used with RHEL6 kernels.
But for backwards compatibility, the better way to do it would be to check the utsname of the running kernel, and use the right value.
But again, this is only required for gdb usage. The crash utility (and makedumpfile) make kernel version checks to determine which x86_64 PAGE_OFFSET value is applicable, and don't rely on the ELF header p_vaddr values for the unity-mapped regions.
Dave Anderson
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 21 lines · Dave Anderson
The
kexec/arch/x86_64/crashdump-x86_64.hfile contains a stalePAGE_OFFSETvalue. In 2.6.27 it was changed from0xffff810000000000ULto0xffff880000000000UL. This is only a problem when using gdb with the vmlinux/vmcore pair, because gdb relies upon thePT_LOADsegment'sp_vaddrvalues in the ELF header to be correct.Anyway, in the RHEL6 kexec-tools, this simple patch was made:
(quoted diff) +1
-1-#define PAGE_OFFSET 0xffff810000000000UL +#define PAGE_OFFSET 0xffff880000000000ULwhich is OK since the RHEL6 version of kexec-tools will only be used with RHEL6 kernels.
But for backwards compatibility, the better way to do it would be to check the utsname of the running kernel, and use the right value.
Quoted 5 lines
But again, this is only required for gdb usage. The crash utility (and makedumpfile) make kernel version checks to determine which
x86_64PAGE_OFFSETvalue is applicable, and don't rely on the ELF headerp_vaddrvalues for the unity-mapped regions.
Hi Dave,
Something like this?
----------------------------------------------------------------------
x86_64: use correct PAGE_OFFSET
This fixes a bug when using gdb with vmcore
as explained by Dave Anderson:
The kexec/arch/x86_64/crashdump-x86_64.h file contains a stale PAGE_OFFSET value. In 2.6.27 it was changed from 0xffff810000000000UL to 0xffff880000000000UL. This is only a problem when using gdb with the vmlinux/vmcore pair, because gdb relies upon the PT_LOAD segment's p_vaddr values in the ELF header to be correct.
kexec/arch/x86_64/crashdump-x86_64.c +10 -9
@@ -36,15 +36,6 @@#include "crashdump-x86_64.h" #include <x86/x86-linux.h> -static struct crash_elf_info elf_info = -{ - class:ELFCLASS64 , - data:ELFDATA2LSB , - machine:EM_X86_64 , - backup_src_start:BACKUP_SRC_START , - backup_src_end:BACKUP_SRC_END , - page_offset:PAGE_OFFSET , -};/* Forward Declaration. */ static int exclude_region (int *nr_ranges,uint64_t start,uint64_t end);
@@ -604,6 +595,16 @@ int load_crashdump_segments(struct kexecint nr_ranges, align =1024 , i;struct memory_range *mem_range, *memmap_p; +struct crash_elf_info elf_info = + { + class:ELFCLASS64 , + data:ELFDATA2LSB , + machine:EM_X86_64 , + backup_src_start:BACKUP_SRC_START , + backup_src_end:BACKUP_SRC_END , + page_offset: page_offset, + }; +if (get_kernel_paddr (info))return -1 ;
kexec/arch/x86_64/crashdump-x86_64.h +6 -2
@@ -1,12 +1,16 @@#ifndef CRASHDUMP_X86_64_H #define CRASHDUMP_X86_64_H +#include "../../kexec.h" +int load_crashdump_segments (struct kexec_info *info,char *mod_cmdline,unsigned long max_addr,unsigned long min_base);#define __START_KERNEL_map 0xffffffff80000000UL -#define PAGE_OFFSET 0xffff810000000000UL -#define __pa (x) (((unsigned long)(x)>=__START_KERNEL_map)?(unsigned long)(x) - (unsigned long)__START_KERNEL_map:(unsigned long)(x) - PAGE_OFFSET) + +extern unsigned long page_offset; + +#define __pa (x) (((unsigned long)(x)>=__START_KERNEL_map)?(unsigned long)(x) - (unsigned long)__START_KERNEL_map:(unsigned long)(x) - page_offset)#define MAXMEM 0x3fffffffffffUL
kexec/kexec.c +2 -0
@@ -1041,6 +1041,8 @@ int main(int argc, char *argv[]) };static const char short_options[] =KEXEC_OPT_STR ; +arch_init (); + opterr =0 ;/* Don't complain about unrecognized options here */ while ((opt =getopt_long (argc, argv, short_options, options,0 )) !=-1 ) {
kexec/Makefile +2 -0
@@ -44,6 +44,8 @@ $(ARCH)_ADD_BUFFER = kexec/add_buffer.c KEXEC_SRCS += $($(ARCH)_ADD_BUFFER) $(ARCH)_ARCH_REUSE_INITRD = kexec/arch_reuse_initrd.c KEXEC_SRCS += $($(ARCH)_ARCH_REUSE_INITRD) +$(ARCH)_ARCH_INIT = kexec/arch_init.c +KEXEC_SRCS += $($(ARCH)_ARCH_INIT) include $(srcdir)/kexec/arch/alpha/Makefile include $(srcdir)/kexec/arch/arm/Makefile
kexec/arch/x86_64/Makefile +2 -0
@@ -13,6 +13,8 @@ x86_64_KEXEC_SRCS += kexec/arch/x86_64/k x86_64_KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-x86_64.c x86_64_KEXEC_SRCS += kexec/arch/x86_64/kexec-elf-rel-x86_64.c +x86_64_ARCH_INIT = kexec/arch/x86_64/arch_init.c + dist += kexec/arch/x86_64/Makefile $(x86_64_KEXEC_SRCS) \ kexec/arch/x86_64/kexec-x86_64.h kexec/arch/x86_64/crashdump-x86_64.h \ kexec/arch/x86_64/include/arch/options.h
kexec/arch/x86_64/arch_init.c new file +83 -0
83 lines not on this page · raw message
kexec/arch_init.c new file +4 -0
@@ -0,0 +1,4 @@ +int arch_init (void ) +{ +return 0 ; +}
kexec/kexec.h +2 -0
@@ -249,6 +249,8 @@ int kexec_iomem_for_each_line(char *matcint parse_iomem_single (char *str,uint64_t *start,uint64_t *end);const char *proc_iomem (void ); +int arch_init (void ); +extern int add_backup_segments (struct kexec_info *info,unsigned long backup_base,unsigned long backup_size);
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec