Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Yuhang.chen <yhchen312@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] RISC-V: KVM: Add kvm-riscv.wfi_trap_policy to control VS-mode WFI trapping
Date: Thu, 09 Jul 2026 12:09:41 +0000	[thread overview]
Message-ID: <20260709120941.BE9001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709115610.287420-1-yhchen312@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The use of `early_param` causes a build failure and breaks parameter configuration when KVM is compiled as a loadable module (`CONFIG_KVM=m`).
--

--- Patch [1]: [PATCH] RISC-V: KVM: Add kvm-riscv.wfi_trap_policy to control VS-mode WFI trapping ---
commit 6cc43e03229541ce24e1b37ff0f4554294688af7
Author: Yuhang.chen <yhchen312@gmail.com>

RISC-V: KVM: Add kvm-riscv.wfi_trap_policy to control VS-mode WFI trapping

This commit introduces a new parameter to control whether VS-mode WFI
instructions trap into KVM or execute natively.

> diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c
> index cf6e231e76e25..09afbb014b47d 100644
> --- a/arch/riscv/kvm/vcpu.c
> +++ b/arch/riscv/kvm/vcpu.c

[ ... ]

> @@ -26,6 +27,42 @@
>  
>  static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_former_vcpu);
>  
> +/*
> + * WFI trap policy for VS-mode guests, controllable through the
> + * kvm-riscv.wfi_trap_policy= kernel command-line option.
> + */
> +enum kvm_riscv_wfi_trap_policy {
> +	KVM_RISCV_WFI_TRAP,	/* Default: trap VS-mode WFI into KVM */
> +	KVM_RISCV_WFI_NOTRAP,	/* Let VS-mode WFI execute natively */
> +};
> +
> +static enum kvm_riscv_wfi_trap_policy kvm_riscv_wfi_trap_policy __read_mostly =
> +	KVM_RISCV_WFI_TRAP;
> +
> +static int __init early_kvm_riscv_wfi_trap_policy_cfg(char *arg)
> +{
[ ... ]
> +	if (strcmp(arg, "notrap") == 0) {
> +		kvm_riscv_wfi_trap_policy = KVM_RISCV_WFI_NOTRAP;
> +		return 0;
> +	}
> +
> +	return -EINVAL;
> +}
> +early_param("kvm-riscv.wfi_trap_policy", early_kvm_riscv_wfi_trap_policy_cfg);

[Severity: Low]
Since KVM can be compiled as a loadable module (CONFIG_KVM=m), will this
use of early_param() cause a build failure?

In include/linux/init.h, early_param() is undefined when MODULE is defined.
Additionally, since early_param() only parses the early boot command line,
this setup prevents configuring the trap policy via arguments when KVM is
loaded dynamically.

Does this need to use module_param() or similar to ensure it builds correctly
as a module and accepts runtime arguments?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260709115610.287420-1-yhchen312@gmail.com?part=1

      reply	other threads:[~2026-07-09 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:56 [PATCH] RISC-V: KVM: Add kvm-riscv.wfi_trap_policy to control VS-mode WFI trapping Yuhang.chen
2026-07-09 12:09 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260709120941.BE9001F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yhchen312@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox