chromeos: Provide common watchdog reboot support

Many ChromeOS devices use a GPIO to reset the system, in order to
guarantee that the TPM cannot be reset without also resetting the CPU.
Often chipset/SoC hardware watchdogs trigger some kind of built-in
CPU reset, bypassing this GPIO and thus leaving the TPM locked. These
ChromeOS devices need to detect that condition in their bootblock and
trigger a second (proper) reboot.

This patch adds some code to generalize this previously
mainboard-specific functionality and uses it on Veyron boards. It also
provides some code to add the proper eventlog entry for a watchdog
reset. Since the second reboot has to happen before firmware
verification and the eventlog is usually only initialized afterwards, we
provide the functionality to place a tombstone in a memlayout-defined
location (which could be SRAM or some MMIO register that is preserved
across reboots).

BRANCH=veyron
BUG=chrome-os-partner:35705
TEST=Run 'mem w 0xff800000 0x9' on a Jerry, watch how a "Hardware
watchdog reset" event appears in the eventlog after the reboot.

Change-Id: I7ee1d02676e9159794d29e033d71c09fdf4620fd
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242404
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
(cherry picked from commit fffc484bb89f5129d62739dcb44d08d7f5b30b33)
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/243123
This commit is contained in:
Julius Werner 2015-01-21 17:39:49 -08:00 committed by ChromeOS Commit Bot
commit c8edb1de29
20 changed files with 82 additions and 28 deletions

View file

@ -45,6 +45,10 @@ ifneq ($(wildcard src/mainboard/$(MAINBOARDDIR)/chromeos.c),)
ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/chromeos.c
romstage-srcs += src/mainboard/$(MAINBOARDDIR)/chromeos.c
endif
ifneq ($(CONFIG_ARCH_X86),y)
bootblock-y += watchdog.c
ramstage-y += watchdog.c
endif
ifeq ($(MOCK_TPM),1)
CFLAGS_common += -DMOCK_TPM=1

View file

@ -57,12 +57,18 @@ void init_chromeos(int bootmode);
/* functions implemented in elog.c */
void elog_add_boot_reason(void);
/* functions implemented in watchdog.c */
void elog_add_watchdog_reset(void);
void reboot_from_watchdog(void);
#else
static inline int developer_mode_enabled(void) { return 0; }
static inline int recovery_mode_enabled(void) { return 0; }
static inline int vboot_skip_display_init(void) { return 0; }
static inline void init_chromeos(int bootmode) { }
static inline void elog_add_boot_reason(void) { return; }
static inline void elog_add_watchdog_reset(void) { return; }
static inline void reboot_from_watchdog(void) { return; }
#endif /* CONFIG_CHROMEOS */
struct romstage_handoff;

View file

@ -47,4 +47,8 @@
#define OVERLAP_VERSTAGE_ROMSTAGE(addr, size) ROMSTAGE(addr, size)
#endif
#define WATCHDOG_TOMBSTONE(addr, size) \
REGION(watchdog_tombstone, addr, size, 4) \
_ = ASSERT(size == 4, "watchdog tombstones should be exactly 4 byte!");
#endif /* __CHROMEOS_MEMLAYOUT_H */

View file

@ -29,4 +29,8 @@ extern u8 _verstage[];
extern u8 _everstage[];
#define _verstage_size (_everstage - _verstage)
extern u8 _watchdog_tombstone[];
extern u8 _ewatchdog_tombstone[];
#define _watchdog_tombstone_size (_ewatchdog_tombstone - _watchdog_tombstone)
#endif /* __CHROMEOS_SYMBOLS_H */

View file

@ -0,0 +1,42 @@
/*
* This file is part of the coreboot project.
*
* Copyright 2015 Google Inc.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
*/
#include <arch/io.h>
#include <console/console.h>
#include <elog.h>
#include <reset.h>
#include "chromeos.h"
#include "symbols.h"
#define WATCHDOG_TOMBSTONE_MAGIC 0x9d2f41a7
void elog_add_watchdog_reset(void)
{
if (readl(_watchdog_tombstone) == WATCHDOG_TOMBSTONE_MAGIC)
elog_add_event(ELOG_TYPE_ASYNC_HW_TIMER_EXPIRED);
writel(0, _watchdog_tombstone);
}
void reboot_from_watchdog(void)
{
printk(BIOS_INFO, "Last reset was watchdog, reboot again to reset TPM!\n");
writel(WATCHDOG_TOMBSTONE_MAGIC, _watchdog_tombstone);
hard_reset();
}