Received: by 10.192.165.156 with SMTP id m28csp1632207imm; Thu, 12 Apr 2018 00:18:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx497nCEZaUSUeeJxy2TU6lrgWP7iZKWb9cOdOFTKILRz5RBDT2HticC6/UlbqirbgQO7Ncq1 X-Received: by 10.98.59.4 with SMTP id i4mr6729169pfa.26.1523517539321; Thu, 12 Apr 2018 00:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523517539; cv=none; d=google.com; s=arc-20160816; b=RAUzV2UcoyIXB0vt+rjJMwU9GfYw0up8rqwqXGMKleEESeSehmnoRAUl30MNs429Fq 0EHrPciEZ+/0ZvoOjMkfMdIuk39rVnYic/k8gUl2KZIkyFoYfYlBryE2VfU+YXM51yX8 nQe2rPGcezd98iVTUkj+h9viSjcVgqD4fEXrs0cKkOjM3v1+Y+A5r1hKuMVqp0rOjt+r gmrnap+49afBB8ZIazYGBKL/6l/jySuPnzGAnq1DgZKnJs9SXc54iFQ8h3YTlszw/f7g tZSlxTyk6UWbFoWM3DdENfRka6Ua1Zaami8dzVHfriWA7JYqqFbgxDaqF6NuuMmpwqTw Ct9A== 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=rVjUifQl0FFbr6o9TJXyylU54fYojEEmMOjQSZ6s8Dc=; b=CxrlZlVYc5eLJ4pUV7LuX1T22D3z/Bfu8tldKnmuGyO0qIR9Z1t2d3ZRw6B8QF6zYg eOt1/X3b/GgcVG2/57k8bpigxKdagD6FF8zcGNNKHYVaLTjFW4+jJAwKbUT8gTDGZYjH nqASzQn/luJoBLsDbqtGTHwGJvIZlv+p4VJscGGW9RptQtwzNSZGeR43h+Spq1B4Umo1 Lz63vKpiXYH5SncyXcHznc9e3YRJHqFHt+yXWWL9vkf7QpR+iozb2P7T5/btLVlCjbvV klZ9cAlhJwNQd+uPCenRJXrFcZPA3O9Ts0AR12HjMy1svNRjVH1l4bAygucE3UoxOMd4 XoCA== 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 t2-v6si2759180plo.235.2018.04.12.00.18.22; Thu, 12 Apr 2018 00:18: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 S1752660AbeDLHP0 (ORCPT + 99 others); Thu, 12 Apr 2018 03:15:26 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40765 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbeDLHPZ (ORCPT ); Thu, 12 Apr 2018 03:15:25 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w3C7ELbv2969953; Thu, 12 Apr 2018 00:14:21 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w3C7EKU42969950; Thu, 12 Apr 2018 00:14:20 -0700 Date: Thu, 12 Apr 2018 00:14:20 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Dave Hansen Message-ID: Cc: dan.j.williams@intel.com, jpoimboe@redhat.com, tglx@linutronix.de, dwmw2@infradead.org, luto@kernel.org, namit@vmware.com, torvalds@linux-foundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, hughd@google.com, keescook@google.com, jgross@suse.com, bp@alien8.de, mingo@kernel.org, hpa@zytor.com, arjan@linux.intel.com, aarcange@redhat.com, dave.hansen@linux.intel.com Reply-To: keescook@google.com, hughd@google.com, mingo@kernel.org, bp@alien8.de, jgross@suse.com, arjan@linux.intel.com, hpa@zytor.com, aarcange@redhat.com, dave.hansen@linux.intel.com, tglx@linutronix.de, dan.j.williams@intel.com, jpoimboe@redhat.com, luto@kernel.org, dwmw2@infradead.org, torvalds@linux-foundation.org, namit@vmware.com, gregkh@linuxfoundation.org, peterz@infradead.org, linux-kernel@vger.kernel.org In-Reply-To: <20180406205511.BC072352@viggo.jf.intel.com> References: <20180406205511.BC072352@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/mm: Remove extra filtering in pageattr code Git-Commit-ID: 1a54420aeb4da1ba5b28283aa5696898220c9a27 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 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: 1a54420aeb4da1ba5b28283aa5696898220c9a27 Gitweb: https://git.kernel.org/tip/1a54420aeb4da1ba5b28283aa5696898220c9a27 Author: Dave Hansen AuthorDate: Fri, 6 Apr 2018 13:55:11 -0700 Committer: Ingo Molnar CommitDate: Thu, 12 Apr 2018 09:05:58 +0200 x86/mm: Remove extra filtering in pageattr code The pageattr code has a mode where it can set or clear PTE bits in existing PTEs, so the page protections of the *new* PTEs come from one of two places: 1. The set/clear masks: cpa->mask_clr / cpa->mask_set 2. The existing PTE We filter ->mask_set/clr for supported PTE bits at entry to __change_page_attr() so we never need to filter them again. The only other place permissions can come from is an existing PTE and those already presumably have good bits. We do not need to filter them again. Signed-off-by: Dave Hansen Cc: Andrea Arcangeli Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Hugh Dickins Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Kees Cook Cc: Linus Torvalds Cc: Nadav Amit Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180406205511.BC072352@viggo.jf.intel.com Signed-off-by: Ingo Molnar --- arch/x86/mm/pageattr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index d3442dfdfced..968f51a2e39b 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -598,7 +598,6 @@ try_preserve_large_page(pte_t *kpte, unsigned long address, req_prot = pgprot_clear_protnone_bits(req_prot); if (pgprot_val(req_prot) & _PAGE_PRESENT) pgprot_val(req_prot) |= _PAGE_PSE; - req_prot = canon_pgprot(req_prot); /* * old_pfn points to the large page base pfn. So we need @@ -718,7 +717,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, */ pfn = ref_pfn; for (i = 0; i < PTRS_PER_PTE; i++, pfn += pfninc) - set_pte(&pbase[i], pfn_pte(pfn, canon_pgprot(ref_prot))); + set_pte(&pbase[i], pfn_pte(pfn, ref_prot)); if (virt_addr_valid(address)) { unsigned long pfn = PFN_DOWN(__pa(address)); @@ -935,7 +934,6 @@ static void populate_pte(struct cpa_data *cpa, pte = pte_offset_kernel(pmd, start); pgprot = pgprot_clear_protnone_bits(pgprot); - pgprot = canon_pgprot(pgprot); while (num_pages-- && start < end) { set_pte(pte, pfn_pte(cpa->pfn, pgprot)); @@ -1234,7 +1232,7 @@ repeat: * after all we're only going to change it's attributes * not the memory it points to */ - new_pte = pfn_pte(pfn, canon_pgprot(new_prot)); + new_pte = pfn_pte(pfn, new_prot); cpa->pfn = pfn; /* * Do we really change anything ?