Received: by 10.213.65.68 with SMTP id h4csp2872323imn; Mon, 9 Apr 2018 10:19:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx489/n+csrCYs3IwtFsvyl3Q1ZGUb6zCIm+Ztx5DtN0dYpkfmxHu4jvJWMRJyRln+gcLTQbC X-Received: by 2002:a17:902:7611:: with SMTP id k17-v6mr2039574pll.244.1523294373794; Mon, 09 Apr 2018 10:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523294373; cv=none; d=google.com; s=arc-20160816; b=TNdLZpOUj0FuUrgsj45p2XjjJlnVbkj2gDuwwu+klUsfDEXogt0vJpP55cIb/uE/xn RHCG0UrVXpL/5ctYstqMjlA98JqLHAT27i4rfvZr776Vpx5mtrT9lTrbLlH9HavXEUiT eGEh19l5ivofhraqp93npLGB1Is7r/9QrhXX7/3p2i+CrG4bss1XfqgIB3WguczxP79X AHqLsWg/zqG+EhzxI4Qz/+7IA1Nl40/ytwjok/wBX9t1CLVmmnL2Uz7mNp5zLe0i0CK2 Vm8t1oBcms1RMmQOncWo+7tF2qOO8NxySrI9U0aa5A9NYLRPcxAK/X5sf2H5UKzcTvVZ Z8rg== 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=79OdL8ByQVnc8Vqglpd73cx2itHLr9x0E3tQXBZXogI=; b=DYRA2YPm7wu4etep+Jot2d66FnsqbPJeS5ERyiPN+I93fHycNDqgM7e38XF+v99wku cRo3q/uPF+OD7DeoL8PAJRFlmx3tHQGS0VdtelPyhQR722fXocPzkLqSY7cw5woEhrQ3 wRRBquEzuL53jiVwgyWkLSL2lc7KdcLicsHev5d/ULN1BqaECh97LW3MCBe8sYZ3uLmB v03gkiX8c0mrEdYbJAZHjHRulonigafvMPlfPccypHe1vzQFQMfXPH8uV+KJ6A9xbxJ8 XSL6xYyX8PrMPrQggq6S8Vr2GQlH2BfSCvn0NQZxJsyQbkxZiILkpnkMzOHt1N27cI5K sYrA== 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 g12-v6si665736pll.184.2018.04.09.10.18.56; Mon, 09 Apr 2018 10:19: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; 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 S1753108AbeDIRPK (ORCPT + 99 others); Mon, 9 Apr 2018 13:15:10 -0400 Received: from terminus.zytor.com ([198.137.202.136]:56505 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610AbeDIRPI (ORCPT ); Mon, 9 Apr 2018 13:15:08 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w39HEEBi1894363; Mon, 9 Apr 2018 10:14:14 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w39HEDFn1894359; Mon, 9 Apr 2018 10:14:13 -0700 Date: Mon, 9 Apr 2018 10:14:13 -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: torvalds@linux-foundation.org, mingo@kernel.org, keescook@google.com, dave.hansen@linux.intel.com, dan.j.williams@intel.com, tglx@linutronix.de, bp@alien8.de, peterz@infradead.org, dwmw2@infradead.org, aarcange@redhat.com, namit@vmware.com, luto@kernel.org, jgross@suse.com, hughd@google.com, hpa@zytor.com, arjan@linux.intel.com, jpoimboe@redhat.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org Reply-To: jgross@suse.com, aarcange@redhat.com, namit@vmware.com, luto@kernel.org, jpoimboe@redhat.com, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, hughd@google.com, hpa@zytor.com, arjan@linux.intel.com, dave.hansen@linux.intel.com, torvalds@linux-foundation.org, mingo@kernel.org, keescook@google.com, peterz@infradead.org, dwmw2@infradead.org, dan.j.williams@intel.com, tglx@linutronix.de, bp@alien8.de 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: e71e836f463dd2cfb319ce88ae4a6e4f83904e6c 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: e71e836f463dd2cfb319ce88ae4a6e4f83904e6c Gitweb: https://git.kernel.org/tip/e71e836f463dd2cfb319ce88ae4a6e4f83904e6c Author: Dave Hansen AuthorDate: Fri, 6 Apr 2018 13:55:11 -0700 Committer: Ingo Molnar CommitDate: Mon, 9 Apr 2018 18:27:33 +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 ?