lkml.org 
[lkml]   [2017]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch 43/60] x86/fixmap: Add debugstore entries to cpu_entry_area
On Mon, Dec 04, 2017 at 03:07:49PM +0100, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> The intel PEBS/BTS debug store is a design trainwreck as is expects virtual
> addresses which must be visible in any execution context.

Sure, what can possibly go wrong?! :-\

> So it is required to make these mappings visible to user space when kernel
> page table isolation is active.
>
> Provide enough room for the buffer mappings in the cpu_entry_area so the
> buffers are available in the user space visible fixmap.
>
> At the point where the kernel side fixmap is populated there is no buffer
> available yet, but the kernel PMD must be populated. To achieve this set
> the fixmap entries for these buffers to non present.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> arch/x86/events/intel/ds.c | 5 +++--
> arch/x86/events/perf_event.h | 21 ++-------------------
> arch/x86/include/asm/fixmap.h | 13 +++++++++++++
> arch/x86/include/asm/intel_ds.h | 36 ++++++++++++++++++++++++++++++++++++
> arch/x86/kernel/cpu/common.c | 21 +++++++++++++++++++++
> 5 files changed, 75 insertions(+), 21 deletions(-)

...

> @@ -592,6 +603,16 @@ static void __init setup_cpu_entry_area(
> __set_fixmap(get_cpu_entry_area_index(cpu, entry_trampoline),
> __pa_symbol(_entry_trampoline), PAGE_KERNEL_RX);
> #endif
> +
> +#ifdef CONFIG_CPU_SUP_INTEL
> + BUILD_BUG_ON(sizeof(struct debug_store) % PAGE_SIZE != 0);
> + set_percpu_fixmap_pages(get_cpu_entry_area_index(cpu, cpu_debug_store),
> + &per_cpu(cpu_debug_store, cpu),
> + sizeof(struct debug_store) / PAGE_SIZE,
> + PAGE_KERNEL);
> + set_percpu_fixmap_ptes(get_cpu_entry_area_index(cpu, cpu_debug_buffers),
> + sizeof(struct debug_store_buffers) / PAGE_SIZE);
> +#endif

I guess we can do that additionally, so as not to setup the mappings on
distro kernels running !INTEL:

---
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1364a8f378f8..5cfb68090a24 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -606,12 +606,16 @@ static void __init setup_cpu_entry_area(int cpu)

#ifdef CONFIG_CPU_SUP_INTEL
BUILD_BUG_ON(sizeof(struct debug_store) % PAGE_SIZE != 0);
- set_percpu_fixmap_pages(get_cpu_entry_area_index(cpu, cpu_debug_store),
- &per_cpu(cpu_debug_store, cpu),
- sizeof(struct debug_store) / PAGE_SIZE,
- PAGE_KERNEL);
- set_percpu_fixmap_ptes(get_cpu_entry_area_index(cpu, cpu_debug_buffers),
- sizeof(struct debug_store_buffers) / PAGE_SIZE);
+
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
+ set_percpu_fixmap_pages(get_cpu_entry_area_index(cpu, cpu_debug_store),
+ &per_cpu(cpu_debug_store, cpu),
+ sizeof(struct debug_store) / PAGE_SIZE,
+ PAGE_KERNEL);
+
+ set_percpu_fixmap_ptes(get_cpu_entry_area_index(cpu, cpu_debug_buffers),
+ sizeof(struct debug_store_buffers) / PAGE_SIZE);
+ }
#endif
}

--
Regards/Gruss,
Boris.
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--

\
 
 \ /
  Last update: 2017-12-07 10:56    [W:0.432 / U:6.324 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site