From: Andreas Schwab <schwab@suse.de>
To: Zishun Yi <vulab@iscas.ac.cn>
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
alex@ghiti.fr, ajones@ventanamicro.com, cleger@rivosinc.com,
charlie@rivosinc.com, namcao@linutronix.de
Subject: Re: [PATCH v2] riscv: misaligned: Restore epc in error path
Date: Mon, 11 May 2026 09:53:08 +0200 [thread overview]
Message-ID: <mvmh5oe1ixn.fsf@suse.de> (raw)
In-Reply-To: <20260509074053.1748061-1-vulab@iscas.ac.cn> (Zishun Yi's message of "Sat, 9 May 2026 15:40:53 +0800")
On Mai 09 2026, Zishun Yi wrote:
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index 2a27d3ff4ac6..24f898853bba 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -307,13 +307,17 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
> return -1;
> }
>
> - if (!IS_ENABLED(CONFIG_FPU) && fp)
> + if (!IS_ENABLED(CONFIG_FPU) && fp) {
> + regs->epc = epc;
> return -EOPNOTSUPP;
> + }
>
> val.data_u64 = 0;
> if (user_mode(regs)) {
> - if (copy_from_user(&val, (u8 __user *)addr, len))
> + if (copy_from_user(&val, (u8 __user *)addr, len)) {
> + regs->epc = epc;
> return -1;
> + }
> } else {
> memcpy(&val, (u8 *)addr, len);
> }
> @@ -409,12 +413,16 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
> return -1;
> }
>
> - if (!IS_ENABLED(CONFIG_FPU) && fp)
> + if (!IS_ENABLED(CONFIG_FPU) && fp) {
> + regs->epc = epc;
> return -EOPNOTSUPP;
> + }
>
> if (user_mode(regs)) {
> - if (copy_to_user((u8 __user *)addr, &val, len))
> + if (copy_to_user((u8 __user *)addr, &val, len)) {
> + regs->epc = epc;
> return -1;
> + }
I think this is better handled by a common error exit.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
WARNING: multiple messages have this Message-ID (diff)
From: Andreas Schwab <schwab@suse.de>
To: Zishun Yi <vulab@iscas.ac.cn>
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
alex@ghiti.fr, ajones@ventanamicro.com, cleger@rivosinc.com,
charlie@rivosinc.com, namcao@linutronix.de
Subject: Re: [PATCH v2] riscv: misaligned: Restore epc in error path
Date: Mon, 11 May 2026 09:53:08 +0200 [thread overview]
Message-ID: <mvmh5oe1ixn.fsf@suse.de> (raw)
In-Reply-To: <20260509074053.1748061-1-vulab@iscas.ac.cn> (Zishun Yi's message of "Sat, 9 May 2026 15:40:53 +0800")
On Mai 09 2026, Zishun Yi wrote:
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index 2a27d3ff4ac6..24f898853bba 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -307,13 +307,17 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
> return -1;
> }
>
> - if (!IS_ENABLED(CONFIG_FPU) && fp)
> + if (!IS_ENABLED(CONFIG_FPU) && fp) {
> + regs->epc = epc;
> return -EOPNOTSUPP;
> + }
>
> val.data_u64 = 0;
> if (user_mode(regs)) {
> - if (copy_from_user(&val, (u8 __user *)addr, len))
> + if (copy_from_user(&val, (u8 __user *)addr, len)) {
> + regs->epc = epc;
> return -1;
> + }
> } else {
> memcpy(&val, (u8 *)addr, len);
> }
> @@ -409,12 +413,16 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
> return -1;
> }
>
> - if (!IS_ENABLED(CONFIG_FPU) && fp)
> + if (!IS_ENABLED(CONFIG_FPU) && fp) {
> + regs->epc = epc;
> return -EOPNOTSUPP;
> + }
>
> if (user_mode(regs)) {
> - if (copy_to_user((u8 __user *)addr, &val, len))
> + if (copy_to_user((u8 __user *)addr, &val, len)) {
> + regs->epc = epc;
> return -1;
> + }
I think this is better handled by a common error exit.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-05-11 7:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 7:40 [PATCH v2] riscv: misaligned: Restore epc in error path Zishun Yi
2026-05-09 7:40 ` Zishun Yi
2026-05-11 7:53 ` Andreas Schwab [this message]
2026-05-11 7:53 ` Andreas Schwab
2026-05-11 12:41 ` [PATCH v3] " Zishun Yi
2026-05-11 12:41 ` Zishun Yi
2026-05-13 2:13 ` Maciej W. Rozycki
2026-05-13 2:13 ` Maciej W. Rozycki
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=mvmh5oe1ixn.fsf@suse.de \
--to=schwab@suse.de \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=namcao@linutronix.de \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=vulab@iscas.ac.cn \
/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.