Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751697AbeAPSLQ (ORCPT + 1 other); Tue, 16 Jan 2018 13:11:16 -0500 Received: from mga09.intel.com ([134.134.136.24]:49447 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbeAPSLP (ORCPT ); Tue, 16 Jan 2018 13:11:15 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,369,1511856000"; d="scan'208";a="193811786" Subject: Re: [PATCH 12/16] x86/mm/pae: Populate the user page-table with user pgd's To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" References: <1516120619-1159-1-git-send-email-joro@8bytes.org> <1516120619-1159-13-git-send-email-joro@8bytes.org> Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , 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 From: Dave Hansen Message-ID: Date: Tue, 16 Jan 2018 10:11:14 -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: <1516120619-1159-13-git-send-email-joro@8bytes.org> Content-Type: text/plain; charset=utf-8 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 Return-Path: On 01/16/2018 08:36 AM, Joerg Roedel wrote: > +#ifdef CONFIG_X86_64 > /* > * If this is normal user memory, make it NX in the kernel > * pagetables so that, if we somehow screw up and return to > @@ -134,10 +135,16 @@ pgd_t __pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd) > * may execute from it > * - we don't have NX support > * - we're clearing the PGD (i.e. the new pgd is not present). > + * - We run on a 32 bit kernel. 2-level paging doesn't support NX at > + * all and PAE paging does not support it on the PGD level. We can > + * set it in the PMD level there in the future, but that means we > + * need to unshare the PMDs between the kernel and the user > + * page-tables. > */ > if ((pgd.pgd & (_PAGE_USER|_PAGE_PRESENT)) == (_PAGE_USER|_PAGE_PRESENT) && > (__supported_pte_mask & _PAGE_NX)) > pgd.pgd |= _PAGE_NX; > +#endif Ugh. The ghosts of PAE have come back to haunt us. Could we do: static inline bool pgd_supports_nx(unsigned long) { #ifdef CONFIG_X86_64 return (__supported_pte_mask & _PAGE_NX); #else /* No 32-bit page tables support NX at PGD level */ return 0; #endif } Nobody will ever spot the #ifdef the way you laid it out.