Bill XIE has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39969 )
Change subject: nb/intel/sandybridge: Read spds only once if measured boot is enabled
......................................................................
nb/intel/sandybridge: Read spds only once if measured boot is enabled
Without considering s3 resume, spd may be used various times depending
on various condition. If spd is stored in CBFS and read various times,
PCR value may become inconsistent.
As mentioned in CB:39906, in order to avoid this, we could read spd
exactly once, and use the data read out various times, when measured
boot is enabled.
Change-Id: I02cad7e85d5e66fd9efb674e4dc9868233f6c233
Signed-off-by: Bill XIE <persmule(a)gmail.com>
---
M src/northbridge/intel/sandybridge/raminit.c
1 file changed, 27 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/69/39969/1
diff --git a/src/northbridge/intel/sandybridge/raminit.c b/src/northbridge/intel/sandybridge/raminit.c
index b096a11..f3c81a6 100644
--- a/src/northbridge/intel/sandybridge/raminit.c
+++ b/src/northbridge/intel/sandybridge/raminit.c
@@ -98,6 +98,17 @@
}
}
+static bool spd_is_available(const spd_raw_data spds[], size_t num_spd)
+{
+ /* An available spd should at least have an non-zero id */
+ size_t i, j, sum = 0;
+ for (i = 0; i < num_spd; i++) {
+ for (j = 117; j < 128; j++)
+ sum += spds[i][j];
+ }
+ return (sum > 0);
+}
+
static void dram_find_spds_ddr3(spd_raw_data *spd, ramctr_timing *ctrl)
{
int dimms = 0, ch_dimms;
@@ -222,6 +233,8 @@
struct region_device rdev;
ramctr_timing *ctrl_cached = NULL;
+ if (CONFIG(TPM_MEASURED_BOOT))
+ memset(spds, 0, sizeof(spds));
MCHBAR32(SAPMCTL) |= 1;
/* Wait for ME to be ready */
@@ -271,8 +284,14 @@
/* Verify MRC cache for fast boot */
if (!s3resume && ctrl_cached) {
/* Load SPD unique information data. */
- memset(spds, 0, sizeof(spds));
- mainboard_get_spd(spds, 1);
+ if (CONFIG(TPM_MEASURED_BOOT)) {
+ /* if CONFIG(TPM_MEASURED_BOOT),
+ we manage to get spds only ONCE */
+ mainboard_get_spd(spds, 0);
+ } else {
+ memset(spds, 0, sizeof(spds));
+ mainboard_get_spd(spds, 1);
+ }
/* check SPD CRC16 to make sure the DIMMs haven't been replaced */
fast_boot = verify_crc16_spds_ddr3(spds, ctrl_cached);
@@ -307,8 +326,12 @@
ctrl.cpu = cpuid;
/* Get DDR3 SPD data */
- memset(spds, 0, sizeof(spds));
- mainboard_get_spd(spds, 0);
+ if (!CONFIG(TPM_MEASURED_BOOT) || !spd_is_available(spds, 4)) {
+ /* without CONFIG(TPM_MEASURED_BOOT), the previous read may
+ only contains id, so read it again */
+ memset(spds, 0, sizeof(spds));
+ mainboard_get_spd(spds, 0);
+ }
dram_find_spds_ddr3(spds, &ctrl);
err = try_init_dram_ddr3(&ctrl, fast_boot, s3resume, me_uma_size);
--
To view, visit https://review.coreboot.org/c/coreboot/+/39969
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I02cad7e85d5e66fd9efb674e4dc9868233f6c233
Gerrit-Change-Number: 39969
Gerrit-PatchSet: 1
Gerrit-Owner: Bill XIE <persmule(a)hardenedlinux.org>
Gerrit-MessageType: newchange
Harshit Sharma has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43938 )
Change subject: [DONOTSUBMIT]lib: Introduce memory bugs to help test ASan
......................................................................
[DONOTSUBMIT]lib: Introduce memory bugs to help test ASan
Introduces a few memory bugs into cbfs code to make testing easier
for the ones who are willing to try out ASan on their hardware.
Change-Id: I0839f2fd2863934ec28e2322bab04b9cc33363b4
Signed-off-by: Harshit Sharma <harshitsharmajs(a)gmail.com>
---
M src/lib/cbfs.c
1 file changed, 21 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/38/43938/1
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index cb66f81..839de94 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -330,9 +330,30 @@
return 0;
}
+#if ENV_RAMSTAGE
+ int global_array[5] = {-1};
+#endif
+
int cbfs_boot_region_device(struct region_device *rdev)
{
+ int stack_array[5], i, *p;
boot_device_init();
+
+ /* global out-of-bounds */
+#if ENV_RAMSTAGE
+ for (i = 10; i > 0; i--)
+ global_array[i] = i;
+#endif
+ /* stack out-of-bounds */
+ for (i = 10; i > 0; i--)
+ stack_array[i] = i;
+
+ /* use-after-scope */
+ {
+ int x = 5;
+ p = &x;
+ }
+ *p = 10;
return vboot_locate_cbfs(rdev) &&
fmap_locate_area_as_rdev("COREBOOT", rdev);
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/43938
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I0839f2fd2863934ec28e2322bab04b9cc33363b4
Gerrit-Change-Number: 43938
Gerrit-PatchSet: 1
Gerrit-Owner: Harshit Sharma <harshitsharmajs(a)gmail.com>
Gerrit-MessageType: newchange
John Zhao has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/45623 )
Change subject: Fix control flow DEADCODE issue
......................................................................
Fix control flow DEADCODE issue
Coverity detects DEADCODE issue in the control flow. Based on both of
KEMPLD_CLK and KEMPLD_I2C_FREQ_STD definitions, execution cannot reach
this statement "prescale = 0". This change removes the DEADCODE code.
Found-by: Coverity CID 1431154
TEST=None
Signed-off-by: John Zhao <john.zhao(a)intel.com>
Change-Id: Ic002e708636961358969b2c1eaec0fee5bbcb73a
---
M src/ec/kontron/kempld/kempld_i2c.c
1 file changed, 0 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/45623/1
diff --git a/src/ec/kontron/kempld/kempld_i2c.c b/src/ec/kontron/kempld/kempld_i2c.c
index 296cf76..165c940 100644
--- a/src/ec/kontron/kempld/kempld_i2c.c
+++ b/src/ec/kontron/kempld/kempld_i2c.c
@@ -250,9 +250,6 @@
else
prescale = KEMPLD_CLK / (KEMPLD_I2C_FREQ_STD * 4) - 3000;
- if (prescale < 0)
- prescale = 0;
-
/* Round to the best matching value */
prescale_corr = prescale / 1000;
if (prescale % 1000 >= 500)
--
To view, visit https://review.coreboot.org/c/coreboot/+/45623
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ic002e708636961358969b2c1eaec0fee5bbcb73a
Gerrit-Change-Number: 45623
Gerrit-PatchSet: 1
Gerrit-Owner: John Zhao <john.zhao(a)intel.com>
Gerrit-MessageType: newchange