All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Ard Biesheuvel
	<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>,
	Jeremy Linton <jeremy.linton-5wv7dgnIgG8@public.gmane.org>,
	Leif Lindholm
	<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Matt Fleming
	<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
	Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] arm64/efi: remove spurious WARN_ON for !4K kernels
Date: Wed, 25 May 2016 16:11:56 +0100	[thread overview]
Message-ID: <1464189116-30898-1-git-send-email-mark.rutland@arm.com> (raw)

Since commit 1fd55a9a09b0293a ("arm64/efi: Apply strict permissions to
UEFI Runtime Services regions"), booting a !4K page kernel results in a
boot-time splat on some systems, due to to a WARN_ONCE added in that
commit which fires if the base address of an EFI memory descriptor is
not aligned to the kernel page size (which might be 4K, 16K, or 64K).

On page 38 of the UEFI 2.6 specification it is stated:

	If a 64KiB physical page contains any 4KiB page with any of the
	following types listed below, then all 4KiB pages in the 64KiB
	page must use identical ARM Memory Page Attributes (as described
	in Table 8):
	— EfiRuntimeServicesCode
	— EfiRuntimeServicesData
	— EfiReserved
	— EfiACPIMemoryNVS
	Mixed attribute mappings within a larger page are not allowed.

On page 158 of the UEFI 2.6 specification, in the description of a
memory descriptor, the PhysicalStart and VirtualStart fields are
mandated as being 4K aligned, with NumberOfPages describing the number
of 4K pages in the region.

No further restriction on alignment is provided in the UEFI
specification, neither generically nor in a rule specific to AArch64.

So while attributes within a naturally-aligned 64K region must be
consistent across memory descriptors, the regions described by those
descriptors are not mandated to be 64K aligned.

Not being able to apply strict permissions is sub-optimal, and worthy of
some notice, but it is not helpful to erroneously suggest that firmware
is buggy, nor is it beneficial to have a noisy backtrace at boot time.

This patch downgrades the WARN_ONCE to a pr_warn_once, and re-words the
message to also describe the implication of the insufficient alignment.

Signed-off-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 
Cc: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
Cc: Jeremy Linton <jeremy.linton-5wv7dgnIgG8@public.gmane.org>
Cc: Leif Lindholm <leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
Cc: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 arch/arm64/kernel/efi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 78f5248..95e748e 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -30,14 +30,15 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md)
 	if (type == EFI_MEMORY_MAPPED_IO)
 		return PROT_DEVICE_nGnRE;
 
