Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751396AbeAPVDb (ORCPT + 1 other); Tue, 16 Jan 2018 16:03:31 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:44281 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbeAPVDZ (ORCPT ); Tue, 16 Jan 2018 16:03:25 -0500 Date: Tue, 16 Jan 2018 22:03:19 +0100 (CET) From: Thomas Gleixner To: Joerg Roedel cc: Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , jroedel@suse.de Subject: Re: [PATCH 09/16] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32 In-Reply-To: <1516120619-1159-10-git-send-email-joro@8bytes.org> Message-ID: References: <1516120619-1159-1-git-send-email-joro@8bytes.org> <1516120619-1159-10-git-send-email-joro@8bytes.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, 16 Jan 2018, Joerg Roedel wrote: > +#ifdef CONFIG_X86_64 > /* > * Clone a single p4d (i.e. a top-level entry on 4-level systems and a > * next-level entry on 5-level systems. > @@ -322,13 +323,29 @@ static void __init pti_clone_p4d(unsigned long addr) > kernel_p4d = p4d_offset(kernel_pgd, addr); > *user_p4d = *kernel_p4d; > } > +#endif > > /* > * Clone the CPU_ENTRY_AREA into the user space visible page table. > */ > static void __init pti_clone_user_shared(void) > { > +#ifdef CONFIG_X86_32 > + /* > + * On 32 bit PAE systems with 1GB of Kernel address space there is only > + * one pgd/p4d for the whole kernel. Cloning that would map the whole > + * address space into the user page-tables, making PTI useless. So clone > + * the page-table on the PMD level to prevent that. > + */ > + unsigned long start, end; > + > + start = CPU_ENTRY_AREA_BASE; > + end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES); > + > + pti_clone_pmds(start, end, _PAGE_GLOBAL); > +#else > pti_clone_p4d(CPU_ENTRY_AREA_BASE); > +#endif > } Just a minor nit. You already wrap pti_clone_p4d() into X86_64. So it would be cleaner to do: kernel_p4d = p4d_offset(kernel_pgd, addr); *user_p4d = *kernel_p4d; } static void __init pti_clone_user_shared(void) { pti_clone_p4d(CPU_ENTRY_AREA_BASE); } #else /* CONFIG_X86_64 */ /* * Big fat comment. */ static void __init pti_clone_user_shared(void) { .... } #endif /* !CONFIG_X86_64 */ Thanks, tglx