From patchwork Wed Jul 18 09:41:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531883 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 0A550600F4 for ; Wed, 18 Jul 2018 09:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5EB28FBC for ; Wed, 18 Jul 2018 09:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE83028FCD; Wed, 18 Jul 2018 09:42:57 +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 87B5928FBC for ; Wed, 18 Jul 2018 09:42:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D47466B02A0; 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 CF8176B02A3; 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 B534E6B02A5; 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-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 4A32F6B02A0 for ; Wed, 18 Jul 2018 05:41:38 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id w10-v6so1685008eds.7 for ; Wed, 18 Jul 2018 02:41:38 -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=yudYNyn1Lxan+E5J+81h1NnRe9DFfy1ORIbUjMxHj1k=; b=D89FhKyn7lErp7n+tSe9XRo+kNH+Ur2KRvq6/k3q/foIpWs2J816QcDh4F1kMhuXuC JnvEiMpGYZz9npm75eczNAvpZzvHdm638hfg1MMO3Udol2y6SX3yFgiCxWhyRCWM/KCB 2ZIRqTWDoiA4PofhBnSQUWaOjrjhPdaSKqWg56BPKCfCF3iD7rQI6BBe5Vrk3PBrCWI+ bjouUUDVW4VGB1GJTZJsx1iTixBK0RmVxDFQ451EqqLY4Us50Hgx8Qqpzc3wZM4FWnQz r4wqPZd7/kqxRc5CxQ1KYewR4rDhcbzBR3dWe8BUuyJ98jgksvGpiP6FHeZfJUX9d5R5 FczQ== X-Gm-Message-State: AOUpUlHM4FTg5Fr6eHOJQ8Ru5xtDRPuxttXw416/wQgPU2idoAxxX9tm K5LqL+9JP2lW9N/xwhVkOgjvBPHLd61pVM/GnkyeNA3IwWVk4Duqtg5S6qx+1PA1jdQyZAekMRj 2ffMIsJ+lInTaWrXadNNMRPhbKE4lK8woftCgJxAVB2bV1Z6ZpEJk6OR/Zm/f3pV5Ig== X-Received: by 2002:a50:b8a4:: with SMTP id l33-v6mr6466698ede.273.1531906897872; Wed, 18 Jul 2018 02:41:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfABdweox16qSSv60pKodiFHR8+KGkrTQGyWIxzxvGgdnSzg+VNmnNEjb+qOXItEeOi0g5N X-Received: by 2002:a50:b8a4:: with SMTP id l33-v6mr6466655ede.273.1531906897239; Wed, 18 Jul 2018 02:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906897; cv=none; d=google.com; s=arc-20160816; b=rgaWahFMTPRxQ5zNtXKwDdVYki+a6K2O4/Vhbo2lazD8rr5nTzi1bP8pDyNBcowT6P CPH7LGYV8v91Y68Zg7tD3/5t4neRsUS/p+Lm7IyfDUeEjvMJraE7kjtheQ2DqmWVgrwP AbIh7/ny3C3kLc6WyKNePcN4z95y3qjV8aGmlhaJzyLBGm/Yec1hjKbac4k5Azzphk88 7VW5nz5BhgdOAK66EQlLjjaoQZz9WCC2rTyBhmaUlF8Im0rBEw6Hpnj68Zn+vG2kfy57 55sm5AjNahsxA7mNCiY5BgnvgV3YjmOVTkyhy50Sy7mN2+jF6BrSaGWkEtc1FolOD74W WBAA== 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=yudYNyn1Lxan+E5J+81h1NnRe9DFfy1ORIbUjMxHj1k=; b=wCD5vDmk8kpWdxPT0ANDc7s3tkdR9cjy0gfALdGgVZfjZVHF9HiWecMS42yrFXohuK L4wNMbzIbqDv6b3J5pbX81ofdrGbUq+XM/Eust6TRi39o27020EUgGnuL2YzYDOAnqJg HmM/dl4XCiFGW4F4TtzhpheL3pOSfPxvmyCRbrp6JX+kdSjmoeIdwY3KbKeyYGCOHJpZ aedu/Hxg7K8+C8nVyDVXESNViHffmXDafEBantaY9kAn3RRUxLNpqGG+rpAYd1ccyDCs AuY3pHK/5b6ht5L0hyRRFYzPs0YRmIAI8e9VusHxqaZCt4bNFJvEAgoqxIQbMYkc5+qt Pa1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=cOlSHeNf; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 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. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id 42-v6si381422edu.414.2018.07.18.02.41.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:37 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=cOlSHeNf; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 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 85DAC2099; 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=dfv0Zih1QJqgNawf7FbV+BW/CZ/u7bR2eHjCpA2aoNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cOlSHeNfP/bPXkP8PlYzUEWoC32mDdwa9aHXeZHiYC8VOy16vxj4V0UzWfSgLhXcv 70qgM1w4VaMKnAYqgqTrF54Pa5wjZrV87DMz4H2OvSxJBQFzrR6/4o653KFsHa1jAE 6C4QppUSfFYh2bZbYMmctDTdzh63TOoRj5qFBLl0ktX5M8FeWOUp5N7WkLxjATqmXH DilzCmSQnTNMZfSzdfZv74HJTYSDzAsMYyh7TMoh9VwkCcIpLe2ECl6aYFAyLnGDqH wcqgXWDoFvZwiNBAHQggF2cOiVbucW1VbNVpvEM19ShttBASv1RYFZ1DwM8tN3YbuK kqRo8G+73G5Ug== 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 28/39] x86/mm/pti: Keep permissions when cloning kernel text in pti_clone_kernel_text() Date: Wed, 18 Jul 2018 11:41:05 +0200 Message-Id: <1531906876-13451-29-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 Mapping the kernel text area to user-space makes only sense if it has the same permissions as in the kernel page-table. If permissions are different this will cause a TLB reload when using the kernel page-table, which is as good as not mapping it at all. On 64-bit kernels this patch makes no difference, as the whole range cloned by pti_clone_kernel_text() is mapped RO anyway. On 32 bit there are writeable mappings in the range, so just keep the permissions as they are. Signed-off-by: Joerg Roedel --- arch/x86/mm/pti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 4f6e933..fc77054 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -482,7 +482,7 @@ void pti_clone_kernel_text(void) * pti_set_kernel_image_nonglobal() did to clear the * global bit. */ - pti_clone_pmds(start, end, _PAGE_RW); + pti_clone_pmds(start, end, 0); } /*