Blob Blame History Raw
From c0a5360613cc83131f2ce478e2a81e1e92b270f6 Mon Sep 17 00:00:00 2001
From: Jessica Yu <ppyu@suse.com>
Date: Wed, 16 May 2018 15:05:53 +0200
Subject: [PATCH] x86/cpu_entry_area: Map also trace_idt_table
Patch-mainline: Never, substitutes removal of tracing idt in v4.14-rc1
References: bsc#1089878

From: Petr Mladek <pmladek@suse.com>

Also trace_idt_table need the extra mapping. The table points to
special variants of interrupt handlers that support tracepoints.

Note that it was not needed upstream. These special variants were
removed in v4.14-rc1 as part of a big clean up. See
https://lkml.kernel.org/r/20170828064715.802987421@linutronix.de.

Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Jessica Yu <ppyu@suse.com>
---
 arch/x86/include/asm/cpu_entry_area.h   | 4 +++-
 arch/x86/include/asm/pgtable_32_types.h | 3 ++-
 arch/x86/kernel/traps.c                 | 6 ++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/cpu_entry_area.h b/arch/x86/include/asm/cpu_entry_area.h
index 4a7884b8dca5..d19a1823e554 100644
--- a/arch/x86/include/asm/cpu_entry_area.h
+++ b/arch/x86/include/asm/cpu_entry_area.h
@@ -64,9 +64,11 @@ extern void setup_cpu_entry_areas(void);
 extern void cea_set_pte(void *cea_vaddr, phys_addr_t pa, pgprot_t flags);
 
 #define	CPU_ENTRY_AREA_RO_IDT		CPU_ENTRY_AREA_BASE
-#define CPU_ENTRY_AREA_PER_CPU		(CPU_ENTRY_AREA_RO_IDT + PAGE_SIZE)
+#define CPU_ENTRY_AREA_RO_TRACE_IDT	(CPU_ENTRY_AREA_RO_IDT + PAGE_SIZE)
+#define CPU_ENTRY_AREA_PER_CPU		(CPU_ENTRY_AREA_RO_IDT + 2 * PAGE_SIZE)
 
 #define CPU_ENTRY_AREA_RO_IDT_VADDR	((void *)CPU_ENTRY_AREA_RO_IDT)
+#define CPU_ENTRY_AREA_RO_TRACE_IDT_VADDR ((void *)CPU_ENTRY_AREA_RO_TRACE_IDT)
 
 #define CPU_ENTRY_AREA_MAP_SIZE			\
 	(CPU_ENTRY_AREA_PER_CPU + CPU_ENTRY_AREA_TOT_SIZE - CPU_ENTRY_AREA_BASE)
diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
index 67b60e11b70d..d2046a3b3f03 100644
--- a/arch/x86/include/asm/pgtable_32_types.h
+++ b/arch/x86/include/asm/pgtable_32_types.h
@@ -43,8 +43,9 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
  */
 #define CPU_ENTRY_AREA_PAGES	(NR_CPUS * 40)
 
+/* The extra 2 pages are for idt_table and trace_idt_table. */
 #define CPU_ENTRY_AREA_BASE				\
-	((FIXADDR_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) & PMD_MASK)
+	((FIXADDR_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 2)) & PMD_MASK)
 
 #define PKMAP_BASE		\
 	((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a21ec5727315..66746cbdd105 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -1042,6 +1042,12 @@ void __init trap_init(void)
 		    PAGE_KERNEL_RO);
 	idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
 
+#ifdef CONFIG_TRACING
+	cea_set_pte(CPU_ENTRY_AREA_RO_TRACE_IDT_VADDR, __pa_symbol(trace_idt_table),
+		    PAGE_KERNEL_RO);
+	trace_idt_descr.address = CPU_ENTRY_AREA_RO_TRACE_IDT;
+#endif
+
 	/*
 	 * Should be a barrier for any external CPU state:
 	 */
-- 
2.12.3