[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAhV-H5XoJqbnh+DzX0Gsq_sDTLB7bK9H7-=fLTPuA4s7VY+Ug@mail.gmail.com>
Date: Tue, 18 Oct 2022 09:59:09 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Xi Ruoyao <xry111@...111.site>
Cc: David Laight <David.Laight@...lab.com>,
Huacai Chen <chenhuacai@...ngson.cn>,
Arnd Bergmann <arnd@...db.de>,
"loongarch@...ts.linux.dev" <loongarch@...ts.linux.dev>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
Xuefeng Li <lixuefeng@...ngson.cn>,
Guo Ren <guoren@...nel.org>, Xuerui Wang <kernel@...0n.name>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V3] LoongArch: Add unaligned access support
On Mon, Oct 17, 2022 at 10:20 PM Xi Ruoyao <xry111@...111.site> wrote:
>
> On Mon, 2022-10-17 at 13:11 +0000, David Laight wrote:
> > From: Huacai Chen
> > > Sent: 17 October 2022 13:52
> > >
> > > Loongson-2 series (Loongson-2K500, Loongson-2K1000) don't support
> > > unaligned access in hardware, while Loongson-3 series (Loongson-3A5000,
> > > Loongson-3C5000) are configurable whether support unaligned access in
> > > hardware. This patch add unaligned access emulation for those LoongArch
> > > processors without hardware support.
> > >
> > .....
> > > + } else if (insn.reg2i12_format.opcode == fstd_op ||
> > > + insn.reg3_format.opcode == fstxd_op) {
> > > + value = read_fpr(insn.reg2i12_format.rd);
> > > + res = unaligned_write(addr, value, 8);
> > > + if (res)
> > > + goto fault;
> > > + } else if (insn.reg2i12_format.opcode == fsts_op ||
> > > + insn.reg3_format.opcode == fstxs_op) {
> > > + value = read_fpr(insn.reg2i12_format.rd);
> > > + res = unaligned_write(addr, value, 4);
> > > + if (res)
> > > + goto fault;
> >
> > Are those right?
> > Shouldn't something be converting from 'double' to
> > 'float' in there?
> > And generating SIGFPE (?) if the exponent is out of range.
>
> To me it looks right.
>
> The semantic of FST.S does not include conversion. It just stores the
> lower 32 bits of a floating-point register into the memory. If someone
> attempts to use FST.S to convert a double into a float, it's a
> programming error.
Agree.
>
> --
> Xi Ruoyao <xry111@...111.site>
> School of Aerospace Science and Technology, Xidian University
Powered by blists - more mailing lists