* [PATCH] Fix unexpected Illegal instruction error on RISC-V.
@ 2024-03-01 14:55 SiHuaN
2024-03-01 15:51 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: SiHuaN @ 2024-03-01 14:55 UTC (permalink / raw)
To: qemu-devel; +Cc: SiHuaN
Avoid right-shifting by a negative number of bits when lmul is 8.
Signed-off-by: SiHuaN <liyongtai@iscas.ac.cn>
---
target/riscv/vector_helper.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 84cec73eb2..f0158ea237 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -53,10 +53,11 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
* VLEN * LMUL >= SEW
* VLEN >> (8 - lmul) >= sew
* (vlenb << 3) >> (8 - lmul) >= sew
+ * Considering that lmul may be 8, the following form cannot be used.
* vlenb >> (8 - 3 - lmul) >= sew
*/
if (vlmul == 4 ||
- cpu->cfg.vlenb >> (8 - 3 - vlmul) < sew) {
+ (cpu->cfg.vlenb << 3) >> (8 - vlmul) < sew) {
vill = true;
}
}
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix unexpected Illegal instruction error on RISC-V.
2024-03-01 14:55 [PATCH] Fix unexpected Illegal instruction error on RISC-V SiHuaN
@ 2024-03-01 15:51 ` Philippe Mathieu-Daudé
2024-03-01 16:15 ` 李永泰
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-03-01 15:51 UTC (permalink / raw)
To: SiHuaN, qemu-devel; +Cc: demin.han, qemu-riscv, Daniel Henrique Barboza
Hi SiHuaN,
On 1/3/24 15:55, SiHuaN wrote:
> Avoid right-shifting by a negative number of bits when lmul is 8.
FYI Demin posted a similar patch, see:
https://lore.kernel.org/qemu-devel/20240225174114.5298-1-demin.han@starfivetech.com/
> Signed-off-by: SiHuaN <liyongtai@iscas.ac.cn>
> ---
> target/riscv/vector_helper.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> index 84cec73eb2..f0158ea237 100644
> --- a/target/riscv/vector_helper.c
> +++ b/target/riscv/vector_helper.c
> @@ -53,10 +53,11 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
> * VLEN * LMUL >= SEW
> * VLEN >> (8 - lmul) >= sew
> * (vlenb << 3) >> (8 - lmul) >= sew
> + * Considering that lmul may be 8, the following form cannot be used.
> * vlenb >> (8 - 3 - lmul) >= sew
> */
> if (vlmul == 4 ||
> - cpu->cfg.vlenb >> (8 - 3 - vlmul) < sew) {
> + (cpu->cfg.vlenb << 3) >> (8 - vlmul) < sew) {
> vill = true;
> }
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Re: [PATCH] Fix unexpected Illegal instruction error on RISC-V.
2024-03-01 15:51 ` Philippe Mathieu-Daudé
@ 2024-03-01 16:15 ` 李永泰
0 siblings, 0 replies; 3+ messages in thread
From: 李永泰 @ 2024-03-01 16:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, demin.han, qemu-riscv, Daniel Henrique Barboza
Hi Philippe,
Thanks for the heads up. Sorry I didn't check for this before sending out my patch.
I'll track this in Demin's thread.
> -----原始邮件-----
> 发件人: "Philippe Mathieu-Daudé" <philmd@linaro.org>
> 发送时间: 2024-03-01 23:51:03 (星期五)
> 收件人: SiHuaN <liyongtai@iscas.ac.cn>, qemu-devel@nongnu.org
> 抄送: "demin.han" <demin.han@starfivetech.com>, qemu-riscv <qemu-riscv@nongnu.org>, "Daniel Henrique Barboza" <dbarboza@ventanamicro.com>
> 主题: Re: [PATCH] Fix unexpected Illegal instruction error on RISC-V.
>
> Hi SiHuaN,
>
> On 1/3/24 15:55, SiHuaN wrote:
> > Avoid right-shifting by a negative number of bits when lmul is 8.
>
> FYI Demin posted a similar patch, see:
> https://lore.kernel.org/qemu-devel/20240225174114.5298-1-demin.han@starfivetech.com/
>
> > Signed-off-by: SiHuaN <liyongtai@iscas.ac.cn>
> > ---
> > target/riscv/vector_helper.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> > index 84cec73eb2..f0158ea237 100644
> > --- a/target/riscv/vector_helper.c
> > +++ b/target/riscv/vector_helper.c
> > @@ -53,10 +53,11 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1,
> > * VLEN * LMUL >= SEW
> > * VLEN >> (8 - lmul) >= sew
> > * (vlenb << 3) >> (8 - lmul) >= sew
> > + * Considering that lmul may be 8, the following form cannot be used.
> > * vlenb >> (8 - 3 - lmul) >= sew
> > */
> > if (vlmul == 4 ||
> > - cpu->cfg.vlenb >> (8 - 3 - vlmul) < sew) {
> > + (cpu->cfg.vlenb << 3) >> (8 - vlmul) < sew) {
> > vill = true;
> > }
> > }
</liyongtai@iscas.ac.cn></dbarboza@ventanamicro.com></qemu-riscv@nongnu.org></demin.han@starfivetech.com></liyongtai@iscas.ac.cn></philmd@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-01 16:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01 14:55 [PATCH] Fix unexpected Illegal instruction error on RISC-V SiHuaN
2024-03-01 15:51 ` Philippe Mathieu-Daudé
2024-03-01 16:15 ` 李永泰
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).