From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbcBWJRF (ORCPT ); Tue, 23 Feb 2016 04:17:05 -0500 Received: from terminus.zytor.com ([198.137.202.10]:58382 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757638AbcBWJK4 (ORCPT ); Tue, 23 Feb 2016 04:10:56 -0500 Date: Mon, 22 Feb 2016 04:16:54 -0800 From: =?UTF-8?B?dGlwLWJvdCBmb3IgU2FpIFByYW5lZXRoIDx0aXBib3RAenl0b3IuY29tPg==?=@zytor.com Message-ID: Cc: dvlasenk@redhat.com, luto@amacapital.net, ard.biesheuvel@linaro.org, akpm@linux-foundation.org, bp@alien8.de, matt@codeblueprint.co.uk, mcgrof@suse.com, ricardo.neri@intel.com, toshi.kani@hp.com, hughd@google.com, sai.praneeth.prakhya@intel.com, torvalds@linux-foundation.org, ravi.v.shankar@intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, jlee@suse.com, hpa@zytor.com, brgerst@gmail.com, peterz@infradead.org, mingo@kernel.org Reply-To: ricardo.neri@intel.com, toshi.kani@hp.com, hughd@google.com, matt@codeblueprint.co.uk, mcgrof@suse.com, dvlasenk@redhat.com, luto@amacapital.net, ard.biesheuvel@linaro.org, akpm@linux-foundation.org, bp@alien8.de, brgerst@gmail.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, jlee@suse.com, hpa@zytor.com, sai.praneeth.prakhya@intel.com, ravi.v.shankar@intel.com, torvalds@linux-foundation.org, tglx@linutronix.de In-Reply-To: <1455712566-16727-12-git-send-email-matt@codeblueprint.co.uk> References: <1455712566-16727-12-git-send-email-matt@codeblueprint.co.uk> To: =?UTF-8?B?bGludXgtdGlwLWNvbW1pdHNAdmdlci5rZXJuZWwub3Jn?=@zytor.com Subject: =?UTF-8?B?W3RpcDplZmkvY29yZV0geDg2L21tL3BhdDogRG9uJ3QgaW1wbGljaXRseSBhbGw=?= =?UTF-8?B?b3cgX1BBR0VfUlcgaW4ga2VybmVsX21hcF9wYWdlc19pbl9wZ2QoKQ==?= Git-Commit-ID: =?UTF-8?B?MTVmMDAzZDIwNzgyYTQwNzllMDc4ZDE2ZGY1NzA4MWViZDFmYzE1MA==?= X-Mailer: =?UTF-8?B?dGlwLWdpdC1sb2ctZGFlbW9u?= Robot-ID: =?UTF-8?B?PHRpcC1ib3QuZ2l0Lmtlcm5lbC5vcmc+?= Robot-Unsubscribe: =?UTF-8?B?Q29udGFjdCA8bWFpbHRvOmhwYUBrZXJuZWwub3JnPiB0byBnZXQgYmxhY2tsaXM=?= =?UTF-8?B?dGVkIGZyb20gdGhlc2UgZW1haWxz?= MIME-Version: =?UTF-8?B?MS4w?= Content-Transfer-Encoding: =?UTF-8?B?OGJpdA==?= Content-Type: =?UTF-8?B?dGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOA==?= Content-Disposition: =?UTF-8?B?aW5saW5l?= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 15f003d20782a4079e078d16df57081ebd1fc150 Gitweb: http://git.kernel.org/tip/15f003d20782a4079e078d16df57081ebd1fc150 Author: Sai Praneeth AuthorDate: Wed, 17 Feb 2016 12:36:04 +0000 Committer: Ingo Molnar CommitDate: Mon, 22 Feb 2016 08:26:28 +0100 x86/mm/pat: Don't implicitly allow _PAGE_RW in kernel_map_pages_in_pgd() As part of the preparation for the EFI_MEMORY_RO flag added in the UEFI 2.5 specification, we need the ability to map pages in kernel page tables without _PAGE_RW being set. Modify kernel_map_pages_in_pgd() to require its callers to pass _PAGE_RW if the pages need to be mapped read/write. Otherwise, we'll map the pages as read-only. Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Matt Fleming Cc: Andrew Morton Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Hugh Dickins Cc: Lee, Chun-Yi Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Ravi Shankar Cc: Ricardo Neri Cc: Thomas Gleixner Cc: Toshi Kani Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/1455712566-16727-12-git-send-email-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar --- arch/x86/mm/pageattr.c | 3 +++ arch/x86/platform/efi/efi_64.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index bf312da..14c38ae 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1971,6 +1971,9 @@ int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, if (!(page_flags & _PAGE_NX)) cpa.mask_clr = __pgprot(_PAGE_NX); + if (!(page_flags & _PAGE_RW)) + cpa.mask_clr = __pgprot(_PAGE_RW); + cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); retval = __change_page_attr_set_clr(&cpa, 0); diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index b492521..b0965b2 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -233,7 +233,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) * phys_efi_set_virtual_address_map(). */ pfn = pa_memmap >> PAGE_SHIFT; - if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX)) { + if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX | _PAGE_RW)) { pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap); return 1; } @@ -262,7 +262,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) pfn = md->phys_addr >> PAGE_SHIFT; npages = md->num_pages; - if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, 0)) { + if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, _PAGE_RW)) { pr_err("Failed to map 1:1 memory\n"); return 1; } @@ -279,7 +279,7 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) text = __pa(_text); pfn = text >> PAGE_SHIFT; - if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, 0)) { + if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, _PAGE_RW)) { pr_err("Failed to map kernel text 1:1\n"); return 1; } @@ -294,7 +294,7 @@ void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages) static void __init __map_region(efi_memory_desc_t *md, u64 va) { - unsigned long flags = 0; + unsigned long flags = _PAGE_RW; unsigned long pfn; pgd_t *pgd = efi_pgd;