Re: [patch V163 24/51] x86/mm/pti: Add mapping helper functions

From: Peter Zijlstra
Date: Mon Dec 18 2017 - 08:51:15 EST


On Mon, Dec 18, 2017 at 12:42:39PM +0100, Thomas Gleixner wrote:
> static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
> {
> +#if defined(CONFIG_PAGE_TABLE_ISOLATION) && !defined(CONFIG_X86_5LEVEL)
> + p4dp->pgd = pti_set_user_pgd(&p4dp->pgd, p4d.pgd);
> +#else
> *p4dp = p4d;
> +#endif
> }
>
> static inline void native_p4d_clear(p4d_t *p4d)
> @@ -147,7 +235,11 @@ static inline void native_p4d_clear(p4d_
>
> static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
> {
> +#ifdef CONFIG_PAGE_TABLE_ISOLATION
> + *pgdp = pti_set_user_pgd(pgdp, pgd);
> +#else
> *pgdp = pgd;
> +#endif
> }

We should probably start using WRITE_ONCE() to set page-table entries.
But that's a whole separate patch series..