From patchwork Wed Jul 18 09:41:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531879 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 87E9C602CA for ; Wed, 18 Jul 2018 09:42:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 766E528FBC for ; Wed, 18 Jul 2018 09:42:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A32728FCD; Wed, 18 Jul 2018 09:42:54 +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 0A9DA28FBC for ; Wed, 18 Jul 2018 09:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DC306B029A; Wed, 18 Jul 2018 05:41:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 68F416B02A1; Wed, 18 Jul 2018 05:41:38 -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 505226B02A2; Wed, 18 Jul 2018 05:41:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id E11536B029A for ; Wed, 18 Jul 2018 05:41:37 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id p5-v6so1699139edh.16 for ; Wed, 18 Jul 2018 02:41:37 -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=7N3anZizDOft8xlTAuSfwQ/IcT1yjNr33O/tPJk9mCQ=; b=Q+V5ZE6GWzmzs+V/+hceQ4gO4By/EvxnLWyv8g2E8S77l21ecD3AApEmiAjk5ZAUsT PIiXxkkQAUiG5VtyLSvGUOUZJavlmtNxRLjHDBpumw3y2PuZLf4w8dlRM9Oo5c0ERDxu 3jWvAdJGNCM8A1zJxzXRwRfIlA0kZUvGkCilnUphVIqGHfzU9Pj3ZvNCbXUetmPBRAAI PzmG+DCvMUDIMGyq/dW0VOC/Qvn4V8J/tRb2k7PtX5R8FSA01rYPg7XwcBwn94RKjeHn uOZ21I1kBPmvdCVmwv2sH0yfVVRrIVw2HcW5bk4rnKzSf7YDPJ/uegGTni/3ziNxpmf6 dTKw== X-Gm-Message-State: AOUpUlFFrYQ+BXi6Y/Fg1KA07pq3gDCelMJ6On0261tm9pJzMnM7yEnY MFwEVzzlDrXVQUXyt9As3fYhMVULLMd7zyulgwrz+8+w+sxdCz605OhvEwVvI1SZKo+HKY3pVfJ qhei5x6++of49k0lucalRDQV0GIHslqbEVYv57gs4ZIwTHgvHr+9MqJg5vOwxD0QrPw== X-Received: by 2002:a50:c211:: with SMTP id n17-v6mr6372356edf.11.1531906897493; Wed, 18 Jul 2018 02:41:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVU6hz2zbGrb9ktVhWI/uMNWKgdT+rGs62U2jRxT9ct7ecD/b/ueL5MHb9D86dntK5toZ2 X-Received: by 2002:a50:c211:: with SMTP id n17-v6mr6372317edf.11.1531906896771; Wed, 18 Jul 2018 02:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906896; cv=none; d=google.com; s=arc-20160816; b=HbTorjGjZjjezPT1wzZUY2XE/lc8ItcJnKm62wK1OvxzwKglvVVz2y0FJFvIZHRaVK WTcVB+BIfGAPCwT8oYChMqhVghwxFf6u3Nx0ApjS/31s/9p2k83ItKtG61kvFbLlxiwl 04OzKuyfeQ9T/YHYx/XA1AxBStwLlsFK3q4i102BsW4fFFMByZ3U7b/x8jMn2CT7b/d3 5WD3nxU46NSyEE3qNpSAXQZjvFg0XdYx9P6K9Lh11AM8k+1FTrMrPaBtgCC/+63S+6X8 Oa++FZsLOsggAfjM1qAiPwbzM1aBoGNWe5F9TOg9zH7nOmRHqKrMgVqN+p97fG9P5Wy4 WW8g== 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=7N3anZizDOft8xlTAuSfwQ/IcT1yjNr33O/tPJk9mCQ=; b=0JYhu2Mws44hy5n0EZNBrmtOqb6s1CdvKB2okVpgftMJly8yeIORpviUqpZasjfPvD Sxqa1XDnM12ifkvmOR9W2NFW6uEJ6h47KYEXUGPX2uLa5y9FndRyvpdhdx2fZQg2aurT 1zOqCmHi17CEdrj7oqnULlMNyFK69gotfMUeM+3ctBgYGgYkOY1FPYlGMr/LY+NZRcxx jwQBQcQFJHsrbC7bU0mAezuue4PQrdDV9Gz6+Qp4O63kwz/qewamiTho1z6S7h8IZKYJ 8G2WL1YkWp0WQbyyxj1U3EwwVd0TwRgPlGwpFDwDUuAwUDO1ooCllTAEFNNjRoF//yMH RYQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=rNd8Jar5; 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 o15-v6si1909040edr.34.2018.07.18.02.41.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:36 -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=rNd8Jar5; 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 39C201B24; Wed, 18 Jul 2018 11:41:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531906884; bh=2V0XCeOUnRlODFqALspBJ8CBUOtjUtaImRZ6+JHIei8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNd8Jar55gKfAMr4Yu8B+/5ju7NlduhGvUHE0RZkD+96CBLyo0mMjWQVxWhW3gcFq T30viFXW4VhpDJbQhe8w6xFBtk3wrbaKsonQxILNPUOXruT4F+n92xT31m1ScgOWCI qTMKB/908rBm/OB4tj2SqCTJM6rbDnFwKBtDINhHZAgSXhb8ndgFm9aan2q/A2zaHH 7ia0qpt3SHVdN9voiez6BVhNWeetx5508+/d9nRarYsJ9lzx4ecG8HeL/xknmkz5o0 jLHdY1UufWuPypa68+3P7Jf73Trr1BJk7BratOTaFXE1UKamRKftMxHIENE8HBOrxk IlwU9lOVI7gew== 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 30/39] x86/mm/pti: Clone entry-text again in pti_finalize() Date: Wed, 18 Jul 2018 11:41:07 +0200 Message-Id: <1531906876-13451-31-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 The mapping for entry-text might have changed in the kernel after it was cloned to the user page-table. Clone again to update the user page-table to bring the mapping in sync with the kernel again. Signed-off-by: Joerg Roedel --- arch/x86/mm/pti.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 1825f30..b879ccd 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -404,7 +404,7 @@ static void __init pti_setup_espfix64(void) /* * Clone the populated PMDs of the entry and irqentry text and force it RO. */ -static void __init pti_clone_entry_text(void) +static void pti_clone_entry_text(void) { pti_clone_pmds((unsigned long) __entry_text_start, (unsigned long) __irqentry_text_end, @@ -528,13 +528,18 @@ void __init pti_init(void) } /* - * Finalize the kernel mappings in the userspace page-table. + * Finalize the kernel mappings in the userspace page-table. Some of the + * mappings for the kernel image might have changed since pti_init() + * cloned them. This is because parts of the kernel image have been + * mapped RO and/or NX. These changes need to be cloned again to the + * userspace page-table. */ void pti_finalize(void) { /* - * Do this after all of the manipulation of the - * kernel text page tables are complete. + * We need to clone everything (again) that maps parts of the + * kernel image. */ + pti_clone_entry_text(); pti_clone_kernel_text(); }