Blame SOURCES/github_da49e201_cpu_entry_area.patch

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