Yu-Ping Wu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36014 )
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
soc/mediatek/mt8183: Verify checksum of cached calibration data
The checksum is stored in the header of calibration data and saved to SPI flash. After reading the data from flash, checksum is used to verify the integrity of the calibration parameters.
BUG=b:139099592 BRANCH=kukui TEST=Calibration data successfully loaded from flash
Change-Id: Ie4a0688ed6e560d4c0c6b316f44e52fd10d71a9d Signed-off-by: Yu-Ping Wu yupingso@chromium.org --- M src/soc/mediatek/mt8183/dramc_param.c M src/soc/mediatek/mt8183/memory.c 2 files changed, 14 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/36014/1
diff --git a/src/soc/mediatek/mt8183/dramc_param.c b/src/soc/mediatek/mt8183/dramc_param.c index ef3c191..bf1fee4 100644 --- a/src/soc/mediatek/mt8183/dramc_param.c +++ b/src/soc/mediatek/mt8183/dramc_param.c @@ -35,7 +35,6 @@ if (hdr->size != sizeof(*param)) return DRAMC_ERR_INVALID_SIZE;
- /* TODO(hungte) Verify and check hdr->checksum. */ return DRAMC_SUCCESS; }
diff --git a/src/soc/mediatek/mt8183/memory.c b/src/soc/mediatek/mt8183/memory.c index e97ea21..b536ebc 100644 --- a/src/soc/mediatek/mt8183/memory.c +++ b/src/soc/mediatek/mt8183/memory.c @@ -16,6 +16,7 @@ #include <assert.h> #include <cbfs.h> #include <console/console.h> +#include <ip_checksum.h> #include <soc/dramc_param.h> #include <soc/dramc_pi_api.h> #include <soc/emi.h> @@ -70,6 +71,12 @@ printk(BIOS_DEBUG, "header.checksum = %#x\n", header->checksum); }
+static u32 compute_checksum(const struct dramc_param *dparam) +{ + return (u32)compute_ip_checksum(dparam->freq_params, + sizeof(dparam->freq_params)); +} + static int dram_run_fast_calibration(const struct dramc_param *dparam, u16 config) { @@ -88,6 +95,12 @@ return -1; }
+ if (compute_checksum(dparam) != dparam->header.checksum) { + printk(BIOS_ERR, + "Invalid DRAM calibration checksum from flash\n"); + return -1; + } + return 0; }
@@ -165,6 +178,7 @@ printk(BIOS_INFO, "Successfully loaded DRAM blobs and " "ran DRAM calibration\n"); set_source_to_flash(dparam->freq_params); + dparam->header.checksum = compute_checksum(dparam); dparam_ops->write_to_flash(dparam); printk(BIOS_DEBUG, "Calibration params saved to flash: " "version=%#x, size=%#x\n",
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36014 )
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
Patch Set 1: Code-Review+2
Hello Julius Werner, Hung-Te Lin, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36014
to look at the new patch set (#2).
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
soc/mediatek/mt8183: Verify checksum of cached calibration data
The checksum is stored in the header of calibration data and saved to SPI flash. After reading the data from flash, checksum is used to verify the integrity of the calibration parameters.
BUG=b:139099592 BRANCH=kukui TEST=Calibration data successfully loaded from flash
Change-Id: Ie4a0688ed6e560d4c0c6b316f44e52fd10d71a9d Signed-off-by: Yu-Ping Wu yupingso@chromium.org --- M src/soc/mediatek/mt8183/dramc_param.c M src/soc/mediatek/mt8183/memory.c 2 files changed, 16 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/36014/2
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36014 )
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... File src/soc/mediatek/mt8183/memory.c:
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... PS2, Line 99: BIOS_ERR also print expected and saved values.
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... PS2, Line 184: %#x\ move this to 'improve code formatting' patch?
Hello Julius Werner, Hung-Te Lin, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36014
to look at the new patch set (#3).
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
soc/mediatek/mt8183: Verify checksum of cached calibration data
The checksum is stored in the header of calibration data and saved to SPI flash. After reading the data from flash, checksum is used to verify the integrity of the calibration parameters.
BUG=b:139099592 BRANCH=kukui TEST=Calibration data successfully loaded from flash
Change-Id: Ie4a0688ed6e560d4c0c6b316f44e52fd10d71a9d Signed-off-by: Yu-Ping Wu yupingso@chromium.org --- M src/soc/mediatek/mt8183/dramc_param.c M src/soc/mediatek/mt8183/memory.c 2 files changed, 17 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/36014/3
Yu-Ping Wu has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36014 )
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... File src/soc/mediatek/mt8183/memory.c:
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... PS2, Line 99: BIOS_ERR
also print expected and saved values.
Done
https://review.coreboot.org/c/coreboot/+/36014/2/src/soc/mediatek/mt8183/mem... PS2, Line 184: %#x\
move this to 'improve code formatting' patch?
Done
Hung-Te Lin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36014 )
Change subject: soc/mediatek/mt8183: Verify checksum of cached calibration data ......................................................................
Patch Set 3: Code-Review+2