Merge tag 'efi-next' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into...
authorThomas Gleixner <tglx@linutronix.de>
Mon, 12 Aug 2019 16:58:34 +0000 (18:58 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 12 Aug 2019 16:58:34 +0000 (18:58 +0200)
Pull EFI changes for v5.4 from Ard:

 - Some refactoring of the EFI config table handling across architectures.
 - Add support for the Dell EMC OEM config table.
 - Include AER diagnostic output to CPER handling of fatal PCIe errors.

16 files changed:
Documentation/ABI/testing/sysfs-firmware-efi
arch/ia64/include/asm/sal.h
arch/ia64/include/asm/sn/sn_sal.h
arch/ia64/kernel/efi.c
arch/ia64/kernel/setup.c
arch/x86/include/asm/efi.h
arch/x86/include/asm/uv/uv.h
arch/x86/mm/ioremap.c
arch/x86/platform/efi/efi.c
arch/x86/platform/uv/bios_uv.c
drivers/firmware/efi/Kconfig
drivers/firmware/efi/Makefile
drivers/firmware/efi/cper.c
drivers/firmware/efi/efi.c
drivers/firmware/efi/rci2-table.c [new file with mode: 0644]
include/linux/efi.h

index e794eac32a90a51c4d01577affe71466cde99a1f..5e4d0b27cdfe00707e29a836c7c48ff6a0a48e5b 100644 (file)
@@ -28,3 +28,11 @@ Description: Displays the physical addresses of all EFI Configuration
                versions are always printed first, i.e. ACPI20 comes
                before ACPI.
 Users:         dmidecode
+
+What:          /sys/firmware/efi/tables/rci2
+Date:          July 2019
+Contact:       Narendra K <Narendra.K@dell.com>, linux-bugs@dell.com
+Description:   Displays the content of the Runtime Configuration Interface
+               Table version 2 on Dell EMC PowerEdge systems in binary format
+Users:         It is used by Dell EMC OpenManage Server Administrator tool to
+               populate BIOS setup page.
index 588f33156da6901053bc1022856b59ca86a1aea6..08f5b6aaed7324096e0d07cc39503c7d65b1dc9d 100644 (file)
@@ -43,6 +43,7 @@
 #include <asm/pal.h>
 #include <asm/fpu.h>
 
+extern unsigned long sal_systab_phys;
 extern spinlock_t sal_lock;
 
 /* SAL spec _requires_ eight args for each call. */
index 1f5ff470a5a18336dabfd257a94cbf5576ad4055..5142c444652dec305d364c478a17e3db3d39d152 100644 (file)
 static inline u32
 sn_sal_rev(void)
 {
-       struct ia64_sal_systab *systab = __va(efi.sal_systab);
+       struct ia64_sal_systab *systab = __va(sal_systab_phys);
 
        return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor);
 }
index 3795d18276c43e9dba11098260651732018690ea..0a34dcc435c6167add04c1a8fc0356fad8c0afa1 100644 (file)
 
 static __initdata unsigned long palo_phys;
 
+unsigned long sal_systab_phys = EFI_INVALID_TABLE_ADDR;
+
 static __initdata efi_config_table_type_t arch_tables[] = {
        {PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID, "PALO", &palo_phys},
+       {SAL_SYSTEM_TABLE_GUID, "SALsystab", &sal_systab_phys},
        {NULL_GUID, NULL, 0},
 };
 
index c9cfa760cd57bfc4c00ce275708e6723422d9769..0e1b4eb149b4bc0537bff5a4807b8f38c06c2000 100644 (file)
@@ -572,7 +572,7 @@ setup_arch (char **cmdline_p)
        find_memory();
 
        /* process SAL system table: */
-       ia64_sal_init(__va(efi.sal_systab));
+       ia64_sal_init(__va(sal_systab_phys));
 
 #ifdef CONFIG_ITANIUM
        ia64_patch_rse((u64) __start___rse_patchlist, (u64) __end___rse_patchlist);
index 606a4b6a9812c3128a5d70fbcac1ef00f7fa0bbb..43a82e59c59d2657d9e319361e7285a15da2fac7 100644 (file)
@@ -242,6 +242,7 @@ static inline bool efi_is_64bit(void)
                __efi_early()->runtime_services), __VA_ARGS__)
 
 extern bool efi_reboot_required(void);
+extern bool efi_is_table_address(unsigned long phys_addr);
 
 #else
 static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {}
@@ -249,6 +250,10 @@ static inline bool efi_reboot_required(void)
 {
        return false;
 }
+static inline  bool efi_is_table_address(unsigned long phys_addr)
+{
+       return false;
+}
 #endif /* CONFIG_EFI */
 
 #endif /* _ASM_X86_EFI_H */
