Remove the dashes in the summary (Set-KVM-initial-privilege-mode).

On Tue, Sep 09, 2025 at 05:09:16PM +0800, Xie Bo wrote:
> For KVM mode, the privilege mode should not include M-mode, and the initial 
> value should be set to S-mode. Additionally,patch 2 adds the implementation 
> of putting the vCPU privilege mode to KVM. When the vCPU runs for the first 
> time, QEMU will first put the privilege state to KVM.If the initial value is 
> set to M-mode, KVM will encounter an error.

Don't reference "patch 2" in a commit message. You may say something like
"a following patch".

> 
> In addition, this patch introduces the 'mp_state' field to RISC-V 
> vCPUs,following the convention used by KVM on x86. The 'mp_state' reflects 
> the multiprocessor state of a vCPU, and is used to control whether the vCPU 
> is runnable by KVM.
> - The bootstrap processor (cpu_index == 0) is initialized with 
> KVM_MP_STATE_RUNNABLE.
> - All other vCPUs are initialized with KVM_MP_STATE_STOPPED.

This is just stating what the code does. What we should put here is
_why_ we choose cpu_index 0 to be the only runnable cpu. Is there some
reason? Or is it just because it's the first cpu and we'd otherwise need
to randomly select a boot cpu.

Use newlines to format commit messages, breaking around 70 chars. The
text is also missing space after commas and periods.

> 
> Signed-off-by: Xie Bo <[email protected]>
> ---
>  target/riscv/cpu.c | 11 ++++++++++-
>  target/riscv/cpu.h |  2 ++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 09ded6829a..5fa48c1485 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -1042,7 +1042,16 @@ static void riscv_cpu_reset_hold(Object *obj, 
> ResetType type)
>      }
>  #ifndef CONFIG_USER_ONLY
>      env->misa_mxl = mcc->misa_mxl_max;
> -    env->priv = PRV_M;
> +    if (kvm_enabled()) {
> +        env->priv = PRV_S;
> +    } else {
> +        env->priv = PRV_M;
> +    }
> +    if (cs->cpu_index == 0) {
> +        env->mp_state = KVM_MP_STATE_RUNNABLE;
> +    } else {
> +        env->mp_state = KVM_MP_STATE_STOPPED;
> +    }
>      env->mstatus &= ~(MSTATUS_MIE | MSTATUS_MPRV);
>      if (env->misa_mxl > MXL_RV32) {
>          /*
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index 51e49e03de..4b1c5bf0e4 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -256,6 +256,8 @@ struct CPUArchState {
>  #endif
>  
>      target_ulong priv;
> +    /* Current multiprocessor state of this vCPU. */
> +    uint32_t mp_state;
>      /* CSRs for execution environment configuration */
>      uint64_t menvcfg;
>      target_ulong senvcfg;
> -- 
> 2.43.0
>

Thanks,
drew

Reply via email to