From patchwork Wed Jul 11 11:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519487 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 F36D96032A for ; Wed, 11 Jul 2018 11:31:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02F1D26861 for ; Wed, 11 Jul 2018 11:31:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA3B428813; Wed, 11 Jul 2018 11:31:40 +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=ham 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 726C926861 for ; Wed, 11 Jul 2018 11:31:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A92EE6B0286; Wed, 11 Jul 2018 07:30:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A44996B0287; Wed, 11 Jul 2018 07:30:16 -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 90B4B6B0288; Wed, 11 Jul 2018 07:30:16 -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 236736B0287 for ; Wed, 11 Jul 2018 07:30:16 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id c2-v6so9864411edi.20 for ; Wed, 11 Jul 2018 04:30:16 -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=UmjqovSRc/FalS9MJ7ZpW7dIS37j5zCnLmcRMdE7pDksY43ivhM+H2fi9nZjALyvLE JvaFDg7xhyWI9fbL4sr968zcUPytGAivIoEKfC2/jMy0zdVjbNibuslhChdP/0kZPzoi Iv6io6SlQmIn3AValy/OEpGhuXr2PPRfTlEPoLtytHysl6vNQ9Rl6mehXDDNvO1TZr67 etbVgvtI4c8QHsYNB/EPB0kxQViLMwg9GUuZ62oyG7BFpKRCP/fZCgBD8dEhyyDbjve1 0c4B3X9TEwBYi6bJK0D4/b7ToT2HFHUtPzvwg2gNDPCPW3w+8PWmaArU47IeWeHC3Z5V NPUQ== X-Gm-Message-State: APt69E221hD/eUoJn8u7qQEM6X3KLAdO6W2H0tMsg46u6bauVPXc9cfb dPH9WXN49vuIYzYsZk4HtTsvKTZI2lyJTVT6x536vm6Df6+gmDJKK7bgVZlcVVnAg+cH2kAZ4ax BKPQX8tl2uwHkW33jXpjs8sMW9JZKpEAOVYG6D0Rp75jW0tvqBW90JoqGvQwvYvkr4Q== X-Received: by 2002:aa7:c542:: with SMTP id s2-v6mr29863698edr.224.1531308615703; Wed, 11 Jul 2018 04:30:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdlG9N0PCgU6AR4zqP1m6pLd/lc0tUR2qm5aj7Y2F1Zz/kJLlnMs5vE13T/DvIVTEJbzqlC X-Received: by 2002:aa7:c542:: with SMTP id s2-v6mr29863671edr.224.1531308615116; Wed, 11 Jul 2018 04:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308615; cv=none; d=google.com; s=arc-20160816; b=lma+fihVnPFaUptzaowzsTRv/Hbb9sVLsLXY5M4uXAP7d2GSSyJcWfZVXQM3UP8VGh CozEplp70HDUpNvKit6x89w0PU5ui4eCJiBCrkPxHMXFpNKgiF8nJt92WUIZ6B1s/5Gy 52zvzgzXemcrp536/Qxq1GaVLOxMyawEim414KRQOqZ6l3iDpqKsME1mZRb3YVMBDFYs thEg3n/FnwaDjdaAi7W/X5fBgYnET64JXwfY8rt8Cg4TPnbIrf8T0nKU0CqPRFU7LSlc Dnx6kMZn9nCuwP0ASnYj4zqL2pU1B6T+HTb/m5T56keSAmVRCTlMZhAUB4y9368XDJ3y 9Tuw== 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=I5cleIoxL+2h2dfQI9cHCkdpN8HC354jxNNVokS4OfZqR91lK4ZuLqfUe8kbnYTwNj 6bCnMTIOJhvYmL1rfwe8XfY3uRm6CdMJMq0DYpTaqkhHpNhkMOkKTwt2DE4lmFaK8YSm gQm8CNf15OFMXrhPCrB6xdMFDZVV0hKGPwLSoX04PKIJxn/sBLSmE6onFXYb/pBWtBEG tLM2p4d21F13+b+qDiojqcLm/rsIC8EEYeeggL5Yvp+PY7ztrW9BmIwyu2OJVVlEn3OA UfE3i4NMrFVzP3OlEAg4QOWRqgjzdGifG4EX4UazRvs3K/mQTwDKNQS04uCCtqnIRlwj wqKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=KfJeW5hD; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 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. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id b16-v6si2228326edh.182.2018.07.11.04.30.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:15 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=KfJeW5hD; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 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 76D2AA96; Wed, 11 Jul 2018 13:30:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308605; bh=48FBcw49wasOWCwH8N3EK5w1EL7mm104AhYjmxHQeP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KfJeW5hDKT7/C0YgavPyjFwVxsz1FtHUIseocuccPONPqhFDNO/07dvP5XgUQJFAF XllvsDt4ExWuliArFKKumHJP9OEdFf7G3E80o0RjAFGurKWdsL2zliZY+bUNTChN6M MeXaucRwEkKGhY9w0bEtNEVjnC0yrBNImR2xziD+wv4iHggWQLRUgexy2qr7z8qeXS XYHoOl33nhFFnLYIsKv70TDv3JfMAEJpfydAGukdI2BiFvxy+Np0Ag4ayQmogsCSyJ CZaw2q2AI92Bht304iTWa0YhFKC0yeTxCxVfUPj81lFHElR047Am/tFLYJsU0F9ph4 CoVZiqIwTCW7A== 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, 11 Jul 2018 13:29:33 +0200 Message-Id: <1531308586-29340-27-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-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 */