Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2257854imm; Thu, 19 Jul 2018 16:36:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfFapB3JhIO8o7hXzs6WDcCdfMqV9VeN5RF8aOL+HW411zH/ampSRoeDnCY2aO6jtaLRtXs X-Received: by 2002:a63:4703:: with SMTP id u3-v6mr11500569pga.405.1532043419687; Thu, 19 Jul 2018 16:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532043419; cv=none; d=google.com; s=arc-20160816; b=IZm+ompouDxIOlS1eWBeA/WzOH+RFuIA/TevKIPnohKq/9gNG28Vrr/7SnCBu4srkL fAB6lOc9Dh6HdDAGSKXXOqrB32rs84phDCZAwtVyS8hm6Vq+Hu7tXw6GQUaqQFWlpGCP nsQC4ZPYi7msVGaSMQGecET6KzmECMY+MnCs1gQZ41TjJL0cSKTVJm1YtV4t9n4hJG1O irN4WJEPOQ24P5LCfhVdZ1L1C0CPbaYchBcASt0HzH821EMAFHaPnP3N563Veou3UETQ 7W9W7PSIN4er68BEBbQnpGZvboZF/r+Nwec+rg8gK36fUGSA5JwK5tqxl9CLZ2R7oOJo 2HfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=TCJKQAaTCq9QXCjk4q6TSY6Tw6DD8w7wDnUHhl61skY=; b=lbaUDv1fyB0nonUWzQsR4pmHerFwmAjtTtjShT/mbwpVcyRPp3mg3TkoQ42y5NDmBr WAoPgqvXMEJSq0N/6CAerfzJ1WgKcziGN1yTnKHQUPw/V0uKIbUVCNChvhZIjpt1nZk1 gJnI6p9IgbIjNSuH0DQnbrgLzWiyZX++PYQOzKocVGnma4AP/zc7iQZiQFxmNNaB12MV bMZYazX/slxcL0NUXuaCCetpoILUFSpezcLlWGzWM0S7ZWOFp0s8JCnJLAMsHKJhB1JY upIdX/aHpjgD7bGfWxe+1It2l/5FMccU1jJwV+/gZFAsluxz+aFhTp507fSEN1Nfr0V2 toXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31-v6si369364pla.190.2018.07.19.16.36.44; Thu, 19 Jul 2018 16:36:59 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731374AbeGTAUq (ORCPT + 99 others); Thu, 19 Jul 2018 20:20:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33053 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbeGTAUp (ORCPT ); Thu, 19 Jul 2018 20:20:45 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w6JNYJFM2454198 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Jul 2018 16:34:19 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w6JNYIB82454195; Thu, 19 Jul 2018 16:34:18 -0700 Date: Thu, 19 Jul 2018 16:34:18 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Joerg Roedel Message-ID: Cc: David.Laight@aculab.com, mingo@kernel.org, hpa@zytor.com, dhgutteridge@sympatico.ca, pavel@ucw.cz, dvlasenk@redhat.com, brgerst@gmail.com, peterz@infradead.org, tglx@linutronix.de, jkosina@suse.cz, bp@alien8.de, luto@kernel.org, jpoimboe@redhat.com, gregkh@linuxfoundation.org, aarcange@redhat.com, will.deacon@arm.com, torvalds@linux-foundation.org, dave.hansen@intel.com, linux-kernel@vger.kernel.org, boris.ostrovsky@oracle.com, jroedel@suse.de, llong@redhat.com, eduval@amazon.com, jgross@suse.com Reply-To: gregkh@linuxfoundation.org, aarcange@redhat.com, will.deacon@arm.com, dave.hansen@intel.com, torvalds@linux-foundation.org, boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, jroedel@suse.de, jgross@suse.com, llong@redhat.com, eduval@amazon.com, mingo@kernel.org, David.Laight@aculab.com, hpa@zytor.com, dhgutteridge@sympatico.ca, pavel@ucw.cz, dvlasenk@redhat.com, jkosina@suse.cz, peterz@infradead.org, tglx@linutronix.de, brgerst@gmail.com, luto@kernel.org, bp@alien8.de, jpoimboe@redhat.com In-Reply-To: <1531906876-13451-31-git-send-email-joro@8bytes.org> References: <1531906876-13451-31-git-send-email-joro@8bytes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/mm/pti: Clone entry-text again in pti_finalize() Git-Commit-ID: ba0364e260ab37c02975557dbecc014a26072236 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ba0364e260ab37c02975557dbecc014a26072236 Gitweb: https://git.kernel.org/tip/ba0364e260ab37c02975557dbecc014a26072236 Author: Joerg Roedel AuthorDate: Wed, 18 Jul 2018 11:41:07 +0200 Committer: Thomas Gleixner CommitDate: Fri, 20 Jul 2018 01:11:45 +0200 x86/mm/pti: Clone entry-text again in pti_finalize() 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 Signed-off-by: Thomas Gleixner Tested-by: Pavel Machek Cc: "H . Peter Anvin" Cc: linux-mm@kvack.org Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Dave Hansen Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Peter Zijlstra Cc: Borislav Petkov Cc: Jiri Kosina Cc: Boris Ostrovsky Cc: Brian Gerst Cc: David Laight Cc: Denys Vlasenko Cc: Eduardo Valentin Cc: Greg KH Cc: Will Deacon Cc: aliguori@amazon.com Cc: daniel.gruss@iaik.tugraz.at Cc: hughd@google.com Cc: keescook@google.com Cc: Andrea Arcangeli Cc: Waiman Long Cc: "David H . Gutteridge" Cc: joro@8bytes.org Link: https://lkml.kernel.org/r/1531906876-13451-31-git-send-email-joro@8bytes.org --- 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 fcfb815d420f..a536ecc91847 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(); }