Skip to contentSkip to conversation

EFI changes for v4.3

GIT PULL Matt Fleming 4 participants 6 messages Aug 6, 2015 – Aug 9, 2015 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Folks, please pull the following changes for v4.3. The biggest changes are the memory map querying updates in the ACPI GHES driver and the revert of commit aeffc4928ea2 ("x86/efi: Request desired alignment via the PE/COFF headers") which was reportedly causing errors when users attempt to sign their kernels with Signtool.

The GHES driver changes touch a mixture of ACPI, x86 and arm64 code but all the patches have been ACKed and/or reviewed by relevant people.

The following changes since commit bc0195aad0daa2ad5b0d76cce22b167bc3435590:

Linux 4.2-rc2 (2015-07-12 15:10:30 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-next

for you to fetch changes up to 8229722e29da369a4e9512a5c18adb4028a7626b:

acpi, apei: use appropriate pgprot_t to map GHES memory (2015-08-06 15:44:41 +0100)

----------------------------------------------------------------
* Add support for the new EFI memory map attribute EFI_MEMORY_RO that was introduced in the UEFI 2.5 spec - Ard Biesheuvel

* Lower the severity of the invalid BGRT message from pr_err() to pr_debug() since it's legitimate (per the spec) for the firmware to pass the kernel a BGRT with the invalid status bit set. The kernel just simply needs to ignore it.

* Revert the optimisation of using CONFIG_PHYSICAL_ALIGN in the PE/COFF header SectionAlignment field of the EFI stub, since it violates the PE/COFF spec which says SizeOfImage must be a multiple of SectionAlignment, and because it was causing Signtool to fail.

* Update the ACPI Platform Error Interface (APEI) GHES driver to query the EFI memory map for the correct cache attributes to use when mapping pages accessed by both the kernel and firmware. This prevents stale data being read by the kernel - Jonathan (Zhixiong) Zhang

----------------------------------------------------------------
Ard Biesheuvel (1):
efi: Add support for EFI_MEMORY_RO attribute introduced by UEFIv2.5

Jonathan (Zhixiong) Zhang (5):
efi: x86: rearrange efi_mem_attributes()
x86: acpi: implement arch_apei_get_mem_attributes()
arm64: mm: add PROT_DEVICE_nGnRnE and PROT_NORMAL_WT
arm64: apei: implement arch_apei_get_mem_attributes() acpi, apei: use appropriate pgprot_t to map GHES memory

Matt Fleming (2):
x86/efi-bgrt: Switch pr_err() to pr_debug() for invalid BGRT Revert "x86/efi: Request desired alignment via the PE/COFF headers"

 arch/arm64/include/asm/acpi.h    | 27 +++++++++++++++++++++++++++
 arch/arm64/include/asm/memory.h  |  1 +
 arch/arm64/include/asm/pgtable.h |  2 ++
 arch/arm64/mm/proc.S             |  4 +++-
 arch/x86/boot/header.S           |  2 +-
 arch/x86/include/asm/acpi.h      | 24 ++++++++++++++++++++++++
 arch/x86/platform/efi/efi-bgrt.c |  9 +++++++--
 arch/x86/platform/efi/efi.c      | 18 ------------------
 drivers/acpi/apei/ghes.c         |  6 ++++--
 drivers/firmware/efi/efi.c       | 39 ++++++++++++++++++++++++++++++++++++---
 include/linux/efi.h              |  1 +
 11 files changed, 106 insertions(+), 27 deletions(-)
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Re: [PATCH 7/8] arm64: apei: implement arch_apei_get_mem_attributes()

Quoted 9 lines · Matt Fleming

From: "Jonathan (Zhixiong) Zhang" <[email protected]>

Table 8 of UEFI 2.5 section 2.3.6.1 defines mappings from EFI memory types to MAIR attribute encodings for arm64.

If the physical address has memory attributes defined by EFI memmap as EFI_MEMORY_[UC|WC|WT], return approprate page protection type according to the UEFI spec. Otherwise, return PAGE_KERNEL.

Quoted 8 lines
---
 arch/arm64/include/asm/acpi.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Ard Biesheuvel has brought up a concern with this patch and it's currently under discussion here,

https://lkml.kernel.org/r/CAKv+Gu8+g3dTaNzXjSD=5GxproaHM+Eu1hLmRWp7cVrQimzbHQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#3 lore raw

Re: [PATCH 7/8] arm64: apei: implement arch_apei_get_mem_attributes()

Quoted 19 lines · Matt Fleming
Quoted 9 lines · Matt Fleming

From: "Jonathan (Zhixiong) Zhang" <[email protected]>

Table 8 of UEFI 2.5 section 2.3.6.1 defines mappings from EFI memory types to MAIR attribute encodings for arm64.

If the physical address has memory attributes defined by EFI memmap as EFI_MEMORY_[UC|WC|WT], return approprate page protection type according to the UEFI spec. Otherwise, return PAGE_KERNEL.

Quoted 8 lines
---
 arch/arm64/include/asm/acpi.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
Quoted 4 lines

Ard Biesheuvel has brought up a concern with this patch and it's currently under discussion here,

https://lkml.kernel.org/r/CAKv+Gu8+g3dTaNzXjSD=5GxproaHM+Eu1hLmRWp7cVrQimzbHQ@mail.gmail.com

Ok, I applied the patches up to this point, to tip:core/efi, to get the ball rolling - and will push them out after testing:

8d446c8647c9 arm64/mm: Add PROT_DEVICE_nGnRnE and PROT_NORMAL_WT b40227fbfb1f acpi, x86: Implement arch_apei_get_mem_attributes() 7bf793115dd9 efi, x86: Rearrange efi_mem_attributes()
fa5c35011a8d Revert "x86/efi: Request desired alignment via the PE/COFF headers" 248fbcd5aee0 x86/efi-bgrt: Switch pr_err() to pr_debug() for invalid BGRT 87db73aebf55 efi: Add support for EFI_MEMORY_RO attribute introduced by UEFIv2.5

Let me know when the concerns are resolved or there are other patches to add.

Thanks,

Ingo

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH 4/8] efi: x86: rearrange efi_mem_attributes()

