From bc4c773cf8cf756859d9c9a68447f994121be2fa Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Wed, 21 Sep 2022 15:27:57 +0800 Subject: [PATCH] hv: add param to control INIT used to kick pCPU By default, notification IPI used to kick sharing pCPU, INIT used to kick partition pCPU. If USE_INIT_IPI flag is passed to hypervisor, only INIT will be used to kick pCPU. Tracked-On: #8207 Signed-off-by: Minggui Cao Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/vcpu.c | 5 ++++- hypervisor/debug/console.c | 11 +++++++++++ hypervisor/include/debug/console.h | 1 + hypervisor/release/console.c | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index 76babb891..86ff3ec1a 100755 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -21,6 +21,7 @@ #include #include #include +#include /* stack_frame is linked with the sequence of stack operation in arch_switch_to() */ struct stack_frame { @@ -526,11 +527,13 @@ int32_t create_vcpu(uint16_t pcpu_id, struct acrn_vm *vm, struct acrn_vcpu **rtn vcpu->vcpu_id = vcpu_id; per_cpu(ever_run_vcpu, pcpu_id) = vcpu; - if (is_lapic_pt_configured(vm)) { + if (is_lapic_pt_configured(vm) || is_using_init_ipi()) { per_cpu(mode_to_kick_pcpu, pcpu_id) = DEL_MODE_INIT; } else { per_cpu(mode_to_kick_pcpu, pcpu_id) = DEL_MODE_IPI; } + 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()); /* Initialize the parent VM reference */ vcpu->vm = vm; diff --git a/hypervisor/debug/console.c b/hypervisor/debug/console.c index f94d170e6..f818d7daa 100644 --- a/hypervisor/debug/console.c +++ b/hypervisor/debug/console.c @@ -25,6 +25,14 @@ struct hv_timer console_timer; #define GUEST_CONSOLE_TO_HV_SWITCH_KEY 0 /* CTRL + SPACE */ uint16_t console_vmid = ACRN_INVALID_VMID; +/* if use INIT to kick pcpu only, if not notification IPI still is used for sharing CPU */ +static bool use_init_ipi = false; + +bool is_using_init_ipi(void) +{ + return use_init_ipi; +} + static void parse_hvdbg_cmdline(void) { const char *start = NULL; @@ -43,6 +51,9 @@ static void parse_hvdbg_cmdline(void) if (!handle_dbg_cmd(start, (int32_t)(end - start))) { /* if not handled by handle_dbg_cmd, it can be handled further */ + if (strncmp(start, "USE_INIT_IPI", (size_t)(end - start)) == 0) { + use_init_ipi = true; + } } start = end; } diff --git a/hypervisor/include/debug/console.h b/hypervisor/include/debug/console.h index b61a94afd..bd924fa7e 100644 --- a/hypervisor/include/debug/console.h +++ b/hypervisor/include/debug/console.h @@ -41,5 +41,6 @@ void console_vmexit_callback(struct acrn_vcpu *vcpu); void suspend_console(void); void resume_console(void); struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm); +bool is_using_init_ipi(void); #endif /* CONSOLE_H */ diff --git a/hypervisor/release/console.c b/hypervisor/release/console.c index 803d71678..fcb6dcabd 100644 --- a/hypervisor/release/console.c +++ b/hypervisor/release/console.c @@ -29,5 +29,7 @@ void resume_console(void) {} bool handle_dbg_cmd(__unused const char *cmd, __unused int32_t len) { return false; } void console_vmexit_callback(__unused struct acrn_vcpu *vcpu) {} +bool is_using_init_ipi(void) { return false; } + void shell_init(void) {} void shell_kick(void) {}