Blame SOURCES/github_46d21219_to_9446958f.patch

608733
commit 46d2121960d81354facf4e2558c81f82257b740e
608733
Author: Dave Anderson <anderson@redhat.com>
608733
Date:   Tue May 29 14:04:03 2018 -0400
608733
608733
    Fix for the "timer -r" command on Linux 4.10 and later kernels that
608733
    contain commit 2456e855354415bfaeb7badaa14e11b3e02c8466, titled
608733
    "ktime: Get rid of the union".  Without the patch, the command fails
608733
    with the error message "timer: invalid structure member offset:
608733
    ktime_t_sec".
608733
    (k-hagio@ab.jp.nec.com)
608733
608733
diff --git a/kernel.c b/kernel.c
608733
index b1886ce..138a47f 100644
608733
--- a/kernel.c
608733
+++ b/kernel.c
608733
@@ -7740,7 +7740,7 @@ ktime_to_ns(const void *ktime)
608733
 	if (VALID_MEMBER(ktime_t_tv64)) {
608733
 		readmem((ulong)ktime + OFFSET(ktime_t_tv64), KVADDR, &ns,
608733
 			sizeof(ns), "ktime_t tv64", QUIET|RETURN_ON_ERROR);
608733
-	} else {
608733
+	} else if (VALID_MEMBER(ktime_t_sec) && VALID_MEMBER(ktime_t_nsec)) {
608733
 		uint32_t sec, nsec;
608733
 
608733
 		sec = 0;
608733
@@ -7753,6 +7753,9 @@ ktime_to_ns(const void *ktime)
608733
 			sizeof(nsec), "ktime_t nsec", QUIET|RETURN_ON_ERROR);
608733
 
608733
 		ns = sec * 1000000000L + nsec;
608733
+	} else {
608733
+		readmem((ulong)ktime, KVADDR, &ns,
608733
+			sizeof(ns), "ktime_t", QUIET|RETURN_ON_ERROR);
608733
 	}
608733
 
608733
 	return ns;
608733
608733
commit a6cd8408d1d214a67ed0c4b09343fec77a8e2ae7
608733
Author: Dave Anderson <anderson@redhat.com>
608733
Date:   Thu May 31 11:43:14 2018 -0400
608733
608733
    Fix for the x86 and x86_64 "mach -m" option on Linux 4.12 and later
608733
    kernels to account for the structure name changes "e820map" to
608733
    "e820_table", and "e820entry" to "e820_entry", and for the symbol
608733
    name change from "e820" to "e820_table".  Also updated the display
608733
    output to properly translate E820_PRAM and E820_RESERVED_KERN entries.
608733
    Without the patch on all kernels, E820_PRAM and E820_RESERVED_KERN
608733
    entries show "type 12" and "type 128" respectively.  Without the
608733
    patch on Linux 4.12 and later kernels, the command fails with the
608733
    error message "mach: cannot resolve e820".
608733
    (anderson@redhat.com)
