lkml.org 
[lkml]   [2017]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [patch 35/60] x86/espfix: Ensure that ESPFIX is visible in user PGD
On Mon, Dec 4, 2017 at 6:07 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> Clone the ESPFIX alias mapping area so the entry/exit code has access to it
> even with the user space page tables.
>
> [ tglx: Remove the per cpu user mapped oddity ]
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>
> ---
> arch/x86/kernel/espfix_64.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> --- a/arch/x86/kernel/espfix_64.c
> +++ b/arch/x86/kernel/espfix_64.c
> @@ -129,6 +129,22 @@ void __init init_espfix_bsp(void)
> p4d = p4d_alloc(&init_mm, pgd, ESPFIX_BASE_ADDR);
> p4d_populate(&init_mm, p4d, espfix_pud_page);
>
> + /*
> + * Just copy the top-level PGD that is mapping the espfix area to
> + * ensure it is mapped into the user page tables.
> + *
> + * For 5-level paging, the espfix pgd was populated when
> + * kpti_init() pre-populated all the pgd entries. The above
> + * p4d_alloc() would never do anything and the p4d_populate() would
> + * be done to a p4d already mapped in the userspace pgd.
> + */

Is this actually true? From brief inspection, it doesn't seem to be
the case, nor do I see why it should be true.

> +#ifdef CONFIG_KERNEL_PAGE_TABLE_ISOLATION
> + if (CONFIG_PGTABLE_LEVELS <= 4) {
> + set_pgd(kernel_to_user_pgdp(pgd),
> + __pgd(_KERNPG_TABLE | (p4d_pfn(*p4d) << PAGE_SHIFT)));
> + }
> +#endif
> +
> /* Randomize the locations */
> init_espfix_random();
>
>
>

\
 
 \ /
  Last update: 2017-12-04 23:30    [W:0.164 / U:5.968 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site