Frans Hendriks has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30811
Change subject: lib/prog_loaders.c: Add prog_locate_hook() for measured and verified boot.
......................................................................
lib/prog_loaders.c: Add prog_locate_hook() for measured and verified boot.
Before images are loaded from cbfs it needs to be measured and/or verified.
prog_locate_hook() is added and can be used to start measured/verified boot.
BUG=N/A
TEST=Created verified binary and verify logging on Facebook FBG-1701
Change-Id: I12207fc8f2e9ca45d048cf8c8d9c057f53e5c2c7
Signed-off-by: Frans Hendriks <fhendriks(a)eltan.com>
---
M src/include/program_loading.h
M src/lib/prog_loaders.c
2 files changed, 7 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/30811/1
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 468f0b3..a382daf 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -3,6 +3,7 @@
*
* Copyright 2015 Google Inc.
* Copyright (C) 2014 Imagination Technologies
+ * Copyright (C) 2018 Eltan B.V.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -136,6 +137,7 @@
/* Locate the identified program to run. Return 0 on success. < 0 on error. */
int prog_locate(struct prog *prog);
+int prog_locate_hook(struct prog *prog);
/* Run the program described by prog. */
void prog_run(struct prog *prog);
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index b763417..4fa9a03 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -2,6 +2,7 @@
* This file is part of the coreboot project.
*
* Copyright 2015 Google Inc.
+ * Copyright (C) 2018 Eltan B.V.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,6 +40,9 @@
{
struct cbfsf file;
+ if (prog_locate_hook(prog))
+ return -1;
+
cbfs_prepare_program_locate();
if (cbfs_boot_locate(&file, prog_name(prog), NULL))
@@ -74,6 +78,7 @@
halt();
}
+int __weak prog_locate_hook(struct prog *prog) {return 0; }
void __weak stage_cache_add(int stage_id,
const struct prog *stage) {}
void __weak stage_cache_load_stage(int stage_id,
--
To view, visit https://review.coreboot.org/c/coreboot/+/30811
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I12207fc8f2e9ca45d048cf8c8d9c057f53e5c2c7
Gerrit-Change-Number: 30811
Gerrit-PatchSet: 1
Gerrit-Owner: Frans Hendriks <fhendriks(a)eltan.com>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31203
Change subject: cpu/intel/common: Compute the TSC tick freq based on FSB
......................................................................
cpu/intel/common: Compute the TSC tick freq based on FSB
This allows the cbmem utility to compute timestamps based on coreboot
tables without relying on other userspace components.
Change-Id: Ie87adec950dc51f4f873c0d852a325b3ff9b18bf
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/cpu/intel/common/fsb.c
1 file changed, 26 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/03/31203/1
diff --git a/src/cpu/intel/common/fsb.c b/src/cpu/intel/common/fsb.c
index 1f7c391..cf258bd 100644
--- a/src/cpu/intel/common/fsb.c
+++ b/src/cpu/intel/common/fsb.c
@@ -11,7 +11,9 @@
* GNU General Public License for more details.
*/
+#include <console/console.h>
#include <cpu/cpu.h>
+#include <cpu/x86/tsc.h>
#include <cpu/x86/msr.h>
#include <cpu/intel/speedstep.h>
#include <cpu/intel/fsb.h>
@@ -83,3 +85,27 @@
printk(BIOS_ERR, "FSB not supported or not found\n");
return -1;
}
+
+unsigned long tsc_freq_mhz(void)
+{
+ msr_t msr;
+ unsigned long multiplier;
+ struct cpuinfo_x86 c;
+
+ get_fms(&c, cpuid_eax(1));
+
+ msr = rdmsr(IA32_PLATFORM_ID);
+ multiplier = (msr.lo & SPEEDSTEP_RATIO_VALUE_MASK)
+ >> SPEEDSTEP_RATIO_SHIFT;
+ if ((c.x86 == 6 && c.x86_model == 0xe) || (c.x86 == 0xf)) {
+ /* Looks like Yonah CPUs don't have the frequency ratio in
+ IA32_PLATFORM_ID. Use IA32_PERF_STATUS instead, the reading
+ should be reliable as those CPUs don't have turbo mode. */
+ msr = rdmsr(IA32_PERF_STATUS);
+ multiplier = (msr.hi & SPEEDSTEP_RATIO_VALUE_MASK)
+ >> SPEEDSTEP_RATIO_SHIFT;
+ }
+
+ printk(BIOS_DEBUG, "CPU freq %ld\n", multiplier * get_ia32_fsb());
+ return multiplier * get_ia32_fsb();
+}
--
To view, visit https://review.coreboot.org/c/coreboot/+/31203
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ie87adec950dc51f4f873c0d852a325b3ff9b18bf
Gerrit-Change-Number: 31203
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31202
Change subject: arch/x86/timestamp.c: Don't depend on CONFIG_TSC_CONSTANT_RATE
......................................................................
arch/x86/timestamp.c: Don't depend on CONFIG_TSC_CONSTANT_RATE
timestamp_tick_freq_mhz() is used to populate the coreboot tables
which cbmem can use to determine timestamps without needing userspace
tools to get the TSC frequency rate. CONFIG_TSC_CONSTANT_RATE depends
on CONFIG_UDELAY_TSC which is not the case on all targets that could
still make use of this functionality.
Change-Id: I8c34eb811e27d2a91ccf1ca6f48a638da5f6cfd9
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/arch/x86/timestamp.c
1 file changed, 13 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/31202/1
diff --git a/src/arch/x86/timestamp.c b/src/arch/x86/timestamp.c
index b5257c4..f7b5541 100644
--- a/src/arch/x86/timestamp.c
+++ b/src/arch/x86/timestamp.c
@@ -21,14 +21,20 @@
return rdtscll();
}
+/* We want build to fail on targets with CONFIG_TSC_CONSTANT_RATE
+ if an implementation is lacking since it used to compute udelays.
+ FIXME: provide an implementation on every target to get rid of this.*/
+#if !IS_ENABLED(CONFIG_TSC_CONSTANT_RATE)
+unsigned long __weak tsc_freq_mhz(void)
+{
+ /* Default to not knowing TSC frequency. cbmem will have to fallback
+ * on trying to determine it in userspace. */
+ return 0;
+}
+#endif
+
int timestamp_tick_freq_mhz(void)
{
/* Chipsets that have a constant TSC provide this value correctly. */
- if (IS_ENABLED(CONFIG_TSC_CONSTANT_RATE))
- return tsc_freq_mhz();
-
- /* Filling tick_freq_mhz = 0 in timestamps-table will trigger
- * userspace utility to try deduce it from the running system.
- */
- return 0;
+ return tsc_freq_mhz();
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/31202
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I8c34eb811e27d2a91ccf1ca6f48a638da5f6cfd9
Gerrit-Change-Number: 31202
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Frans Hendriks has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/30810
Change subject: device/pci_device.c: Use verified boot to check oprom
......................................................................
device/pci_device.c: Use verified boot to check oprom
Before oprom is executed, no check is performed if rom passes verification.
Add call to verified_boot_should_run_oprom() to verify the oprom.
BUG=N/A
TEST=Created verified binary and verify logging on Portwell PQ-M107
Change-Id: Iec5092e85d34940ea3a3bb1192ea49f3bc3e5b27
Signed-off-by: Frans Hendriks <fhendriks(a)eltan.com>
---
M src/device/pci_device.c
M src/include/device/pci_rom.h
2 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/10/30810/1
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index 82033a6..40012f9 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -16,6 +16,7 @@
* Copyright (C) 2005-2009 coresystems GmbH
* (Written by Stefan Reinauer <stepan(a)coresystems.de> for coresystems GmbH)
* Copyright (C) 2014 Sage Electronic Engineering, LLC.
+ * Copyright (C) 2018 Eltan B.V.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -802,6 +803,10 @@
if (!should_run_oprom(dev))
return;
+ if (IS_ENABLED(CONFIG_VERIFIED_BOOT))
+ if (!verified_boot_should_run_oprom(rom))
+ return;
+
run_bios(dev, (unsigned long)ram);
gfx_set_init_done(1);
printk(BIOS_DEBUG, "VGA Option ROM was run\n");
diff --git a/src/include/device/pci_rom.h b/src/include/device/pci_rom.h
index a4aa52a..865fea3 100644
--- a/src/include/device/pci_rom.h
+++ b/src/include/device/pci_rom.h
@@ -1,3 +1,19 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ * Copyright (C) 2018 Eltan B.V.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
#ifndef PCI_ROM_H
#define PCI_ROM_H
#include <endian.h>
@@ -47,4 +63,5 @@
u32 map_oprom_vendev(u32 vendev);
+int verified_boot_should_run_oprom(struct rom_header *rom_header);
#endif
--
To view, visit https://review.coreboot.org/c/coreboot/+/30810
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Iec5092e85d34940ea3a3bb1192ea49f3bc3e5b27
Gerrit-Change-Number: 30810
Gerrit-PatchSet: 1
Gerrit-Owner: Frans Hendriks <fhendriks(a)eltan.com>
Gerrit-MessageType: newchange