security/vboot: relocate and rename vboot_platform_is_resuming()

After measured boot is decoupled from verified boot in CB:35077,
vboot_platform_is_resuming() is never vboot-specific, thus it is
renamed to platform_is_resuming() and declared in bootmode.h.

Change-Id: I29b5b88af0576c34c10cfbd99659a5cdc0c75842
Signed-off-by: Bill XIE <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39103
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Bill XIE 2020-02-24 23:08:35 +08:00 committed by Philipp Deppenwiese
parent bad08c2c29
commit 516c0a5338
10 changed files with 30 additions and 25 deletions

View File

@ -29,4 +29,10 @@ int display_init_required(void);
int gfx_get_init_done(void); int gfx_get_init_done(void);
void gfx_set_init_done(int done); void gfx_set_init_done(int done);
/*
* Determine if the platform is resuming from suspend. Returns 0 when
* not resuming, > 0 if resuming, and < 0 on error.
*/
int platform_is_resuming(void);
#endif /* __BOOTMODE_H__ */ #endif /* __BOOTMODE_H__ */

View File

@ -48,12 +48,6 @@ int vboot_save_hash(void *digest, size_t digest_size);
*/ */
int vboot_retrieve_hash(void *digest, size_t digest_size); int vboot_retrieve_hash(void *digest, size_t digest_size);
/*
* Determine if the platform is resuming from suspend. Returns 0 when
* not resuming, > 0 if resuming, and < 0 on error.
*/
int vboot_platform_is_resuming(void);
/* ============================= VERSTAGE ================================== */ /* ============================= VERSTAGE ================================== */
/* /*
* Main logic for verified boot. verstage_main() is just the core vboot logic. * Main logic for verified boot. verstage_main() is just the core vboot logic.

View File

@ -113,7 +113,7 @@ static int handle_digest_result(void *slot_hash, size_t slot_hash_sz)
if (!CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)) if (!CONFIG(VBOOT_STARTS_IN_BOOTBLOCK))
return 0; return 0;
is_resume = vboot_platform_is_resuming(); is_resume = platform_is_resuming();
if (is_resume > 0) { if (is_resume > 0) {
uint8_t saved_hash[VBOOT_MAX_HASH_SIZE]; uint8_t saved_hash[VBOOT_MAX_HASH_SIZE];
@ -272,7 +272,7 @@ void verstage_main(void)
* does verification of memory init and thus must ensure it resumes with * does verification of memory init and thus must ensure it resumes with
* the same slot that it booted from. */ * the same slot that it booted from. */
if (CONFIG(RESUME_PATH_SAME_AS_BOOT) && if (CONFIG(RESUME_PATH_SAME_AS_BOOT) &&
vboot_platform_is_resuming()) platform_is_resuming())
ctx->flags |= VB2_CONTEXT_S3_RESUME; ctx->flags |= VB2_CONTEXT_S3_RESUME;
/* Read secdata from TPM. Initialize TPM if secdata not found. We don't /* Read secdata from TPM. Initialize TPM if secdata not found. We don't

View File

@ -12,15 +12,17 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <arch/acpi.h>
#include <cbmem.h>
#include <elog.h>
#include <console/console.h>
#include <soc/southbridge.h>
#include <amdblocks/acpimmio.h> #include <amdblocks/acpimmio.h>
#include <amdblocks/acpi.h> #include <amdblocks/acpi.h>
#include <arch/acpi.h>
#include <bootmode.h>
#include <cbmem.h>
#include <console/console.h>
#include <elog.h>
#include <halt.h> #include <halt.h>
#include <security/vboot/vboot_common.h> #include <security/vboot/vboot_common.h>
#include <soc/southbridge.h>
#include <halt.h>
void poweroff(void) void poweroff(void)
{ {
@ -136,7 +138,7 @@ int acpi_get_sleep_type(void)
return acpi_sleep_from_pm1(acpi_read16(MMIO_ACPI_PM1_CNT_BLK)); return acpi_sleep_from_pm1(acpi_read16(MMIO_ACPI_PM1_CNT_BLK));
} }
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
if (!(acpi_read16(MMIO_ACPI_PM1_STS) & WAK_STS)) if (!(acpi_read16(MMIO_ACPI_PM1_STS) & WAK_STS))
return 0; return 0;

View File

@ -15,6 +15,7 @@
#include <stdint.h> #include <stdint.h>
#include <arch/acpi.h> #include <arch/acpi.h>
#include <arch/io.h> #include <arch/io.h>
#include <bootmode.h>
#include <device/device.h> #include <device/device.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <device/pci.h> #include <device/pci.h>
@ -27,7 +28,6 @@
#include <soc/pci_devs.h> #include <soc/pci_devs.h>
#include <soc/pmc.h> #include <soc/pmc.h>
#include <security/vboot/vbnv.h> #include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
#if defined(__SIMPLE_DEVICE__) #if defined(__SIMPLE_DEVICE__)
@ -387,7 +387,7 @@ int vbnv_cmos_failed(void)
return rtc_failure(); return rtc_failure();
} }
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS)) if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS))
return 0; return 0;

View File

@ -15,6 +15,7 @@
#include <arch/acpi.h> #include <arch/acpi.h>
#include <arch/io.h> #include <arch/io.h>
#include <assert.h> #include <assert.h>
#include <bootmode.h>
#include <device/device.h> #include <device/device.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <device/pci.h> #include <device/pci.h>
@ -26,7 +27,6 @@
#include <soc/pm.h> #include <soc/pm.h>
#include <stdint.h> #include <stdint.h>
#include <security/vboot/vbnv.h> #include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
#if defined(__SIMPLE_DEVICE__) #if defined(__SIMPLE_DEVICE__)
@ -380,7 +380,7 @@ int vbnv_cmos_failed(void)
return rtc_failure(); return rtc_failure();
} }
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS)) if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS))
return 0; return 0;

View File

@ -19,6 +19,7 @@
#include <arch/acpi.h> #include <arch/acpi.h>
#include <arch/io.h> #include <arch/io.h>
#include <bootmode.h>
#include <device/pci_ops.h> #include <device/pci_ops.h>
#include <device/device.h> #include <device/device.h>
#include <device/pci.h> #include <device/pci.h>
@ -30,7 +31,6 @@
#include <soc/pm.h> #include <soc/pm.h>
#include <soc/gpio.h> #include <soc/gpio.h>
#include <security/vboot/vbnv.h> #include <security/vboot/vbnv.h>
#include <security/vboot/vboot_common.h>
/* Print status bits with descriptive names */ /* Print status bits with descriptive names */
static void print_status_bits(u32 status, const char *bit_names[]) static void print_status_bits(u32 status, const char *bit_names[])
@ -450,7 +450,7 @@ int acpi_sci_irq(void)
return sci_irq; return sci_irq;
} }
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS)) if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS))
return 0; return 0;