-	if (WARN_ONCE(!PAGE_ALIGNED(md->phys_addr),
-		      "UEFI Runtime regions are not aligned to 64 KB -- buggy firmware?"))
+	if (!PAGE_ALIGNED(md->phys_addr)) {
+		pr_warn_once("UEFI Runtime regions insufficiently aligned for strict permissions\n");
 		/*
 		 * If the region is not aligned to the page size of the OS, we
 		 * can not use strict permissions, since that would also affect
 		 * the mapping attributes of the adjacent regions.
 		 */
 		return pgprot_val(PAGE_KERNEL_EXEC);
+	}
 
 	/* R-- */
 	if ((attr & (EFI_MEMORY_XP | EFI_MEMORY_RO)) ==
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64/efi: remove spurious WARN_ON for !4K kernels
Date: Wed, 25 May 2016 16:11:56 +0100	[thread overview]
Message-ID: <1464189116-30898-1-git-send-email-mark.rutland@arm.com> (raw)

Since commit 1fd55a9a09b0293a ("arm64/efi: Apply strict permissions to
UEFI Runtime Services regions"), booting a !4K page kernel results in a
boot-time splat on some systems, due to to a WARN_ONCE added in that
commit which fires if the base address of an EFI memory descriptor is
not aligned to the kernel page size (which might be 4K, 16K, or 64K).

On page 38 of the UEFI 2.6 specification it is stated:

	If a 64KiB physical page contains any 4KiB page with any of the
	following types listed below, then all 4KiB pages in the 64KiB
	page must use identical ARM Memory Page Attributes (as described
	in Table 8):
	? EfiRuntimeServicesCode
	? EfiRuntimeServicesData
	? EfiReserved
	? EfiACPIMemoryNVS
	Mixed attribute mappings within a larger page are not allowed.

On page 158 of the UEFI 2.6 specification, in the description of a
memory descriptor, the PhysicalStart and VirtualStart fields are
mandated as being 4K aligned, with NumberOfPages describing the number
of 4K pages in the region.

No further restriction on alignment is provided in the UEFI
specification, neither generically nor in a rule specific to AArch64.

So while attributes within a naturally-aligned 64K region must be
consistent across memory descriptors, the regions described by those
descriptors are not mandated to be 64K aligned.

Not being able to apply strict permissions is sub-optimal, and worthy of
some notice, but it is not helpful to erroneously suggest that firmware
is buggy, nor is it beneficial to have a noisy backtrace at boot time.

This patch downgrades the WARN_ONCE to a pr_warn_once, and re-words the
message to also describe the implication of the insufficient alignment.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> 
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-efi at vger.kernel.org
---
 arch/arm64/kernel/efi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 78f5248..95e748e 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -30,14 +30,15 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md)
 	if (type == EFI_MEMORY_MAPPED_IO)
 		return PROT_DEVICE_nGnRE;
 
-	if (WARN_ONCE(!PAGE_ALIGNED(md->phys_addr),
-		      "UEFI Runtime regions are not aligned to 64 KB -- buggy firmware?"))
+	if (!PAGE_ALIGNED(md->phys_addr)) {
+		pr_warn_once("UEFI Runtime regions insufficiently aligned for strict permissions\n");
 		/*
 		 * If the region is not aligned to the page size of the OS, we
 		 * can not use strict permissions, since that would also affect
 		 * the mapping attributes of the adjacent regions.
 		 */
 		return pgprot_val(PAGE_KERNEL_EXEC);
+	}
 
 	/* R-- */
 	if ((attr & (EFI_MEMORY_XP | EFI_MEMORY_RO)) ==
-- 
1.9.1

             reply	other threads:[~2016-05-25 15:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 15:11 Mark Rutland [this message]
2016-05-25 15:11 ` [PATCH] arm64/efi: remove spurious WARN_ON for !4K kernels Mark Rutland
     [not found] ` <1464189116-30898-1-git-send-email-mark.rutland-5wv7dgnIgG8@public.gmane.org>
2016-05-25 15:23   ` Ard Biesheuvel
2016-05-25 15:23     ` Ard Biesheuvel
     [not found]     ` <BA565A9C-8CC0-42E4-9821-7941852F835A-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-05-25 16:12       ` Mark Rutland
2016-05-25 16:12         ` Mark Rutland
2016-05-25 18:23         ` Ard Biesheuvel
2016-05-25 18:23           ` Ard Biesheuvel
     [not found]           ` <CAKv+Gu94GLWUJBCtNUDb4Jak3KL0-MGkUfk82fZ5UdwWH60P_w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-05-26 10:56             ` Mark Rutland
2016-05-26 10:56               ` Mark Rutland
2016-06-03 15:50               ` Ard Biesheuvel
2016-06-03 15:50                 ` Ard Biesheuvel
2016-05-25 15:31   ` Catalin Marinas
2016-05-25 15:31     ` Catalin Marinas
2016-05-25 15:38   ` Jeremy Linton
2016-05-25 15:38     ` Jeremy Linton
2016-05-30 21:12   ` Matt Fleming
2016-05-30 21:12     ` Matt Fleming
     [not found]     ` <20160530211212.GG2984-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-06-03 10:00       ` Will Deacon
2016-06-03 10:00         ` Will Deacon
     [not found]         ` <20160603100040.GJ9915-5wv7dgnIgG8@public.gmane.org>
2016-06-17 21:16           ` Matt Fleming
2016-06-17 21:16             ` Matt Fleming
     [not found]             ` <20160617211601.GN2658-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-06-23 13:17               ` Mark Rutland
2016-06-23 13:17                 ` Mark Rutland

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=1464189116-30898-1-git-send-email-mark.rutland@arm.com \
    --to=mark.rutland-5wv7dgnigg8@public.gmane.org \
    --cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
    --cc=jeremy.linton-5wv7dgnIgG8@public.gmane.org \
    --cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
    --cc=will.deacon-5wv7dgnIgG8@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.