Received: by 10.223.185.116 with SMTP id b49csp2458130wrg; Mon, 5 Mar 2018 03:19:13 -0800 (PST) X-Google-Smtp-Source: AG47ELutrWkCOTmco2RAxevd/nRZb4yLatB5Isrg4G/8wTcJ7gAbhructgSdDtH5hOs2BzfcejsO X-Received: by 10.99.114.77 with SMTP id c13mr11886562pgn.286.1520248753121; Mon, 05 Mar 2018 03:19:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520248753; cv=none; d=google.com; s=arc-20160816; b=MA4Pa57Pr6XpINuy8GcpCsHU2pNbz+2FywYnBmL+qFXRLKQbLgPAJc2l6FSMNrAoQ/ 1jnty4lxuzWOUBmV2ocyCrleEmGlm+LMB5YAFB7Tpwr8nbxXrXULvBEME/FjzpAnRwou SbCnpB07RDIRTpavXkPEHpPwQ0Wns8tf+5lk17XnyPUTD6SPMGIu1Ez0TGwNa204oqkW GveYSKJ6iaVQ59y88h0AMZFge+EOqHnT8O2rzDks3i+B+7QEiYKbRj0gQ0Tf4M5JgPjJ 1so1WKnMOqZIK+yOavP67fXik2/8/T/XdtT+AMlEbeKbPgIW3KPeRfmTuTV2lsObdurd bOtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=fxqqdR30HdE5nJ4R83bfo1x7u9xYefePfoB7rp7Zl2Y=; b=c9Br5fZ9CRfH8rHTmQD0l9YGwX8JFR6gDt0VwnwmKN8F3pMJOdBTtFBlbsfYYwNTZP 2kGkmzS5u/xKxQjYsKDY5wNs9nOYJ47gNbYcTb69iwaH9jgklS+ocoeixaccKTGUvQ6t SILhPKnYOPWpMtbForZQAy74EZleWjJj/XZ55w60arbc8ryCLg3msTQzGjnESxt5Vowg 2IVxFkMNziVAPz4eJokn7vsVQ3FwV904mxAX9BlhaEhrDbQRJxh76cNLes0axIUr7Dx2 5bGOp1rC2dPOb3hv33r+rcIpwr3Fiko67oWuPC9Jxaum6Up4GqFgXT4NFTb7wmXvluCK SNkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=bdBLHE7Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15-v6si9236114pli.828.2018.03.05.03.18.58; Mon, 05 Mar 2018 03:19:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=bdBLHE7Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933429AbeCEK3g (ORCPT + 99 others); Mon, 5 Mar 2018 05:29:36 -0500 Received: from 8bytes.org ([81.169.241.247]:54586 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933264AbeCEK0U (ORCPT ); Mon, 5 Mar 2018 05:26:20 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 7396A1F74; Mon, 5 Mar 2018 11:26:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520245569; bh=RnAjLBAPfCylQRsA0GlmDdIoVOR/RZDeaA6KztSLS/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdBLHE7QvGjsQfF5W2HL0fwLouEVa8L1q8YdLjpF8p+YvUuQB4EEsPBzAVtW9k8aI kABcvisNCjjCJRx57Gz3OzC/fmkauGMOdw4BI3EITJAxSBhdopnqxoZmx1ovFX9iAJ wPMcs5C96jKBxDPuYqNCBTPa92z48pG1CpBFbYGgaCo8gJJNvpqjzRnOTuPrmkyv6a FJRKfaWxMhyZQ2g1Oe5m77704xdzXj0kdMGEN3p2DxgZ937hgRCba5K5s1vB7WH8w9 vPmGDU1gkyv1lLE1qREOROZuPS8tqPQlt8aVSw3lfH2vD0l4vAzaHe1ve4XY1SXDOa +VjyCus/ENuIg== 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 , Pavel Machek , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 26/34] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32 Date: Mon, 5 Mar 2018 11:25:55 +0100 Message-Id: <1520245563-8444-27-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520245563-8444-1-git-send-email-joro@8bytes.org> References: <1520245563-8444-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Cloning on the P4D level would clone the complete kernel address space into the user-space page-tables for PAE kernels. Cloning on PMD level is fine for PAE and legacy paging. Signed-off-by: Joerg Roedel --- arch/x86/mm/pti.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 96a690e..3ffd923 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -312,6 +312,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear) } } +#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. @@ -335,6 +336,25 @@ static void __init pti_clone_user_shared(void) pti_clone_p4d(CPU_ENTRY_AREA_BASE); } +#else /* CONFIG_X86_64 */ + +/* + * 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. + */ +static void __init pti_clone_user_shared(void) +{ + unsigned long start, end; + + start = CPU_ENTRY_AREA_BASE; + end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES); + + pti_clone_pmds(start, end, _PAGE_GLOBAL); +} +#endif /* CONFIG_X86_64 */ + /* * Clone the ESPFIX P4D into the user space visinble page table */ -- 2.7.4