Skip to content

efi/firmware/platform-x86: Add EFI embedded fw support

Hans de Goede linux-doc linux-efi linux-input lkml platform-driver-x86 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v12 Latest10 patches 8 repliesIn review
  2. v1110 patches 9 repliesSuperseded
  3. v1010 patches 5 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v910 patches0 repliesSuperseded
v88 patches4 repliesSuperseded
v78 patches35 repliesSuperseded

Changes in v12 from the cover letter

- Use memcmp to check the prefix in efi_check_for_embedded_firmwares()
- Move the vmalloc (vmemdup) for the firmware copy owned by the firmare subsys from efi_get_embedded_fw() to firmware_fallback_platform(), so that it is is in the same subsys as the vfree which eventually frees it.
- Use local / private firmware variable for the test instead of the global test_firmware variable and drop the mutex lock + unlock needed for accessing the global test_firmware variable

Patches in v12 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10efi: Export boot-services code and data as debugfs-blobsarch/x86/platform/efi/efi.c arch/x86/platform/efi/quirks.c drivers/firmware/efi/efi.c +1 more+63 -00 replies
2/10efi: Add embedded peripheral firmware supportarch/x86/platform/efi/efi.c drivers/firmware/efi/Kconfig drivers/firmware/efi/Makefile +3 more+201 -00 replies
3/10firmware: Rename FW_OPT_NOFALLBACK to FW_OPT_NOFALLBACK_SYSFSdrivers/base/firmware_loader/fallback.c drivers/base/firmware_loader/firmware.h drivers/base/firmware_loader/main.c+15 -146 replies
4/10firmware: Add new platform fallback mechanism and firmware_request_platform()Documentation/driver-api/firmware/fallback-mechanisms.rst Documentation/driver-api/firmware/lookup-order.rst Documentation/driver-api/firmware/request_firmware.rst +7 more+198 -00 replies
5/10test_firmware: add support for firmware_request_platformlib/test_firmware.c+55 -01 reply
6/10selftests: firmware: Add firmware_request_platform teststools/testing/selftests/firmware/fw_filesystem.sh+23 -01 reply
7/10Input: silead - Switch to firmware_request_platform for retreiving the fwdrivers/input/touchscreen/silead.c+1 -10 replies
8/10Input: icn8505 - Switch to firmware_request_platform for retreiving the fwdrivers/input/touchscreen/chipone_icn8505.c+1 -10 replies
9/10platform/x86: touchscreen_dmi: Add EFI embedded firmware info supportdrivers/firmware/efi/embedded-firmware.c drivers/platform/x86/Kconfig drivers/platform/x86/touchscreen_dmi.c +1 more+46 -10 replies
10/10platform/x86: touchscreen_dmi: Add info for the Chuwi Vi8 Plus tabletdrivers/platform/x86/touchscreen_dmi.c+24 -00 replies

Reviews trailers per patch

All 10 patches have a Reviewed-by or Acked-by.

PatchGreg Kroah-HartmanArd BiesheuvelLuis ChamberlainDmitry TorokhovAndy Shevchenko
1/10R-b A-b
2/10A-b
3/10A-b
4/10A-b
5/10A-b
6/10A-b
7/10A-b
8/10A-b
9/10A-b A-b
10/10A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v12 thread

Cover letter [PATCH v12 00/10] efi/firmware/platform-x86: Add EFI embedded fw support

Hi All,

Here is v12 of my patch-set to add support for EFI embedded fw to the kernel.

This version addresses Luis' review remarks for the test_firmware stuff and addresses some of Andy Lutomirski's remarks (while for some others I've explained why I've done things a certain way).

It would be nice if we could at least get patches 1 and 2 merged for 5.6 (assuming Andy is ok with them now), then we can get the rest merged once 5.6-rc1 is out.

As mentioned in the v11 cover letter, I've based this version on Ard's efi/next branch to avoid conflict with some changes already there.

Regards,

Hans

---
Changes in v12:
- Use memcmp to check the prefix in efi_check_for_embedded_firmwares()
- Move the vmalloc (vmemdup) for the firmware copy owned by the firmare subsys from efi_get_embedded_fw() to firmware_fallback_platform(), so that it is is in the same subsys as the vfree which eventually frees it.
- Use local / private firmware variable for the test instead of the global test_firmware variable and drop the mutex lock + unlock needed for accessing the global test_firmware variable

Changes in v11:
- Rebase on top of Ardb's efi/next
- Drop a couple of empty lines which snuck into:
"test_firmware: add support for firmware_request_platform"

Changes in v10:
- Rebase on top of 5.5-rc1

