mtd: maps: add INT0800 firmware-flash map driver
PATCH v2 1/1 mtd: maps: add INT0800 firmware-flash map driver
Add a read-only mapping driver that binds the ACPI INT0800 "Intel 82802 firmware hub" device and exposes the system firmware flash as an MTD ROM device.
On x86 machines the boot flash is decoded into the physical address space below 4 GB, so a plain ioremap() of the declared resource window is sufficient for reads - no SPI or LPC controller access is needed. The window may be larger than the real flash; undecoded holes read as 0xff.
This gives userspace a clean, safe way to read firmware flash contents without flashrom or relaxed /dev/mem access - for firmware analysis, and for extracting option ROMs stored inside EFI firmware volumes (e.g. the NVIDIA VBIOS on EFI-booted Apple machines, which can then be fed to nouveau via nouveau.config=NvBios=). There is deliberately no write or erase support.
Tested on a MacBookPro4,1 (ICH8M): /dev/mtd0 reads are byte-identical to a flashrom dump of the 2 MiB SST25VF016B, except for live NVRAM variable-store regions.
---
Changes in v2:
- Per-device state via devm_kzalloc instead of globals (fixes shared state corruption with multiple INT0800 devices)
- Clean up map probe on mtd_device_register() failure (fixes memory/mapping leak)
- Use %pa for resource_size_t in dev_info (fixes format string on 32-bit)
- Add missing Signed-off-by
drivers/mtd/maps/Kconfig | 17 ++++++ drivers/mtd/maps/Makefile | 1 + drivers/mtd/maps/int0800.c | 108 +++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 drivers/mtd/maps/int0800.c
drivers/mtd/maps/Kconfig +17 -0
@@ -161,6 +161,23 @@ config MTD_AMD76XROM BE VERY CAREFUL. +config MTD_INT0800 + tristate "Read-only BIOS/firmware flash via ACPI INT0800" + depends on X86 && ACPI + select MTD_ROM + help + Support for reading the system firmware (BIOS/EFI) flash chip + through the memory window described by the ACPI INT0800 + "82802 firmware hub" device, present on most x86 machines. + + The flash is exposed read-only via the ROM chip driver, e.g. + for firmware analysis or extracting option ROMs (such as + video BIOS images embedded in EFI firmware volumes). There is + no write or erase support. + + To compile this driver as a module, choose M here: the + module will be called int0800. + config MTD_ICHXROM tristate "BIOS flash chip on Intel Controller Hub 2/3/4/5" depends on X86 && MTD_JEDECPROBE
drivers/mtd/maps/Makefile +1 -0
@@ -14,6 +14,7 @@ obj-$(CONFIG_MTD_L440GX) += l440gx.o obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o obj-$(CONFIG_MTD_ESB2ROM) += esb2rom.o obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o +obj-$(CONFIG_MTD_INT0800) += int0800.o obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o obj-$(CONFIG_MTD_PXA2XX) += pxa2xx-flash.o
drivers/mtd/maps/int0800.c new file +108 -0
108 lines not on this page · raw message
Signature · 6 lines
2.43.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal
maintainerHi Stephen,
Quoted 1 line
+MODULE_AUTHOR("Devin");
Except this line which is missing your full identity, I guess I'm fine with the contribution.
drivers/mtd/maps/int0800.c line 108
Quoted 2 lines
drivers/mtd/maps/int0800.c new file +2
-0+MODULE_DESCRIPTION ("Read-only MTD map over the INT0800 firmware flash window" ); +MODULE_LICENSE ("GPL" );
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/