Re: [PATCH V2 03/20] x86: Add entry trampolines to kcore

From: Arnaldo Carvalho de Melo
Date: Thu May 17 2018 - 13:13:01 EST


Em Thu, May 17, 2018 at 10:52:30AM -0700, Dave Hansen escreveu:
> On 05/17/2018 02:21 AM, Adrian Hunter wrote:
> > From: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
> >
> > Signed-off-by: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
>
> For the benefit of the poor souls looking at this code in the decades to
> come, could you please take a few minutes to write a couple of sentences
> about why this is being done?

Hey, for the poor souls reading in _this_ decade as well! ;-)

- Arnaldo

> > diff --git a/arch/x86/mm/cpu_entry_area.c b/arch/x86/mm/cpu_entry_area.c
> > index d1da5cf4b2de..fb1fbc8538fa 100644
> > --- a/arch/x86/mm/cpu_entry_area.c
> > +++ b/arch/x86/mm/cpu_entry_area.c
> > @@ -3,6 +3,7 @@
> > #include <linux/spinlock.h>
> > #include <linux/percpu.h>
> > #include <linux/kallsyms.h>
> > +#include <linux/kcore.h>
> >
> > #include <asm/cpu_entry_area.h>
> > #include <asm/pgtable.h>
> > @@ -14,6 +15,7 @@
> > #ifdef CONFIG_X86_64
> > static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
> > [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
> > +static DEFINE_PER_CPU(struct kcore_list, kcore_entry_trampoline);
> > #endif
> >
> > struct cpu_entry_area *get_cpu_entry_area(int cpu)
> > @@ -147,6 +149,9 @@ static void __init setup_cpu_entry_area(int cpu)
> >
> > cea_set_pte(&get_cpu_entry_area(cpu)->entry_trampoline,
> > __pa_symbol(_entry_trampoline), PAGE_KERNEL_RX);
> > + kclist_add(&per_cpu(kcore_entry_trampoline, cpu),
> > + &get_cpu_entry_area(cpu)->entry_trampoline, PAGE_SIZE,
> > + KCORE_TEXT);
> > #endif
>
> Any reason not to add a comment like:
>
> /*
> * The cpu_entry_area alias addresses are not in the kernel binary
> * so they do not show up in /proc/kcore normally. This adds entries
> * for them manually.
> */