All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Charlie Jenkins" <thecharlesjenkins@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 09/17] riscv: kvm: Use generated instruction headers for csr code
Date: Wed, 08 Jul 2026 03:48:47 +0000	[thread overview]
Message-ID: <20260708034847.C37D71F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260707-riscv_insn_table-v3-9-3f8e5f75ba97@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Undefined macro `GET_REG` causes a build failure, and intended `get_reg()` usage masks a logic error where an immediate is treated as a register index.
--

--- Patch [9]: [PATCH v3 09/17] riscv: kvm: Use generated instruction headers for csr code ---
commit d70b1983c271eb6387c8473892b04f021becb8ff
Author: Charlie Jenkins <thecharlesjenkins@gmail.com>

riscv: kvm: Use generated instruction headers for csr code

This commit migrates the CSR parsing code in RISC-V KVM to use the generated
instruction headers instead of hand-written instruction composition functions.

> diff --git a/arch/riscv/kvm/vcpu_insn.c b/arch/riscv/kvm/vcpu_insn.c
> index f09f9251d1f0a..a1898ab8bbe85 100644
> --- a/arch/riscv/kvm/vcpu_insn.c
> +++ b/arch/riscv/kvm/vcpu_insn.c

[ ... ]

> @@ -144,45 +144,49 @@ static int csr_insn(struct kvm_vcpu *vcpu, struct kvm_run *run, ulong insn)
>  	const struct csr_func *tcfn, *cfn = NULL;
>  	ulong val = 0, wr_mask = 0, new_val = 0;
>  
>  	/* Decode the CSR instruction */

[ ... ]

> +	} else if (riscv_insn_is_csrrwi(insn)) {
>  		wr_mask = -1UL;
> +		new_val = riscv_insn_csrrwi_extract_imm(insn);
> +		csr_num = riscv_insn_csrrwi_extract_csr(insn);
> +	} else if (riscv_insn_is_csrrsi(insn)) {
> +		wr_mask = riscv_insn_csrrwi_extract_imm(insn);

[Severity: High]
Should this use a csrrsi specific extraction function? It looks like it is
currently reusing riscv_insn_csrrwi_extract_imm() due to a copy-paste error.

>  		new_val = -1UL;
> +		csr_num = riscv_insn_csrrsi_extract_csr(insn);
> +	} else if (riscv_insn_is_csrrci(insn)) {
> +		wr_mask = GET_REG(riscv_insn_csrrwi_extract_imm(insn));

[Severity: High]
This introduces an undefined macro GET_REG, which will break the build.

If the intention was to use the newly added get_reg() helper, does that
introduce a logic error? The csrrci instruction uses a 5-bit zero-extended
immediate directly as the write mask, rather than using the immediate as a
register index.

Also, similar to the csrrsi branch above, should this use the csrrci
extraction functions instead of riscv_insn_csrrwi_extract_imm() and
riscv_insn_csrrwi_extract_csr()?

>  		new_val = 0;
> +		csr_num = riscv_insn_csrrwi_extract_csr(insn);
> +	} else {
>  		return rc;
>  	}
>  
> +	#undef GET_REG
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260707-riscv_insn_table-v3-0-3f8e5f75ba97@gmail.com?part=9

  reply	other threads:[~2026-07-08  3:48 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  3:34 [PATCH v3 00/17] riscv: Generate riscv instruction functions Charlie Jenkins
2026-07-08  3:34 ` Charlie Jenkins
2026-07-08  3:34 ` Charlie Jenkins
2026-07-08  3:34 ` [PATCH v3 01/17] riscv: Introduce instruction table generation Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:50   ` sashiko-bot
2026-07-09  6:23     ` Charlie Jenkins
2026-07-08  3:34 ` [PATCH v3 02/17] riscv: alternatives: Use generated instruction headers for patching code Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:45   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 03/17] riscv: kgdb: Use generated instruction headers Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34 ` [PATCH v3 04/17] riscv: Add kprobes instruction simulation KUnit Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:51   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 05/17] riscv: kprobes: Use generated instruction headers Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:52   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 06/17] riscv: cfi: " Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34 ` [PATCH v3 07/17] riscv: Maintain epc on misaligned emulation error Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:55   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 08/17] riscv: Use generated instruction headers for misaligned loads/stores Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:49   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 09/17] riscv: kvm: Use generated instruction headers for csr code Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:48   ` sashiko-bot [this message]
2026-07-08  3:34 ` [PATCH v3 10/17] KVM: device: Add test device Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:48   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 11/17] KVM: riscv: selftests: Add mmio test Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:59   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 12/17] riscv: kvm: Use generated instruction headers for mmio emulation Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  4:01   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 13/17] riscv: kvm: Add emulated test csr Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  4:00   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 14/17] KVM: riscv: selftests: Add csr emulation test Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:58   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 15/17] riscv: kvm: Use generated instruction headers for csr emulation Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  4:04   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 16/17] riscv: kexec: Use generated instruction headers for kexec relocations Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  4:01   ` sashiko-bot
2026-07-08  3:34 ` [PATCH v3 17/17] riscv: Remove unused instruction headers Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  3:34   ` Charlie Jenkins
2026-07-08  4:09   ` sashiko-bot
2026-07-09  6:26 ` [syzbot ci] Re: riscv: Generate riscv instruction functions syzbot ci
2026-07-09  6:26   ` syzbot ci
2026-07-09  6:26   ` syzbot ci

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=20260708034847.C37D71F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=thecharlesjenkins@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.