Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from flashrom to flashprog #1769

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0cd00f2
add flashprog support: failed attempt to use review.sourcearcade.org …
tlaurion Aug 31, 2024
f8eb0a2
flashprog: use latest head commit of wp_cli branch which is experimen…
tlaurion Sep 1, 2024
04bb3be
ash_functions: make sure newlines are passed, fix error redirection
tlaurion Sep 1, 2024
58081cb
flash.sh: FLASHROM_OPTIONS->FLASH_OPTIONS: require FLASH_OPTIONS to s…
tlaurion Sep 1, 2024
36aea9e
boards FLASH_OPTIONS: add --noverify. No point verifying flash with i…
tlaurion Sep 1, 2024
e26cd76
boards FLASH_OPTIONS: remove --noverify/--noverify-all for now
tlaurion Sep 1, 2024
8b524be
flash.sh: replace die calls by recovery calls where relevant otherwis…
tlaurion Sep 1, 2024
56ae5f7
xx20 boards: reintroduce hwseq for flashprog
tlaurion Sep 7, 2024
efb6126
kgpe-d16 server: TODO AST1100 patch still missing @i-c-o-n https://gi…
tlaurion Sep 8, 2024
668f697
boards CONFIG_FLASH_OPTIONS: 'flashprog memory' -> 'flashprog' since …
tlaurion Sep 9, 2024
af2c45b
Haswell boards : renamed to UNTESTED_* while still built by CircleCI …
tlaurion Sep 9, 2024
a407462
board t440p: move board away from UNTESTED_ with improved Makefile he…
tlaurion Sep 10, 2024
bd7b1c8
BOARD_TESTERS.md: updated and reordered testers
tlaurion Sep 10, 2024
29c97e8
WP_NOTES.md: add notes on WP wanted, work done and why it's still unused
tlaurion Sep 10, 2024
6fe86df
x230 legacy boards: move to unmaintained
tlaurion Sep 10, 2024
75f1c2a
move w541 boards back to tested to dodge drama. Still this board has …
tlaurion Sep 10, 2024
aad131b
WP_NOTES.md: add some more links to past discussions and Platform Chi…
tlaurion Sep 10, 2024
5cba23e
BOARD_TESTERS.md: add @ResendeGHF as first contact board tester for w…
tlaurion Sep 11, 2024
6c16a50
flash.sh: remove last references in code to flashrom, use more generi…
tlaurion Sep 11, 2024
d5ddab5
BOARD_TESTERS.md: reorder known testers by responsiveness
tlaurion Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ bin_modules-$(CONFIG_KEXEC) += kexec
bin_modules-$(CONFIG_TPMTOTP) += tpmtotp
bin_modules-$(CONFIG_PCIUTILS) += pciutils
bin_modules-$(CONFIG_FLASHROM) += flashrom
bin_modules-$(CONFIG_FLASHPROG) += flashprog
bin_modules-$(CONFIG_CRYPTSETUP) += cryptsetup
bin_modules-$(CONFIG_CRYPTSETUP2) += cryptsetup2
bin_modules-$(CONFIG_GPG) += gpg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ CONFIG_BUSYBOX=n
else
#Modules packed into tools.cpio
CONFIG_CRYPTSETUP2=y
CONFIG_FLASHROM=y
#CONFIG_FLASHROM=y
CONFIG_FLASHPROG=y
CONFIG_FLASHTOOLS=y
CONFIG_GPG2=y
CONFIG_KEXEC=y
Expand Down
46 changes: 46 additions & 0 deletions modules/flashprog
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
modules-$(CONFIG_FLASHPROG) += flashprog

flashprog_depends := pciutils $(musl_dep)

flashprog_version := 9dc6d843b0678001c9baf0e8602ecb25b16329d2
flashprog_dir := flashprog-$(flashprog_version)
flashprog_tar := $(flashprog_dir).tar.gz
flashprog_url := https://github.com/SourceArcade/flashprog/archive/$(flashprog_version).tar.gz
flashprog_hash := fa4ddf3b60314994a37e4599122ae4c7f42135c13c782e580bc580d715cfa2fc
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@i-c-o-n still good commit? would wp_cli branch need update prior of merging? next iteration?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's sitting ducks for review. I don't expect bigger changes.
@SergiiDmytruk know any users of the block protection that could give some feedback on the CLI?

Copy link
Contributor

@SergiiDmytruk SergiiDmytruk Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe users who commented in flashrom/flashrom#185? My impression on WP is that people are interested in it for a relatively short period of time until they realize its practical limitations @i-c-o-n

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yeah, it's not just a give-me-security switch. Modern chips don't even have a /WP pin (because they prefer quad-i/o). Biggest bummer though is the lacking support to read/write all registers on Intel platforms (I have one more idea to try but little hope), otherwise one could use the protect-until-powercycle feature.

