Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15457
-gerrit
commit 40aae009b0715ce19b940e1af6700f0b9db8f105
Author: Furquan Shaikh <furquan(a)google.com>
Date: Mon Jun 27 16:19:09 2016 -0700
vbnv: Do not silently reset cache in read_vbnv
Currently, read_vbnv performs a reset of the vbnv cache if it is not
valid. However, this information is not passed up to the vboot layer,
thus resulting in missed write-back of vbnv cache to storage if vboot
does not update the cache itself.
Update read_vbnv to return a value depending upon whether it wants a
write-back to be performed when save is called.
Return value:
0 = No write-back required
1 = Write-back of VBNV cache is required.
Change-Id: I239939d5f9731d89a9d53fe662321b93fc1ab113
Signed-off-by: Furquan Shaikh <furquan(a)google.com>
---
src/vendorcode/google/chromeos/vbnv.c | 15 +++++++++++----
src/vendorcode/google/chromeos/vbnv.h | 7 ++++++-
src/vendorcode/google/chromeos/vboot2/vboot_logic.c | 8 ++++++--
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/src/vendorcode/google/chromeos/vbnv.c b/src/vendorcode/google/chromeos/vbnv.c
index 92f03fb..baccb23 100644
--- a/src/vendorcode/google/chromeos/vbnv.c
+++ b/src/vendorcode/google/chromeos/vbnv.c
@@ -85,8 +85,12 @@ int verify_vbnv(uint8_t *vbnv_copy)
(crc8_vbnv(vbnv_copy, CRC_OFFSET) == vbnv_copy[CRC_OFFSET]);
}
-/* Read VBNV data from configured storage backend. */
-void read_vbnv(uint8_t *vbnv_copy)
+/*
+ * Read VBNV data from configured storage backend.
+ * If VBNV verification fails, reset the vbnv copy.
+ * Returns 1 if write-back of vbnv copy is required. Else, returns 0.
+ */
+int read_vbnv(uint8_t *vbnv_copy)
{
if (IS_ENABLED(CONFIG_CHROMEOS_VBNV_CMOS))
read_vbnv_cmos(vbnv_copy);
@@ -96,8 +100,11 @@ void read_vbnv(uint8_t *vbnv_copy)
read_vbnv_flash(vbnv_copy);
/* Check data for consistency */
- if (!verify_vbnv(vbnv_copy))
- reset_vbnv(vbnv_copy);
+ if (verify_vbnv(vbnv_copy))
+ return 0;
+
+ reset_vbnv(vbnv_copy);
+ return 1;
}
/*
diff --git a/src/vendorcode/google/chromeos/vbnv.h b/src/vendorcode/google/chromeos/vbnv.h
index 5d21cc8..a66d687 100644
--- a/src/vendorcode/google/chromeos/vbnv.h
+++ b/src/vendorcode/google/chromeos/vbnv.h
@@ -19,7 +19,12 @@
#include <types.h>
/* Generic functions */
-void read_vbnv(uint8_t *vbnv_copy);
+/*
+ * Return value for read_vbnv:
+ * 1 = write-back of vbnv copy is required.
+ * 0 = otherwise
+ */
+int read_vbnv(uint8_t *vbnv_copy);
void save_vbnv(const uint8_t *vbnv_copy);
int verify_vbnv(uint8_t *vbnv_copy);
int get_recovery_mode_from_vbnv(void);
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
index a81a9c2..116c949 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
@@ -301,8 +301,12 @@ void verstage_main(void)
/* Set up context and work buffer */
vb2_init_work_context(&ctx);
- /* Read nvdata from a non-volatile storage */
- read_vbnv(ctx.nvdata);
+ /*
+ * Read nvdata from a non-volatile storage and mark data as changed
+ * if instructed.
+ */
+ if (read_vbnv(ctx.nvdata))
+ ctx.flags |= VB2_CONTEXT_NVDATA_CHANGED;
/* Set S3 resume flag if vboot should behave differently when selecting
* which slot to boot. This is only relevant to vboot if the platform
Furquan Shaikh (furquan(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15457
-gerrit
commit 2aed33345f3fc90da0e14c49f3fbc98fc7424b61
Author: Furquan Shaikh <furquan(a)google.com>
Date: Mon Jun 27 16:19:09 2016 -0700
vbnv: Do not silently reset cache in read_vbnv
Currently, read_vbnv performs a reset of the vbnv cache if it is not
valid. However, this information is not passed up to the vboot layer,
thus resulting in missed write-back of vbnv cache to storage if vboot
does not update the cache itself.
Update read_vbnv to return a value depending upon whether it wants a
write-back to be performed when save is called.
Return value:
0 = No write-back required
1 = Write-back of VBNV cache is required.
Change-Id: I239939d5f9731d89a9d53fe662321b93fc1ab113
Signed-off-by: Furquan Shaikh <furquan(a)google.com>
---
src/vendorcode/google/chromeos/vbnv.c | 15 +++++++++++----
src/vendorcode/google/chromeos/vbnv.h | 2 +-
src/vendorcode/google/chromeos/vboot2/vboot_logic.c | 3 ++-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/vendorcode/google/chromeos/vbnv.c b/src/vendorcode/google/chromeos/vbnv.c
index 92f03fb..7b257f7 100644
--- a/src/vendorcode/google/chromeos/vbnv.c
+++ b/src/vendorcode/google/chromeos/vbnv.c
@@ -85,8 +85,12 @@ int verify_vbnv(uint8_t *vbnv_copy)
(crc8_vbnv(vbnv_copy, CRC_OFFSET) == vbnv_copy[CRC_OFFSET]);
}
-/* Read VBNV data from configured storage backend. */
-void read_vbnv(uint8_t *vbnv_copy)
+/*
+ * Read VBNV data from configured storage backend.
+ * If VBNV verification fails, reset the vbnv copy.
+ * Returns 1 if write-back of vbnv copy is required. Else, returns 0.
+ */
+uint8_t read_vbnv(uint8_t *vbnv_copy)
{
if (IS_ENABLED(CONFIG_CHROMEOS_VBNV_CMOS))
read_vbnv_cmos(vbnv_copy);
@@ -96,8 +100,11 @@ void read_vbnv(uint8_t *vbnv_copy)
read_vbnv_flash(vbnv_copy);
/* Check data for consistency */
- if (!verify_vbnv(vbnv_copy))
- reset_vbnv(vbnv_copy);
+ if (verify_vbnv(vbnv_copy))
+ return 0;
+
+ reset_vbnv(vbnv_copy);
+ return 1;
}
/*
diff --git a/src/vendorcode/google/chromeos/vbnv.h b/src/vendorcode/google/chromeos/vbnv.h
index 5d21cc8..e8cd99d 100644
--- a/src/vendorcode/google/chromeos/vbnv.h
+++ b/src/vendorcode/google/chromeos/vbnv.h
@@ -19,7 +19,7 @@
#include <types.h>
/* Generic functions */
-void read_vbnv(uint8_t *vbnv_copy);
+uint8_t read_vbnv(uint8_t *vbnv_copy);
void save_vbnv(const uint8_t *vbnv_copy);
int verify_vbnv(uint8_t *vbnv_copy);
int get_recovery_mode_from_vbnv(void);
diff --git a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
index a81a9c2..e704d1f 100644
--- a/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
+++ b/src/vendorcode/google/chromeos/vboot2/vboot_logic.c
@@ -302,7 +302,8 @@ void verstage_main(void)
vb2_init_work_context(&ctx);
/* Read nvdata from a non-volatile storage */
- read_vbnv(ctx.nvdata);
+ if (read_vbnv(ctx.nvdata))
+ ctx.flags |= VB2_CONTEXT_NVDATA_CHANGED;
/* Set S3 resume flag if vboot should behave differently when selecting
* which slot to boot. This is only relevant to vboot if the platform
Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15456
-gerrit
commit f3733ddb21a0b6e54facbcd4e1ec8d369ca8e2ca
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Fri Jun 24 18:40:28 2016 -0700
WIP: soc/intel/apollolake: Cache cbmem region
Configure write-back MTRRs so that 16 MiB under cbmem_top is cached.
This allows caching of FSP reserved memory and postcar stage itself.
On CAR teardown the memory is flushed with clflush instruction.
Depending on what cache configuration is used, either L1 (NEM) or
both L1 and L2 (CQOS) storage is used for caching purposes.
This is WIP patch, because currently location of cbmem_top can not
be known before memory is trained. So addresses are hardcoded.
BUG=chrome-os-partner:51959
TEST=run primitive memtest on 16 MiB cached memory region after mem
is trained, observe x7 improvement on L1 only, x12 on L2 of 256 KiB
Change-Id: I62aad238a3056f9bbe5327dfb33a2a1112d61194
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
---
src/soc/intel/apollolake/exit_car.S | 8 ++++++++
src/soc/intel/apollolake/romstage.c | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/soc/intel/apollolake/exit_car.S b/src/soc/intel/apollolake/exit_car.S
index e5706cf..c0fb39b 100644
--- a/src/soc/intel/apollolake/exit_car.S
+++ b/src/soc/intel/apollolake/exit_car.S
@@ -38,6 +38,14 @@ chipset_teardown_car:
and $(~(MTRR_DEF_TYPE_EN | MTRR_DEF_TYPE_FIX_EN)), %eax
wrmsr
+ /* Flush down whatever we have */
+ mov $0x7a000000, %eax
+loop:
+ clflush (%eax)
+ add $CACHE_LINE_SIZE, %eax
+ cmp $0x7b000000, %eax
+ jl loop
+
#if IS_ENABLED(CONFIG_CAR_CQOS)
mov $MTRR_L2_QOS_MASK(0), %ecx
rdmsr
diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c
index ce28326..1fa52fd 100644
--- a/src/soc/intel/apollolake/romstage.c
+++ b/src/soc/intel/apollolake/romstage.c
@@ -112,7 +112,7 @@ asmlinkage void car_stage_entry(void)
struct postcar_frame pcf;
size_t mrc_data_size;
uintptr_t top_of_ram;
- int prev_sleep_state;
+ int prev_sleep_state, mtrr;
struct romstage_handoff *handoff;
struct chipset_power_state *ps = car_get_var_ptr(&power_state);
@@ -129,6 +129,13 @@ asmlinkage void car_stage_entry(void)
range_entry_init(®_car, (uintptr_t)_car_relocatable_data_end,
(uintptr_t)_car_region_end, 0);
+ mtrr = get_free_var_mtrr();
+ if (mtrr==-1)
+ printk(BIOS_CRIT, "no available MTRRs to cache cbmem!\n");
+ else
+ /* Make sure cbmem 16 MiB under CBMEM is cachable */
+ set_var_mtrr(mtrr, 0x7a000000, 16 * MiB, MTRR_TYPE_WRBACK);
+
if (fsp_memory_init(&hob_list_ptr, ®_car) != FSP_SUCCESS) {
die("FSP memory init failed. Giving up.");
}
Andrey Petrov (andrey.petrov(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15456
-gerrit
commit 02dd47ce7f3d1673403f99499127be2ebd0e4b3a
Author: Andrey Petrov <andrey.petrov(a)intel.com>
Date: Fri Jun 24 18:40:28 2016 -0700
WIP: soc/intel/apollolake: Cache cbmem region
Configure write-back MTRRs so that 16 MiB under cbmem_top is cached.
This allows caching of FSP reserved memory and postcar stage itself.
On CAR teardown the memory is flushed with clflush instruction.
Depending on what cache configuration is used, either L1 (NEM) or
both L1 and L2 (CQOS) storage is used for caching purposes.
This is WIP patch, because currently location of cbmem_top can not
be known before memory is trained. So addresses are hardcoded.
BUG=chrome-os-partner:51959
TEST=run primitive memtest on 16 MiB cached memory region after mem
is trained, observe x7 improvement on L1 only, x12 on L2 of 256 KiB
Change-Id: I62aad238a3056f9bbe5327dfb33a2a1112d61194
Signed-off-by: Andrey Petrov <andrey.petrov(a)intel.com>
---
src/soc/intel/apollolake/exit_car.S | 8 ++++++++
src/soc/intel/apollolake/romstage.c | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/soc/intel/apollolake/exit_car.S b/src/soc/intel/apollolake/exit_car.S
index e5706cf..c0fb39b 100644
--- a/src/soc/intel/apollolake/exit_car.S
+++ b/src/soc/intel/apollolake/exit_car.S
@@ -38,6 +38,14 @@ chipset_teardown_car:
and $(~(MTRR_DEF_TYPE_EN | MTRR_DEF_TYPE_FIX_EN)), %eax
wrmsr
+ /* Flush down whatever we have */
+ mov $0x7a000000, %eax
+loop:
+ clflush (%eax)
+ add $CACHE_LINE_SIZE, %eax
+ cmp $0x7b000000, %eax
+ jl loop
+
#if IS_ENABLED(CONFIG_CAR_CQOS)
mov $MTRR_L2_QOS_MASK(0), %ecx
rdmsr
diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c
index ce28326..1fa52fd 100644
--- a/src/soc/intel/apollolake/romstage.c
+++ b/src/soc/intel/apollolake/romstage.c
@@ -112,7 +112,7 @@ asmlinkage void car_stage_entry(void)
struct postcar_frame pcf;
size_t mrc_data_size;
uintptr_t top_of_ram;
- int prev_sleep_state;
+ int prev_sleep_state, mtrr;
struct romstage_handoff *handoff;
struct chipset_power_state *ps = car_get_var_ptr(&power_state);
@@ -129,6 +129,13 @@ asmlinkage void car_stage_entry(void)
range_entry_init(®_car, (uintptr_t)_car_relocatable_data_end,
(uintptr_t)_car_region_end, 0);
+ mtrr = get_free_var_mtrr();
+ if (mtrr==-1)
+ printk(BIOS_CRIT, "no available MTRRs to cache cbmem!\n");
+ else
+ /* Make sure cbmem 16 MiB under CBMEM is cachable */
+ set_var_mtrr(mtrr, 0x7a000000, 16 * MiB, MTRR_TYPE_WRBACK);
+
if (fsp_memory_init(&hob_list_ptr, ®_car) != FSP_SUCCESS) {
die("FSP memory init failed. Giving up.");
}