Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp595104imm; Wed, 11 Jul 2018 07:49:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf/iIXQKgJjBU1QKlHGhZ5Zsg2FBCUsLPOaFgvzb3lHbkJNoawCzKNN12w8LSFVsp6GloCo X-Received: by 2002:a63:5866:: with SMTP id i38-v6mr27120965pgm.63.1531320573420; Wed, 11 Jul 2018 07:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531320573; cv=none; d=google.com; s=arc-20160816; b=IDUk/SyiKBhAWYn+V618vqyImvbvn2TeDXbeFOQDm2SMBvOI1D3M61BLUqwCd16R6Z RziUkZ0YwtKh98+RPJa4Y2IzAWz2i5HVsCjdDtD9/bUjU9/HbVOBHSNFkGDTlKSU+bdf yAjEFR98EFPwizUYvkg0lZnXqiAKOzKBxUjelhkHph3GOWxr+WoKjFUC6X6gdKyLM5Hi O0IVa+mdPiOFACY707v4Zqkmd8ZjA+eCVIFVpBjNNsOjsuLFeB9/VuZCZ+fp3WkrwmAw goIfO4vSTa2r771VvE98Mvvia9Dl8wweVO41Dk7zJeYNoXTD6koppKTRQQ/A/wJf1t+l vqVQ== 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=EofXQ357HUDpclwhoXw8zcJzr5j630Dhk5U2tqASwEKOxjg+c+TjywBEwV39F6sUpn 729vAZZx7R0a8pRanAePEk/yA3gc1DdugjpY/NZ0Wamvs+1dF2zscC+AwWTOZdRveZzA j/unm2cm2zjDFpq4QXIHQw1jwTayr4Vtw+Q4YyqH4l/8YnEOLgXsWZrRh0mBOU3XtkSL GHkqhhev4ECywddLEJiOQL7W7Fb7FlAbIYbUk7uD2qMzQ0//uNJbYzWhHfG1c4DX8cWX ILSYp/QMg04PiLs2K/MU+6Tx0o4S/a8qNTvoc0YlZenCtxfB4A7KYZC6BywaDgGsOhGf bX1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=kODeHpl7; 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 7-v6si19882925pll.212.2018.07.11.07.49.17; Wed, 11 Jul 2018 07:49:33 -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=kODeHpl7; 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 S1733179AbeGKLeu (ORCPT + 99 others); Wed, 11 Jul 2018 07:34:50 -0400 Received: from 8bytes.org ([81.169.241.247]:37770 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733050AbeGKLeN (ORCPT ); Wed, 11 Jul 2018 07:34:13 -0400 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> 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