Fix for the determination of the ARM64 phys_offset value when

running live against /proc/kcore.  Without the patch, the message
"WARNING: cannot access vmalloc'd module memory" may be displayed
during session initialization, and vmalloc/module memory will be
unaccessible.  It should be noted that at the time of this patch,
the upstream (4.16.0) version of /proc/kcore does not work correctly
for ARM64, because PT_LOAD segments for unity-mapped blocks of
physical memory are not generated.
(anderson@redhat.com)
This commit is contained in:
Dave Anderson 2018-04-25 17:02:54 -04:00
parent 6504149678
commit d66564ae3a
3 changed files with 23 additions and 12 deletions

View File

@ -443,7 +443,7 @@ arm64_verify_symbol(const char *name, ulong value, char type)
machdep->machspec->kernel_flags = le64toh(value);
if ((type == 'A') && STREQ(name, "_kernel_flags_le_hi32"))
machdep->machspec->kernel_flags |= (le32toh(value) << 32);
machdep->machspec->kernel_flags |= ((ulong)le32toh(value) << 32);
if ((type == 'A') && STREQ(name, "_kernel_flags_le_lo32"))
machdep->machspec->kernel_flags |= le32toh(value);
@ -842,7 +842,10 @@ arm64_calc_phys_offset(void)
if ((machdep->flags & NEW_VMEMMAP) &&
ms->kimage_voffset && (sp = kernel_symbol_search("memstart_addr"))) {
paddr = sp->value - machdep->machspec->kimage_voffset;
if (pc->flags & PROC_KCORE)
paddr = KCORE_USE_VADDR;
else
paddr = sp->value - machdep->machspec->kimage_voffset;
if (READMEM(pc->mfd, &phys_offset, sizeof(phys_offset),
sp->value, paddr) > 0) {
ms->phys_offset = phys_offset;

1
defs.h
View File

@ -184,6 +184,7 @@ static inline int string_exists(char *s) { return (s ? TRUE : FALSE); }
typedef uint64_t physaddr_t;
#define PADDR_NOT_AVAILABLE (0x1ULL)
#define KCORE_USE_VADDR (-1ULL)
typedef unsigned long long int ulonglong;
struct number_option {

View File

@ -1,7 +1,7 @@
/* netdump.c
*
* Copyright (C) 2002-2017 David Anderson
* Copyright (C) 2002-2017 Red Hat, Inc. All rights reserved.
* Copyright (C) 2002-2018 David Anderson
* Copyright (C) 2002-2018 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -4098,19 +4098,26 @@ read_proc_kcore(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr)
Elf64_Phdr *lp64;
off_t offset;
if (!machdep->verify_paddr(paddr)) {
if (CRASHDEBUG(1))
error(INFO, "verify_paddr(%lx) failed\n", paddr);
return READ_ERROR;
if (paddr != KCORE_USE_VADDR) {
if (!machdep->verify_paddr(paddr)) {
if (CRASHDEBUG(1))
error(INFO, "verify_paddr(%lx) failed\n", paddr);
return READ_ERROR;
}
}
/*
* Turn the physical address into a unity-mapped kernel
* virtual address, which should work for 64-bit architectures,
* and for lowmem access for 32-bit architectures.
* Unless specified otherwise, turn the physical address into
* a unity-mapped kernel virtual address, which should work
* for 64-bit architectures, and for lowmem access for 32-bit
* architectures.
*/
if (paddr == KCORE_USE_VADDR)
kvaddr = addr;
else
kvaddr = PTOV((ulong)paddr);
offset = UNINITIALIZED;
kvaddr = PTOV((ulong)paddr);
readcnt = cnt;
switch (pkd->flags & (KCORE_ELF32|KCORE_ELF64))