This patch makes a couple of changes to the SMBIOS/DMI scanning code so it can be used on other archs (such as ARM and arm64): (a) wrap the calls to ioremap()/iounmap(), this allows the use of a flavor of ioremap() more suitable for random unaligned access; (b) allow the non-EFI fallback probe into hardcoded physical address 0xF0000 to be disabled.
Signed-off-by: Yi Li yi.li@linaro.org --- drivers/firmware/dmi_scan.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index fa0affb..92d7ce0 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -108,7 +108,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, { u8 *buf;
- buf = dmi_ioremap(dmi_base, dmi_len); + buf = dmi_early_remap(dmi_base, dmi_len); if (buf == NULL) return -1;
@@ -116,7 +116,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
add_device_randomness(buf, dmi_len);
- dmi_iounmap(buf, dmi_len); + dmi_early_unmap(buf, dmi_len); return 0; }
@@ -483,18 +483,19 @@ void __init dmi_scan_machine(void) * needed during early boot. This also means we can * iounmap the space when we're done with it. */ - p = dmi_ioremap(efi.smbios, 32); + p = dmi_early_remap(efi.smbios, 32); if (p == NULL) goto error; memcpy_fromio(buf, p, 32); - dmi_iounmap(p, 32); + dmi_early_unmap(p, 32);
if (!dmi_present(buf)) { dmi_available = 1; goto out; } } else { - p = dmi_ioremap(0xF0000, 0x10000); +#ifdef DMI_SCAN_MACHINE_NON_EFI_FALLBACK + p = dmi_early_ioremap(0xF0000, 0x10000); if (p == NULL) goto error;
@@ -510,12 +511,13 @@ void __init dmi_scan_machine(void) memcpy_fromio(buf + 16, q, 16); if (!dmi_present(buf)) { dmi_available = 1; - dmi_iounmap(p, 0x10000); + dmi_early_unmap(p, 0x10000); goto out; } memcpy(buf, buf + 16, 16); } - dmi_iounmap(p, 0x10000); + dmi_early_unmap(p, 0x10000); +#endif } error: pr_info("DMI not present or invalid.\n"); @@ -787,13 +789,13 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *), if (!dmi_available) return -1;
- buf = ioremap(dmi_base, dmi_len); + buf = dmi_remap(dmi_base, dmi_len); if (buf == NULL) return -1;
dmi_table(buf, dmi_len, dmi_num, decode, private_data);
- iounmap(buf); + dmi_unmap(buf, dmi_len); return 0; } EXPORT_SYMBOL_GPL(dmi_walk);
Add dmi support on arm64, it depends on efi boot.
Signed-off-by: Yi Li yi.li@linaro.org --- arch/arm64/Kconfig | 8 ++++++++ arch/arm64/include/asm/dmi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/setup.c | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 arch/arm64/include/asm/dmi.h
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index d5aaddf..5fda3b4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -292,6 +292,14 @@ config EFI_STUB by EFI firmware without the use of a bootloader. See Documentation/efi-stub.txt for more information.
+config DMI + default y + bool "Enable DMI scanning" + ---help--- + Enabled scanning of DMI to identify machine quirks. Say Y + here unless you have verified that your setup is not + affected by entries in the DMI blacklist. Required by EFI + support. endmenu
menu "Userspace binary formats" diff --git a/arch/arm64/include/asm/dmi.h b/arch/arm64/include/asm/dmi.h new file mode 100644 index 0000000..f25a7da --- /dev/null +++ b/arch/arm64/include/asm/dmi.h @@ -0,0 +1,29 @@ +/* + * arch/arm64/include/asm/dmi.h + * + * Copyright (C) 2013 Linaro Limited. + * Written by: Yi Li (yi.li@linaro.org) + * + * based on arch/ia64/include/asm/dmi.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + + +#ifndef _ASM_DMI_H +#define _ASM_DMI_H 1 + +#include <linux/slab.h> +#include <asm/io.h> + +/* Use normal IO mappings for DMI */ +#define dmi_early_remap early_memremap +#define dmi_early_unmap(x, l) early_iounmap(x, l) +#define dmi_remap early_memremap +#define dmi_unmap(x, l) early_iounmap(x, l) +#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) + +#endif + diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 1aeaaf5..1480843 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -45,6 +45,7 @@ #ifdef CONFIG_ACPI #include <linux/acpi.h> #endif +#include <linux/dmi.h>
#include <asm/fixmap.h> #include <asm/cputype.h> @@ -312,6 +313,7 @@ static int __init arm64_device_init(void) { of_clk_init(NULL); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); + dmi_scan_machine(); return 0; } arch_initcall(arm64_device_init);
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
Add dmi support on arm64, it depends on efi boot.
Signed-off-by: Yi Li yi.li@linaro.org
arch/arm64/Kconfig | 8 ++++++++ arch/arm64/include/asm/dmi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/setup.c | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 arch/arm64/include/asm/dmi.h
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index d5aaddf..5fda3b4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -292,6 +292,14 @@ config EFI_STUB by EFI firmware without the use of a bootloader. See Documentation/efi-stub.txt for more information.
+config DMI
default y
bool "Enable DMI scanning"
---help---
Enabled scanning of DMI to identify machine quirks. Say Y
here unless you have verified that your setup is not
affected by entries in the DMI blacklist. Required by EFI
support.
endmenu
Where does this text come from? It more or less suggests that you can disable this once you have checked that your system is not blacklisted, which seems bogus to me. Also, if EFI requires it, should we not have a 'depends on' or 'select' relation between the two somewhere?
menu "Userspace binary formats" diff --git a/arch/arm64/include/asm/dmi.h b/arch/arm64/include/asm/dmi.h new file mode 100644 index 0000000..f25a7da --- /dev/null +++ b/arch/arm64/include/asm/dmi.h @@ -0,0 +1,29 @@ +/*
- arch/arm64/include/asm/dmi.h
- Copyright (C) 2013 Linaro Limited.
- Written by: Yi Li (yi.li@linaro.org)
- based on arch/ia64/include/asm/dmi.h
- This file is subject to the terms and conditions of the GNU General Public
- License. See the file "COPYING" in the main directory of this archive
- for more details.
- */
+#ifndef _ASM_DMI_H +#define _ASM_DMI_H 1
+#include <linux/slab.h> +#include <asm/io.h>
+/* Use normal IO mappings for DMI */ +#define dmi_early_remap early_memremap +#define dmi_early_unmap(x, l) early_iounmap(x, l)
This seems sane, although you can drop the (x, l) here
+#define dmi_remap early_memremap +#define dmi_unmap(x, l) early_iounmap(x, l)
As far as I understand from Leif, these are not callable anymore when the memory system is fully up and running.
On Saturday, November 23, 2013 01:05 AM, Ard Biesheuvel wrote:
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
Add dmi support on arm64, it depends on efi boot.
Signed-off-by: Yi Li yi.li@linaro.org
arch/arm64/Kconfig | 8 ++++++++ arch/arm64/include/asm/dmi.h | 29 +++++++++++++++++++++++++++++ arch/arm64/kernel/setup.c | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 arch/arm64/include/asm/dmi.h
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index d5aaddf..5fda3b4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -292,6 +292,14 @@ config EFI_STUB by EFI firmware without the use of a bootloader. See Documentation/efi-stub.txt for more information.
+config DMI
default y
bool "Enable DMI scanning"
---help---
Enabled scanning of DMI to identify machine quirks. Say Y
here unless you have verified that your setup is not
affected by entries in the DMI blacklist. Required by EFI
endmenusupport.
Where does this text come from? It more or less suggests that you can disable this once you have checked that your system is not blacklisted, which seems bogus to me. Also, if EFI requires it, should we not have a 'depends on' or 'select' relation between the two somewhere?
Yi: the text comes from arch/x86/Kconfig.
menu "Userspace binary formats" diff --git a/arch/arm64/include/asm/dmi.h b/arch/arm64/include/asm/dmi.h new file mode 100644 index 0000000..f25a7da --- /dev/null +++ b/arch/arm64/include/asm/dmi.h @@ -0,0 +1,29 @@ +/*
- arch/arm64/include/asm/dmi.h
- Copyright (C) 2013 Linaro Limited.
- Written by: Yi Li (yi.li@linaro.org)
- based on arch/ia64/include/asm/dmi.h
- This file is subject to the terms and conditions of the GNU General Public
- License. See the file "COPYING" in the main directory of this archive
- for more details.
- */
+#ifndef _ASM_DMI_H +#define _ASM_DMI_H 1
+#include <linux/slab.h> +#include <asm/io.h>
+/* Use normal IO mappings for DMI */ +#define dmi_early_remap early_memremap +#define dmi_early_unmap(x, l) early_iounmap(x, l)
This seems sane, although you can drop the (x, l) here
Yi: ok.
+#define dmi_remap early_memremap +#define dmi_unmap(x, l) early_iounmap(x, l)
As far as I understand from Leif, these are not callable anymore when the memory system is fully up and running.
Yi: maybe, but it is tested under FVP.
Add dmi support on arm32, it depends on efi boot.
Signed-off-by: Yi Li yi.li@linaro.org --- arch/arm/Kconfig | 11 +++++++++++ arch/arm/include/asm/dmi.h | 30 ++++++++++++++++++++++++++++++ arch/arm/kernel/setup.c | 7 +++++++ 3 files changed, 48 insertions(+) create mode 100644 arch/arm/include/asm/dmi.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 11367a4..6c54d16 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1910,6 +1910,15 @@ config EFI_STUB executed directly by EFI firmware. See Documentation/efi-stub.txt for more information.
+config DMI + default y + bool "Enable DMI scanning" if EXPERT + ---help--- + Enabled scanning of DMI to identify machine quirks. Say Y + here unless you have verified that your setup is not + affected by entries in the DMI blacklist. Required by EFI + support. + config SECCOMP bool prompt "Enable seccomp to safely compute untrusted bytecode" @@ -2348,6 +2357,8 @@ source "net/Kconfig"
source "drivers/Kconfig"
+source "drivers/firmware/Kconfig" + source "fs/Kconfig"
source "arch/arm/Kconfig.debug" diff --git a/arch/arm/include/asm/dmi.h b/arch/arm/include/asm/dmi.h new file mode 100644 index 0000000..2abd4bf --- /dev/null +++ b/arch/arm/include/asm/dmi.h @@ -0,0 +1,30 @@ +/* + * arch/arm/include/asm/dmi.h + * + * Copyright (C) 2013 Linaro Limited. + * Written by: Yi Li (yi.li@linaro.org) + * + * based on arch/arm64/include/asm/dmi.h + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + + +#ifndef _ASM_DMI_H +#define _ASM_DMI_H 1 + +#include <linux/slab.h> +#include <asm/io.h> +#include <asm/mach/map.h> + +/* Use normal IO mappings for DMI */ +#define dmi_early_remap(x, l) __arm_ioremap((x), (l), MT_MEMORY) +#define dmi_early_unmap(x, l) __arm_iounmap(x) +#define dmi_remap ioremap +#define dmi_unmap(x, l) iounmap(x) +#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) + +#endif + diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 0bde4e3..ba6e612 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -34,6 +34,7 @@ #ifdef CONFIG_ACPI #include <linux/acpi.h> #endif +#include <linux/dmi.h>
#include <asm/unified.h> #include <asm/cp15.h> @@ -1063,3 +1064,9 @@ const struct seq_operations cpuinfo_op = { .stop = c_stop, .show = c_show }; + +#ifdef CONFIG_DMI + core_initcall(dmi_scan_machine); +#endif + +
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
Add dmi support on arm32, it depends on efi boot.
Signed-off-by: Yi Li yi.li@linaro.org
arch/arm/Kconfig | 11 +++++++++++ arch/arm/include/asm/dmi.h | 30 ++++++++++++++++++++++++++++++ arch/arm/kernel/setup.c | 7 +++++++ 3 files changed, 48 insertions(+) create mode 100644 arch/arm/include/asm/dmi.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 11367a4..6c54d16 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1910,6 +1910,15 @@ config EFI_STUB executed directly by EFI firmware. See Documentation/efi-stub.txt for more information.
+config DMI
default y
bool "Enable DMI scanning" if EXPERT
Same point as for arm64. Also, why the 'if EXPERT' here and not for arm64? Anyway, I think you could remove the help text completely and replace this line with something like
bool "Enable support for SMBIOS (DMI) tables" depends on EFI
---help---
Enabled scanning of DMI to identify machine quirks. Say Y
here unless you have verified that your setup is not
affected by entries in the DMI blacklist. Required by EFI
support.
config SECCOMP bool prompt "Enable seccomp to safely compute untrusted bytecode" @@ -2348,6 +2357,8 @@ source "net/Kconfig"
source "drivers/Kconfig"
+source "drivers/firmware/Kconfig"
source "fs/Kconfig"
source "arch/arm/Kconfig.debug" diff --git a/arch/arm/include/asm/dmi.h b/arch/arm/include/asm/dmi.h new file mode 100644 index 0000000..2abd4bf --- /dev/null +++ b/arch/arm/include/asm/dmi.h @@ -0,0 +1,30 @@ +/*
- arch/arm/include/asm/dmi.h
- Copyright (C) 2013 Linaro Limited.
- Written by: Yi Li (yi.li@linaro.org)
- based on arch/arm64/include/asm/dmi.h
- This file is subject to the terms and conditions of the GNU General Public
- License. See the file "COPYING" in the main directory of this archive
- for more details.
- */
+#ifndef _ASM_DMI_H +#define _ASM_DMI_H 1
+#include <linux/slab.h> +#include <asm/io.h> +#include <asm/mach/map.h>
+/* Use normal IO mappings for DMI */ +#define dmi_early_remap(x, l) __arm_ioremap((x), (l), MT_MEMORY) +#define dmi_early_unmap(x, l) __arm_iounmap(x) +#define dmi_remap ioremap +#define dmi_unmap(x, l) iounmap(x) +#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC)
Please refer to the other email regarding the mapping functions
+#endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 0bde4e3..ba6e612 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -34,6 +34,7 @@ #ifdef CONFIG_ACPI #include <linux/acpi.h> #endif +#include <linux/dmi.h>
#include <asm/unified.h> #include <asm/cp15.h> @@ -1063,3 +1064,9 @@ const struct seq_operations cpuinfo_op = { .stop = c_stop, .show = c_show };
+#ifdef CONFIG_DMI
core_initcall(dmi_scan_machine);
+#endif
You could add the call to dmi_scan_machine() to customize_machine(), and frop the #ifdef as well.
Regards,
Change header to support dmi driver on multi archs, it depends on [DMI: Enhance for multi archs] patch.
Signed-off-by: Yi Li yi.li@linaro.org --- arch/x86/include/asm/dmi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/dmi.h b/arch/x86/include/asm/dmi.h index fd8f9e2..7790d52 100644 --- a/arch/x86/include/asm/dmi.h +++ b/arch/x86/include/asm/dmi.h @@ -12,8 +12,12 @@ static __always_inline __init void *dmi_alloc(unsigned len) return extend_brk(len, sizeof(int)); }
+#define DMI_SCAN_MACHINE_NON_EFI_FALLBACK 1 + /* Use early IO mappings for DMI because it's initialized early */ -#define dmi_ioremap early_ioremap -#define dmi_iounmap early_iounmap +#define dmi_early_remap early_ioremap +#define dmi_early_unmap early_iounmap +#define dmi_remap ioremap +#define dmi_unmap(x, l) iounmap(x)
#endif /* _ASM_X86_DMI_H */
Change header to support dmi driver on multi archs, it depends on [DMI: Enhance for multi archs] patch.
Signed-off-by: Yi Li yi.li@linaro.org --- arch/ia64/include/asm/dmi.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/ia64/include/asm/dmi.h b/arch/ia64/include/asm/dmi.h index 185d3d1..080e0f3 100644 --- a/arch/ia64/include/asm/dmi.h +++ b/arch/ia64/include/asm/dmi.h @@ -5,8 +5,9 @@ #include <asm/io.h>
/* Use normal IO mappings for DMI */ -#define dmi_ioremap ioremap -#define dmi_iounmap(x,l) iounmap(x) -#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) - +#define dmi_early_remap ioremap +#define dmi_early_unmap(x, l) iounmap(x) +#define dmi_remap ioremap +#define dmi_unmap(x, l) iounmap(x) +#define dmi_alloc(l) kzalloc(l, GFP_ATOMIC) #endif
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
This patch makes a couple of changes to the SMBIOS/DMI scanning code so it can be used on other archs (such as ARM and arm64): (a) wrap the calls to ioremap()/iounmap(), this allows the use of a flavor of ioremap() more suitable for random unaligned access; (b) allow the non-EFI fallback probe into hardcoded physical address 0xF0000 to be disabled.
Signed-off-by: Yi Li yi.li@linaro.org
This patch and the ones that change x86 and ia64 dmi.h *must* stay combined, otherwise you may break bisect for other people. (If you apply this patch, but not the other ones, you break the build on x86 and/or ia64 because dma_early_ioremap does not exist yet)
I have already sent this patch to the list: I am hoping to get it acked by one of the x86 maintainers, so you will be able to send it to catalin and/or russell as part of this series and they can merge it through their respective trees.
On Saturday, November 23, 2013 12:52 AM, Ard Biesheuvel wrote:
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
This patch makes a couple of changes to the SMBIOS/DMI scanning code so it can be used on other archs (such as ARM and arm64): (a) wrap the calls to ioremap()/iounmap(), this allows the use of a flavor of ioremap() more suitable for random unaligned access; (b) allow the non-EFI fallback probe into hardcoded physical address 0xF0000 to be disabled.
Signed-off-by: Yi Li yi.li@linaro.org
This patch and the ones that change x86 and ia64 dmi.h *must* stay combined, otherwise you may break bisect for other people. (If you apply this patch, but not the other ones, you break the build on x86 and/or ia64 because dma_early_ioremap does not exist yet)
Yi: shall we make dmi_scan.c + dmi.h (x86/ia64) as one patch. if they will be accepted ,then create the patch for arm/arm64? only two patches are enough?
I have already sent this patch to the list: I am hoping to get it acked by one of the x86 maintainers, so you will be able to send it to catalin and/or russell as part of this series and they can merge it through their respective trees.
Yi: just wait the answer by maintainers?
On 22 November 2013 18:06, Yi Li yi.li@linaro.org wrote:
On Saturday, November 23, 2013 12:52 AM, Ard Biesheuvel wrote:
On 22 November 2013 17:43, Yi Li yi.li@linaro.org wrote:
This patch makes a couple of changes to the SMBIOS/DMI scanning code so it can be used on other archs (such as ARM and arm64): (a) wrap the calls to ioremap()/iounmap(), this allows the use of a flavor of ioremap() more suitable for random unaligned access; (b) allow the non-EFI fallback probe into hardcoded physical address 0xF0000 to be disabled.
Signed-off-by: Yi Li yi.li@linaro.org
This patch and the ones that change x86 and ia64 dmi.h *must* stay combined, otherwise you may break bisect for other people. (If you apply this patch, but not the other ones, you break the build on x86 and/or ia64 because dma_early_ioremap does not exist yet)
Yi: shall we make dmi_scan.c + dmi.h (x86/ia64) as one patch. if they will be accepted ,then create the patch for arm/arm64? only two patches are enough?
Well, it was already just one patch. Once we receive the ack from the x86 guys, I will share the updated version with you and you should be able to just load it into your git branch using 'git am'
I have already sent this patch to the list: I am hoping to get it acked by one of the x86 maintainers, so you will be able to send it to catalin and/or russell as part of this series and they can merge it through their respective trees.
Yi: just wait the answer by maintainers?
Well, I am open to suggestions (Grant?) on whom to poke from team-x86 and how to poke them, but for now, yeah, let's just wait a bit.