608733
608733
diff --git a/x86.c b/x86.c
608733
index 47767b6..88562b6 100644
608733
--- a/x86.c
608733
+++ b/x86.c
608733
@@ -1,8 +1,8 @@
608733
 /* x86.c - core analysis suite
608733
  *
608733
  * Portions Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
608733
- * Copyright (C) 2002-2014,2017 David Anderson
608733
- * Copyright (C) 2002-2014,2017 Red Hat, Inc. All rights reserved.
608733
+ * Copyright (C) 2002-2014,2017-2018 David Anderson
608733
+ * Copyright (C) 2002-2014,2017-2018 Red Hat, Inc. All rights reserved.
608733
  *
608733
  * This program is free software; you can redistribute it and/or modify
608733
  * it under the terms of the GNU General Public License as published by
608733
@@ -1967,15 +1967,27 @@ x86_init(int when)
608733
 		}
608733
 		MEMBER_OFFSET_INIT(thread_struct_cr3, "thread_struct", "cr3");
608733
 		STRUCT_SIZE_INIT(cpuinfo_x86, "cpuinfo_x86");
608733
-		STRUCT_SIZE_INIT(e820map, "e820map");
608733
-		STRUCT_SIZE_INIT(e820entry, "e820entry");
608733
 		STRUCT_SIZE_INIT(irq_ctx, "irq_ctx");
608733
+		if (STRUCT_EXISTS("e820map")) {
608733
+			STRUCT_SIZE_INIT(e820map, "e820map");
608733
+			MEMBER_OFFSET_INIT(e820map_nr_map, "e820map", "nr_map");
608733
+		} else {
608733
+			STRUCT_SIZE_INIT(e820map, "e820_table");
608733
+			MEMBER_OFFSET_INIT(e820map_nr_map, "e820_table", "nr_entries");
608733
+		}
608733
+		if (STRUCT_EXISTS("e820entry")) {
608733
+			STRUCT_SIZE_INIT(e820entry, "e820entry");
608733
+			MEMBER_OFFSET_INIT(e820entry_addr, "e820entry", "addr");
608733
+			MEMBER_OFFSET_INIT(e820entry_size, "e820entry", "size");
608733
+			MEMBER_OFFSET_INIT(e820entry_type, "e820entry", "type");
608733
+		} else {
608733
+			STRUCT_SIZE_INIT(e820entry, "e820_entry");
608733
+			MEMBER_OFFSET_INIT(e820entry_addr, "e820_entry", "addr");
608733
+			MEMBER_OFFSET_INIT(e820entry_size, "e820_entry", "size");
608733
+			MEMBER_OFFSET_INIT(e820entry_type, "e820_entry", "type");
608733
+		}
608733
 		if (!VALID_STRUCT(irq_ctx))
608733
 			STRUCT_SIZE_INIT(irq_ctx, "irq_stack");
608733
-		MEMBER_OFFSET_INIT(e820map_nr_map, "e820map", "nr_map");
608733
-		MEMBER_OFFSET_INIT(e820entry_addr, "e820entry", "addr");
608733
-		MEMBER_OFFSET_INIT(e820entry_size, "e820entry", "size");
608733
-		MEMBER_OFFSET_INIT(e820entry_type, "e820entry", "type");
608733
 		if (KVMDUMP_DUMPFILE())
608733
 			set_kvm_iohole(NULL);
608733
 		if (symbol_exists("irq_desc"))
608733
@@ -4415,33 +4427,54 @@ static char *e820type[] = {
608733
 static void
608733
 x86_display_memmap(void)
608733
 {
608733
-	ulong e820;
608733
-	int nr_map, i;
608733
-	char *buf, *e820entry_ptr;
608733
-	ulonglong addr, size;
608733
-	ulong type;
608733
+        ulong e820;
608733
+        int nr_map, i;
608733
+        char *buf, *e820entry_ptr;
608733
+        ulonglong addr, size;
608733
+        uint type;
608733
+
608733
+	if (kernel_symbol_exists("e820")) {
608733
+		if (get_symbol_type("e820", NULL, NULL) == TYPE_CODE_PTR)
608733
+			get_symbol_data("e820", sizeof(void *), &e820);
608733
+		else
608733
+			e820 = symbol_value("e820");
608733
+
608733
+	} else if (kernel_symbol_exists("e820_table"))
608733
+		get_symbol_data("e820_table", sizeof(void *), &e820);
608733
+	else
608733
+		error(FATAL, "neither e820 or e820_table symbols exist\n");
608733
 
608733
-	e820 = symbol_value("e820");
608733
-	buf = (char *)GETBUF(SIZE(e820map));
608733
+	if (CRASHDEBUG(1)) {
608733
+		if (STRUCT_EXISTS("e820map"))
608733
+			dump_struct("e820map", e820, RADIX(16));
608733
+		else if (STRUCT_EXISTS("e820_table"))
608733
+			dump_struct("e820_table", e820, RADIX(16));
608733
+	}
608733
+        buf = (char *)GETBUF(SIZE(e820map));
608733
 
608733
-        readmem(e820, KVADDR, &buf[0], SIZE(e820map), 
608733
-		"e820map", FAULT_ON_ERROR);
608733
+        readmem(e820, KVADDR, &buf[0], SIZE(e820map),
608733
+                "e820map", FAULT_ON_ERROR);
608733
 
608733
-	nr_map = INT(buf + OFFSET(e820map_nr_map));
608733
+        nr_map = INT(buf + OFFSET(e820map_nr_map));
608733
 
608733
-	fprintf(fp, "      PHYSICAL ADDRESS RANGE         TYPE\n");
608733
+        fprintf(fp, "      PHYSICAL ADDRESS RANGE         TYPE\n");
608733
 
608733
-	for (i = 0; i < nr_map; i++) {
608733
-		e820entry_ptr = buf + sizeof(int) + (SIZE(e820entry) * i);
608733
-		addr = ULONGLONG(e820entry_ptr + OFFSET(e820entry_addr));
608733
-		size = ULONGLONG(e820entry_ptr + OFFSET(e820entry_size));
608733
-		type = ULONG(e820entry_ptr + OFFSET(e820entry_type));
608733
+        for (i = 0; i < nr_map; i++) {
608733
+                e820entry_ptr = buf + sizeof(int) + (SIZE(e820entry) * i);
608733
+                addr = ULONGLONG(e820entry_ptr + OFFSET(e820entry_addr));
608733
+                size = ULONGLONG(e820entry_ptr + OFFSET(e820entry_size));
608733
+                type = UINT(e820entry_ptr + OFFSET(e820entry_type));
608733
 		fprintf(fp, "%016llx - %016llx  ", addr, addr+size);
608733
-		if (type >= (sizeof(e820type)/sizeof(char *)))
608733
-			fprintf(fp, "type %ld\n", type);
608733
-		else
608733
+		if (type >= (sizeof(e820type)/sizeof(char *))) {
608733
+			if (type == 12)
608733
+				fprintf(fp, "E820_PRAM\n");
608733
+			else if (type == 128)
608733
+				fprintf(fp, "E820_RESERVED_KERN\n");
608733
+			else
608733
+				fprintf(fp, "type %d\n", type);
608733
+		} else
608733
 			fprintf(fp, "%s\n", e820type[type]);
608733
-	}
608733
+        }
608733
 }
608733
 
608733
 /*
608733
diff --git a/x86_64.c b/x86_64.c
608733
index 921552b..1d5e155 100644
608733
--- a/x86_64.c
608733
+++ b/x86_64.c
608733
@@ -415,12 +415,26 @@ x86_64_init(int when)
608733
 			STRUCT_SIZE_INIT(gate_struct, "gate_desc");
608733
 		else
608733
 			STRUCT_SIZE_INIT(gate_struct, "gate_struct");
608733
-                STRUCT_SIZE_INIT(e820map, "e820map");
608733
-                STRUCT_SIZE_INIT(e820entry, "e820entry");
608733
-                MEMBER_OFFSET_INIT(e820map_nr_map, "e820map", "nr_map");
608733
-                MEMBER_OFFSET_INIT(e820entry_addr, "e820entry", "addr");
608733
-                MEMBER_OFFSET_INIT(e820entry_size, "e820entry", "size");
608733
-                MEMBER_OFFSET_INIT(e820entry_type, "e820entry", "type");
608733
+
608733
+		if (STRUCT_EXISTS("e820map")) {
608733
+			STRUCT_SIZE_INIT(e820map, "e820map");
608733
+			MEMBER_OFFSET_INIT(e820map_nr_map, "e820map", "nr_map");
608733
+		} else {
608733
+			STRUCT_SIZE_INIT(e820map, "e820_table");
608733
+			MEMBER_OFFSET_INIT(e820map_nr_map, "e820_table", "nr_entries");
608733
+		}
608733
+		if (STRUCT_EXISTS("e820entry")) {
608733
+			STRUCT_SIZE_INIT(e820entry, "e820entry");
608733
+			MEMBER_OFFSET_INIT(e820entry_addr, "e820entry", "addr");
608733
+			MEMBER_OFFSET_INIT(e820entry_size, "e820entry", "size");
608733
+			MEMBER_OFFSET_INIT(e820entry_type, "e820entry", "type");
608733
+		} else {
608733
+			STRUCT_SIZE_INIT(e820entry, "e820_entry");
608733
+			MEMBER_OFFSET_INIT(e820entry_addr, "e820_entry", "addr");
608733
+			MEMBER_OFFSET_INIT(e820entry_size, "e820_entry", "size");
608733
+			MEMBER_OFFSET_INIT(e820entry_type, "e820_entry", "type");
608733
+		}
608733
+
608733
 		if (KVMDUMP_DUMPFILE())
608733
 			set_kvm_iohole(NULL);
608733
 		MEMBER_OFFSET_INIT(thread_struct_rip, "thread_struct", "rip");
608733
@@ -5643,12 +5657,23 @@ x86_64_display_memmap(void)
608733
         ulonglong addr, size;
608733
         uint type;
608733
 
608733
-	if (get_symbol_type("e820", NULL, NULL) == TYPE_CODE_PTR)
608733
-		get_symbol_data("e820", sizeof(void *), &e820);
608733
+	if (kernel_symbol_exists("e820")) {
608733
+		if (get_symbol_type("e820", NULL, NULL) == TYPE_CODE_PTR)
608733
+			get_symbol_data("e820", sizeof(void *), &e820);
608733
+		else
608733
+			e820 = symbol_value("e820");
608733
+
608733
+	} else if (kernel_symbol_exists("e820_table"))
608733
+		get_symbol_data("e820_table", sizeof(void *), &e820);
608733
 	else
608733
-		e820 = symbol_value("e820");
608733
-	if (CRASHDEBUG(1))
608733
-		dump_struct("e820map", e820, RADIX(16));
608733
+		error(FATAL, "neither e820 or e820_table symbols exist\n");
608733
+
608733
+	if (CRASHDEBUG(1)) {
608733
+		if (STRUCT_EXISTS("e820map"))
608733
+			dump_struct("e820map", e820, RADIX(16));
608733
+		else if (STRUCT_EXISTS("e820_table"))
608733
+			dump_struct("e820_table", e820, RADIX(16));
608733
+	}
608733
         buf = (char *)GETBUF(SIZE(e820map));
608733
 
608733
         readmem(e820, KVADDR, &buf[0], SIZE(e820map),
608733
@@ -5664,9 +5689,14 @@ x86_64_display_memmap(void)
608733
                 size = ULONGLONG(e820entry_ptr + OFFSET(e820entry_size));
608733
                 type = UINT(e820entry_ptr + OFFSET(e820entry_type));
608733
 		fprintf(fp, "%016llx - %016llx  ", addr, addr+size);
608733
-		if (type >= (sizeof(e820type)/sizeof(char *)))
608733
-			fprintf(fp, "type %d\n", type);
608733
-		else
608733
+		if (type >= (sizeof(e820type)/sizeof(char *))) {
608733
+			if (type == 12)
608733
+				fprintf(fp, "E820_PRAM\n");
608733
+			else if (type == 128)
608733
+				fprintf(fp, "E820_RESERVED_KERN\n");
608733
+			else
608733
+				fprintf(fp, "type %d\n", type);
608733
+		} else
608733
 			fprintf(fp, "%s\n", e820type[type]);
608733
         }
608733
 }
608733
608733
commit da49e2010b3cb88b4755d69d38fe90af6ba218b2
608733
Author: Dave Anderson <anderson@redhat.com>
608733
Date:   Fri Jun 1 10:58:00 2018 -0400
608733
608733
    Update for the recognition of the new x86_64 CPU_ENTRY_AREA virtual
608733
    address range introduced in Linux 4.15.  The memory range exists
608733
    above the vmemmap range and below the mapped kernel static text/data
608733
    region, and where all of the x86_64 exception stacks have been moved.
608733
    Without the patch, reads from the new memory region fail because the
608733
    address range is not recognized as a legitimate virtual address.
608733
    Most notable is the failure of "bt" on tasks whose backtraces
608733
    originate from any of the exception stacks, which fail with the two
608733
    error messages "bt: seek error: kernel virtual address: <address>
608733
    type: stack contents" followed by "bt: read of stack at <address>
608733
    failed".
608733
    (anderson@redhat.com)
608733
608733
diff --git a/defs.h b/defs.h
608733
index 931be07..6e6f6be 100644
608733
--- a/defs.h
608733
+++ b/defs.h
608733
@@ -3391,6 +3391,9 @@ struct arm64_stackframe {
608733
 #define VSYSCALL_START             0xffffffffff600000
608733
 #define VSYSCALL_END               0xffffffffff601000
608733
 
608733
+#define CPU_ENTRY_AREA_START       0xfffffe0000000000
608733
+#define CPU_ENTRY_AREA_END         0xfffffe7fffffffff
608733
+
608733
 #define PTOV(X)               ((unsigned long)(X)+(machdep->kvbase))
608733
 #define VTOP(X)               x86_64_VTOP((ulong)(X))
608733
 #define IS_VMALLOC_ADDR(X)    x86_64_IS_VMALLOC_ADDR((ulong)(X))
608733
@@ -5829,6 +5832,8 @@ struct machine_specific {
608733
 	ulong kpti_entry_stack;
608733
 	ulong kpti_entry_stack_size;
608733
 	ulong ptrs_per_pgd;
608733
+	ulong cpu_entry_area_start;
608733
+	ulong cpu_entry_area_end;
608733
 };
608733
 
608733
 #define KSYMS_START    (0x1)
608733
diff --git a/x86_64.c b/x86_64.c
608733
index 1d5e155..54b6539 100644
608733
--- a/x86_64.c
608733
+++ b/x86_64.c
608733
@@ -407,6 +407,11 @@ x86_64_init(int when)
608733
 				machdep->machspec->modules_end = MODULES_END_2_6_31;
608733
 			}
608733
 		}
608733
+		if (STRUCT_EXISTS("cpu_entry_area")) {
608733
+			machdep->machspec->cpu_entry_area_start = CPU_ENTRY_AREA_START;	
608733
+			machdep->machspec->cpu_entry_area_end = CPU_ENTRY_AREA_END;	
608733
+		}
608733
+
608733
                 STRUCT_SIZE_INIT(cpuinfo_x86, "cpuinfo_x86");
608733
 		/* 
608733
 		 * Before 2.6.25 the structure was called gate_struct
608733
@@ -879,20 +884,21 @@ x86_64_dump_machdep_table(ulong arg)
608733
 
608733
 	/* pml4 and upml is legacy for extension modules */
