From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753190AbdLDQwJ (ORCPT ); Mon, 4 Dec 2017 11:52:09 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:60269 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751421AbdLDQva (ORCPT ); Mon, 4 Dec 2017 11:51:30 -0500 Message-Id: <20171204150608.041596550@linutronix.de> User-Agent: quilt/0.63-1 Date: Mon, 04 Dec 2017 15:07:45 +0100 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andy Lutomirsky , Peter Zijlstra , Dave Hansen , Borislav Petkov , Greg KH , keescook@google.com, hughd@google.com, Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Rik van Riel , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , aliguori@amazon.com, Will Deacon , daniel.gruss@iaik.tugraz.at Subject: [patch 39/60] x86/mm/kpti: Share cpu_entry_area PMDs References: <20171204140706.296109558@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=x86-kpti--Clone_cpu_entry_area_PMDs.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Lutomirski Share the FIX_USR_SHARED PMDs so the user space and kernel space page tables have the same PMD page. [ tglx: Made it use the FIX_USR_SHARED range so later additions are covered automatically ] Signed-off-by: Andy Lutomirski Signed-off-by: Thomas Gleixner --- arch/x86/mm/kpti.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/arch/x86/mm/kpti.c +++ b/arch/x86/mm/kpti.c @@ -167,6 +167,23 @@ kpti_clone_pmds(unsigned long start, uns } /* + * Clone the populated PMDs of the user shared fixmaps into the user space + * visible page table. + */ +static void __init kpti_clone_user_shared(void) +{ + unsigned long bot, top; + + bot = __fix_to_virt(FIX_USR_SHARED_BOTTOM); + top = __fix_to_virt(FIX_USR_SHARED_TOP) + PAGE_SIZE; + + /* Top of the user shared block must be PMD-aligned. */ + WARN_ON(top & ~PMD_MASK); + + kpti_clone_pmds(bot, top, 0); +} + +/* * Ensure that the top level of the user page tables are entirely * populated. This ensures that all processes that get forked have the * same entries. This way, we do not have to ever go set up new entries in @@ -216,4 +233,5 @@ void __init kpti_init(void) pr_info("enabled\n"); kpti_init_all_pgds(); + kpti_clone_user_shared(); }