index e60c45fd3679bf900a8e1d53d2cb731c316d519f..6bc6d89d8e2ad8d36819ae2457a815c9083f2d4b 100644 (file)
@@ -12,10 +12,12 @@ struct mm_struct;
 #ifdef CONFIG_X86_UV
 #include <linux/efi.h>
 
+extern unsigned long uv_systab_phys;
+
 extern enum uv_system_type get_uv_system_type(void);
 static inline bool is_early_uv_system(void)
 {
-       return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab);
+       return uv_systab_phys && uv_systab_phys != EFI_INVALID_TABLE_ADDR;
 }
 extern int is_uv_system(void);
 extern int is_uv_hubless(void);
index 63e99f15d7cf0eedc9b5b522b4d24e36a2708fde..a39dcdb5ae34e018393276f4e2fd502ade7f30e2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <asm/set_memory.h>
 #include <asm/e820/api.h>
+#include <asm/efi.h>
 #include <asm/fixmap.h>
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
index a7189a3b4d70f759ab9743f8b43c4a2b83c1e47f..c202e1b07e290c9f7bceeeb8a0c0deb887e990f6 100644 (file)
@@ -59,11 +59,34 @@ static efi_system_table_t efi_systab __initdata;
 
 static efi_config_table_type_t arch_tables[] __initdata = {
 #ifdef CONFIG_X86_UV
-       {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab},
+       {UV_SYSTEM_TABLE_GUID, "UVsystab", &uv_systab_phys},
 #endif
        {NULL_GUID, NULL, NULL},
 };
 
+static const unsigned long * const efi_tables[] = {
+       &efi.mps,
+       &efi.acpi,
+       &efi.acpi20,
+       &efi.smbios,
+       &efi.smbios3,
+       &efi.boot_info,
+       &efi.hcdp,
+       &efi.uga,
+#ifdef CONFIG_X86_UV
+       &uv_systab_phys,
+#endif
+       &efi.fw_vendor,
+       &efi.runtime,
+       &efi.config_table,
+       &efi.esrt,
+       &efi.properties_table,
+       &efi.mem_attr_table,
+#ifdef CONFIG_EFI_RCI2_TABLE
+       &rci2_table_phys,
+#endif
+};
+
 u64 efi_setup;         /* efi setup_data physical address */
 
 static int add_efi_memmap __initdata;
@@ -1049,3 +1072,17 @@ static int __init arch_parse_efi_cmdline(char *str)
        return 0;
 }
 early_param("efi", arch_parse_efi_cmdline);
+
+bool efi_is_table_address(unsigned long phys_addr)
+{
+       unsigned int i;
+
+       if (phys_addr == EFI_INVALID_TABLE_ADDR)
+               return false;
+
+       for (i = 0; i < ARRAY_SIZE(efi_tables); i++)
+               if (*(efi_tables[i]) == phys_addr)
+                       return true;
+
+       return false;
+}
index 7c69652ffeea2e6c3de91a8c6a349eea60b4bf55..c2ee31953372d4ed2b8a5fc9b19d9856eeaa9398 100644 (file)
@@ -14,6 +14,8 @@
 #include <asm/uv/bios.h>
 #include <asm/uv/uv_hub.h>
 
+unsigned long uv_systab_phys __ro_after_init = EFI_INVALID_TABLE_ADDR;
+
 struct uv_systab *uv_systab;
 
 static s64 __uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3,
