platform: Make the platform read-only

platform should be a read-only variable, if it is placed in the data
segment, it may be exploited.

Signed-off-by: Xiang Wang <wxjstz@126.com>
This commit is contained in:
Xiang Wang
2019-03-06 15:29:34 +08:00
committed by Atish Patra
parent 27fae182dc
commit 9eb8f0f90d
11 changed files with 45 additions and 43 deletions

View File

@@ -32,7 +32,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
{
int rc;
char str[64];
struct sbi_platform *plat = sbi_platform_ptr(scratch);
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
rc = sbi_system_early_init(scratch, TRUE);
if (rc)
@@ -96,7 +96,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid)
{
int rc;
struct sbi_platform *plat = sbi_platform_ptr(scratch);
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
if (!sbi_platform_has_hart_hotplug(plat))
sbi_hart_wait_for_coldboot(scratch, hartid);
@@ -156,7 +156,7 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
{
bool coldboot = FALSE;
u32 hartid = sbi_current_hartid();
struct sbi_platform *plat = sbi_platform_ptr(scratch);
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
if (sbi_platform_hart_disabled(plat, hartid))
sbi_hart_hang();