Blame SOURCES/github_b9d76838_c79a11fa_proc_kcore.patch

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