[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c7941874-758b-49eb-af58-23c371b7d1e8@ghiti.fr>
Date: Mon, 21 Apr 2025 09:47:44 +0200
From: Alexandre Ghiti <alex@...ti.fr>
To: Nylon Chen <nylon.chen@...ive.com>, linux-kernel@...r.kernel.org
Cc: linux-riscv@...ts.infradead.org, paul.walmsley@...ive.com,
palmer@...belt.com, aou@...s.berkeley.edu, charlie@...osinc.com,
jesse@...osinc.com, evan@...osinc.com, cleger@...osinc.com,
zhangchunyan@...as.ac.cn, samuel.holland@...ive.com, zong.li@...ive.com
Subject: Re: [PATCH 1/2] riscv: misaligned: Add handling for ZCB instructions
Hi Nylon,
On 11/04/2025 09:38, Nylon Chen wrote:
> Add support for the Zcb extension's compressed half-word instructions
> (C.LHU, C.LH, and C.SH) in the RISC-V misaligned access trap handler.
>
> Signed-off-by: Zong Li <zong.li@...ive.com>
> Signed-off-by: Nylon Chen <nylon.chen@...ive.com>
I would add the following fixes tag:
Fixes: 956d705dd279 ("riscv: Unaligned load/store handling for M_MODE")
> ---
> arch/riscv/kernel/traps_misaligned.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index 7cc108aed74e..d7275dfb6b7e 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -88,6 +88,13 @@
> #define INSN_MATCH_C_FSWSP 0xe002
> #define INSN_MASK_C_FSWSP 0xe003
>
> +#define INSN_MATCH_C_LHU 0x8400
> +#define INSN_MASK_C_LHU 0xfc43
> +#define INSN_MATCH_C_LH 0x8440
> +#define INSN_MASK_C_LH 0xfc43
> +#define INSN_MATCH_C_SH 0x8c00
> +#define INSN_MASK_C_SH 0xfc43
> +
> #define INSN_LEN(insn) ((((insn) & 0x3) < 0x3) ? 2 : 4)
>
> #if defined(CONFIG_64BIT)
> @@ -431,6 +438,13 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
> fp = 1;
> len = 4;
> #endif
> + } else if ((insn & INSN_MASK_C_LHU) == INSN_MATCH_C_LHU) {
> + len = 2;
> + insn = RVC_RS2S(insn) << SH_RD;
> + } else if ((insn & INSN_MASK_C_LH) == INSN_MATCH_C_LH) {
> + len = 2;
> + shift = 8 * (sizeof(ulong) - len);
> + insn = RVC_RS2S(insn) << SH_RD;
> } else {
> regs->epc = epc;
> return -1;
> @@ -530,6 +544,9 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
> len = 4;
> val.data_ulong = GET_F32_RS2C(insn, regs);
> #endif
> + } else if ((insn & INSN_MASK_C_SH) == INSN_MATCH_C_SH) {
> + len = 2;
> + val.data_ulong = GET_RS2S(insn, regs);
> } else {
> regs->epc = epc;
> return -1;
Reviewed-by: Alexandre Ghiti <alexghiti@...osinc.com>
Thanks,
Alex
Powered by blists - more mailing lists