ARM: qca: Skipping u-boot prompt during crashdump

If crashdump magic is found, should not allow user
to access u-boot prompt as tz will be in unsecure state.

Change-Id: Icdc94c33fb87664857bafa981950f9768794cf11
Signed-off-by: Gokul Sriram Palanisamy <gokulsri@codeaurora.org>
This commit is contained in:
Gokul Sriram Palanisamy 2017-12-20 17:57:24 +05:30 committed by Gerrit - the friendly Code Review server
parent 897bc3b2a4
commit e1b9106107
6 changed files with 69 additions and 83 deletions

View file

@ -50,6 +50,8 @@ int qca_mmc_init(bd_t *, qca_mmc *);
void board_mmc_deinit(void);
void set_flash_secondary_type(qca_smem_flash_info_t *);
void dump_func(void);
int apps_iscrashed(void);
struct dumpinfo_t{
char name[16]; /* use only file name in 8.3 format */

View file

@ -193,27 +193,7 @@ static int do_dumpqca_data(void)
* requested to stop
*/
#ifdef CONFIG_QCA_APPSBL_DLOAD
static int inline do_dumpipq_data(void)
{
uint64_t etime;
if (do_dumpqca_data() != CMD_RET_SUCCESS) {
printf("\nAuto crashdump saving failed!"
"\nPress any key within 10s to take control of U-Boot");
etime = get_timer_masked() + (10 * CONFIG_SYS_HZ);
while (get_timer_masked() < etime) {
if (tstc())
break;
}
if (get_timer_masked() < etime)
return CMD_RET_FAILURE;
}
return CMD_RET_SUCCESS;
}
static int dump_func(void)
void dump_func(void)
{
uint64_t etime;
@ -223,12 +203,11 @@ static int dump_func(void)
#endif
etime = get_timer_masked() + (10 * CONFIG_SYS_HZ);
printf("\nCrashdump magic found."
"\nHit any key within 10s to stop dump activity...");
printf("\nHit any key within 10s to stop dump activity...");
while (!tstc()) { /* while no incoming data */
if (get_timer_masked() >= etime) {
if (do_dumpipq_data() == CMD_RET_FAILURE)
return CMD_RET_FAILURE;
if (do_dumpqca_data() == CMD_RET_FAILURE)
printf("Crashdump saving failed!\n");
break;
}
}
@ -236,56 +215,6 @@ static int dump_func(void)
* when crashmagic is found
*/
run_command("reset", 0);
return CMD_RET_SUCCESS;
}
static int qca_appsbl_dload(void) {
int ret = 0;
u32 rsp = 0;
u32 *addr = (u32 *) 0x193D100;
volatile u32 val;
unsigned long * dmagic1 = (unsigned long *) 0x2A03F000;
unsigned long * dmagic2 = (unsigned long *) 0x2A03F004;
if (is_scm_armv8())
{
ret = qca_scm_call_read(SCM_SVC_IO, SCM_IO_READ, addr, &rsp);
if (rsp == DLOAD_MAGIC_COOKIE) {
val = 0x0;
ret = qca_scm_call_write(SCM_SVC_IO, SCM_IO_WRITE, addr, val);
if (ret)
printf ("Error in reseting the Magic cookie\n");
if (dump_func() == CMD_RET_FAILURE)
return CMD_RET_FAILURE;
}
}
else
{
ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_RD, (void *)&val, sizeof(val));
if (ret) {
if (*dmagic1 == 0xE47B337D && *dmagic2 == 0x0501CAB0) {
/* clear the magic and run the dump command */
*dmagic1 = 0;
*dmagic2 = 0;
if (dump_func() == CMD_RET_FAILURE)
return CMD_RET_FAILURE;
}
}
else {
/* check if we are in download mode */
if (val == DLOAD_MAGIC_COOKIE) {
/* clear the magic and run the dump command */
val = 0x0;
ret = qca_scm_call(SCM_SVC_BOOT, SCM_SVC_WR, (void *)&val, sizeof(val));
if (ret)
printf ("Error in reseting the Magic cookie\n");
if (dump_func() == CMD_RET_FAILURE)
return CMD_RET_FAILURE;
}
}
}
}
#endif
@ -434,10 +363,6 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a
if (argc == 2 && strncmp(argv[1], "debug", 5) == 0)
debug = 1;
#ifdef CONFIG_QCA_APPSBL_DLOAD
if (qca_appsbl_dload() == CMD_RET_FAILURE)
return CMD_RET_CRASH_DUMP;
#endif
if ((ret = set_fs_bootargs(&ipq_fs_on_nand)))
return ret;
@ -615,10 +540,6 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const
if (argc == 2 && strncmp(argv[1], "debug", 5) == 0)
debug = 1;
#ifdef CONFIG_QCA_APPSBL_DLOAD
if (qca_appsbl_dload() == CMD_RET_FAILURE)
return CMD_RET_CRASH_DUMP;
#endif
if ((ret = set_fs_bootargs(&ipq_fs_on_nand)))
return ret;