View File

@ -13,6 +13,7 @@
*/ */
#include <arch/io.h> #include <arch/io.h>
#include <bootmode.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <cbmem.h> #include <cbmem.h>
#include <console/console.h> #include <console/console.h>
@ -21,11 +22,12 @@
#include <intelblocks/gpio.h> #include <intelblocks/gpio.h>
#include <intelblocks/tco.h> #include <intelblocks/tco.h>
#include <option.h> #include <option.h>
#include <pc80/mc146818rtc.h>
#include <security/vboot/vboot_common.h>
#include <soc/pm.h> #include <soc/pm.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <timer.h> #include <timer.h>
#include <security/vboot/vboot_common.h>
static struct chipset_power_state power_state; static struct chipset_power_state power_state;
@ -440,7 +442,7 @@ void pmc_global_reset_enable(bool enable)
} }
#endif // CONFIG_PMC_GLOBAL_RESET_ENABLE_LOCK #endif // CONFIG_PMC_GLOBAL_RESET_ENABLE_LOCK
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS)) if (!(inw(ACPI_BASE_ADDRESS + PM1_STS) & WAK_STS))
return 0; return 0;

View File

@ -15,11 +15,11 @@
#include <stdint.h> #include <stdint.h>
#include <arch/acpi.h> #include <arch/acpi.h>
#include <arch/io.h> #include <arch/io.h>
#include <bootmode.h>
#include <device/pci_ops.h> #include <device/pci_ops.h>
#include <device/device.h> #include <device/device.h>
#include <device/pci.h> #include <device/pci.h>
#include <assert.h> #include <assert.h>
#include <security/vboot/vboot_common.h>
#include "pmbase.h" #include "pmbase.h"
#include "pmutil.h" #include "pmutil.h"
@ -94,7 +94,7 @@ u8 read_pmbase8(const u8 addr)
return inb(lpc_get_pmbase() + addr); return inb(lpc_get_pmbase() + addr);
} }
int vboot_platform_is_resuming(void) int platform_is_resuming(void)
{ {
u16 reg16 = read_pmbase16(PM1_STS); u16 reg16 = read_pmbase16(PM1_STS);

View File

@ -14,6 +14,7 @@
#include <boot_device.h> #include <boot_device.h>
#include <bootmem.h> #include <bootmem.h>
#include <bootmode.h>
#include <cbfs.h> #include <cbfs.h>
#include <vboot_check.h> #include <vboot_check.h>
#include <vboot_common.h> #include <vboot_common.h>
@ -290,7 +291,7 @@ void verified_boot_early_check(void)
if (CONFIG(VENDORCODE_ELTAN_MBOOT)) { if (CONFIG(VENDORCODE_ELTAN_MBOOT)) {
printk(BIOS_DEBUG, "mb_measure returned 0x%x\n", printk(BIOS_DEBUG, "mb_measure returned 0x%x\n",
mb_measure(vboot_platform_is_resuming())); mb_measure(platform_is_resuming()));
} }
printk(BIOS_SPEW, "%s: process early verify list\n", __func__); printk(BIOS_SPEW, "%s: process early verify list\n", __func__);