Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968AbeAPQzh (ORCPT + 1 other); Tue, 16 Jan 2018 11:55:37 -0500 Received: from 8bytes.org ([81.169.241.247]:54758 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751366AbeAPQsd (ORCPT ); Tue, 16 Jan 2018 11:48:33 -0500 From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: 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, joro@8bytes.org Subject: [PATCH 10/16] x86/mm/pti: Populate valid user pud entries Date: Tue, 16 Jan 2018 17:36:53 +0100 Message-Id: <1516120619-1159-11-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516120619-1159-1-git-send-email-joro@8bytes.org> References: <1516120619-1159-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Joerg Roedel With PAE paging we don't have PGD and P4D levels in the page-table, instead the PUD level is the highest one. In PAE page-tables at the top-level most bits we usually set with _KERNPG_TABLE are reserved, resulting in a #GP when they are loaded by the processor. Work around this by populating PUD entries in the user page-table only with _PAGE_PRESENT set. I am pretty sure there is a cleaner way to do this, but until I find it use this #ifdef solution. Signed-off-by: Joerg Roedel --- arch/x86/mm/pti.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 20be21301a59..6b6bfd13350e 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -202,8 +202,12 @@ static __init pmd_t *pti_user_pagetable_walk_pmd(unsigned long address) unsigned long new_pmd_page = __get_free_page(gfp); if (!new_pmd_page) return NULL; - +#ifdef CONFIG_X86_PAE + /* TODO: There must be a cleaner way to do this */ + set_pud(pud, __pud(_PAGE_PRESENT | __pa(new_pmd_page))); +#else set_pud(pud, __pud(_KERNPG_TABLE | __pa(new_pmd_page))); +#endif } return pmd_offset(pud, address); -- 2.13.6