Received: by 10.223.185.116 with SMTP id b49csp2374132wrg; Thu, 22 Feb 2018 12:41:02 -0800 (PST) X-Google-Smtp-Source: AH8x2272FWx4AqyaGZuWaSqkFS5LLpJQQ0KdUCd3fjXSSX+aeC81m558nKXOYyCqmpO5o9ps8Ese X-Received: by 2002:a17:902:a512:: with SMTP id s18-v6mr7680104plq.296.1519332062452; Thu, 22 Feb 2018 12:41:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519332062; cv=none; d=google.com; s=arc-20160816; b=dhlK8AsZlQveDnnLcYfJRO/S7/zolL7ob6k76BjzrQn6w5wJy5b8FMSS+mNbKQYcak rh+Dr2oqRH6lUVJK9bCf5795rnYhT4JGxiDxXM1WMeOXZZGvD8vMvnQlqn8m789s7b+D CSWla1LLyPTx0R63GDD9VMQhu5Zhi5C6SidxfSo39aTw48ObZ3dNPRiVyXd+Xs1LVnEC qMnHQgoAIYzvyjZiWSJrbBhlF60PChPywhRt9W8Knn6ByJdkcpZzE915qZbPTmkDCDZc +d2vYVB648Zl7UHxjQaoxqfuoLyhXL+vwENRU96WJe7JfLtQAJj3dY4Pdb94opK/48tz o9+Q== 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=3MPCJa+dUveWgv5W2W4AozX/IASapJEuwM5wNU0UI70=; b=PpIpbqyu68k4BE/jmK0Zqih9Sa3IkYpAeXmLHazUyXBiw85taJozrXJxq2jRAXkqtY iQiNt2a7EWMzbRqy3G3gvzEHy8/EB05xwuBqDp9ypJStp17jhvZYN89gvqSQ5VhHyBCf KYJx3Q4/rH85zdmX4elvucKb4NWfG/NCmZFO2S+S4lEQqLtC6EPf9BRqRPi6PwWx03rR kKRrcaGtCNd3SJMX0hNqnE1F5ohar0JdWRaWs6gzjVaU1A4L/OBClx0G9wmyA7DBsddx sX9vf6mA/q8ixTSX2Oi9gS5rV4tjkCglGPpapcDRXrFzUAPkJ0pRbQBSP//tH+3MdxVq T9Aw== 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 b2si472488pgt.458.2018.02.22.12.40.47; Thu, 22 Feb 2018 12:41:02 -0800 (PST) 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 S1751626AbeBVUi2 (ORCPT + 99 others); Thu, 22 Feb 2018 15:38:28 -0500 Received: from mga12.intel.com ([192.55.52.136]:15124 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbeBVUhJ (ORCPT ); Thu, 22 Feb 2018 15:37:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Feb 2018 12:37:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,378,1515484800"; d="scan'208";a="20353992" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by orsmga006.jf.intel.com with ESMTP; 22 Feb 2018 12:37:09 -0800 Subject: [RFC][PATCH 06/10] x86/mm: remove extra filtering in pageattr code To: linux-kernel@vger.kernel.org Cc: 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: Thu, 22 Feb 2018 12:37:01 -0800 References: <20180222203651.B776810C@viggo.jf.intel.com> In-Reply-To: <20180222203651.B776810C@viggo.jf.intel.com> Message-Id: <20180222203701.0518257D@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-02-22 12:36:20.456036549 -0800 +++ b/arch/x86/mm/pageattr.c 2018-02-22 12:36:20.460036549 -0800 @@ -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 ? _