Arthur Heymans has uploaded this change for review.

View Change

[UNTESTED]drivers/pc80/rtc: Cache CMOS option table in CBMEM

Fetching the option table from cbfs each time is slowing things down
and adds a vulnerability during S3 resume.

Change-Id: I9f9001fd0090fd1b56ee518d426aa3d3025dba59
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
M src/commonlib/include/commonlib/cbmem_id.h
M src/drivers/pc80/rtc/mc146818rtc.c
2 files changed, 20 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/58/33058/1
diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h
index 535ba33..5ef8506 100644
--- a/src/commonlib/include/commonlib/cbmem_id.h
+++ b/src/commonlib/include/commonlib/cbmem_id.h
@@ -25,6 +25,7 @@
#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3
#define CBMEM_ID_CBTABLE 0x43425442
#define CBMEM_ID_CBTABLE_FWD 0x43425443
+#define CBMEM_ID_CMOS_TABLE 0x366f1abb
#define CBMEM_ID_CONSOLE 0x434f4e53
#define CBMEM_ID_COVERAGE 0x47434f56
#define CBMEM_ID_EHCI_DEBUG 0xe4c1deb9
@@ -88,6 +89,7 @@
{ CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" }, \
{ CBMEM_ID_CBTABLE, "COREBOOT " }, \
{ CBMEM_ID_CBTABLE_FWD, "COREBOOTFWD" }, \
+ { CBMEM_ID_CMOS_TABLE, "CMOS " }, \
{ CBMEM_ID_CONSOLE, "CONSOLE " }, \
{ CBMEM_ID_COVERAGE, "COVERAGE " }, \
{ CBMEM_ID_EHCI_DEBUG, "USBDEBUG " }, \
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 3667354..ee16cf1 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -18,6 +18,7 @@
#include <arch/acpi.h>
#include <arch/io.h>
#include <bcd.h>
+#include <cbmem.h>
#include <fallback.h>
#include <stdint.h>
#include <version.h>
@@ -272,6 +273,15 @@

static enum cb_err get_layout(struct cmos_option_table *ct)
{
+#if !(defined(__PRE_RAM__) || ENV_SMM)
+ struct cmos_option_table *table;
+ table = cbmem_find(CBMEM_ID_CMOS_TABLE);
+ if (table) {
+ ct = table;
+ return CB_SUCCESS;
+ }
+#endif
+
LOCK_NVRAM_CBFS_SPINLOCK();

if (locate_cmos_layout(&rdev) != CB_SUCCESS) {
@@ -286,6 +296,14 @@
UNLOCK_NVRAM_CBFS_SPINLOCK();
return CB_CMOS_LAYOUT_NOT_FOUND;
}
+#if !(defined(__PRE_RAM__) || ENV_SMM)
+ table = cbmem_add(CBMEM_ID_CMOS_TABLE, region_device_sz(&rdev));
+ if (table) {
+ memcpy(table, ct, region_device_sz(&rdev));
+ ct = table;
+ }
+#endif
+
return CB_SUCCESS;
}


To view, visit change 33058. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I9f9001fd0090fd1b56ee518d426aa3d3025dba59
Gerrit-Change-Number: 33058
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange