linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] arm64: apei: implement arch_apei_get_mem_attributes()
@ 2015-08-14 22:37 Jonathan (Zhixiong) Zhang
  2015-08-14 22:37 ` [PATCH 2/2] acpi, apei: use appropriate pgprot_t to map GHES memory Jonathan (Zhixiong) Zhang
       [not found] ` <1439591850-29002-1-git-send-email-zjzhang-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Jonathan (Zhixiong) Zhang @ 2015-08-14 22:37 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Matt Fleming, Ard Biesheuvel,
	Catalin Marinas, Hanjun Guo, Will Deacon
  Cc: Jonathan (Zhixiong) Zhang

From: "Jonathan (Zhixiong) Zhang" <zjzhang-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

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.

Reviewed-by: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
Acked-by: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Jonathan (Zhixiong) Zhang <zjzhang-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
---
V2: Changed arm64's implementation of arch_apei_get_mem_attributes()
    from inline function to out of line function, based on Ingo's
    feedback.

 arch/arm64/include/asm/acpi.h |  5 +++++
 arch/arm64/kernel/acpi.c      | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 406485ed110a..8084f3640006 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -92,4 +92,9 @@ static inline const char *acpi_get_enable_method(int cpu)
 {
 	return acpi_psci_present() ? "psci" : NULL;
 }
+
+#ifdef	CONFIG_ACPI_APEI
+pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
+#endif
+
 #endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index 19de7537e7d3..9f083606e5bf 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -29,6 +29,11 @@
 #include <asm/cpu_ops.h>
 #include <asm/smp_plat.h>
 
+#ifdef CONFIG_ACPI_APEI
+#include <linux/efi.h>
+#include <asm/pgtable.h>
+#endif
+
 int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
 int acpi_disabled = 1;
 EXPORT_SYMBOL(acpi_disabled);
@@ -230,3 +235,27 @@ void __init acpi_gic_init(void)
 
 	early_acpi_os_unmap_memory((char *)table, tbl_size);
 }
+
+#ifdef  CONFIG_ACPI_APEI
+pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
+{
+	/*
+	 * According to "Table 8 Map: EFI memory types to AArch64 memory
+	 * types" of UEFI 2.5 section 2.3.6.1, each EFI memory type is
+	 * mapped to a corresponding MAIR attribute encoding.
+	 * The EFI memory attribute advises all possible capabilities
+	 * of a memory region. We use the most efficient capability.
+	 */
+
+	u64 attr;
+
+	attr = efi_mem_attributes(addr);
+	if (attr & EFI_MEMORY_WB)
+		return PAGE_KERNEL;
+	if (attr & EFI_MEMORY_WT)
+		return __pgprot(PROT_NORMAL_WT);
+	if (attr & EFI_MEMORY_WC)
+		return __pgprot(PROT_NORMAL_NC);
+	return __pgprot(PROT_DEVICE_nGnRnE);
+}
+#endif
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-08-25 17:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14 22:37 [PATCH V2 1/2] arm64: apei: implement arch_apei_get_mem_attributes() Jonathan (Zhixiong) Zhang
2015-08-14 22:37 ` [PATCH 2/2] acpi, apei: use appropriate pgprot_t to map GHES memory Jonathan (Zhixiong) Zhang
     [not found]   ` <1439591850-29002-2-git-send-email-zjzhang-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-08-17 13:13     ` Matt Fleming
     [not found]       ` <20150817131357.GB3233-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-08-17 21:10         ` Zhang, Jonathan Zhixiong
2015-08-22  9:24     ` Ingo Molnar
     [not found]       ` <20150822092429.GB18233-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-24 18:22         ` Zhang, Jonathan Zhixiong
     [not found]           ` <55DB60FA.8050406-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-08-25  8:59             ` Ingo Molnar
     [not found]               ` <20150825085923.GA22414-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-25 17:30                 ` Zhang, Jonathan Zhixiong
     [not found] ` <1439591850-29002-1-git-send-email-zjzhang-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-08-17 13:05   ` [PATCH V2 1/2] arm64: apei: implement arch_apei_get_mem_attributes() Matt Fleming
     [not found]     ` <20150817130553.GA3233-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2015-08-17 21:09       ` Zhang, Jonathan Zhixiong

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).