@@ -185,13 +187,13 @@ EXPORT_SYMBOL_GPL(uv_bios_set_legacy_vga_target);
 void uv_bios_init(void)
 {
        uv_systab = NULL;
-       if ((efi.uv_systab == EFI_INVALID_TABLE_ADDR) ||
-           !efi.uv_systab || efi_runtime_disabled()) {
+       if ((uv_systab_phys == EFI_INVALID_TABLE_ADDR) ||
+           !uv_systab_phys || efi_runtime_disabled()) {
                pr_crit("UV: UVsystab: missing\n");
                return;
        }
 
-       uv_systab = ioremap(efi.uv_systab, sizeof(struct uv_systab));
+       uv_systab = ioremap(uv_systab_phys, sizeof(struct uv_systab));
        if (!uv_systab || strncmp(uv_systab->signature, UV_SYSTAB_SIG, 4)) {
                pr_err("UV: UVsystab: bad signature!\n");
                iounmap(uv_systab);
@@ -203,7 +205,7 @@ void uv_bios_init(void)
                int size = uv_systab->size;
 
                iounmap(uv_systab);
-               uv_systab = ioremap(efi.uv_systab, size);
+               uv_systab = ioremap(uv_systab_phys, size);
                if (!uv_systab) {
                        pr_err("UV: UVsystab: ioremap(%d) failed!\n", size);
                        return;
index d4ea929e8b344c1a48e0c96fc771ef374c65c4c2..178ee8106828775f90a317bbb86a3b75d8dfb9ac 100644 (file)
@@ -180,6 +180,19 @@ config RESET_ATTACK_MITIGATION
          have been evicted, since otherwise it will trigger even on clean
          reboots.
 
+config EFI_RCI2_TABLE
+       bool "EFI Runtime Configuration Interface Table Version 2 Support"
+       help
+         Displays the content of the Runtime Configuration Interface
+         Table version 2 on Dell EMC PowerEdge systems as a binary
+         attribute 'rci2' under /sys/firmware/efi/tables directory.
+
+         RCI2 table contains BIOS HII in XML format and is used to populate
+         BIOS setup page in Dell EMC OpenManage Server Administrator tool.
+         The BIOS setup page contains BIOS tokens which can be configured.
+
+         Say Y here for Dell EMC PowerEdge systems.
+
 endmenu
 
 config UEFI_CPER
index d2d0d20306200eedece2d5de4e708e70a9bbb16c..4ac2de4dfa72aaf6e22a351417dd5c1dac207819 100644 (file)
@@ -25,6 +25,7 @@ obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)  += efibc.o
 obj-$(CONFIG_EFI_TEST)                 += test/
 obj-$(CONFIG_EFI_DEV_PATH_PARSER)      += dev-path-parser.o
 obj-$(CONFIG_APPLE_PROPERTIES)         += apple-properties.o
+obj-$(CONFIG_EFI_RCI2_TABLE)           += rci2-table.o
 
 arm-obj-$(CONFIG_EFI)                  := arm-init.o arm-runtime.o
 obj-$(CONFIG_ARM)                      += $(arm-obj-y)
index 8fa977c7861f961c32af4dfa3b949e9c5f1460ec..addf0749dd8b6ea6b3d6f423363fbdfddbaea17e 100644 (file)
@@ -390,6 +390,21 @@ static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
                printk(
        "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n",
        pfx, pcie->bridge.secondary_status, pcie->bridge.control);
+
+       /* Fatal errors call __ghes_panic() before AER handler prints this */
+       if ((pcie->validation_bits & CPER_PCIE_VALID_AER_INFO) &&
+           (gdata->error_severity & CPER_SEV_FATAL)) {
+               struct aer_capability_regs *aer;
+
+               aer = (struct aer_capability_regs *)pcie->aer_info;
+               printk("%saer_uncor_status: 0x%08x, aer_uncor_mask: 0x%08x\n",
+                      pfx, aer->uncor_status, aer->uncor_mask);
+               printk("%saer_uncor_severity: 0x%08x\n",
+                      pfx, aer->uncor_severity);
+               printk("%sTLP Header: %08x %08x %08x %08x\n", pfx,
+                      aer->header_log.dw0, aer->header_log.dw1,
+                      aer->header_log.dw2, aer->header_log.dw3);
+       }
 }
 
 static void cper_print_tstamp(const char *pfx,
index ad3b1f4866b35951592dc4a4ecef92cf30cd4a1d..8f1ab04f6743ae9c402ac813195fd1a19d8f5b63 100644 (file)
@@ -39,11 +39,9 @@ struct efi __read_mostly efi = {
        .acpi20                 = EFI_INVALID_TABLE_ADDR,
        .smbios                 = EFI_INVALID_TABLE_ADDR,
        .smbios3                = EFI_INVALID_TABLE_ADDR,
-       .sal_systab             = EFI_INVALID_TABLE_ADDR,
        .boot_info              = EFI_INVALID_TABLE_ADDR,
        .hcdp                   = EFI_INVALID_TABLE_ADDR,
        .uga                    = EFI_INVALID_TABLE_ADDR,
-       .uv_systab              = EFI_INVALID_TABLE_ADDR,
        .fw_vendor              = EFI_INVALID_TABLE_ADDR,
        .runtime                = EFI_INVALID_TABLE_ADDR,
        .config_table           = EFI_INVALID_TABLE_ADDR,
@@ -57,25 +55,6 @@ struct efi __read_mostly efi = {
 };
 EXPORT_SYMBOL(efi);
 
-static unsigned long *efi_tables[] = {
-       &efi.mps,
-       &efi.acpi,
-       &efi.acpi20,
-       &efi.smbios,
-       &efi.smbios3,
-       &efi.sal_systab,
-       &efi.boot_info,
-       &efi.hcdp,
-       &efi.uga,
-       &efi.uv_systab,
-       &efi.fw_vendor,
-       &efi.runtime,
-       &efi.config_table,
-       &efi.esrt,
-       &efi.properties_table,
-       &efi.mem_attr_table,
-};
-
 struct mm_struct efi_mm = {
        .mm_rb                  = RB_ROOT,
        .mm_users               = ATOMIC_INIT(2),
@@ -476,7 +455,6 @@ static __initdata efi_config_table_type_t common_tables[] = {
        {ACPI_TABLE_GUID, "ACPI", &efi.acpi},
        {HCDP_TABLE_GUID, "HCDP", &efi.hcdp},
        {MPS_TABLE_GUID, "MPS", &efi.mps},
-       {SAL_SYSTEM_TABLE_GUID, "SALsystab", &efi.sal_systab},
        {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios},
        {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3},
        {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga},
@@ -487,6 +465,9 @@ static __initdata efi_config_table_type_t common_tables[] = {
        {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log},
        {LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log},
        {LINUX_EFI_MEMRESERVE_TABLE_GUID, "MEMRESERVE", &efi.mem_reserve},
+#ifdef CONFIG_EFI_RCI2_TABLE
+       {DELLEMC_EFI_RCI2_TABLE_GUID, NULL, &rci2_table_phys},
+#endif
        {NULL_GUID, NULL, NULL},
 };
 
@@ -964,20 +945,6 @@ int efi_status_to_err(efi_status_t status)
        return err;
 }
 
-bool efi_is_table_address(unsigned long phys_addr)
-{
-       unsigned int i;
-
-       if (phys_addr == EFI_INVALID_TABLE_ADDR)
-               return false;
-
-       for (i = 0; i < ARRAY_SIZE(efi_tables); i++)
-               if (*(efi_tables[i]) == phys_addr)
-                       return true;
-
-       return false;
-}
-
 static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock);
 static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init;
 
diff --git a/drivers/firmware/efi/rci2-table.c b/drivers/firmware/efi/rci2-table.c
new file mode 100644 (file)
index 0000000..3e290f9
--- /dev/null
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Export Runtime Configuration Interface Table Version 2 (RCI2)
+ * to sysfs
+ *
+ * Copyright (C) 2019 Dell Inc
+ * by Narendra K <Narendra.K@dell.com>
+ *
+ * System firmware advertises the address of the RCI2 Table via
+ * an EFI Configuration Table entry. This code retrieves the RCI2
+ * table from the address and exports it to sysfs as a binary
+ * attribute 'rci2' under /sys/firmware/efi/tables directory.
+ */
+
+#include <linux/kobject.h>
+#include <linux/device.h>
+#include <linux/sysfs.h>
+#include <linux/efi.h>
+#include <linux/types.h>
+#include <linux/io.h>
+
+#define RCI_SIGNATURE  "_RC_"
+
+struct rci2_table_global_hdr {
+       u16 type;
+       u16 resvd0;
+       u16 hdr_len;
+       u8 rci2_sig[4];
+       u16 resvd1;
+       u32 resvd2;
+       u32 resvd3;
+       u8 major_rev;
+       u8 minor_rev;
+       u16 num_of_structs;
+       u32 rci2_len;
+       u16 rci2_chksum;
+} __packed;
+
+static u8 *rci2_base;
+static u32 rci2_table_len;
+unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR;
+
+static ssize_t raw_table_read(struct file *file, struct kobject *kobj,
+                             struct bin_attribute *attr, char *buf,
+                             loff_t pos, size_t count)
+{
+       memcpy(buf, attr->private + pos, count);
+       return count;
+}
+
+static BIN_ATTR(rci2, S_IRUSR, raw_table_read, NULL, 0);
+
+static u16 checksum(void)
+{
+       u8 len_is_odd = rci2_table_len % 2;
+       u32 chksum_len = rci2_table_len;
+       u16 *base = (u16 *)rci2_base;
+       u8 buf[2] = {0};
+       u32 offset = 0;
+       u16 chksum = 0;
+
+       if (len_is_odd)
+               chksum_len -= 1;
+
+       while (offset < chksum_len) {
+               chksum += *base;
+               offset += 2;
+               base++;
+       }
+
+       if (len_is_odd) {
+               buf[0] = *(u8 *)base;
+               chksum += *(u16 *)(buf);
+       }
+
+       return chksum;
+}
+
+int __init efi_rci2_sysfs_init(void)
+{
+       struct kobject *tables_kobj;
+       int ret = -ENOMEM;
+
+       rci2_base = memremap(rci2_table_phys,
+                            sizeof(struct rci2_table_global_hdr),
+                            MEMREMAP_WB);
+       if (!rci2_base) {
+               pr_debug("RCI2 table init failed - could not map RCI2 table\n");
+               goto err;
+       }
+
+       if (strncmp(rci2_base +
+                   offsetof(struct rci2_table_global_hdr, rci2_sig),
+                   RCI_SIGNATURE, 4)) {
+               pr_debug("RCI2 table init failed - incorrect signature\n");
+               ret = -ENODEV;
+               goto err_unmap;
+       }
+
+       rci2_table_len = *(u32 *)(rci2_base +
+                                 offsetof(struct rci2_table_global_hdr,
+                                 rci2_len));
+
+       memunmap(rci2_base);
+
+       if (!rci2_table_len) {
+               pr_debug("RCI2 table init failed - incorrect table length\n");
+               goto err;
+       }
+
+       rci2_base = memremap(rci2_table_phys, rci2_table_len, MEMREMAP_WB);
+       if (!rci2_base) {
+               pr_debug("RCI2 table - could not map RCI2 table\n");
+               goto err;
+       }
+
+       if (checksum() != 0) {
+               pr_debug("RCI2 table - incorrect checksum\n");
+               ret = -ENODEV;
+               goto err_unmap;
+       }
+
+       tables_kobj = kobject_create_and_add("tables", efi_kobj);
+       if (!tables_kobj) {
+               pr_debug("RCI2 table - tables_kobj creation failed\n");
+               goto err_unmap;
+       }
+
+       bin_attr_rci2.size = rci2_table_len;
+       bin_attr_rci2.private = rci2_base;
+       ret = sysfs_create_bin_file(tables_kobj, &bin_attr_rci2);
+       if (ret != 0) {
+               pr_debug("RCI2 table - rci2 sysfs bin file creation failed\n");
+               kobject_del(tables_kobj);
+               kobject_put(tables_kobj);
+               goto err_unmap;
+       }
+
+       return 0;
+
+ err_unmap:
+       memunmap(rci2_base);
+ err:
+       pr_debug("RCI2 table - sysfs initialization failed\n");
+       return ret;
+}
+late_initcall(efi_rci2_sysfs_init);
index f87fabea4a859fa36998538dbdc8a572033e7a24..bd3837022307ac34271054b4024f8ec6bab09e5a 100644 (file)
@@ -692,6 +692,9 @@ void efi_native_runtime_setup(void);
 #define LINUX_EFI_TPM_FINAL_LOG_GUID           EFI_GUID(0x1e2ed096, 0x30e2, 0x4254,  0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
 #define LINUX_EFI_MEMRESERVE_TABLE_GUID                EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5,  0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2)
 
+/* OEM GUIDs */
+#define DELLEMC_EFI_RCI2_TABLE_GUID            EFI_GUID(0x2d9f28a2, 0xa886, 0x456a,  0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55)
+
 typedef struct {
        efi_guid_t guid;
        u64 table;
@@ -984,11 +987,9 @@ extern struct efi {
        unsigned long acpi20;           /* ACPI table  (ACPI 2.0) */
        unsigned long smbios;           /* SMBIOS table (32 bit entry point) */
        unsigned long smbios3;          /* SMBIOS table (64 bit entry point) */
-       unsigned long sal_systab;       /* SAL system table */
        unsigned long boot_info;        /* boot info table */
        unsigned long hcdp;             /* HCDP table */
        unsigned long uga;              /* UGA table */
-       unsigned long uv_systab;        /* UV system table */
        unsigned long fw_vendor;        /* fw_vendor */
        unsigned long runtime;          /* runtime table */
        unsigned long config_table;     /* config tables */
@@ -1211,8 +1212,6 @@ static inline bool efi_enabled(int feature)
        return test_bit(feature, &efi.flags) != 0;
 }
 extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
-
-extern bool efi_is_table_address(unsigned long phys_addr);
 #else
 static inline bool efi_enabled(int feature)
 {
@@ -1226,11 +1225,6 @@ efi_capsule_pending(int *reset_type)
 {
        return false;
 }
-
-static inline bool efi_is_table_address(unsigned long phys_addr)
-{
-       return false;
-}
 #endif
 
 extern int efi_status_to_err(efi_status_t status);
@@ -1722,6 +1716,8 @@ struct efi_tcg2_final_events_table {
 };
 extern int efi_tpm_final_log_size;
 
+extern unsigned long rci2_table_phys;
+
 /*
  * efi_runtime_service() function identifiers.
  * "NONE" is used by efi_recover_from_page_fault() to check if the page