Received: by 10.223.176.5 with SMTP id f5csp450256wra; Fri, 9 Feb 2018 01:37:59 -0800 (PST) X-Google-Smtp-Source: AH8x224GyLb6fPxPZZrGa2wow0ZNMyOsCeiXCDOB+5GNPxOiWLy50dVFLS7FRLnP1Sc20y84Fwjb X-Received: by 10.98.17.154 with SMTP id 26mr2214186pfr.112.1518169079342; Fri, 09 Feb 2018 01:37:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518169079; cv=none; d=google.com; s=arc-20160816; b=i0aUMHZG/dvLzQpNhvgjaP7PuUF531hLfo0lPtAePjDkjkINvufQ+i/t6slhVAfqdJ E9FPvEkjUxFQ+Q4rE3DUI4zdX2ak1PXv0djKa+0X0fbYZe5wD73py3TXZ4yiua+hQyh+ zjpkqYdVSk9QRfj2dhbNnnVNcpfLgpc81qklXHJjAAdL80/W0oKqwhbh/4w1vT3z2/9M EB05zD51MxfOrJaXVJhe6ZzJQpMANNaoDsNCH/g/oqA7Gz6L9Jc7DP3Kcwbg6R3JAAGQ lGeT5r2/uOUNl9g9R9BTlCEgpyAbnRZ6adrcZzKox8VnSsnuJgwoa4LuKPdhP80kntjl Tl9Q== 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=oYC3VCVmw4xmAo9+2f9aJAJDcdMYv4+pCeVRgT5SRog=; b=EZ0nJ4xQVV+aRA8BVyrfsbyiMkJbb2fYy274sDXsvihRSRLXNPrVZoymrbzPHX27mI i/pxEqktafTGvQ2KoVx7TDpY7CUI/n4GvjhZ2WPHjfut9g9bpgabgMK2gCbPbS8rpmLu begjEYRFUdUNgorlFin+o6NSS4476y521WjmCMyGhuwMegDUUJBdk1TB4G+Gz3uxHNFR P0I5VYY91W6VKTY7vBQj/id6h+zky6ZGQQty0ZWYALRQHZ831CbovYnBBLt62Y0Lqz1l rUw3/KxR/kHoi+WKbwIGAPZm+7kYiC1NpfQjikkYI/sbZcIEEx2ps015ki6Vy4Vyt2vF sjoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=Hva0t/xU; 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 43-v6si1276582plb.498.2018.02.09.01.37.44; Fri, 09 Feb 2018 01:37:59 -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=Hva0t/xU; 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 S1752710AbeBIJbu (ORCPT + 99 others); Fri, 9 Feb 2018 04:31:50 -0500 Received: from 8bytes.org ([81.169.241.247]:43862 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbeBIJ0G (ORCPT ); Fri, 9 Feb 2018 04:26:06 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 129F9916; Fri, 9 Feb 2018 10:25:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1518168355; bh=IXwhBqp9tlBtGKrT+nafZfWJx84JJtVDAYVADU9Ot3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hva0t/xU+070en0vvFjg0baE1RSaK/ZTiJ68iEgw69cb1GP/3GJp1GLO2Sjz91Rgh kQsmYHa/MzGMjYE/yHidVSJRlNjFUr1YgqB3UyGdgUr+8wlJ4FH5BRBtGpawRCVutj DKlNUvl14iO6Z4VJH1LuLMh1Rww6XO+oJYe+rK4nSLA6soHNvTp8FbRkQTeF4gv9/n C+qpIzlC9Y3W14pmbqsXwCc5vaMX0NOR5aR5EB109InLIdaO+TtVIZiB2fNI3FxPOD /+wgrl1wQ7G5kfjQunsi2WFU3/+cgC8pIGxTvTzYdhlsil+CRSuyUKRa5O3d22+vd9 Fg1iX3TFB+Vig== 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 24/31] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32 Date: Fri, 9 Feb 2018 10:25:33 +0100 Message-Id: <1518168340-9392-25-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518168340-9392-1-git-send-email-joro@8bytes.org> References: <1518168340-9392-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 7f5e698..ec9852a 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