01fc30
commit b9d76838372d1b4087bb506ce6da425afad68876
01fc30
Author: Dave Anderson <anderson@redhat.com>
01fc30
Date:   Thu Jun 7 13:20:16 2018 -0400
01fc30
01fc30
    If /proc/kcore gets selected for the live memory source because
01fc30
    /dev/mem was configured with CONFIG_STRICT_DEVMEM, its ELF header
01fc30
    contents are not displayed by "help -[dD]", and are not displayed
01fc30
    when the crash session is invoked with -d<number>".  Without the
01fc30
    patch, the ELF contents are only displayed in those two situations
01fc30
    if "/proc/kcore" is explicitly entered on the crash command line.
01fc30
    (anderson@redhat.com)
01fc30
01fc30
diff --git a/netdump.c b/netdump.c
01fc30
index 25683eb..1f3e26c 100644
01fc30
--- a/netdump.c
01fc30
+++ b/netdump.c
01fc30
@@ -4334,11 +4334,8 @@ kcore_memory_dump(FILE *ofp)
01fc30
 	Elf32_Phdr *lp32;
01fc30
 	Elf64_Phdr *lp64;
01fc30
 
01fc30
-	if (!(pkd->flags & KCORE_LOCAL))
01fc30
-		return FALSE;
01fc30
-
01fc30
 	fprintf(ofp, "proc_kcore_data:\n");
01fc30
-	fprintf(ofp, "       flags: %lx (", nd->flags);
01fc30
+	fprintf(ofp, "       flags: %x (", pkd->flags);
01fc30
 	others = 0;
01fc30
 	if (pkd->flags & KCORE_LOCAL)
01fc30
 		fprintf(ofp, "%sKCORE_LOCAL", others++ ? "|" : "");
01fc30
commit c79a11fa10da94b71ddf341ec996c522fbd75237
01fc30
Author: Dave Anderson <anderson@redhat.com>
01fc30
Date:   Fri Jun 8 14:31:08 2018 -0400
01fc30
01fc30
    If the default live memory source /dev/mem is determined to be
01fc30
    unusable because the kernel was configured with CONFIG_STRICT_DEVMEM,
01fc30
    the first memory read during session initialization will fail.  The
01fc30
    current behavior results in a readmem() error message, followed by two
01fc30
    notification messages that indicate that /dev/mem is restricted and
01fc30
    a switch to using /proc/kcore will be attempted; the readmem is
01fc30
    reattempted from /proc/kcore, and if successful, the session will
01fc30
    continue initialization.  With this patch, the behavior will change
01fc30
    such that if the switch to /proc/kcore and the reattempted readmem()
01fc30
    are successful, no messages will be displayed unless the crash
01fc30
    session is invoked with "crash -d<number>".
01fc30
    (anderson@redhat.com)
01fc30
01fc30
diff --git a/kernel.c b/kernel.c
01fc30
index 138a47f..3cd5bf1 100644
01fc30
--- a/kernel.c
01fc30
+++ b/kernel.c
01fc30
@@ -882,7 +882,7 @@ cpu_maps_init(void)
01fc30
 {
01fc30
         int i, c, m, cpu, len;
01fc30
         char *buf;
01fc30
-        ulong *maskptr, addr;
01fc30
+        ulong *maskptr, addr, error_handle;
01fc30
 	struct mapinfo {
01fc30
 		ulong cpu_flag;
01fc30
 		char *name;
01fc30
@@ -902,8 +902,9 @@ cpu_maps_init(void)
01fc30
 		if (!(addr = cpu_map_addr(mapinfo[m].name)))
01fc30
 			continue;
01fc30
 
01fc30
+		error_handle = pc->flags & DEVMEM ? RETURN_ON_ERROR|QUIET : RETURN_ON_ERROR;
01fc30
 		if (!readmem(addr, KVADDR, buf, len,
01fc30
-		    mapinfo[m].name, RETURN_ON_ERROR)) {
01fc30
+		    mapinfo[m].name, error_handle)) {
01fc30
 			error(WARNING, "cannot read cpu_%s_map\n",
01fc30
 			      mapinfo[m].name);
01fc30
 			continue;
01fc30
diff --git a/memory.c b/memory.c
01fc30
index 82f9cbf..2f568d5 100644
01fc30
--- a/memory.c
01fc30
+++ b/memory.c
01fc30
@@ -2243,9 +2243,11 @@ readmem(ulonglong addr, int memtype, void *buffer, long size,
01fc30
 				error(INFO, READ_ERRMSG, memtype_string(memtype, 0), addr, type);
01fc30
 			if ((pc->flags & DEVMEM) && (kt->flags & PRE_KERNEL_INIT) &&
01fc30
 			    !(error_handle & NO_DEVMEM_SWITCH) && devmem_is_restricted() && 
01fc30
-			    switch_to_proc_kcore())
01fc30
+			    switch_to_proc_kcore()) {
01fc30
+				error_handle &= ~QUIET;
01fc30
 				return(readmem(addr, memtype, bufptr, size,
01fc30
 					type, error_handle));
01fc30
+			}
01fc30
 			goto readmem_error;
01fc30
 
01fc30
 		case PAGE_EXCLUDED:
01fc30
@@ -2457,7 +2459,7 @@ devmem_is_restricted(void)
01fc30
 		    QUIET|RETURN_ON_ERROR|NO_DEVMEM_SWITCH))
