[PATCH v4 02/10] riscv: Define arch_apei_get_mem_attribute for RISC-V
Himanshu Chauhan
himanshu.chauhan at oss.qualcomm.com
Wed May 13 01:43:17 PDT 2026
ghes_map function uses arch_apei_get_mem_attribute to get the
protection bits for a given physical address. These protection
bits are then used to map the physical address.
Signed-off-by: Himanshu Chauhan <himanshu.chauhan at oss.qualcomm.com>
---
arch/riscv/include/asm/acpi.h | 16 ++++++++++++++++
arch/riscv/kernel/acpi.c | 12 ++++++++++++
2 files changed, 28 insertions(+)
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 26ab37c171bc..c142db9f81a7 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -14,6 +14,7 @@
/* Basic configuration for ACPI */
#ifdef CONFIG_ACPI
+pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
typedef u64 phys_cpuid_t;
#define PHYS_CPUID_INVALID INVALID_HARTID
@@ -27,6 +28,21 @@ extern int acpi_disabled;
extern int acpi_noirq;
extern int acpi_pci_disabled;
+#ifdef CONFIG_ACPI_APEI
+/*
+ * acpi_disable_cmcff to disable IA-32 Corrected Machine Check (CMC)
+ * Firmware-First mode. It is not required in RISC-V architecture
+ * and is present for compatibility
+ */
+#define acpi_disable_cmcff 1
+static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
+{
+ return __acpi_get_mem_attribute(addr);
+}
+#else /* CONFIG_ACPI_APEI */
+#define acpi_disable_cmcff 0
+#endif /* !CONFIG_ACPI_APEI */
+
static inline void disable_acpi(void)
{
acpi_disabled = 1;
diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
index 068e0b404b6f..7a6770697999 100644
--- a/arch/riscv/kernel/acpi.c
+++ b/arch/riscv/kernel/acpi.c
@@ -204,6 +204,18 @@ struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu)
return &cpu_madt_rintc[cpu];
}
+pgprot_t __acpi_get_mem_attribute(phys_addr_t addr)
+{
+ u64 attr;
+
+ attr = efi_mem_attributes(addr);
+ if (attr & EFI_MEMORY_WB)
+ return PAGE_KERNEL;
+ if ((attr & EFI_MEMORY_WC) || (attr & EFI_MEMORY_WT))
+ return pgprot_writecombine(PAGE_KERNEL);
+ return PAGE_KERNEL;
+}
+
/*
* __acpi_map_table() will be called before paging_init(), so early_ioremap()
* or early_memremap() should be called here to for ACPI table mapping.
--
2.43.0
More information about the linux-riscv
mailing list