From patchwork Wed Jul 18 09:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531897 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2646760547 for ; Wed, 18 Jul 2018 09:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16EBC28FD4 for ; Wed, 18 Jul 2018 09:43:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B23628FCD; Wed, 18 Jul 2018 09:43:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A141C28FC3 for ; Wed, 18 Jul 2018 09:43:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81DE76B02A8; Wed, 18 Jul 2018 05:41:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 752B76B02A7; Wed, 18 Jul 2018 05:41:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 541546B02A9; Wed, 18 Jul 2018 05:41:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id C63796B02A4 for ; Wed, 18 Jul 2018 05:41:39 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id p5-v6so1699167edh.16 for ; Wed, 18 Jul 2018 02:41:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=XwF25D7lzXwncdQohfhWybwGD6TdHiTqCNaArXvInwM=; b=FKxt67XPE1Agml8GyvgePrqL/E58dbCOutKtH1jBz+NUjmvDdREnhWWaKHX9Dlp8Yj 3i7gvXsf2INbBdUchzLnD4bBKQ4v0zC4E3duFcXBGTP2PwSQAhTLE9a15g57zNey8Z1L VTim4p5R7xDU/7pFA5jvPAhLR5ATeWnEPUwoWW09wKSoq8NA9EQygphFN3GxlOKeOuRG 8zA/EHzmNig51+41vTpNgWoNZpJJSxYjG4oWxhRpLE+XeKiycoYtV9XTxF8fxFlM0UX0 Rl5Dpd44gInJBWBkqXywhf6pyZ5zeLNMYGHH6wPwtryM0PISE3vmvdxsOLhRrTq82jQm hX9w== X-Gm-Message-State: AOUpUlFD6Q47mOT2MkzDYDwIovebRd2AwMAK+s+vMCsTtiHV+bjR5RJQ Wv8igUe81D3Q69pDi/byF9krcIVHxfGSy/OTKu5S60xGlh2QHfkdq74l0lh4/FxNRCsR0eODKCN iq7A7Pdi2n8Coy3njify/chtZAPS52hbJ5/Ov3L6iCx6xrE7NXBh+bULso/FXG5/vkA== X-Received: by 2002:a50:fe13:: with SMTP id f19-v6mr6307081edt.291.1531906899378; Wed, 18 Jul 2018 02:41:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd7j/5K2s5kJYJxVJe67dQwbRCX7HzBaJtb+X2Kx/Cs+UQmML6eHN4K6qTuNENeZjofHx0K X-Received: by 2002:a50:fe13:: with SMTP id f19-v6mr6307044edt.291.1531906898770; Wed, 18 Jul 2018 02:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906898; cv=none; d=google.com; s=arc-20160816; b=XsaON4A2n9+X4rpOxrP36sWCvt/gcFBo2zbMZypPiIgVEIjaTkGvFCDi6wv/N80Vi0 ooChSb24nClT8WMUNx6RpJZ6FY6E4pOZk/CSKZPYjSboq956V5TilqNcWAE/DoEyahVc QO0QbyNeBDgaMF92MeurgYWkU6TZHqcz8IOQnvX0BYvo4rUoCO4lVGEn6bP3VDWeR8HI eShQgUGrmEtAlfp9KboiC33AuofkZOAVD2Cz3Iuym/81T89dAp9UamHvZHZ3zosyF9oa 2eyEtvnv4kbpIdS6gBzL6yDHEm9VIVlYtVYqkxt4LydZIqB60VU+Dj1Ve9cPWHqN2gBa 4jfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=XwF25D7lzXwncdQohfhWybwGD6TdHiTqCNaArXvInwM=; b=x0a4OFYOcLPazoQjBtpumm40LvXuWzQKpuRAn8dz8co3pm4r1GdQUGMsx7XxCUrnU6 wPH4nNH6mb6VZRJiIfNX2jNxhacMVsMIKxR3ihOpIQkq0Dk7ltw7OoAQCfhuuQwdj7gp edBNDwWYIpYsWufpOLc12+IkSFSFaX/eAz5lAT4ns0igUL2jg0aRMR9zgBmTiycLsLLi i3NJnRTddekMfHQMA+87dc2hnkRPPYqMFP7Mz7+YURGcFq9emM5nabVWF1pmPar0S+bf ABT551ro/ZC75oqdaGzdFex/R9gM5e4Yby+VxZrQRSOF8wIrpCN0lEbCPsqMM6t8hGiw 22HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=BnprfT3p; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from theia.8bytes.org (8bytes.org. [81.169.241.247]) by mx.google.com with ESMTPS id v11-v6si3335343edk.204.2018.07.18.02.41.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:38 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) client-ip=81.169.241.247; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=BnprfT3p; spf=pass (google.com: domain of joro@8bytes.org designates 81.169.241.247 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: by theia.8bytes.org (Postfix, from userid 1000) id AFFC7C98; Wed, 18 Jul 2018 11:41:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531906885; bh=48FBcw49wasOWCwH8N3EK5w1EL7mm104AhYjmxHQeP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnprfT3po/XG5LQkuR6EeRLOLHrWtwuxvsbtkdWqOj4VJuc/I7dnjGn6cPNpDS9In guejVb/XWr3HGHUsrkLwPa4jBvWOloV1B2TdfIlx+3Y9dCGFtkVYZWegk+3r2Xe0ZJ NBZH8VamnQGJuzZGSB7rua+pqbE+dVBz5g5Qz6tKYgstEI5eRaq8x4U8oTXwOpAwHW /OIbCQBsDMC9dUdNRClrynvxmTNe+ubtruTDAZp9CcjPyGgt/C5PTpcEg4IvdSsjFc uuXcFzEoirJEFLYhxw/NKJJ0382aQvglHyv0oHpvNs/cd1nEBJGpEsk3MN7NDS4zJY TddYHr8JjVKSg== 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 , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 26/39] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32 Date: Wed, 18 Jul 2018 11:41:03 +0200 Message-Id: <1531906876-13451-27-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531906876-13451-1-git-send-email-joro@8bytes.org> References: <1531906876-13451-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 dc02fd4..2eadab0 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -348,6 +348,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. @@ -371,6 +372,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, 0); +} +#endif /* CONFIG_X86_64 */ + /* * Clone the ESPFIX P4D into the user space visible page table */