01fc30
 			restricted = TRUE;
01fc30
 
01fc30
-		if (restricted)
01fc30
+		if (restricted && CRASHDEBUG(1))
01fc30
 			error(INFO, 
01fc30
  	    		    "this kernel may be configured with CONFIG_STRICT_DEVMEM,"
01fc30
 			    " which\n       renders /dev/mem unusable as a live memory "
01fc30
@@ -2472,9 +2474,10 @@ switch_to_proc_kcore(void)
01fc30
 {
01fc30
 	close(pc->mfd);
01fc30
 
01fc30
-	if (file_exists("/proc/kcore", NULL))
01fc30
-		error(INFO, "trying /proc/kcore as an alternative to /dev/mem\n\n");
01fc30
-	else
01fc30
+	if (file_exists("/proc/kcore", NULL)) {
01fc30
+		if (CRASHDEBUG(1))
01fc30
+			error(INFO, "trying /proc/kcore as an alternative to /dev/mem\n\n");
01fc30
+	} else
01fc30
 		return FALSE;
01fc30
 
01fc30
 	if ((pc->mfd = open("/proc/kcore", O_RDONLY)) < 0) {
01fc30
diff --git a/ppc64.c b/ppc64.c
01fc30
index 0b04187..0dd8a2a 100644
01fc30
--- a/ppc64.c
01fc30
+++ b/ppc64.c
01fc30
@@ -1,7 +1,7 @@
01fc30
 /* ppc64.c -- core analysis suite
01fc30
  *
01fc30
- * Copyright (C) 2004-2015,2017 David Anderson
01fc30
- * Copyright (C) 2004-2015,2017 Red Hat, Inc. All rights reserved.
01fc30
+ * Copyright (C) 2004-2015,2018 David Anderson
01fc30
+ * Copyright (C) 2004-2015,2018 Red Hat, Inc. All rights reserved.
01fc30
  * Copyright (C) 2004, 2006 Haren Myneni, IBM Corporation
01fc30
  *
01fc30
  * This program is free software; you can redistribute it and/or modify
01fc30
@@ -343,8 +343,9 @@ ppc64_init(int when)
01fc30
 
01fc30
 		if (symbol_exists("vmemmap_populate")) {
01fc30
 			if (symbol_exists("vmemmap")) {
01fc30
-				get_symbol_data("vmemmap", sizeof(void *),
01fc30
-					&machdep->machspec->vmemmap_base);
01fc30
+				readmem(symbol_value("vmemmap"), KVADDR,
01fc30
+					&machdep->machspec->vmemmap_base,
01fc30
+					sizeof(void *), "vmemmap", QUIET|FAULT_ON_ERROR);
01fc30
 			} else
01fc30
 				machdep->machspec->vmemmap_base =
01fc30
 					VMEMMAP_REGION_ID << REGION_SHIFT;
01fc30
diff --git a/x86_64.c b/x86_64.c
01fc30
index 54b6539..e01082b 100644
01fc30
--- a/x86_64.c
01fc30
+++ b/x86_64.c
01fc30
@@ -356,7 +356,7 @@ x86_64_init(int when)
01fc30
 			machdep->flags |= RANDOMIZED;
01fc30
 			readmem(symbol_value("page_offset_base"), KVADDR,
01fc30
 				&machdep->machspec->page_offset, sizeof(ulong),
01fc30
-				"page_offset_base", FAULT_ON_ERROR);
01fc30
+				"page_offset_base", QUIET|FAULT_ON_ERROR);
01fc30
 			machdep->kvbase = machdep->machspec->page_offset;
01fc30
 			machdep->identity_map_base = machdep->machspec->page_offset;
01fc30
 		}