mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 21:47:22 +00:00
hv: rename BOOT_CPU_ID to BSP_CPU_ID
1. Rename BOOT_CPU_ID to BSP_CPU_ID 2. Repace hardcoded value with BSP_CPU_ID when ID of BSP is referenced. Tracked-On: #4420 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
parent
4adad73cfc
commit
64b874ce4c
@ -104,7 +104,7 @@ void init_pcpu_pre(bool is_bsp)
|
|||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
if (is_bsp) {
|
if (is_bsp) {
|
||||||
pcpu_id = BOOT_CPU_ID;
|
pcpu_id = BSP_CPU_ID;
|
||||||
start_tsc = rdtsc();
|
start_tsc = rdtsc();
|
||||||
|
|
||||||
/* Get CPU capabilities thru CPUID, including the physical address bit
|
/* Get CPU capabilities thru CPUID, including the physical address bit
|
||||||
@ -187,7 +187,7 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
|
|
||||||
init_pcpu_xsave();
|
init_pcpu_xsave();
|
||||||
|
|
||||||
if (pcpu_id == BOOT_CPU_ID) {
|
if (pcpu_id == BSP_CPU_ID) {
|
||||||
/* Print Hypervisor Banner */
|
/* Print Hypervisor Banner */
|
||||||
print_hv_banner();
|
print_hv_banner();
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
|
|
||||||
pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name);
|
pr_acrnlog("Detect processor: %s", (get_pcpu_info())->model_name);
|
||||||
|
|
||||||
pr_dbg("Core %hu is up", BOOT_CPU_ID);
|
pr_dbg("Core %hu is up", BSP_CPU_ID);
|
||||||
|
|
||||||
if (!sanitize_vm_config()) {
|
if (!sanitize_vm_config()) {
|
||||||
panic("VM Configuration Error!");
|
panic("VM Configuration Error!");
|
||||||
@ -218,7 +218,7 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize interrupts */
|
/* Initialize interrupts */
|
||||||
init_interrupt(BOOT_CPU_ID);
|
init_interrupt(BSP_CPU_ID);
|
||||||
|
|
||||||
timer_init();
|
timer_init();
|
||||||
setup_notification();
|
setup_notification();
|
||||||
@ -242,7 +242,7 @@ void init_pcpu_post(uint16_t pcpu_id)
|
|||||||
panic("Failed to start all secondary cores!");
|
panic("Failed to start all secondary cores!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(get_pcpu_id() == BOOT_CPU_ID, "");
|
ASSERT(get_pcpu_id() == BSP_CPU_ID, "");
|
||||||
} else {
|
} else {
|
||||||
pr_dbg("Core %hu is up", pcpu_id);
|
pr_dbg("Core %hu is up", pcpu_id);
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ static void init_pcpu_xsave(void)
|
|||||||
val64 |= CR4_OSXSAVE;
|
val64 |= CR4_OSXSAVE;
|
||||||
CPU_CR_WRITE(cr4, val64);
|
CPU_CR_WRITE(cr4, val64);
|
||||||
|
|
||||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
if (get_pcpu_id() == BSP_CPU_ID) {
|
||||||
cpuid(CPUID_FEATURES, &unused, &unused, &ecx, &unused);
|
cpuid(CPUID_FEATURES, &unused, &unused, &ecx, &unused);
|
||||||
|
|
||||||
/* if set, update it */
|
/* if set, update it */
|
||||||
|
@ -126,7 +126,7 @@ static bool vcpu_do_pending_extint(const struct acrn_vcpu *vcpu)
|
|||||||
|
|
||||||
/* check if there is valid interrupt from vPIC, if yes just inject it */
|
/* check if there is valid interrupt from vPIC, if yes just inject it */
|
||||||
/* PIC only connect with primary CPU */
|
/* PIC only connect with primary CPU */
|
||||||
primary = vcpu_from_vid(vm, BOOT_CPU_ID);
|
primary = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
if (vcpu == primary) {
|
if (vcpu == primary) {
|
||||||
|
|
||||||
vpic_pending_intr(vm_pic(vcpu->vm), &vector);
|
vpic_pending_intr(vm_pic(vcpu->vm), &vector);
|
||||||
|
@ -1652,7 +1652,7 @@ vlapic_reset(struct acrn_vlapic *vlapic, const struct acrn_apicv_ops *ops, enum
|
|||||||
|
|
||||||
vlapic->msr_apicbase = DEFAULT_APIC_BASE;
|
vlapic->msr_apicbase = DEFAULT_APIC_BASE;
|
||||||
|
|
||||||
if (vlapic->vcpu->vcpu_id == BOOT_CPU_ID) {
|
if (vlapic->vcpu->vcpu_id == BSP_CPU_ID) {
|
||||||
vlapic->msr_apicbase |= APICBASE_BSP;
|
vlapic->msr_apicbase |= APICBASE_BSP;
|
||||||
}
|
}
|
||||||
if (mode == INIT_RESET) {
|
if (mode == INIT_RESET) {
|
||||||
|
@ -199,7 +199,7 @@ static inline uint16_t get_vm_bsp_pcpu_id(const struct acrn_vm_config *vm_config
|
|||||||
{
|
{
|
||||||
uint16_t cpu_id = INVALID_CPU_ID;
|
uint16_t cpu_id = INVALID_CPU_ID;
|
||||||
|
|
||||||
cpu_id = ffs64(vm_config->vcpu_affinity[0]);
|
cpu_id = ffs64(vm_config->vcpu_affinity[BSP_CPU_ID]);
|
||||||
|
|
||||||
return (cpu_id < get_pcpu_nums()) ? cpu_id : INVALID_CPU_ID;
|
return (cpu_id < get_pcpu_nums()) ? cpu_id : INVALID_CPU_ID;
|
||||||
}
|
}
|
||||||
@ -730,7 +730,7 @@ void start_vm(struct acrn_vm *vm)
|
|||||||
vm->state = VM_STARTED;
|
vm->state = VM_STARTED;
|
||||||
|
|
||||||
/* Only start BSP (vid = 0) and let BSP start other APs */
|
/* Only start BSP (vid = 0) and let BSP start other APs */
|
||||||
bsp = vcpu_from_vid(vm, BOOT_CPU_ID);
|
bsp = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
vcpu_make_request(bsp, ACRN_REQUEST_INIT_VMCS);
|
vcpu_make_request(bsp, ACRN_REQUEST_INIT_VMCS);
|
||||||
launch_vcpu(bsp);
|
launch_vcpu(bsp);
|
||||||
}
|
}
|
||||||
@ -824,7 +824,7 @@ void pause_vm(struct acrn_vm *vm)
|
|||||||
*/
|
*/
|
||||||
void resume_vm_from_s3(struct acrn_vm *vm, uint32_t wakeup_vec)
|
void resume_vm_from_s3(struct acrn_vm *vm, uint32_t wakeup_vec)
|
||||||
{
|
{
|
||||||
struct acrn_vcpu *bsp = vcpu_from_vid(vm, BOOT_CPU_ID);
|
struct acrn_vcpu *bsp = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
|
|
||||||
vm->state = VM_STARTED;
|
vm->state = VM_STARTED;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static bool handle_common_reset_reg_write(struct acrn_vm *vm, bool reset)
|
|||||||
* or pre-launched VM reset,
|
* or pre-launched VM reset,
|
||||||
* ACRN doesn't support re-launch, just shutdown the guest.
|
* ACRN doesn't support re-launch, just shutdown the guest.
|
||||||
*/
|
*/
|
||||||
const struct acrn_vcpu *bsp = vcpu_from_vid(vm, BOOT_CPU_ID);
|
const struct acrn_vcpu *bsp = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
|
|
||||||
pause_vm(vm);
|
pause_vm(vm);
|
||||||
per_cpu(shutdown_vm_id, pcpuid_from_vcpu(bsp)) = vm->vm_id;
|
per_cpu(shutdown_vm_id, pcpuid_from_vcpu(bsp)) = vm->vm_id;
|
||||||
|
@ -22,13 +22,13 @@ void arch_fire_vhm_interrupt(void)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* use vLAPIC to inject vector to SOS vcpu 0 if vlapic is enabled
|
* use vLAPIC to inject vector to SOS vcpu 0 if vlapic is enabled
|
||||||
* otherwise, send IPI hardcoded to BOOT_CPU_ID
|
* otherwise, send IPI hardcoded to BSP_CPU_ID
|
||||||
*/
|
*/
|
||||||
struct acrn_vm *sos_vm;
|
struct acrn_vm *sos_vm;
|
||||||
struct acrn_vcpu *vcpu;
|
struct acrn_vcpu *vcpu;
|
||||||
|
|
||||||
sos_vm = get_sos_vm();
|
sos_vm = get_sos_vm();
|
||||||
vcpu = vcpu_from_vid(sos_vm, BOOT_CPU_ID);
|
vcpu = vcpu_from_vid(sos_vm, BSP_CPU_ID);
|
||||||
|
|
||||||
vlapic_set_intr(vcpu, get_vhm_notification_vector(), LAPIC_TRIG_EDGE);
|
vlapic_set_intr(vcpu, get_vhm_notification_vector(), LAPIC_TRIG_EDGE);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ static void init_debug_pre(void)
|
|||||||
/*TODO: move into debug module */
|
/*TODO: move into debug module */
|
||||||
static void init_debug_post(uint16_t pcpu_id)
|
static void init_debug_post(uint16_t pcpu_id)
|
||||||
{
|
{
|
||||||
if (pcpu_id == BOOT_CPU_ID) {
|
if (pcpu_id == BSP_CPU_ID) {
|
||||||
/* Initialize the shell */
|
/* Initialize the shell */
|
||||||
shell_init();
|
shell_init();
|
||||||
console_setup_timer();
|
console_setup_timer();
|
||||||
@ -69,11 +69,11 @@ static void init_primary_pcpu_post(void)
|
|||||||
{
|
{
|
||||||
init_seed();
|
init_seed();
|
||||||
|
|
||||||
init_pcpu_post(BOOT_CPU_ID);
|
init_pcpu_post(BSP_CPU_ID);
|
||||||
|
|
||||||
init_debug_post(BOOT_CPU_ID);
|
init_debug_post(BSP_CPU_ID);
|
||||||
|
|
||||||
init_guest_mode(BOOT_CPU_ID);
|
init_guest_mode(BSP_CPU_ID);
|
||||||
|
|
||||||
run_idle_thread();
|
run_idle_thread();
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ static void disable_pic_irqs(void)
|
|||||||
|
|
||||||
void init_default_irqs(uint16_t cpu_id)
|
void init_default_irqs(uint16_t cpu_id)
|
||||||
{
|
{
|
||||||
if (cpu_id == BOOT_CPU_ID) {
|
if (cpu_id == BSP_CPU_ID) {
|
||||||
init_irq_descs();
|
init_irq_descs();
|
||||||
|
|
||||||
/* we use ioapic only, disable legacy PIC */
|
/* we use ioapic only, disable legacy PIC */
|
||||||
@ -488,7 +488,7 @@ void init_interrupt(uint16_t pcpu_id)
|
|||||||
{
|
{
|
||||||
struct host_idt_descriptor *idtd = &HOST_IDTR;
|
struct host_idt_descriptor *idtd = &HOST_IDTR;
|
||||||
|
|
||||||
if (pcpu_id == BOOT_CPU_ID) {
|
if (pcpu_id == BSP_CPU_ID) {
|
||||||
fixup_idt(idtd);
|
fixup_idt(idtd);
|
||||||
}
|
}
|
||||||
set_idt(idtd);
|
set_idt(idtd);
|
||||||
|
@ -197,7 +197,7 @@ void timer_init(void)
|
|||||||
|
|
||||||
init_percpu_timer(pcpu_id);
|
init_percpu_timer(pcpu_id);
|
||||||
|
|
||||||
if (pcpu_id == BOOT_CPU_ID) {
|
if (pcpu_id == BSP_CPU_ID) {
|
||||||
register_softirq(SOFTIRQ_TIMER, timer_softirq);
|
register_softirq(SOFTIRQ_TIMER, timer_softirq);
|
||||||
|
|
||||||
retval = request_irq(TIMER_IRQ, (irq_action_t)tsc_deadline_handler, NULL, IRQF_NONE);
|
retval = request_irq(TIMER_IRQ, (irq_action_t)tsc_deadline_handler, NULL, IRQF_NONE);
|
||||||
|
@ -269,8 +269,8 @@ static int32_t init_general_vm_boot_info(struct acrn_vm *vm)
|
|||||||
|
|
||||||
static void depri_boot_spurious_handler(uint32_t vector)
|
static void depri_boot_spurious_handler(uint32_t vector)
|
||||||
{
|
{
|
||||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
if (get_pcpu_id() == BSP_CPU_ID) {
|
||||||
struct acrn_vcpu *vcpu = vcpu_from_vid(get_sos_vm(), BOOT_CPU_ID);
|
struct acrn_vcpu *vcpu = vcpu_from_vid(get_sos_vm(), BSP_CPU_ID);
|
||||||
|
|
||||||
if (vcpu != NULL) {
|
if (vcpu != NULL) {
|
||||||
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
|
vlapic_set_intr(vcpu, vector, LAPIC_TRIG_EDGE);
|
||||||
@ -284,7 +284,7 @@ static int32_t depri_boot_sw_loader(struct acrn_vm *vm)
|
|||||||
{
|
{
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
/* get primary vcpu */
|
/* get primary vcpu */
|
||||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
struct acrn_vcpu_regs *vcpu_regs = &boot_context;
|
||||||
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
|
const struct depri_boot_context *depri_boot_ctx = get_depri_boot_ctx();
|
||||||
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
|
const struct lapic_regs *depri_boot_lapic_regs = get_depri_boot_lapic_regs();
|
||||||
|
@ -59,7 +59,7 @@ int32_t hcall_sos_offline_cpu(struct acrn_vm *vm, uint64_t lapicid)
|
|||||||
foreach_vcpu(i, vm, vcpu) {
|
foreach_vcpu(i, vm, vcpu) {
|
||||||
if (vlapic_get_apicid(vcpu_vlapic(vcpu)) == lapicid) {
|
if (vlapic_get_apicid(vcpu_vlapic(vcpu)) == lapicid) {
|
||||||
/* should not offline BSP */
|
/* should not offline BSP */
|
||||||
if (vcpu->vcpu_id == BOOT_CPU_ID) {
|
if (vcpu->vcpu_id == BSP_CPU_ID) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ void ptirq_deactivate_entry(struct ptirq_remapping_info *entry)
|
|||||||
|
|
||||||
void ptdev_init(void)
|
void ptdev_init(void)
|
||||||
{
|
{
|
||||||
if (get_pcpu_id() == BOOT_CPU_ID) {
|
if (get_pcpu_id() == BSP_CPU_ID) {
|
||||||
spinlock_init(&ptdev_lock);
|
spinlock_init(&ptdev_lock);
|
||||||
register_softirq(SOFTIRQ_PTDEV, ptirq_softirq);
|
register_softirq(SOFTIRQ_PTDEV, ptirq_softirq);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ int32_t direct_boot_sw_loader(struct acrn_vm *vm)
|
|||||||
struct sw_module_info *bootargs_info = &(vm->sw.bootargs_info);
|
struct sw_module_info *bootargs_info = &(vm->sw.bootargs_info);
|
||||||
struct sw_module_info *ramdisk_info = &(vm->sw.ramdisk_info);
|
struct sw_module_info *ramdisk_info = &(vm->sw.ramdisk_info);
|
||||||
/* get primary vcpu */
|
/* get primary vcpu */
|
||||||
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
struct acrn_vcpu *vcpu = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
|
|
||||||
pr_dbg("Loading guest to run-time location");
|
pr_dbg("Loading guest to run-time location");
|
||||||
|
|
||||||
|
@ -1412,7 +1412,7 @@ void profiling_setup(void)
|
|||||||
dev_dbg(DBG_LEVEL_PROFILING, "%s: entering", __func__);
|
dev_dbg(DBG_LEVEL_PROFILING, "%s: entering", __func__);
|
||||||
cpu = get_pcpu_id();
|
cpu = get_pcpu_id();
|
||||||
/* support PMI notification, SOS_VM will register all CPU */
|
/* support PMI notification, SOS_VM will register all CPU */
|
||||||
if ((cpu == BOOT_CPU_ID) && (profiling_pmi_irq == IRQ_INVALID)) {
|
if ((cpu == BSP_CPU_ID) && (profiling_pmi_irq == IRQ_INVALID)) {
|
||||||
pr_info("%s: calling request_irq", __func__);
|
pr_info("%s: calling request_irq", __func__);
|
||||||
retval = request_irq(PMI_IRQ,
|
retval = request_irq(PMI_IRQ,
|
||||||
profiling_pmi_handler, NULL, IRQF_NONE);
|
profiling_pmi_handler, NULL, IRQF_NONE);
|
||||||
|
@ -937,7 +937,7 @@ static int32_t shell_dump_guest_mem(int32_t argc, char **argv)
|
|||||||
length = (uint64_t)strtol_deci(argv[3]);
|
length = (uint64_t)strtol_deci(argv[3]);
|
||||||
|
|
||||||
vm = get_vm_from_vmid(vm_id);
|
vm = get_vm_from_vmid(vm_id);
|
||||||
vcpu = vcpu_from_vid(vm, BOOT_CPU_ID);
|
vcpu = vcpu_from_vid(vm, BSP_CPU_ID);
|
||||||
|
|
||||||
dump.vcpu = vcpu;
|
dump.vcpu = vcpu;
|
||||||
dump.gva = gva;
|
dump.gva = gva;
|
||||||
|
@ -202,7 +202,7 @@ static void vpic_notify_intr(struct acrn_vpic *vpic)
|
|||||||
*/
|
*/
|
||||||
i8259->intr_raised = true;
|
i8259->intr_raised = true;
|
||||||
if (vpic->vm->wire_mode == VPIC_WIRE_INTR) {
|
if (vpic->vm->wire_mode == VPIC_WIRE_INTR) {
|
||||||
struct acrn_vcpu *bsp = vcpu_from_vid(vpic->vm, BOOT_CPU_ID);
|
struct acrn_vcpu *bsp = vcpu_from_vid(vpic->vm, BSP_CPU_ID);
|
||||||
vcpu_inject_extint(bsp);
|
vcpu_inject_extint(bsp);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -145,8 +145,6 @@
|
|||||||
#define CPU_MHZ_TO_HZ 1000000
|
#define CPU_MHZ_TO_HZ 1000000
|
||||||
#define CPU_MHZ_TO_KHZ 1000
|
#define CPU_MHZ_TO_KHZ 1000
|
||||||
|
|
||||||
/* Boot CPU ID */
|
|
||||||
#define BOOT_CPU_ID 0U
|
|
||||||
|
|
||||||
/* Number of GPRs saved / restored for guest in VCPU structure */
|
/* Number of GPRs saved / restored for guest in VCPU structure */
|
||||||
#define NUM_GPRS 16U
|
#define NUM_GPRS 16U
|
||||||
@ -276,6 +274,9 @@ extern uint64_t secondary_cpu_stack[1];
|
|||||||
* to locate the per cpu data.
|
* to locate the per cpu data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Boot CPU ID */
|
||||||
|
#define BSP_CPU_ID 0U
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*The invalid cpu_id (INVALID_CPU_ID) is error
|
*The invalid cpu_id (INVALID_CPU_ID) is error
|
||||||
*code for error handling, this means that
|
*code for error handling, this means that
|
||||||
|
@ -283,7 +283,7 @@ struct guest_mem_dump {
|
|||||||
|
|
||||||
static inline bool is_vcpu_bsp(const struct acrn_vcpu *vcpu)
|
static inline bool is_vcpu_bsp(const struct acrn_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
return (vcpu->vcpu_id == BOOT_CPU_ID);
|
return (vcpu->vcpu_id == BSP_CPU_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline enum vm_cpu_mode get_vcpu_mode(const struct acrn_vcpu *vcpu)
|
static inline enum vm_cpu_mode get_vcpu_mode(const struct acrn_vcpu *vcpu)
|
||||||
|
Loading…
Reference in New Issue
Block a user