From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935596AbdLRUea (ORCPT ); Mon, 18 Dec 2017 15:34:30 -0500 Received: from mga05.intel.com ([192.55.52.43]:27192 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759470AbdLRUe3 (ORCPT ); Mon, 18 Dec 2017 15:34:29 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,423,1508828400"; d="scan'208";a="159874188" Subject: Re: [patch V163 27/51] x86/mm/pti: Populate user PGD To: Thomas Gleixner , LKML References: <20171218114215.239543034@linutronix.de> <20171218115255.827361623@linutronix.de> Cc: x86@kernel.org, Linus Torvalds , Andy Lutomirsky , Peter Zijlstra , 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, Dave Hansen , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" From: Dave Hansen Message-ID: <93e88e2c-50fc-49a6-7113-d9b64cf70fbd@intel.com> Date: Mon, 18 Dec 2017 12:34:22 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171218115255.827361623@linutronix.de> Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/18/2017 03:42 AM, Thomas Gleixner wrote: > --- a/arch/x86/include/asm/pgtable.h > +++ b/arch/x86/include/asm/pgtable.h > @@ -1120,6 +1120,11 @@ static inline void pmdp_set_wrprotect(st > static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count) > { > memcpy(dst, src, count * sizeof(pgd_t)); > +#ifdef CONFIG_PAGE_TABLE_ISOLATION > + /* Clone the user space pgd as well */ > + memcpy(kernel_to_user_pgdp(dst), kernel_to_user_pgdp(src), > + count * sizeof(pgd_t)); > +#endif > } I was just thinking about this as I re-write the documentation about where the overhead of pti comes from. This obviously *works* for now. But, we certainly have the pti-mapped stuff spread much less through the address space than when this was thrown in here. It *seems* like we could probably do this with just 4 PGDs: > pti_clone_user_shared(); > pti_clone_entry_text(); > pti_setup_espfix64(); > pti_setup_vsyscall(); The vsyscall is just one page and the espfix is *sized* to be one PGD, so we know each of those only takes one entry. We surely don't have 512GB of entry_text, and I don't think KASLR can ever cause it to span two PGD entries. I also don't think the user_shared area of the fixmap can get *that* big. Does anybody know offhand what the theoretical limits are there?