Attention is currently required from: Angel Pons, Arthur Heymans, Elyes Haouas, Felix Held, Julius Werner.
Hello Angel Pons, Elyes Haouas, Felix Held, Julius Werner, Nico Huber, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/84059?usp=email
to look at the new patch set (#3).
Change subject: drivers/spi: Stop using a variable-length array, 2nd try ......................................................................
drivers/spi: Stop using a variable-length array, 2nd try
Only the call in `spi_flash_cmd_write_page_program` uses non-constant values for the array length. However, the value for `data_len` has an upper bound: `flash->page_size` is set to `1U << vi->page_size_shift` which depends on the flash chip vendor info, and the largest value it can currently have is 8. Thus, the maximum page size is currently 256.
Define the `MAX_FLASH_CMD_DATA_SIZE` macro to place an upper bound on the amount of data that can be written in one command. Then, use this value to allocate a fixed-size buffer in `spi_flash_cmd_write`. Also, add a check to prevent buffer overflow problems. Finally, ensure that the `spi_flash_cmd_write_page_program` function always writes no more than 256 bytes of data when using the `spi_flash_cmd_write` function.
The buffer is placed in .bss so that it does not increase stack usage in some use cases.
Tested on Asrock B85M Pro4 (Winbond W25Q64FV), MRC cache still works.
Repost of 59626b86 with 'static' so that the buffer is in bss.
Change-Id: I157ecec69c049ead06467b0328efd7d1a09bd268 Signed-off-by: Angel Pons th3fanbus@gmail.com Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/spi/spi_flash.c M src/drivers/spi/spi_flash_internal.h 2 files changed, 9 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/59/84059/3