608733
 	if (ms->pml4) {
608733
-		fprintf(fp, "			  pml4: %lx\n", (ulong)ms->pml4);
608733
-		fprintf(fp, "		last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
608733
+		fprintf(fp, "                     pml4: %lx\n", (ulong)ms->pml4);
608733
+		fprintf(fp, "           last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
608733
 
608733
 	} else {
608733
-		fprintf(fp, "		      pml4: (unused)\n");
608733
-		fprintf(fp, "	    last_pml4_read: (unused)\n");
608733
+		fprintf(fp, "                     pml4: (unused)\n");
608733
+		fprintf(fp, "           last_pml4_read: (unused)\n");
608733
 	}
608733
 
608733
 	if (ms->upml) {
608733
-		fprintf(fp, "		      upml: %lx\n", (ulong)ms->upml);
608733
-		fprintf(fp, "	    last_upml_read: %lx\n", (ulong)ms->last_upml_read);
608733
+		fprintf(fp, "                     upml: %lx\n", (ulong)ms->upml);
608733
+		fprintf(fp, "           last_upml_read: %lx\n", (ulong)ms->last_upml_read);
608733
 	} else {
608733
-		fprintf(fp, "		      upml: (unused)\n");
608733
-		fprintf(fp, "	    last_upml_read: (unused)\n");
608733
+		fprintf(fp, "                 GART_end: %lx\n", ms->GART_end);
608733
+		fprintf(fp, "                     upml: (unused)\n");
608733
+		fprintf(fp, "           last_upml_read: (unused)\n");
608733
 	}
608733
 
608733
 	if (ms->p4d) {
608733
@@ -1016,10 +1022,14 @@ x86_64_dump_machdep_table(ulong arg)
608733
 			fprintf(fp, "\n   ");
608733
 		fprintf(fp, "%016lx ", ms->stkinfo.ibase[c]);
608733
 	}
608733
-	fprintf(fp, "\n                 kpti_entry_stack_size: %ld", ms->kpti_entry_stack_size);
608733
-	fprintf(fp, "\n                      kpti_entry_stack: ");
608733
+	fprintf(fp, "\n    kpti_entry_stack_size: ");
608733
+	if (ms->kpti_entry_stack_size)
608733
+		fprintf(fp, "%ld", ms->kpti_entry_stack_size);
608733
+	else
608733
+		fprintf(fp, "(unused)");
608733
+	fprintf(fp, "\n         kpti_entry_stack: ");
608733
 	if (machdep->flags & KPTI) {
608733
-		fprintf(fp, "%lx\n   ", ms->kpti_entry_stack);
608733
+		fprintf(fp, "(percpu: %lx):\n   ", ms->kpti_entry_stack);
608733
 		for (c = 0; c < cpus; c++) {
608733
 			if (c && !(c%4))
608733
 				fprintf(fp, "\n   ");
608733
@@ -1028,6 +1038,16 @@ x86_64_dump_machdep_table(ulong arg)
608733
 		fprintf(fp, "\n");
608733
 	} else
608733
 		fprintf(fp, "(unused)\n");
608733
+	fprintf(fp, "     cpu_entry_area_start: ");
608733
+	if (ms->cpu_entry_area_start)
608733
+		fprintf(fp, "%016lx\n", (ulong)ms->cpu_entry_area_start);
608733
+	else
608733
+		fprintf(fp, "(unused)\n");
608733
+	fprintf(fp, "       cpu_entry_area_end: ");
608733
+	if (ms->cpu_entry_area_end)
608733
+		fprintf(fp, "%016lx\n", (ulong)ms->cpu_entry_area_end);
608733
+	else
608733
+		fprintf(fp, "(unused)\n");
608733
 }
608733
 
608733
 /*
608733
@@ -1586,7 +1606,10 @@ x86_64_IS_VMALLOC_ADDR(ulong vaddr)
608733
                 ((machdep->flags & VMEMMAP) && 
608733
 		 (vaddr >= VMEMMAP_VADDR && vaddr <= VMEMMAP_END)) ||
608733
                 (vaddr >= MODULES_VADDR && vaddr <= MODULES_END) ||
608733
-		(vaddr >= VSYSCALL_START && vaddr < VSYSCALL_END));
608733
+		(vaddr >= VSYSCALL_START && vaddr < VSYSCALL_END) ||
608733
+		(machdep->machspec->cpu_entry_area_start && 
608733
+		 vaddr >= machdep->machspec->cpu_entry_area_start &&
608733
+		 vaddr <= machdep->machspec->cpu_entry_area_end));
608733
 }
608733
 
608733
 static int 
608733
608733
commit 9446958fe211825ed5524317b05d5ea020bb00d6
608733
Author: Dave Anderson <anderson@redhat.com>
608733
Date:   Fri Jun 1 14:01:01 2018 -0400
608733
608733
    Fix to address a "__builtin___snprintf_chk" compiler warning if bpf.c
608733
    is compiled with -D_FORTIFY_SOURCE=2.
608733
    (anderson@redhat.com)
608733
608733
diff --git a/bpf.c b/bpf.c
608733
index 305d49f..ee1986f 100644
608733
--- a/bpf.c
608733
+++ b/bpf.c
608733
@@ -362,7 +362,7 @@ do_bpf(ulong flags, ulong prog_id, ulong map_id, int radix)
608733
 			fprintf(fp, "     LOAD_TIME: ");
608733
 			if (VALID_MEMBER(bpf_prog_aux_load_time)) {
608733
 				load_time = ULONGLONG(bpf->bpf_prog_aux_buf + OFFSET(bpf_prog_aux_load_time));
608733
-				print_boot_time(load_time, buf5, BUFSIZE);
608733
+				print_boot_time(load_time, buf5, BUFSIZE/2);
608733
 				fprintf(fp, "%s\n", buf5);
608733
 			} else
608733
 				fprintf(fp, "(unknown)\n");