arm64: implement cpu_info() correctly
There are 2 things wrong with the current implementation: 1. the stack isn't guaranteed to be aligned to CONFIG_STACK_SIZE. 2. the stack isn't necessarily CONFIG_STACK_SIZE bytes. Utilize the smp_processor_id() function to obtain the correct cpu_info structure to obtain the correct index. BUG=chrome-os-partner:31545 BRANC=None TEST=Built and booted. Change-Id: I2825118e2313dbbf13712a4afdfa05a2e38ee3a4 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/214665 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
parent
d5c5c68329
commit
e2c32b1a46
1 changed files with 3 additions and 7 deletions
|
|
@ -30,13 +30,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
/* Return the cpu struct which is at the high memory address of the stack.
|
||||
*/
|
||||
static struct cpu_info cpu_infos[CONFIG_MAX_CPUS];
|
||||
|
||||
struct cpu_info *cpu_info(void)
|
||||
{
|
||||
uintptr_t addr = ALIGN((uintptr_t)__builtin_frame_address(0),
|
||||
CONFIG_STACK_SIZE);
|
||||
addr -= sizeof(struct cpu_info);
|
||||
return (void *)addr;
|
||||
return &cpu_infos[smp_processor_id()];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue