cpu: add physical cpu active bitmap support

use pcpu_active_bitmap presents which cpu is active

Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Tian, Kevin <kevin.tian@intel.com>
This commit is contained in:
Jason Chen CJ 2018-04-10 19:51:29 +08:00 committed by Jack Ren
parent d3a640da92
commit 96f7ff3be1
2 changed files with 10 additions and 0 deletions

View File

@ -59,6 +59,9 @@ int phy_cpu_num;
unsigned long pcpu_sync = 0;
uint32_t up_count = 0;
/* physical cpu active bitmap, support up to 64 cpus */
uint64_t pcpu_active_bitmap = 0;
DEFINE_CPU_DATA(uint8_t[STACK_SIZE], stack) __aligned(16);
DEFINE_CPU_DATA(uint8_t, lapic_id);
DEFINE_CPU_DATA(void *, vcpu);
@ -392,6 +395,8 @@ void bsp_boot_init(void)
VMX_MACHINE_T_GUEST_SPEC_CTRL_OFFSET,
"run_context ia32_spec_ctrl offset not match");
bitmap_set(CPU_BOOT_ID, &pcpu_active_bitmap);
/* Get CPU capabilities thru CPUID, including the physical address bit
* limit which is required for initializing paging.
*/
@ -535,6 +540,8 @@ void cpu_secondary_init(void)
(get_cur_lapic_id()),
CPU_STATE_INITIALIZING);
bitmap_set(get_cpu_id(), &pcpu_active_bitmap);
/* Switch to run-time stack */
CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]);
@ -646,6 +653,8 @@ void cpu_halt(uint32_t logical_id)
/* Set state to show CPU is halted */
cpu_set_current_state(logical_id, CPU_STATE_HALTED);
bitmap_clr(get_cpu_id(), &pcpu_active_bitmap);
/* Halt the CPU */
do {
asm volatile ("hlt");

View File

@ -198,6 +198,7 @@ EXTERN_CPU_DATA(uint8_t[STACK_SIZE], stack) __aligned(16);
extern void *per_cpu_data_base_ptr;
extern int phy_cpu_num;
extern uint64_t pcpu_active_bitmap;
#define PER_CPU_DATA_OFFSET(sym_addr) \
((uint64_t)(sym_addr) - (uint64_t)(_ld_cpu_data_start))