hv: move percpu delivery mode and idle mode from common to x86

delivery mode and idle mode are x86 specific percpu, so move it from common to
x86 arch, also change the name of mode_to_idle to be idle_mode, change the name
of mode_to_kick_pcpu to be kick_pcpu_mode.

Tracked-On: #8812
Signed-off-by: Xue Bosheng <bosheng.xue@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Xue Bosheng
2025-08-25 20:05:23 +08:00
committed by acrnsi-robot
parent b03dc25119
commit e278b38ec4
8 changed files with 24 additions and 22 deletions

View File

@@ -108,6 +108,12 @@ static void enable_gp_for_uclock(void)
#endif /*CONFIG_UC_LOCK_DETECTION_ENABLED*/ #endif /*CONFIG_UC_LOCK_DETECTION_ENABLED*/
} }
static void init_pcpu_idle_and_kick(uint16_t pcpu_id)
{
per_cpu(arch.idle_mode, pcpu_id) = IDLE_MODE_HLT;
per_cpu(arch.kick_pcpu_mode, pcpu_id) = DEL_MODE_IPI;
}
void init_pcpu_pre(bool is_bsp) void init_pcpu_pre(bool is_bsp)
{ {
uint16_t pcpu_id; uint16_t pcpu_id;
@@ -292,6 +298,8 @@ void init_pcpu_post(uint16_t pcpu_id)
apply_frequency_policy(); apply_frequency_policy();
init_pcpu_idle_and_kick(pcpu_id);
init_sched(pcpu_id); init_sched(pcpu_id);
#ifdef CONFIG_RDT_ENABLED #ifdef CONFIG_RDT_ENABLED
@@ -391,7 +399,7 @@ void cpu_do_idle(void)
#else #else
uint16_t pcpu_id = get_pcpu_id(); uint16_t pcpu_id = get_pcpu_id();
if (per_cpu(mode_to_idle, pcpu_id) == IDLE_MODE_HLT) { if (per_cpu(arch.idle_mode, pcpu_id) == IDLE_MODE_HLT) {
asm_safe_hlt(); asm_safe_hlt();
} else { } else {
struct acrn_vcpu *vcpu = get_ever_run_vcpu(pcpu_id); struct acrn_vcpu *vcpu = get_ever_run_vcpu(pcpu_id);

View File

@@ -536,17 +536,17 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn
* idle, the kick mode is certainly ipi kick) will change * idle, the kick mode is certainly ipi kick) will change
* it to PAUSE idle right away. * it to PAUSE idle right away.
*/ */
if (per_cpu(mode_to_idle, pcpu_id) == IDLE_MODE_HLT) { if (per_cpu(arch.idle_mode, pcpu_id) == IDLE_MODE_HLT) {
per_cpu(mode_to_idle, pcpu_id) = IDLE_MODE_PAUSE; per_cpu(arch.idle_mode, pcpu_id) = IDLE_MODE_PAUSE;
kick_pcpu(pcpu_id); kick_pcpu(pcpu_id);
} }
per_cpu(mode_to_kick_pcpu, pcpu_id) = DEL_MODE_INIT; per_cpu(arch.kick_pcpu_mode, pcpu_id) = DEL_MODE_INIT;
} else { } else {
per_cpu(mode_to_kick_pcpu, pcpu_id) = DEL_MODE_IPI; per_cpu(arch.kick_pcpu_mode, pcpu_id) = DEL_MODE_IPI;
per_cpu(mode_to_idle, pcpu_id) = IDLE_MODE_HLT; per_cpu(arch.idle_mode, pcpu_id) = IDLE_MODE_HLT;
} }
pr_info("pcpu=%d, kick-mode=%d, use_init_flag=%d", pcpu_id, pr_info("pcpu=%d, kick-mode=%d, use_init_flag=%d", pcpu_id,
per_cpu(mode_to_kick_pcpu, pcpu_id), is_using_init_ipi()); per_cpu(arch.kick_pcpu_mode, pcpu_id), is_using_init_ipi());
/* Initialize the parent VM reference */ /* Initialize the parent VM reference */
vcpu->vm = vm; vcpu->vm = vm;