View file

@ -34,6 +34,7 @@
#include "qca_common.h"
#include "ipq_phy.h"
#define DLOAD_MAGIC_COOKIE 0x10
DECLARE_GLOBAL_DATA_PTR;
qca_mmc mmc_host;
@ -354,3 +355,13 @@ void set_flash_secondary_type(qca_smem_flash_info_t * smem)
{
return;
}
int apps_iscrashed(void)
{
u32 *dmagic = (u32 *)0x193D100;
if (*dmagic == DLOAD_MAGIC_COOKIE)
return 1;
return 0;
}

View file

@ -31,6 +31,9 @@
#include "qca_common.h"
#include <asm/arch-qca-common/scm.h>
#define DLOAD_MAGIC_COOKIE_1 0xE47B337D
#define DLOAD_MAGIC_COOKIE_2 0x0501CAB0
ipq_gmac_board_cfg_t gmac_cfg[CONFIG_IPQ_NO_MACS];
DECLARE_GLOBAL_DATA_PTR;
@ -151,11 +154,19 @@ unsigned long timer_read_counter(void)
void reset_crashdump(void)
{
unsigned long *dmagic1 = (unsigned long *) 0x2A03F000;
unsigned long *dmagic2 = (unsigned long *) 0x2A03F004;
*dmagic1 = 0;
*dmagic2 = 0;
return;
}
void reset_cpu(unsigned long a)
{
reset_crashdump();
printf("\nResetting with watch dog!\n");
writel(0, APCS_WDT0_EN);
@ -791,3 +802,15 @@ int ipq_board_usb_init(void)
return 0;
}
#endif /* CONFIG_USB_XHCI_IPQ */
int apps_iscrashed(void)
{
u32 *dmagic1 = (u32 *)0x2A03F000;
u32 *dmagic2 = (u32 *)0x2A03F004;
if (*dmagic1 == DLOAD_MAGIC_COOKIE_1
&& *dmagic2 == DLOAD_MAGIC_COOKIE_2)
return 1;
return 0;
}

View file

@ -28,6 +28,7 @@
#include <linux/linkage.h>
#include <sdhci.h>
#define DLOAD_MAGIC_COOKIE 0x10
DECLARE_GLOBAL_DATA_PTR;
#define GCNT_PSHOLD 0x004AB000
@ -1024,3 +1025,13 @@ unsigned int get_smem_spi_addr_len(void)
return spi_flash_addr_len;
}
int apps_iscrashed(void)
{
u32 *dmagic = (u32 *)0x193D100;
if (*dmagic == DLOAD_MAGIC_COOKIE)
return 1;
return 0;
}

View file

@ -14,6 +14,7 @@
#include <menu.h>
#include <post.h>
#include <u-boot/sha256.h>
#include <asm/arch-qca-common/qca_common.h>
DECLARE_GLOBAL_DATA_PTR;
@ -353,10 +354,27 @@ const char *bootdelay_process(void)
return s;
}
__weak int apps_iscrashed(void)
{
return 0;
}
void autoboot_command(const char *s)
{
debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
#ifdef CONFIG_QCA_APPSBL_DLOAD
/*
* If kernel has crashed in previous boot,
* jump to crash dump collection.
*/
if (apps_iscrashed()) {
printf("Crashdump magic found, initializing dump activity..\n");
dump_func();
return;
}
#endif
if (stored_bootdelay != -1 && s && !abortboot(stored_bootdelay)) {
#if defined(CONFIG_AUTOBOOT_KEYED) && !defined(CONFIG_AUTOBOOT_KEYED_CTRLC)
int prev = disable_ctrlc(1); /* disable Control C checking */