Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp320463imm; Wed, 18 Jul 2018 02:44:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe8y0Du6aWPlGM9JqECeczTB/dwAUIfXILMRyVh9wmj4E7p774ywFCbY9N5aLBlL3pedLFK X-Received: by 2002:a17:902:18a:: with SMTP id b10-v6mr5355169plb.62.1531907057769; Wed, 18 Jul 2018 02:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531907057; cv=none; d=google.com; s=arc-20160816; b=t/iLV0v4EY5gpkNZ56LX57kwATy0p62BeHhwuDo5sKm9GMhLXGoRAa1sS4AbaChneN +WK+xDu/+plSfVI9srmCkhyhzPgbV7wzqT/96NAX8wf+WDx9RwJ9+BLx85Mj/IgHuGBT 0LJTgXGq4DIzCQca7i6zDkRQ1flrQCqDWRJjCUVtDymltE7Mqo4r9t8yVcIUhd1eT2EW gFKjBfbBIeeXdJ1kyLMie1kWZOpwYeZi6YvP06P9N+jT17UzhxIsMp2ep2OmPdZjHlaN qPAcL2p54YdKRQkPhje1mhh4OKZy2MOca/+GHNJKTeLiStewM+4Lf3uZGMSbNy2m5Hpt cSfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7N3anZizDOft8xlTAuSfwQ/IcT1yjNr33O/tPJk9mCQ=; b=F5MhUG04w0qdgjeHYJBpeEietdp0LAPZwSWZ/oiMQ5gp52lJA9YOrezK7458ihoml9 HopUf7aqz1SejPel03Hx1zlUxVYd2HOQOQOdz0Pb5CFsH6ZuABJb7Wd0YdEQYx3oSqED t7SmStFLZovIhBjFPEd7fosyRxzaksrCoZxUyxZnzN4NLN7c4syIQaYgcAwVXAWGptSM sulUoic0QThljsso/X06jjPMY+3joIP3Jhn9o0oyxB9/jGzR2eyt25wtjGBV9uQ1yYmo vrJRqTpyJfgOz5nGzz1eszMHOrz3cLJZ8rSuFRAVNxA19/gZ3zyAabqa4g0BZBHzXO3U sxwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=rNd8Jar5; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u186-v6si3215486pfu.263.2018.07.18.02.44.02; Wed, 18 Jul 2018 02:44:17 -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; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=rNd8Jar5; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbeGRKSk (ORCPT + 99 others); Wed, 18 Jul 2018 06:18:40 -0400 Received: from 8bytes.org ([81.169.241.247]:54154 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731731AbeGRKSj (ORCPT ); Wed, 18 Jul 2018 06:18:39 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); } -- 2.7.4