From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 10/10] arm64/efi: improve /dev/mem mmap() handling under UEFI
Date: Thu, 6 Nov 2014 15:13:26 +0100 [thread overview]
Message-ID: <1415283206-14713-11-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1415283206-14713-1-git-send-email-ard.biesheuvel@linaro.org>
When booting via UEFI, we need to ensure that mappings of arbitrary
physical ranges through /dev/mem do not violate architectural rules
regarding conflicting cacheability attributes of overlapping regions.
Also, when CONFIG_STRICT_DEVMEM is in effect, memory regions with
special significance to UEFI should be protected sufficiently.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/mm/mmu.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 3e8b3732ca87..9ae3904f386c 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -19,6 +19,7 @@
#include <linux/export.h>
#include <linux/kernel.h>
+#include <linux/efi.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/mman.h>
@@ -28,6 +29,7 @@
#include <linux/io.h>
#include <asm/cputype.h>
+#include <asm/efi.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/sizes.h>
@@ -121,6 +123,8 @@ early_param("cachepolicy", early_cachepolicy);
pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
unsigned long size, pgprot_t vma_prot)
{
+ if (efi_enabled(EFI_MEMMAP) && efi_mem_access_prot(pfn, &vma_prot))
+ return vma_prot;
if (!pfn_valid(pfn))
return pgprot_noncached(vma_prot);
else if (file->f_flags & O_SYNC)
@@ -129,6 +133,19 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
}
EXPORT_SYMBOL(phys_mem_access_prot);
+/*
+ * This definition of phys_mem_access_prot_allowed() overrides
+ * the __weak definition in drivers/char/mem.c
+ */
+int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
+ unsigned long size, pgprot_t *prot)
+{
+ if (efi_enabled(EFI_MEMMAP))
+ return efi_mem_access_allowed(pfn, size,
+ pgprot_val(*prot) & PTE_WRITE);
+ return 1;
+}
+
static void __init *early_alloc(unsigned long sz)
{
void *ptr = __va(memblock_alloc(sz, sz));
--
1.8.3.2
prev parent reply other threads:[~2014-11-06 14:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 14:13 [PATCH v2 00/10] arm64: stable UEFI mappings for kexec Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 01/10] arm64/mm: add explicit struct_mm argument to __create_mapping() Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 02/10] arm64/mm: add create_pgd_mapping() to create private page tables Ard Biesheuvel
2014-11-07 15:08 ` Steve Capper
2014-11-07 15:12 ` Ard Biesheuvel
2014-11-07 15:21 ` Steve Capper
2014-11-06 14:13 ` [PATCH v2 03/10] efi: split off remapping code from efi_config_init() Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 04/10] efi: add common infrastructure for stub-installed virtual mapping Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 05/10] arm64/efi: move SetVirtualAddressMap() to UEFI stub Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 06/10] arm64/efi: remove free_boot_services() and friends Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 07/10] arm64/efi: remove idmap manipulations from UEFI code Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 08/10] arm64/efi: use UEFI memory map unconditionally if available Ard Biesheuvel
2014-11-06 14:13 ` [PATCH v2 09/10] arm64/efi: ignore unusable regions instead of reserving them Ard Biesheuvel
2014-11-10 4:11 ` Mark Salter
2014-11-10 7:31 ` Ard Biesheuvel
2014-11-11 15:42 ` Mark Salter
2014-11-11 17:12 ` Mark Salter
2014-11-11 17:44 ` Mark Rutland
2014-11-11 17:55 ` Ard Biesheuvel
2014-11-11 18:39 ` Mark Rutland
2014-11-11 18:23 ` Mark Salter
2014-11-06 14:13 ` Ard Biesheuvel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415283206-14713-11-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).