Blame SOURCES/github_da49e201_cpu_entry_area.patch

01fc30
commit da49e2010b3cb88b4755d69d38fe90af6ba218b2
01fc30
Author: Dave Anderson <anderson@redhat.com>
01fc30
Date:   Fri Jun 1 10:58:00 2018 -0400
01fc30
01fc30
    Update for the recognition of the new x86_64 CPU_ENTRY_AREA virtual
01fc30
    address range introduced in Linux 4.15.  The memory range exists
01fc30
    above the vmemmap range and below the mapped kernel static text/data
01fc30
    region, and where all of the x86_64 exception stacks have been moved.
01fc30
    Without the patch, reads from the new memory region fail because the
01fc30
    address range is not recognized as a legitimate virtual address.
01fc30
    Most notable is the failure of "bt" on tasks whose backtraces
01fc30
    originate from any of the exception stacks, which fail with the two
01fc30
    error messages "bt: seek error: kernel virtual address: <address>
01fc30
    type: stack contents" followed by "bt: read of stack at <address>
01fc30
    failed".
01fc30
    (anderson@redhat.com)
01fc30
01fc30
diff --git a/defs.h b/defs.h
01fc30
index 931be07..6e6f6be 100644
01fc30
--- a/defs.h
01fc30
+++ b/defs.h
01fc30
@@ -3391,6 +3391,9 @@ struct arm64_stackframe {
01fc30
 #define VSYSCALL_START             0xffffffffff600000
01fc30
 #define VSYSCALL_END               0xffffffffff601000
01fc30
 
01fc30
+#define CPU_ENTRY_AREA_START       0xfffffe0000000000
01fc30
+#define CPU_ENTRY_AREA_END         0xfffffe7fffffffff
01fc30
+
01fc30
 #define PTOV(X)               ((unsigned long)(X)+(machdep->kvbase))
01fc30
 #define VTOP(X)               x86_64_VTOP((ulong)(X))
01fc30
 #define IS_VMALLOC_ADDR(X)    x86_64_IS_VMALLOC_ADDR((ulong)(X))
01fc30
@@ -5829,6 +5832,8 @@ struct machine_specific {
01fc30
 	ulong kpti_entry_stack;
01fc30
 	ulong kpti_entry_stack_size;
01fc30
 	ulong ptrs_per_pgd;
01fc30
+	ulong cpu_entry_area_start;
01fc30
+	ulong cpu_entry_area_end;
01fc30
 };
01fc30
 
01fc30
 #define KSYMS_START    (0x1)
01fc30
diff --git a/x86_64.c b/x86_64.c
01fc30
index 1d5e155..54b6539 100644
01fc30
--- a/x86_64.c
01fc30
+++ b/x86_64.c
01fc30
@@ -407,6 +407,11 @@ x86_64_init(int when)
01fc30
 				machdep->machspec->modules_end = MODULES_END_2_6_31;
01fc30
 			}
01fc30
 		}
01fc30
+		if (STRUCT_EXISTS("cpu_entry_area")) {
01fc30
+			machdep->machspec->cpu_entry_area_start = CPU_ENTRY_AREA_START;	
01fc30
+			machdep->machspec->cpu_entry_area_end = CPU_ENTRY_AREA_END;	
01fc30
+		}
01fc30
+
01fc30
                 STRUCT_SIZE_INIT(cpuinfo_x86, "cpuinfo_x86");
01fc30
 		/* 
01fc30
 		 * Before 2.6.25 the structure was called gate_struct
01fc30
@@ -879,20 +884,21 @@ x86_64_dump_machdep_table(ulong arg)
01fc30
 
01fc30
 	/* pml4 and upml is legacy for extension modules */
