Received: by 10.213.65.68 with SMTP id h4csp1070224imn; Fri, 6 Apr 2018 14:04:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/K1n16N3HX08bgyHM59xdQ5BT4yxtQsCW4p2jsBIqCa3qiJ1WVqgds+xsw+oY/Jq2KHZbA X-Received: by 2002:a17:902:aa46:: with SMTP id c6-v6mr28233440plr.154.1523048640547; Fri, 06 Apr 2018 14:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523048640; cv=none; d=google.com; s=arc-20160816; b=oaJ8SGWWke1GMp9q+r6L1ipm/EbnlGQwcmE6WHC5ZbVNjrfFEkalxEbQF+twKA5kp4 71ZPYO9g9d1ND2NIe11P37AelzRkghq1sKmvJlkEhccW/wFg+z4enRhV39B+XT9foPIu JPnOUU77hFWikUG+05G/EYV2RsDIO/ybYQIgFb6KTEdVIWx94Ow+yCpeGxb0dKELnWHL AtxjrlYK3zVD/CzHwNbYrYfQXDwnfxLmHTrsw8keWdFazHhtSafVRcQ/ntn32kZTCU7c py18bPeHnAY+MJCfGJPVmmg5OZipCLY1Wt1TrJu6u97JfD7wWONAawvQyFwFYEeZxv1B VHqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:arc-authentication-results; bh=JB7BZN2af8qEarbCn3O2IcBfDaroCLxjjdHun8FcolM=; b=DN2ReHaICc3RjsEpC9jVkyqinrGqz3MSz7z6P1hOBQgRNs8MU7aQ+UTQbtpUkFvupJ 5PBVdjX2sqP6hvzuFN355XtVd1nZkF5ryJvfF4FnSXlNbRrUQZOv3usAvV84KIj6cXd5 Gffi6dq61H4FgQoQntrHQHFIoFW7oTUtvPeGefRgTeMd3HouixXnDqyzCCo6xi9ze/Hl /gycTxLRjXbWcrMlJHINXvd/RaHRCId2I3V9FDiQsUnpNQngBgr5yfscqgRaz5GOcN8q GL0PItK/g2THj8MfT7PGWnzMQ3YdjenO+rGimssD//Djopz+rPN5Zflnce/9sziKHG46 /yqw== 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 v23-v6si9313165plo.235.2018.04.06.14.03.22; Fri, 06 Apr 2018 14:04:00 -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 S1752168AbeDFU6L (ORCPT + 99 others); Fri, 6 Apr 2018 16:58:11 -0400 Received: from mga02.intel.com ([134.134.136.20]:47870 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752093AbeDFU6I (ORCPT ); Fri, 6 Apr 2018 16:58:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2018 13:58:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,416,1517904000"; d="scan'208";a="45626950" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by orsmga001.jf.intel.com with ESMTP; 06 Apr 2018 13:58:07 -0700 Subject: [PATCH 06/11] x86/mm: remove extra filtering in pageattr code To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , aarcange@redhat.com, luto@kernel.org, torvalds@linux-foundation.org, keescook@google.com, hughd@google.com, jgross@suse.com, x86@kernel.org, namit@vmware.com From: Dave Hansen Date: Fri, 06 Apr 2018 13:55:11 -0700 References: <20180406205501.24A1A4E7@viggo.jf.intel.com> In-Reply-To: <20180406205501.24A1A4E7@viggo.jf.intel.com> Message-Id: <20180406205511.BC072352@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen 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: Linus Torvalds Cc: Kees Cook Cc: Hugh Dickins Cc: Juergen Gross Cc: x86@kernel.org Cc: Nadav Amit --- b/arch/x86/mm/pageattr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff -puN arch/x86/mm/pageattr.c~x86-pageattr-dont-filter-global arch/x86/mm/pageattr.c --- a/arch/x86/mm/pageattr.c~x86-pageattr-dont-filter-global 2018-04-06 10:47:56.635796122 -0700 +++ b/arch/x86/mm/pageattr.c 2018-04-06 10:47:56.639796122 -0700 @@ -598,7 +598,6 @@ try_preserve_large_page(pte_t *kpte, uns 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, */ 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 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 ? _