Changes in v9:
- Add 2 new patches adding selftests
- At least touchscreen_dmi.c uses the same dmi_table for its own private data and the fw_desc structs, putting the fw_desc struct first in the data driver_data points to so that the dmi_table can be shared with efi_check_for_embedded_firmwares(). But not all entries there have embedded-fw so in some cases the fw_desc is empty (zero-ed out). This can lead to a possible crash because fw_desc->length now is less then 8, so if the segment size is close enough to a multiple of the page_size, then the memcmp to check the prefix my segfault. Crashing the machine. v9 checks for and skips these empty fw_desc entries avoiding this.
- Add static inline wrapper for firmware_request_platform() to firmware.h, for when CONFIG_FW_LOADER is not set

Changes in v8:
- Add pr_warn if there are mode then EFI_DEBUGFS_MAX_BLOBS boot service segments
- Document how the EFI debugfs boot_service_code? files can be used to check for embedded firmware
- Properly deal with the case of an EFI segment being smaller then the fw we are looking for
- Log a warning when efi_get_embedded_fw get called while we did not (yet) check for embedded firmwares
- Only build fallback_platform.c if CONFIG_EFI_EMBEDDED_FIRMWARE is defined, otherwise make firmware_fallback_platform() a static inline stub

Changes in v7:
- Split drivers/firmware/efi and drivers/base/firmware_loader changes into 2 patches
- Use new, standalone, lib/crypto/sha256.c code
- Address kdoc comments from Randy Dunlap
- Add new FW_OPT_FALLBACK_PLATFORM flag and firmware_request_platform() _request_firmware() wrapper, as requested by Luis R. Rodriguez
- Stop using "efi-embedded-firmware" device-property, now that drivers need to use the new firmware_request_platform() to enable fallback to a device fw copy embedded in the platform's main firmware, we no longer need a property on the device to trigger this behavior
- Use security_kernel_load_data instead of calling security_kernel_read_file with a NULL file pointer argument
- Move the docs to Documentation/driver-api/firmware/fallback-mechanisms.rst
- Document the new firmware_request_platform() function in Documentation/driver-api/firmware/request_firmware.rst
- Add 2 new patches for the silead and chipone-icn8505 touchscreen drivers to use the new firmware_request_platform() method
- Rebased on top of 5.4-rc1

Changes in v6:
-Rework code to remove casts from if (prefix == mem) comparison -Use SHA256 hashes instead of crc32 sums
-Add new READING_FIRMWARE_EFI_EMBEDDED read_file_id and use it -Call security_kernel_read_file(NULL, READING_FIRMWARE_EFI_EMBEDDED)
to check if this is allowed before looking at EFI embedded fw
-Document why we are not using the PI Firmware Volume protocol

Changes in v5:
-Rename the EFI_BOOT_SERVICES flag to EFI_PRESERVE_BS_REGIONS

Changes in v4:
-Drop note in docs about EFI_FIRMWARE_VOLUME_PROTOCOL, it is not part of
UEFI proper, so the EFI maintainers don't want us referring people to it
-Use new EFI_BOOT_SERVICES flag
-Put the new fw_get_efi_embedded_fw() function in its own fallback_efi.c
file which only gets built when EFI_EMBEDDED_FIRMWARE is selected
-Define an empty stub for fw_get_efi_embedded_fw() in fallback.h hwen
EFI_EMBEDDED_FIRMWARE is not selected, to avoid the need for #ifdefs in firmware_loader/main.c
-Properly call security_kernel_post_read_file() on the firmware returned
by efi_get_embedded_fw() to make sure that we are allowed to use it

Changes in v2:
-Rebased on driver-core/driver-core-next
-Add documentation describing the EFI embedded firmware mechanism to:
Documentation/driver-api/firmware/request_firmware.rst
-Add a new EFI_EMBEDDED_FIRMWARE Kconfig bool and only build the embedded
fw support if this is set. This is an invisible option which should be selected by drivers which need this
-Remove the efi_embedded_fw_desc and dmi_system_id-s for known devices
from the efi-embedded-fw code, instead drivers using this are expected to export a dmi_system_id array, with each entries' driver_data pointing to a efi_embedded_fw_desc struct and register this with the efi-embedded-fw code
-Use kmemdup to make a copy instead of efi_mem_reserve()-ing the firmware,
this avoids us messing with the EFI memmap and avoids the need to make changes to efi_mem_desc_lookup()
-Make the firmware-loader code only fallback to efi_get_embedded_fw() if the
passed in device has the "efi-embedded-firmware" device-property bool set
-Skip usermodehelper fallback when "efi-embedded-firmware" device-property
is set