From: Andrew Jones <ajones@ventanamicro.com>
To: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, kvm-riscv@lists.infradead.org
Subject: Re: [PATCH 2/3] riscv: Strengthen duplicate and inconsistent definition of RV_X()
Date: Thu, 24 Apr 2025 10:45:46 +0200 [thread overview]
Message-ID: <20250424-f322adab22126ae97dd7c5b4@orel> (raw)
In-Reply-To: <20250422082545.450453-3-alexghiti@rivosinc.com>
On Tue, Apr 22, 2025 at 10:25:44AM +0200, Alexandre Ghiti wrote:
> RV_X() macro is defined in two different ways which is error prone.
>
> So harmonize its first definition and add another macro RV_X_mask() for
> the second one.
>
> Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
> ---
> arch/riscv/include/asm/insn.h | 39 ++++++++++++++--------------
> arch/riscv/kernel/elf_kexec.c | 1 -
> arch/riscv/kernel/traps_misaligned.c | 1 -
> arch/riscv/kvm/vcpu_insn.c | 1 -
> 4 files changed, 20 insertions(+), 22 deletions(-)
>
> diff --git a/arch/riscv/include/asm/insn.h b/arch/riscv/include/asm/insn.h
> index 2a589a58b291..4063ca35be9b 100644
> --- a/arch/riscv/include/asm/insn.h
> +++ b/arch/riscv/include/asm/insn.h
> @@ -288,43 +288,44 @@ static __always_inline bool riscv_insn_is_c_jalr(u32 code)
>
> #define RV_IMM_SIGN(x) (-(((x) >> 31) & 1))
> #define RVC_IMM_SIGN(x) (-(((x) >> 12) & 1))
> -#define RV_X(X, s, mask) (((X) >> (s)) & (mask))
> -#define RVC_X(X, s, mask) RV_X(X, s, mask)
> +#define RV_X(X, s, n) (((X) >> (s)) & ((1 << (n)) - 1))
Assuming n is arbitrary then we should be using BIT_ULL.
Thanks,
drew
next prev parent reply other threads:[~2025-04-24 8:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 8:25 [PATCH 0/3] Move duplicated instructions macros into asm/insn.h Alexandre Ghiti
2025-04-22 8:25 ` [PATCH 1/3] riscv: Fix typo EXRACT -> EXTRACT Alexandre Ghiti
2025-04-22 9:04 ` Clément Léger
2025-04-22 10:20 ` Philippe Mathieu-Daudé
2025-04-24 10:35 ` Andrew Jones
2025-04-22 8:25 ` [PATCH 2/3] riscv: Strengthen duplicate and inconsistent definition of RV_X() Alexandre Ghiti
2025-04-22 9:14 ` Clément Léger
2025-04-24 8:45 ` Andrew Jones [this message]
2025-04-25 7:26 ` Andrew Jones
2025-04-22 8:25 ` [PATCH 3/3] riscv: Move all duplicate insn parsing macros into asm/insn.h Alexandre Ghiti
2025-04-22 9:36 ` Clément Léger
2025-05-06 8:05 ` Alexandre Ghiti
2025-04-24 10:35 ` Andrew Jones
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=20250424-f322adab22126ae97dd7c5b4@orel \
--to=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=alexghiti@rivosinc.com \
--cc=anup@brainfault.org \
--cc=atishp@atishpatra.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.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