Skip to content

Commit 96f7ff3

Browse files
JasonChenCJjren1
authored andcommitted
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>
1 parent d3a640d commit 96f7ff3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hypervisor/arch/x86/cpu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ int phy_cpu_num;
5959
unsigned long pcpu_sync = 0;
6060
uint32_t up_count = 0;
6161

62+
/* physical cpu active bitmap, support up to 64 cpus */
63+
uint64_t pcpu_active_bitmap = 0;
64+
6265
DEFINE_CPU_DATA(uint8_t[STACK_SIZE], stack) __aligned(16);
6366
DEFINE_CPU_DATA(uint8_t, lapic_id);
6467
DEFINE_CPU_DATA(void *, vcpu);
@@ -392,6 +395,8 @@ void bsp_boot_init(void)
392395
VMX_MACHINE_T_GUEST_SPEC_CTRL_OFFSET,
393396
"run_context ia32_spec_ctrl offset not match");
394397

398+
bitmap_set(CPU_BOOT_ID, &pcpu_active_bitmap);
399+
395400
/* Get CPU capabilities thru CPUID, including the physical address bit
396401
* limit which is required for initializing paging.
397402
*/
@@ -535,6 +540,8 @@ void cpu_secondary_init(void)
535540
(get_cur_lapic_id()),
536541
CPU_STATE_INITIALIZING);
537542

543+
bitmap_set(get_cpu_id(), &pcpu_active_bitmap);
544+
538545
/* Switch to run-time stack */
539546
CPU_SP_WRITE(&get_cpu_var(stack)[STACK_SIZE - 1]);
540547

@@ -646,6 +653,8 @@ void cpu_halt(uint32_t logical_id)
646653
/* Set state to show CPU is halted */
647654
cpu_set_current_state(logical_id, CPU_STATE_HALTED);
648655

656+
bitmap_clr(get_cpu_id(), &pcpu_active_bitmap);
657+
649658
/* Halt the CPU */
650659
do {
651660
asm volatile ("hlt");

hypervisor/include/arch/x86/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ EXTERN_CPU_DATA(uint8_t[STACK_SIZE], stack) __aligned(16);
198198

199199
extern void *per_cpu_data_base_ptr;
200200
extern int phy_cpu_num;
201+
extern uint64_t pcpu_active_bitmap;
201202

202203
#define PER_CPU_DATA_OFFSET(sym_addr) \
203204
((uint64_t)(sym_addr) - (uint64_t)(_ld_cpu_data_start))

0 commit comments

Comments
 (0)