of/fdt: export fdt blob as /sys/firmware/fdt
PATCH 1/1 of/fdt: export fdt blob as /sys/firmware/fdt
Create a new /sys entry '/sys/firmware/fdt' to export the FDT blob that was passed to the kernel by the bootloader. This allows userland applications such as kexec to access the raw binary.
The fact that this node does not reside under /sys/firmware/device-tree is deliberate: FDT is also used on arm64 UEFI/ACPI systems to communicate just the UEFI and ACPI entry points, but the FDT is never unflattened and used to configure the system.
---
Resending with CC LAKML and devicetree at vger.kernel.org added. Apologies for the noise.
drivers/of/fdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/of/fdt.c +20 -0
@@ -22,6 +22,7 @@#include <linux/libfdt.h> #include <linux/debugfs.h> #include <linux/serial_core.h> +#include <linux/sysfs.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h>
@@ -1103,4 +1104,23 @@ static int __init of_flat_dt_debugfs_export_fdt(void)module_init (of_flat_dt_debugfs_export_fdt);#endif +#ifdef CONFIG_SYSFS +static ssize_t of_fdt_raw_read (struct file *filp,struct kobject *kobj, +struct bin_attribute *bin_attr, +char *buf,loff_t off,size_t count) +{ +memcpy (buf, initial_boot_params + off, count); +return count; +} + +static int __init of_fdt_raw_init (void ) +{ +static struct bin_attribute of_fdt_raw_attr = +__BIN_ATTR (fdt,S_IRUSR , of_fdt_raw_read,NULL ,0 ); + of_fdt_raw_attr.size =fdt_totalsize (initial_boot_params); +return sysfs_create_bin_file (firmware_kobj, &of_fdt_raw_attr); +} +module_init (of_fdt_raw_init); +#endif +#endif /* CONFIG_OF_EARLY_FLATTREE */
Signature · 1 line
1.8.3.2
PATCH 1/1 of/fdt: export fdt blob as /sys/firmware/fdt
Quoted 10 lines · On Monday 10 November 2014 17:51:45 Ard Biesheuvel wrote:
Create a new /sys entry '
/sys/firmware/fdt' to export the FDT blob that was passed to the kernel by the bootloader. This allows userland applications such as kexec to access the raw binary.The fact that this node does not reside under
/sys/firmware/device-treeis deliberate: FDT is also used on arm64 UEFI/ACPI systems to communicate just the UEFI and ACPI entry points, but the FDT is never unflattened and used to configure the system.Signed-off-by Ard Biesheuvel <[email protected]>
Can you elaborate on the motivation? Initially the fdt format was introduced to make it easy to pass the information from /proc/device-tree to the next kernel for kexec. Are you interested in cases where this does not work?
Arnd
PATCH 1/1 of/fdt: export fdt blob as /sys/firmware/fdt
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Monday 10 November 2014 17:51:45 Ard Biesheuvel wrote:
Create a new /sys entry '
/sys/firmware/fdt' to export the FDT blob that was passed to the kernel by the bootloader. This allows userland applications such as kexec to access the raw binary.The fact that this node does not reside under
/sys/firmware/device-treeis deliberate: FDT is also used on arm64 UEFI/ACPI systems to communicate just the UEFI and ACPI entry points, but the FDT is never unflattened and used to configure the system.
Quoted 7 lines
Quoted 1 line
Signed-off-by Ard Biesheuvel <[email protected]>Can you elaborate on the motivation? Initially the fdt format was introduced to make it easy to pass the information from
/proc/device-treeto the next kernel for kexec. Are you interested in cases where this does not work?
/sys/firmware/device-tree only gets populated if you are really booting in DT mode, i.e., when the device tree is unflattened. However, in ACPI mode we still need to access the data that was communicated between UEFI and the kernel in the /chosen node if we want to support kexec under UEFI.
Signature · 1 line
Ard.
PATCH 1/1 of/fdt: export fdt blob as /sys/firmware/fdt
Quoted 19 lines · On Monday 10 November 2014 18:08:03 Ard Biesheuvel wrote:
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · On Monday 10 November 2014 17:51:45 Ard Biesheuvel wrote:
Create a new /sys entry '
/sys/firmware/fdt' to export the FDT blob that was passed to the kernel by the bootloader. This allows userland applications such as kexec to access the raw binary.The fact that this node does not reside under
/sys/firmware/device-treeis deliberate: FDT is also used on arm64 UEFI/ACPI systems to communicate just the UEFI and ACPI entry points, but the FDT is never unflattened and used to configure the system.Quoted 7 lines
Quoted 1 line
Signed-off-by Ard Biesheuvel <[email protected]>Can you elaborate on the motivation? Initially the fdt format was introduced to make it easy to pass the information from
/proc/device-treeto the next kernel for kexec. Are you interested in cases where this does not work?
Quoted 5 lines
/sys/firmware/device-treeonly gets populated if you are really booting in DT mode, i.e., when the device tree is unflattened. However, in ACPI mode we still need to access the data that was communicated between UEFI and the kernel in the /chosen node if we want to support kexec under UEFI.
Ah, now I get it.
Arnd