01fc30
 	if (ms->pml4) {
01fc30
-		fprintf(fp, "			  pml4: %lx\n", (ulong)ms->pml4);
01fc30
-		fprintf(fp, "		last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
01fc30
+		fprintf(fp, "                     pml4: %lx\n", (ulong)ms->pml4);
01fc30
+		fprintf(fp, "           last_pml4_read: %lx\n", (ulong)ms->last_pml4_read);
01fc30
 
01fc30
 	} else {
01fc30
-		fprintf(fp, "		      pml4: (unused)\n");
01fc30
-		fprintf(fp, "	    last_pml4_read: (unused)\n");
01fc30
+		fprintf(fp, "                     pml4: (unused)\n");
01fc30
+		fprintf(fp, "           last_pml4_read: (unused)\n");
01fc30
 	}
01fc30
 
01fc30
 	if (ms->upml) {
01fc30
-		fprintf(fp, "		      upml: %lx\n", (ulong)ms->upml);
01fc30
-		fprintf(fp, "	    last_upml_read: %lx\n", (ulong)ms->last_upml_read);
01fc30
+		fprintf(fp, "                     upml: %lx\n", (ulong)ms->upml);
01fc30
+		fprintf(fp, "           last_upml_read: %lx\n", (ulong)ms->last_upml_read);
01fc30
 	} else {
01fc30
-		fprintf(fp, "		      upml: (unused)\n");
01fc30
-		fprintf(fp, "	    last_upml_read: (unused)\n");
01fc30
+		fprintf(fp, "                 GART_end: %lx\n", ms->GART_end);
01fc30
+		fprintf(fp, "                     upml: (unused)\n");
01fc30
+		fprintf(fp, "           last_upml_read: (unused)\n");
01fc30
 	}
01fc30
 
01fc30
 	if (ms->p4d) {
01fc30
@@ -1016,10 +1022,14 @@ x86_64_dump_machdep_table(ulong arg)
01fc30
 			fprintf(fp, "\n   ");
01fc30
 		fprintf(fp, "%016lx ", ms->stkinfo.ibase[c]);
01fc30
 	}
01fc30
-	fprintf(fp, "\n                 kpti_entry_stack_size: %ld", ms->kpti_entry_stack_size);
01fc30
-	fprintf(fp, "\n                      kpti_entry_stack: ");
01fc30
+	fprintf(fp, "\n    kpti_entry_stack_size: ");
01fc30
+	if (ms->kpti_entry_stack_size)
01fc30
+		fprintf(fp, "%ld", ms->kpti_entry_stack_size);
01fc30
+	else
01fc30
+		fprintf(fp, "(unused)");
01fc30
+	fprintf(fp, "\n         kpti_entry_stack: ");
01fc30
 	if (machdep->flags & KPTI) {
01fc30
-		fprintf(fp, "%lx\n   ", ms->kpti_entry_stack);
01fc30
+		fprintf(fp, "(percpu: %lx):\n   ", ms->kpti_entry_stack);
01fc30
 		for (c = 0; c < cpus; c++) {
01fc30
 			if (c && !(c%4))
01fc30
 				fprintf(fp, "\n   ");
01fc30
@@ -1028,6 +1038,16 @@ x86_64_dump_machdep_table(ulong arg)
01fc30
 		fprintf(fp, "\n");
01fc30
 	} else
01fc30
 		fprintf(fp, "(unused)\n");
01fc30
+	fprintf(fp, "     cpu_entry_area_start: ");
01fc30
+	if (ms->cpu_entry_area_start)
01fc30
+		fprintf(fp, "%016lx\n", (ulong)ms->cpu_entry_area_start);
01fc30
+	else
01fc30
+		fprintf(fp, "(unused)\n");
01fc30
+	fprintf(fp, "       cpu_entry_area_end: ");
01fc30
+	if (ms->cpu_entry_area_end)
01fc30
+		fprintf(fp, "%016lx\n", (ulong)ms->cpu_entry_area_end);
01fc30
+	else
01fc30
+		fprintf(fp, "(unused)\n");
01fc30
 }
01fc30
 
01fc30
 /*
01fc30
@@ -1586,7 +1606,10 @@ x86_64_IS_VMALLOC_ADDR(ulong vaddr)
01fc30
                 ((machdep->flags & VMEMMAP) && 
01fc30
 		 (vaddr >= VMEMMAP_VADDR && vaddr <= VMEMMAP_END)) ||
01fc30
                 (vaddr >= MODULES_VADDR && vaddr <= MODULES_END) ||
01fc30
-		(vaddr >= VSYSCALL_START && vaddr < VSYSCALL_END));
01fc30
+		(vaddr >= VSYSCALL_START && vaddr < VSYSCALL_END) ||
01fc30
+		(machdep->machspec->cpu_entry_area_start && 
01fc30
+		 vaddr >= machdep->machspec->cpu_entry_area_start &&
01fc30
+		 vaddr <= machdep->machspec->cpu_entry_area_end));
01fc30
 }
01fc30
 
01fc30
 static int