mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
ipqsoc: board: Add restriction for bootm and mw cmd
Added restriction for secure board Change-Id: I7a7b4089689d98a6502b0360bb742fa42eff4759 Signed-off-by: Gurumoorthy Santhakumar <quic_gsanthak@quicinc.com>
This commit is contained in:
parent
d0daefec80
commit
e42b0b340e
11 changed files with 95 additions and 7 deletions
|
|
@ -20,4 +20,8 @@ config USB_XHCI_IPQ
|
||||||
|
|
||||||
config PCI_IPQ
|
config PCI_IPQ
|
||||||
bool "ipq40xx pci"
|
bool "ipq40xx pci"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -51,4 +51,7 @@ config GEPHY
|
||||||
config ART_COMPRESSED
|
config ART_COMPRESSED
|
||||||
bool "Enable uncompress support for ipq5018"
|
bool "Enable uncompress support for ipq5018"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -53,4 +53,8 @@ config QCA8081_PHY
|
||||||
|
|
||||||
config DPR_EXECUTE
|
config DPR_EXECUTE
|
||||||
bool "Enable DPR support"
|
bool "Enable DPR support"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,8 @@ config PCI_IPQ
|
||||||
config IPQ6018_QCA_AQUANTIA_PHY
|
config IPQ6018_QCA_AQUANTIA_PHY
|
||||||
bool "Enable Aquantia PHY support for ipq6018"
|
bool "Enable Aquantia PHY support for ipq6018"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,8 @@ config USB_XHCI_IPQ
|
||||||
config PCI_IPQ
|
config PCI_IPQ
|
||||||
bool "ipq806x pci"
|
bool "ipq806x pci"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,7 @@ config QCA8081_PHY
|
||||||
|
|
||||||
config QCA8075_PHY
|
config QCA8075_PHY
|
||||||
bool "Enable QCA8075 PHY support for ipq807x"
|
bool "Enable QCA8075 PHY support for ipq807x"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,8 @@ config IPQ9574_QCA_AQUANTIA_PHY
|
||||||
|
|
||||||
config IPQ9574_QCA8075_PHY
|
config IPQ9574_QCA8075_PHY
|
||||||
bool "Enable Malibu PHY support for ipq9574"
|
bool "Enable Malibu PHY support for ipq9574"
|
||||||
|
|
||||||
|
config BOARD_TYPES
|
||||||
|
bool "Support board_type member in global data"
|
||||||
|
default y
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,32 @@ __weak int bring_sec_core_up(unsigned int cpuid, unsigned int entry, unsigned in
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SECURE_BOARD_MAGIC 0x5ECB001
|
||||||
|
|
||||||
|
void update_board_type(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
uint8_t buf = 0;
|
||||||
|
qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||||
|
|
||||||
|
if(SMEM_BOOT_NO_FLASH == sfi->flash_type)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ret = qca_scm_call(SCM_SVC_FUSE, QFPROM_IS_AUTHENTICATE_CMD, &buf,
|
||||||
|
sizeof(char));
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
printf("%s: scm call failed. ret = %d\n", __func__, ret);
|
||||||
|
printf("%s: Failed\n", __func__);
|
||||||
|
gd->board_type = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gd->board_type = (buf == 1) ? SECURE_BOARD_MAGIC : 0;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int board_init(void)
|
int board_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -262,6 +288,9 @@ int board_init(void)
|
||||||
* serial init after relocation
|
* serial init after relocation
|
||||||
*/
|
*/
|
||||||
uart_wait_tx_empty();
|
uart_wait_tx_empty();
|
||||||
|
|
||||||
|
update_board_type();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <bootm.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <nand.h>
|
#include <nand.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
@ -86,6 +87,21 @@ typedef struct {
|
||||||
} image_info;
|
} image_info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern bootm_headers_t images; /* pointers to os/initrd/fdt images */
|
||||||
|
|
||||||
|
static int boot_os(int argc, char *const argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
return do_bootm_states(NULL, 0, argc, argv, BOOTM_STATE_START |
|
||||||
|
BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER |
|
||||||
|
BOOTM_STATE_LOADOS |
|
||||||
|
#if defined(CONFIG_PPC) || defined(CONFIG_MIPS)
|
||||||
|
BOOTM_STATE_OS_CMDLINE |
|
||||||
|
#endif
|
||||||
|
BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
|
||||||
|
BOOTM_STATE_OS_GO, &images, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void __stack_chk_fail(void)
|
void __stack_chk_fail(void)
|
||||||
{
|
{
|
||||||
printf("stack-protector: U-boot stack is corrupted.\n");
|
printf("stack-protector: U-boot stack is corrupted.\n");
|
||||||
|
|
@ -268,7 +284,7 @@ int config_select(unsigned int addr, char *rcmd, int rcmd_size)
|
||||||
ret = update_bootargs((void *)addr);
|
ret = update_bootargs((void *)addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
snprintf(rcmd, rcmd_size, "bootm 0x%x#%s\n",
|
snprintf(rcmd, rcmd_size, "0x%x#%s",
|
||||||
addr, dtb_config_name);
|
addr, dtb_config_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +317,7 @@ int config_select(unsigned int addr, char *rcmd, int rcmd_size)
|
||||||
ret = update_bootargs((void *)addr);
|
ret = update_bootargs((void *)addr);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto fail;
|
goto fail;
|
||||||
snprintf(rcmd, rcmd_size, "bootm 0x%x#%s\n",
|
snprintf(rcmd, rcmd_size, "0x%x#%s",
|
||||||
addr, dtb_config_name);
|
addr, dtb_config_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -501,6 +517,7 @@ static int authenticate_rootfs_elf(unsigned int rootfs_hdr)
|
||||||
static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
char runcmd[256];
|
char runcmd[256];
|
||||||
|
char * const arg[1] = {runcmd};
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int request;
|
unsigned int request;
|
||||||
#ifdef CONFIG_VERSION_ROLLBACK_PARTITION_INFO
|
#ifdef CONFIG_VERSION_ROLLBACK_PARTITION_INFO
|
||||||
|
|
@ -745,7 +762,7 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a
|
||||||
if (debug)
|
if (debug)
|
||||||
printf("%s", runcmd);
|
printf("%s", runcmd);
|
||||||
|
|
||||||
if (ret < 0 || run_command(runcmd, 0) != CMD_RET_SUCCESS) {
|
if (ret < 0 || boot_os(1, arg) != CMD_RET_SUCCESS) {
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
mmc_initialize(gd->bd);
|
mmc_initialize(gd->bd);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -766,6 +783,7 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char runcmd[256];
|
char runcmd[256];
|
||||||
|
char * const arg[1] = {runcmd};
|
||||||
#ifdef CONFIG_QCA_MMC
|
#ifdef CONFIG_QCA_MMC
|
||||||
block_dev_desc_t *blk_dev;
|
block_dev_desc_t *blk_dev;
|
||||||
disk_partition_t disk_info;
|
disk_partition_t disk_info;
|
||||||
|
|
@ -884,7 +902,7 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const
|
||||||
runcmd, sizeof(runcmd));
|
runcmd, sizeof(runcmd));
|
||||||
} else if (ret == IMAGE_FORMAT_LEGACY) {
|
} else if (ret == IMAGE_FORMAT_LEGACY) {
|
||||||
snprintf(runcmd, sizeof(runcmd),
|
snprintf(runcmd, sizeof(runcmd),
|
||||||
"bootm 0x%x\n", CONFIG_SYS_LOAD_ADDR);
|
"0x%x", CONFIG_SYS_LOAD_ADDR);
|
||||||
} else {
|
} else {
|
||||||
ret = genimg_get_format((void *)CONFIG_SYS_LOAD_ADDR +
|
ret = genimg_get_format((void *)CONFIG_SYS_LOAD_ADDR +
|
||||||
sizeof(mbn_header_t));
|
sizeof(mbn_header_t));
|
||||||
|
|
@ -901,16 +919,16 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const
|
||||||
#endif
|
#endif
|
||||||
} else if (ret == IMAGE_FORMAT_LEGACY) {
|
} else if (ret == IMAGE_FORMAT_LEGACY) {
|
||||||
snprintf(runcmd, sizeof(runcmd),
|
snprintf(runcmd, sizeof(runcmd),
|
||||||
"bootm 0x%x\n", (CONFIG_SYS_LOAD_ADDR +
|
"0x%x", (CONFIG_SYS_LOAD_ADDR +
|
||||||
sizeof(mbn_header_t)));
|
sizeof(mbn_header_t)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dcache_disable();
|
dcache_disable();
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret < 0 || boot_os(1, arg) != CMD_RET_SUCCESS) {
|
||||||
if (ret < 0 || run_command(runcmd, 0) != CMD_RET_SUCCESS) {
|
|
||||||
#ifdef CONFIG_USB_XHCI_IPQ
|
#ifdef CONFIG_USB_XHCI_IPQ
|
||||||
ipq_board_usb_init();
|
ipq_board_usb_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
#define SECURE_BOARD_MAGIC 0x5ECB001
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_IMI)
|
#if defined(CONFIG_CMD_IMI)
|
||||||
static int image_info(unsigned long addr);
|
static int image_info(unsigned long addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -96,6 +98,11 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
|
|
||||||
int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
|
if(SECURE_BOARD_MAGIC == gd->board_type) {
|
||||||
|
printf("Booting restricted without authentication!!\n");
|
||||||
|
reset_board();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
#ifdef CONFIG_NEEDS_MANUAL_RELOC
|
||||||
static int relocated = 0;
|
static int relocated = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||||
#define CONFIG_SYS_MEMTEST_SCRATCH 0
|
#define CONFIG_SYS_MEMTEST_SCRATCH 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SECURE_BOARD_MAGIC 0x5ECB001
|
||||||
|
|
||||||
static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
|
static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
|
||||||
|
|
||||||
/* Display values from last command.
|
/* Display values from last command.
|
||||||
|
|
@ -171,6 +173,11 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
void *buf, *start;
|
void *buf, *start;
|
||||||
ulong bytes;
|
ulong bytes;
|
||||||
|
|
||||||
|
if(SECURE_BOARD_MAGIC == gd->board_type) {
|
||||||
|
printf("Command not supported \'%s\'\n", argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((argc < 3) || (argc > 4))
|
if ((argc < 3) || (argc > 4))
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue