From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbdLDW3L (ORCPT ); Mon, 4 Dec 2017 17:29:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:40422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751982AbdLDW3I (ORCPT ); Mon, 4 Dec 2017 17:29:08 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE367219A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org X-Google-Smtp-Source: AGs4zMa3Zw9YyzakXxnE3bzWQT0vxz3VpJxh4IpT95LovL/hTYhnvD5c2wEmKtXaSPLIvcKwTwLNDgtPmr8d4smXNJ0= MIME-Version: 1.0 In-Reply-To: <20171204150607.722883469@linutronix.de> References: <20171204140706.296109558@linutronix.de> <20171204150607.722883469@linutronix.de> From: Andy Lutomirski Date: Mon, 4 Dec 2017 14:28:46 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 35/60] x86/espfix: Ensure that ESPFIX is visible in user PGD To: Thomas Gleixner Cc: LKML , X86 ML , Linus Torvalds , Andy Lutomirsky , Peter Zijlstra , Dave Hansen , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Rik van Riel , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , Daniel Gruss , Dave Hansen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 4, 2017 at 6:07 AM, Thomas Gleixner wrote: > From: Dave Hansen > > 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 > Signed-off-by: Thomas Gleixner > > --- > 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(); > > >