Overlay USB config instead of sed-patching upstream's config/usb.h - #4
Merged
Conversation
Every EFI binary this repository publishes is built without a USB keyboard
driver. On ipxe.efi that leaves the machine with no keyboard at all at the FOG
boot menu (forums #18213, Lenovo M70t/M80t Gen3).
buildipxe.sh patched three settings into upstream's config/usb.h with sed:
sed -i 's+//#define\tUSB_HCD_USBIO+#define\tUSB_HCD_USBIO+g'
sed -i 's+//#undef\tUSB_KEYBOARD+#define\tUSB_KEYBOARD+g'
sed -i 's+//#undef\tUSB_EFI+#undef\tUSB_EFI+g'
v2.0.0 restructured that file. USB_HCD_USBIO now has a space where the pattern
wants a tab, and USB_KEYBOARD/USB_EFI are no longer commented-out lines at all
-- upstream moved them into a live PLATFORM_efi block:
#if defined ( PLATFORM_efi )
#define USB_EFI
//#define USB_HCD_USBIO
#undef USB_KEYBOARD /* Use built-in EFI keyboard driver */
#endif
All three patterns stopped matching. sed exits 0 when nothing matches, so the
build stayed green and every EFI binary silently took upstream's defaults.
Upstream's default is coherent on its own terms: leave USB_KEYBOARD out, and
re-expose the devices iPXE owns through USB_EFI so the firmware's own keyboard
driver can re-bind on top. But ipxe.efi carries the native xHCI/EHCI/UHCI
drivers and efi_driver_connect_all() binds them, taking the controller off the
firmware first. Where that re-bind does not happen there is no keyboard driver
left anywhere. snponly.efi has no native host controller drivers, so the
firmware keeps USB and its keyboard works -- which is exactly the asymmetry
reported.
Fixed by overlaying config/local/usb.h, which upstream's config/usb.h includes
last, after its own PLATFORM_efi block, so FOG's values win. This restores the
configuration FOG shipped and tested for years rather than inventing one. The
point is not just that it works today: an overlaid file cannot half-apply the
way a sed pattern can, so the next refresh onto a new upstream tag can only
break this loudly. Same reasoning as the general.h override in 9b69e5b --
state the deviation, do not edit upstream's copy.
The BIOS overlay is a no-op against v2.0.0, where USB_HCD_USBIO exists only
inside the PLATFORM_efi block and a BIOS build cannot pick it up. It is kept
because the sed it replaces was load-bearing against an older layout that did
define it unconditionally, and a standing #undef holds whichever way a future
refresh moves the default.
Verified by building config/config_usb.c both ways and reading the objects it
drags in:
EFI, before: obj_efi_usb obj_xhci (no keyboard driver)
EFI, after: obj_usbio obj_usbkbd obj_xhci
BIOS, after: obj_usbkbd obj_xhci (unchanged)
Does not address the second half of #18213, the /dev/ram0 kernel panic on
snponly.efi -- that one is the installer publishing autoexec.ipxe into the
TFTP root, and is fixed in fogproject.
Refs FOGProject/fogproject#960.
Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every EFI binary this repository publishes is built without a USB keyboard driver. On
ipxe.efithat leaves the machine with no keyboard at all at the FOG boot menu — reported against Lenovo M70t/M80t Gen3 in forums #18213.buildipxe.shpatched three settings into upstream'sconfig/usb.hwithsed. v2.0.0 restructured that file — a space where the pattern wants a tab, andUSB_KEYBOARD/USB_EFImoved into a livePLATFORM_efiblock instead of being commented-out lines:All three patterns stopped matching.
sedexits 0 when nothing matches, so the build stayed green and every EFI binary silently took upstream's defaults.Upstream's default is coherent on its own terms: leave
USB_KEYBOARDout and re-expose the devices iPXE owns throughUSB_EFIso the firmware's keyboard driver can re-bind. Butipxe.eficarries the native xHCI/EHCI/UHCI drivers andefi_driver_connect_all()binds them, taking the controller off the firmware first. Where that re-bind doesn't happen, no keyboard driver is left anywhere.Fixed by overlaying
config/local/usb.h, which upstream'sconfig/usb.hincludes last, so FOG's values win. This restores the configuration FOG shipped for years rather than inventing one. The point isn't only that it works today — an overlaid file can't half-apply the way asedpattern can, so the next refresh onto a new upstream tag can only break this loudly. Same pattern as thegeneral.hoverride in 9b69e5b.Verification
Built
config/config_usb.cboth ways and read the objects it drags in:obj_efi_usb obj_xhci— no keyboard driverobj_usbio obj_usbkbd obj_xhciobj_usbkbd obj_xhciobj_usbkbd obj_xhci(unchanged)Linked both EFI targets to confirm the blast radius is limited to
ipxe.efi:snponly.efilinks no USB objects either way and is byte-identical with and without the overlay (267776 bytes both). That also confirms the reported asymmetry:ipxe.efibinds the USB controllers away from the firmware and then has nothing to drive the keyboard with, whilesnponly.efinever touches USB.Not yet verified on affected hardware.
Scope
Does not address the other half of #18213, the
/dev/ram0kernel panic onsnponly.efi. That one is the installer publishingautoexec.ipxeinto the TFTP root and is fixed in fogproject.Refs FOGProject/fogproject#960.
🤖 Generated with Claude Code