Named quirksDraft
A quirk is a workaround that one board needs and another does not. Each
quirk has a name, registered once in devices/quirks.toml. A descriptor
lists the names its board needs under [quirks], and code asks for a
quirk by name instead of comparing chip ids.
How it works#
devices/quirks.tomllists the quirks as[[quirk]]rows. The row order gives each quirk a bit number.tools/devgen/devgen.pywritesquirk_ids.h, with one macro per quirk, and gives every descriptor a mask built from its names. The build fails if a descriptor names a quirk that is not registered.- During start-up,
devident_init(chip_id, board_id)looks up the board once, stores the mask and prints one console line,quirks: <names>(ornone). The line is printed in every image. - Code calls
quirk_on(QUIRK_NAME)fromopenboot/src/devident.h.
Asking before devident_init has run is a firmware panic: a workaround
silently skipped is the dangerous direction. A device with no descriptor
has mask 0, so every query answers no.
The scope of a quirk is the exact pair (chip id, board id). The SoC-level
tables [layout] and [cpu] are different: they are looked up by chip
id alone.
Registered quirks#
pmc-dvfs-voter#
- Used by: one descriptor today; the generated device pages list the quirks of each board.
- Asked for at: guest launch, by
memdvfs_bootinopenboot/src/memdvfs.c. - Applies to: images built with
MEMDVFS=1. - What it does: writes the CLPC floor and sets the PMC voter enable bits that memory frequency scaling needs.
- Without it: no PMC write is made and memory frequency stays at the firmware default.
- Reuse: the register addresses and the frequency table are in code and belong to one SoC, so the name is not reusable on another SoC without a fresh probe. What the quirk does on the generation that uses it is on its CPU and power page.
mcc-adt-carveouts#
- Used by: one descriptor today; the generated device pages list the quirks of each board.
- Asked for at: hypervisor-level setup (stage
el2-init), bymcc_unmap_carveoutsinopenboot/src/mcc.c. - What it does: builds the deny list for the trusted-zone carveouts from
the device tree, because
mcc.cdoes not know the memory-controller register layout of this SoC. - Without it: the trusted-zone regions stay in the hypervisor's read-write-execute map. That is not fail-safe, and it is the state in which unattributable SErrors were seen.
- Reuse: do not copy the name to another board without the same probe. The evidence for the generation that uses it is on its platform page.
Adding a quirk#
- Append a row at the end of
quirks.toml. Never insert in the middle or reorder: the bit number is the row index, and there is room for 32 rows. - Fill all four keys:
name,stage,summary,when_absent.when_absentsays what mask 0 means, which is what every other board gets. - List the name only in the descriptors of boards where the workaround was shown to be needed. A name is a claim about a board, so do not copy it to a new board without the probe that justified it.
- Run
python3 -I tools/devgen/devgen.py --devices devices --check.
Scope decisions on record#
- The same SoC on another board has neither quirk, because the scope is the exact pair of ids. No such board is known.
- A descriptor that has never been seen on real hardware lists no quirks.