mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-23 07:03:08 +00:00
smp: Guard CPU indexes > MAX_CPUS
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
be1421d2ad
commit
d580963043
1 changed files with 21 additions and 0 deletions
21
src/smp.c
21
src/smp.c
|
@ -73,6 +73,9 @@ static void smp_start_cpu(int index, int cluster, int core, u64 rvbar, u64 cpu_s
|
|||
{
|
||||
int i;
|
||||
|
||||
if (index >= MAX_CPUS)
|
||||
return;
|
||||
|
||||
if (spin_table[index].flag)
|
||||
return;
|
||||
|
||||
|
@ -171,12 +174,18 @@ void smp_start_secondaries(void)
|
|||
|
||||
void smp_send_ipi(int cpu)
|
||||
{
|
||||
if (cpu >= MAX_CPUS)
|
||||
return;
|
||||
|
||||
u64 mpidr = spin_table[cpu].mpidr;
|
||||
msr(SYS_IMP_APL_IPI_RR_GLOBAL_EL1, (mpidr & 0xff) | ((mpidr & 0xff00) << 8));
|
||||
}
|
||||
|
||||
void smp_call4(int cpu, void *func, u64 arg0, u64 arg1, u64 arg2, u64 arg3)
|
||||
{
|
||||
if (cpu >= MAX_CPUS)
|
||||
return;
|
||||
|
||||
struct spin_table *target = &spin_table[cpu];
|
||||
|
||||
if (cpu == 0)
|
||||
|
@ -202,6 +211,9 @@ void smp_call4(int cpu, void *func, u64 arg0, u64 arg1, u64 arg2, u64 arg3)
|
|||
|
||||
u64 smp_wait(int cpu)
|
||||
{
|
||||
if (cpu >= MAX_CPUS)
|
||||
return 0;
|
||||
|
||||
struct spin_table *target = &spin_table[cpu];
|
||||
|
||||
while (target->target)
|
||||
|
@ -224,11 +236,17 @@ void smp_set_wfe_mode(bool new_mode)
|
|||
|
||||
bool smp_is_alive(int cpu)
|
||||
{
|
||||
if (cpu >= MAX_CPUS)
|
||||
return false;
|
||||
|
||||
return spin_table[cpu].flag;
|
||||
}
|
||||
|
||||
uint64_t smp_get_mpidr(int cpu)
|
||||
{
|
||||
if (cpu >= MAX_CPUS)
|
||||
return 0;
|
||||
|
||||
return spin_table[cpu].mpidr;
|
||||
}
|
||||
|
||||
|
@ -236,6 +254,9 @@ u64 smp_get_release_addr(int cpu)
|
|||
{
|
||||
struct spin_table *target = &spin_table[cpu];
|
||||
|
||||
if (cpu >= MAX_CPUS)
|
||||
return 0;
|
||||
|
||||
target->args[0] = 0;
|
||||
target->args[1] = 0;
|
||||
target->args[2] = 0;
|
||||
|
|
Loading…
Reference in a new issue