@ln2max, @jtf7 looking for user test and feedback on the WP CLI available through this PR, or this branch. It's not too different from flashrom's, e.g. wp --status instead of --wp-status. And it supports only one command at a time to be sure about the execution order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise one could use the protect-until-powercycle feature.

@i-c-o-n are you talking about chipset locking (PR0) as per #1373 (comment) OP's todo pointing to @root-hardenedvault 's x11 downstream (non-upstreamed) work for Haswell+ platforms https://github.com/hardenedvault/vaultboot/blob/master/patches/coreboot/0001-x11.patch ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there's another feature of the flash chip itself. Most common for SPI flashes is that you can configure which blocks to protect and then there are four states:

  1. the configuration is unprotected,
  2. the configuration is locked by the /WP pin,
  3. the configuration is locked until a power cycle, or
  4. the configuration is permanently locked.

For 2. we need the pin and support or modification of the mainboard. 3. and 4. often require to write a bit in a secondary register. Problem is so far nobody knows how to write that register with Intel's hwseq, which is the only option since Skylake. I don't think Intel implemented that. They just want you to use their protection mechanisms like PR0; those are, however, very inconvenient when Intel FSP is involved.

Something like that hardenedvault patch wouldn't work on (at least some) newer systems because FSP would lock PR0 too early, unconditionally. Security with Intel is never easy.

Copy link
Contributor

@SergiiDmytruk SergiiDmytruk Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the configuration is locked until a power cycle

(tlaurion edit: tagging @i-c-o-n) :

I thought chips supporting this feature are fairly uncommon. I remember seeing notes in a bunch of datasheets to the effect of "this feature is available per request" (maybe all from a single vendor).

Copy link

@i-c-o-n i-c-o-n Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, my recollection may be biased by our own chip selection (we used this feature on an AMD based system almost 15 years ago). I thought it's very common for Winbond; and GD and XMC for instance seem to copy everything from them judging from datasheets. Macronix seems to be an exception. This "available per request" does ring a bell, but I usually see this regarding 4., the permanent locking.

(tlaurion edit : please tag people to trigger a notification to external people directly. Here @SergiiDmytruk)


# Default options for flashprog
flashprog_cfg := \
WARNERROR=no \
CONFIG_NOTHING=yes \
CONFIG_INTERNAL=yes \
CONFIG_INTERNAL_X86=yes \

ifeq "$(CONFIG_TARGET_ARCH)" "ppc64"
flashprog_cfg := \
WARNERROR=no \
CONFIG_NOTHING=yes \
CONFIG_LINUX_MTD=yes
endif

#Only enable AST1100 if requested per board configs
ifeq "$(CONFIG_FLASHPROG_AST1100)" "y"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch missing. Even i currently activated under server board and passed at make, doesn't o anything without https://github.com/linuxboot/heads/blob/master/patches/flashrom-b1f858f65b2abd276542650d8cb9e382da258967/0100-enable-kgpe-d16.patch missing

@i-c-o-n?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can have a look at it. AFAIR, nobody made a real effort to upstream this. If I rebase this, we'd still need somebody to test it thoroughly. We are quite pedantic when it comes to internal flashing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@i-c-o-n it is a problem of upstreaming indeed, keeping track of patches downstream never proved to do any good.

If not under flashprog/flashrom: this means end users need to flash bmc externally which is not a desirable thing. Also as you may know, that bmc port is old but still in charge of best fan control out there for the d16. Having heads flash through https://github.com/linuxboot/heads/pull/1769/files#diff-08a8a9080a4ca4377e0de4dbef6bd94c84209343b4e12a8982352a1c1b09b71b would be useful.

That would be ideal, but not a blocker for this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@i-c-o-n do you see anything else that should be improved in the flashprog makefile for size/functionalities inclusion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see anything that should be added in board config for flash options that should be passed? Something that would make speed of internal flashing faster?

Also not a requirement for this PR, but a nice thing to track in separate issue for improvements, let me know.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@i-c-o-n do you see anything else that should be improved in the flashprog makefile for size/functionalities inclusion?

No, the current selection is already the minimum AFAICT. Anything else would need some hacking on the code. One low hanging fruit: For targets that use Intel hwseq or linux_mtd, you could drop everything else from flashchips.c. Haven't tried, but it probably won't link the chip drivers then.

Do you see anything that should be added in board config for flash options that should be passed? Something that would make speed of internal flashing faster?

--noverify-all gives you a little reading-speed advantage. But assuming that you update most of the flash anyway, it won't make much of a difference.

flashprog_cfg += CONFIG_AST1100=yes
endif

flashprog_target := \
$(MAKE_JOBS) \
CFLAGS="-Os -I$(INSTALL)/include/pci" \
DESTDIR="$(INSTALL)" \
INSTALL="$(INSTALL)" \
LDFLAGS="-L$(INSTALL)/lib" \
PREFIX="$(INSTALL)" \
$(CROSS_TOOLS) \
$(flashprog_cfg) \
flashprog

flashprog_output := \
flashprog

flashprog_libraries := \

flashprog_configure :=