Thank you Matt for your help. I tried to find the cover letter and patch 1, 2, 3 of the patch set. But I did not find them. Probably the subject has typo? I appreciate that you re-post the patch set to get more feed backs, I just wanted to be sure.

Signature · 3 lines
Jonathan (Zhixiong) Zhang
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#6 lore raw

Re: [PATCH 4/8] efi: x86: rearrange efi_mem_attributes()

Quoted 4 lines · Jonathan Zhixiong

Thank you Matt for your help. I tried to find the cover letter and patch 1, 2, 3 of the patch set. But I did not find them. Probably the subject has typo? I appreciate that you re-post the patch set to get more feed backs, I just wanted to be sure.

I sent the patches as follow-up to my GIT PULL request here,

https://lkml.kernel.org/r/[email protected]

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#7 lore raw

[tip:core/efi] efi, x86: Rearrange efi_mem_attributes()

In reply to a message not in the archive
efi, x86: Rearrange efi_mem_attributes()
Commit-ID:  7bf793115dd96ce9bd8ed1665fc187d961a95dba
Gitweb:     http://git.kernel.org/tip/7bf793115dd96ce9bd8ed1665fc187d961a95dba
Author:     Jonathan (Zhixiong) Zhang <[email protected]>
AuthorDate: Fri, 7 Aug 2015 09:36:57 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 8 Aug 2015 10:37:39 +0200

efi, x86: Rearrange efi_mem_attributes()

x86 and ia64 implement efi_mem_attributes() differently. This function needs to be available for other architectures (such as arm64) as well, such as for the purpose of ACPI/APEI.

ia64 EFI does not set up a 'memmap' variable and does not set the EFI_MEMMAP flag, so it needs to have its unique implementation of efi_mem_attributes().

Move efi_mem_attributes() implementation from x86 to the core EFI code, and declare it with __weak.

It is recommended that other architectures should not override the default implementation.

---
 arch/x86/platform/efi/efi.c | 18 ------------------
 drivers/firmware/efi/efi.c  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 18 deletions(-)
arch/x86/platform/efi/efi.c +0 -18
index e4308fe..2f61fcd 100644
@@ -952,24 +952,6 @@ u32 efi_mem_type(unsigned long phys_addr)
 	return 0;
 }
 
-u64 efi_mem_attributes(unsigned long phys_addr)
-{
-	efi_memory_desc_t *md;
-	void *p;
-
-	if (!efi_enabled(EFI_MEMMAP))
-		return 0;
-
-	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
-		md = p;
-		if ((md->phys_addr <= phys_addr) &&
-		    (phys_addr < (md->phys_addr +
-				  (md->num_pages << EFI_PAGE_SHIFT))))
-			return md->attribute;
-	}
-	return 0;
-}
-
 static int __init arch_parse_efi_cmdline(char *str)
 {
 	if (!str) {
drivers/firmware/efi/efi.c +31 -0
index d7a9160..afee2880 100644
@@ -607,3 +607,34 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
 			 attr & EFI_MEMORY_UC      ? "UC"  : "");
 	return buf;
 }
+
+/*
+ * efi_mem_attributes - lookup memmap attributes for physical address
+ * @phys_addr: the physical address to lookup
+ *
+ * Search in the EFI memory map for the region covering
+ * @phys_addr. Returns the EFI memory attributes if the region
+ * was found in the memory map, 0 otherwise.
+ *
+ * Despite being marked __weak, most architectures should *not*
+ * override this function. It is __weak solely for the benefit
+ * of ia64 which has a funky EFI memory map that doesn't work
+ * the same way as other architectures.
+ */
+u64 __weak efi_mem_attributes(unsigned long phys_addr)
+{
+	efi_memory_desc_t *md;
+	void *p;
+
+	if (!efi_enabled(EFI_MEMMAP))
+		return 0;
+
+	for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
+		md = p;
+		if ((md->phys_addr <= phys_addr) &&
+		    (phys_addr < (md->phys_addr +
+		    (md->num_pages << EFI_PAGE_SHIFT))))
+			return md->attribute;
+	}
+	return 0;
+}