View File

@@ -297,7 +297,7 @@ void send_single_init(uint16_t pcpu_id)
void kick_pcpu(uint16_t pcpu_id) void kick_pcpu(uint16_t pcpu_id)
{ {
if (per_cpu(mode_to_kick_pcpu, pcpu_id) == DEL_MODE_INIT) { if (per_cpu(arch.kick_pcpu_mode, pcpu_id) == DEL_MODE_INIT) {
send_single_init(pcpu_id); send_single_init(pcpu_id);
} else { } else {
send_single_ipi(pcpu_id, NOTIFY_VCPU_VECTOR); send_single_ipi(pcpu_id, NOTIFY_VCPU_VECTOR);

View File

@@ -65,9 +65,6 @@ void init_sched(uint16_t pcpu_id)
{ {
struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id); struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id);
per_cpu(mode_to_idle, pcpu_id) = IDLE_MODE_HLT;
per_cpu(mode_to_kick_pcpu, pcpu_id) = DEL_MODE_IPI;
spinlock_init(&ctl->scheduler_lock); spinlock_init(&ctl->scheduler_lock);
ctl->flags = 0UL; ctl->flags = 0UL;
ctl->curr_obj = NULL; ctl->curr_obj = NULL;
@@ -145,9 +142,6 @@ struct thread_object *sched_get_current(uint16_t pcpu_id)
return ctl->curr_obj; return ctl->curr_obj;
} }
/**
* @pre delmode == DEL_MODE_IPI || delmode == DEL_MODE_INIT
*/
void make_reschedule_request(uint16_t pcpu_id) void make_reschedule_request(uint16_t pcpu_id)
{ {
struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id); struct sched_control *ctl = &per_cpu(sched_ctl, pcpu_id);

View File

@@ -294,6 +294,12 @@ extern uint64_t secondary_cpu_stack[1];
*/ */
#define BROADCAST_CPU_ID 0xfffeU #define BROADCAST_CPU_ID 0xfffeU
#define DEL_MODE_INIT (1U)
#define DEL_MODE_IPI (2U)
#define IDLE_MODE_PAUSE (1U)
#define IDLE_MODE_HLT (2U)
struct descriptor_table { struct descriptor_table {
uint16_t limit; uint16_t limit;
uint64_t base; uint64_t base;

View File

@@ -30,6 +30,8 @@ struct per_cpu_arch {
#endif #endif
uint64_t tsc_suspend; uint64_t tsc_suspend;
struct acrn_vcpu *whose_iwkey; struct acrn_vcpu *whose_iwkey;
uint32_t kick_pcpu_mode;
uint32_t idle_mode;
} __aligned(PAGE_SIZE); /* per_cpu_region size aligned with PAGE_SIZE */ } __aligned(PAGE_SIZE); /* per_cpu_region size aligned with PAGE_SIZE */

View File

@@ -47,8 +47,6 @@ struct per_cpu_region {
struct thread_object idle; struct thread_object idle;
uint64_t pcpu_flag; uint64_t pcpu_flag;
uint32_t softirq_servicing; uint32_t softirq_servicing;
uint32_t mode_to_kick_pcpu;
uint32_t mode_to_idle;
struct smp_call_info_data smp_call_info; struct smp_call_info_data smp_call_info;
struct list_head softirq_dev_entry_list; struct list_head softirq_dev_entry_list;
enum pcpu_boot_state boot_state; enum pcpu_boot_state boot_state;

View File

@@ -12,12 +12,6 @@
#define NEED_RESCHEDULE (1U) #define NEED_RESCHEDULE (1U)
#define DEL_MODE_INIT (1U)
#define DEL_MODE_IPI (2U)
#define IDLE_MODE_PAUSE (1U)
#define IDLE_MODE_HLT (2U)
#define THREAD_DATA_SIZE (256U) #define THREAD_DATA_SIZE (256U)
enum thread_object_state { enum thread_object_state {