From patchwork Wed Jul 11 11:29:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519517 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 4BECF6032A for ; Wed, 11 Jul 2018 11:32:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DFD828592 for ; Wed, 11 Jul 2018 11:32:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DC98285A5; Wed, 11 Jul 2018 11:32:16 +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 D279828592 for ; Wed, 11 Jul 2018 11:32:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47B636B0290; Wed, 11 Jul 2018 07:30:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4299E6B0294; Wed, 11 Jul 2018 07:30:22 -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 2CAC56B0293; Wed, 11 Jul 2018 07:30:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id C44976B0291 for ; Wed, 11 Jul 2018 07:30:21 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id n2-v6so9876590edr.5 for ; Wed, 11 Jul 2018 04:30:21 -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=GTyFUm2ENHQo73SIP+htjQmokP28toCTKOKfQMH3MtUT6bM6HC29Jui5V1QCd4YVKl if/+Q1no9trSn81uoaIwCgDbCw/yMF9VMu6U3zIuUqe/AV4xsCeyz4BIUtvuR2dXMJDk TTB8OQUD9zeRG6wDgZbP7C/A7ANid3fBI2isb9WdZwWtulgafE3yZHDCtw/TGimfOime 5rzg/hdgjbDb19zJ+nCJW6YyjhR8+lLwOWHyBdkwnPWCx7oGW/hR5s2NFWhNDhrIJw9b aTHOuY6yYLs9CI/ExApMYVyROQgKU9NnvXm0rC+i1oMQZO9YKTeLhP7UGQuTXT+DNzUu ctIQ== X-Gm-Message-State: APt69E2q/cb2tdZ/8mfjuRKnetkN7bWPbvdqlnA3C07m2qqAFnFX9FDU zm3vODOAideUDCe/tlwR3QfnqbCUBLgez17VKCAUyRQNbtSrVya2RyIoAvUkt6c1CiUbRWE/ZGo Dp8h9IYen7GL43TmixQX1wZ/kBTMvrZggy4qiG+UgM1OelDqPaJ1J+9SQR33szGTcUw== X-Received: by 2002:a50:8b25:: with SMTP id l34-v6mr10269631edl.265.1531308621372; Wed, 11 Jul 2018 04:30:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd5OgMygtuqhbSOJhCuY/Fi8ZGqEepXWB1r/s7Fn1aSERiLer3L0b7jF+hLArbnx6oA1RiY X-Received: by 2002:a50:8b25:: with SMTP id l34-v6mr10269596edl.265.1531308620694; Wed, 11 Jul 2018 04:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308620; cv=none; d=google.com; s=arc-20160816; b=Oxyl8kGaF7w49z55DOR0e+LsY11CNQf3ncgSdi2ql/Rib3HDA9IquYzm3t/YJHZig6 +MFR0geFrorRWohQwBndjRimkyb3dT+JmW8Nl2SmvamJcqnC3CuAPcQUNow9NcWJG2P7 9reanctxZifub0k0fkWiW+BjHf1p5CunMZZ8A+OQFJOEO9Re/pYVqgyd8ch9uRCOjFcq qp9ST9Q+jUvJ5Efdp8zKHfwEpRxcz9JB1JqMrEG9RfRE494wBOjjYwSxN+ZOTDp9TDtE 1ceop1rfqW4OhnqW15oEQPb2oEkKkvh8DZ1hQEyInWgGq/XgZSeGM3lkY2yr4Mwk0cdB R02g== 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=TXzOyYgMU7/sOFs5vIuYrOZeVDR0U7mtu2DeYIjHwUkxREsr389k1B86hUE1GrtMOA 4WsP75uJroriniuKsIDz79hDB6ajN3PgIjc74Ms8+DEf4IOHKUjGFq7DaUXH1gE+T1EM HTB8Pr6KhSxhNIsN35N87KaSIpSLS/W4a1STOfxDY5yM6CJ3t5eHjl2jOlksF5ekQWlZ FT+0zncIRV1OxmzpwqkCW9nh1KbjcKIyBUmzKd26pixo4tNCuTvo42u7ZcBBHGPELtvx IC3alJRw4PGvRn/1Pfg4s/jUhViyfwnGOX98sdagveYmbyMVRRqVrTo795TW/Eoy29DV MjvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=kODeHpl7; 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 x17-v6si2934371edl.345.2018.07.11.04.30.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:20 -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=kODeHpl7; 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 CC92B399F; Wed, 11 Jul 2018 13:30:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308607; bh=2V0XCeOUnRlODFqALspBJ8CBUOtjUtaImRZ6+JHIei8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kODeHpl7UsQbPsWyx6FcWfUrNwf2paoUi3eCZ4Ds3yPqUqC9EUpHB8sTofIoQhHfl BolLeB2kYCiq9ko+PWYQIR0J7/vKbmk/yRXNAEJim1yY1Jn+09XQXu338yXpFabV29 p/zdSvYZqlrat96Zl1lxiRVO9hqSC9Be+jldy45UbM2CarCJIjjr5WlnUBhTtZmz3P iRxv5FMNsGHX0qGad90XridEHHbvIOu3F0U9GQhrI7qIXueE/VaIIz9BhTYHY6WZPD DXUJ5rztB2FSOv/7r7Cky3li9uhmUuVZtBLqo9Zo5MWAeOwZgFKfbJm05BeiDUjARn YKnv4mhU+Pasw== 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, 11 Jul 2018 13:29:37 +0200 Message-Id: <1531308586-29340-31-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 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(); }