[PATCH 1/2] RISC-V: Fix alignment issue in sigjmp_buf

9 views
Skip to first unread message

Kito Cheng

unread,
Jan 17, 2018, 10:04:41 PM1/17/18
to Newlib, pat...@groups.riscv.org
This patch fix a potential mis-alignment issue in sigjump_buf, load a
double floating value required 8 bytes align, but we just align to
size of long, it's may cause mis-align memory access in rv32imafd.
0001-RISC-V-Fix-alignment-issue-in-sigjmp_buf.patch

Palmer Dabbelt

unread,
Jan 18, 2018, 1:58:09 PM1/18/18
to Kito Cheng, new...@sourceware.org, pat...@groups.riscv.org
> From d23ba9ea7f842dda65b89cb80c396d1254b4e934 Mon Sep 17 00:00:00 2001
> From: Kito Cheng <kito....@gmail.com>
> Date: Fri, 17 Nov 2017 14:50:52 +0800
> Subject: [PATCH 1/2] RISC-V: Fix alignment issue in sigjmp_buf
>
> ---
> newlib/libc/include/machine/setjmp.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h
> index b33f437..9212f84 100644
> --- a/newlib/libc/include/machine/setjmp.h
> +++ b/newlib/libc/include/machine/setjmp.h
> @@ -359,7 +359,9 @@ _BEGIN_STD_C
> #endif
>
> #ifdef __riscv
> -#define _JBTYPE long
> +/* _JBTYPE using long long to make sure the alignment is align to 8 byte,
> + otherwise in rv32imafd, store/restore FPR may mis-align. */
> +#define _JBTYPE long long
> #ifdef __riscv_32e
> #define _JBLEN ((4*sizeof(long))/sizeof(long))
> #else
> --
> 2.7.4

This looks good to me. Do you want me to co-maintain the RISC-V newlib port?
IIRC you're the only maintainer, which can be a lot of work.

Jim Wilson

unread,
Jan 18, 2018, 2:42:58 PM1/18/18
to Palmer Dabbelt, Kito Cheng, new...@sourceware.org, pat...@groups.riscv.org
On 01/18/2018 10:58 AM, Palmer Dabbelt wrote:
> On Wed, 17 Jan 2018 19:04:20 PST (-0800), Kito Cheng wrote:
>> This patch fix a potential mis-alignment issue in sigjump_buf, load a
>> double floating value required 8 bytes align, but we just align to
>> size of long, it's may cause mis-align memory access in rv32imafd.
> This looks good to me.  Do you want me to co-maintain the RISC-V newlib
> port? IIRC you're the only maintainer, which can be a lot of work.

I already have write after approval access for newlib, and have been
reviewing pull requests in the github riscv-newlib project. This patch
was part of
https://github.com/riscv/riscv-newlib/pull/30/
I also checked in the last set of patches that Kito sent. If we need a
co-maintainer, it might make more sense for it to be me.

Jim

Palmer Dabbelt

unread,
Jan 18, 2018, 3:56:13 PM1/18/18
to Jim Wilson, Kito Cheng, new...@sourceware.org, pat...@groups.riscv.org
That works for me. Thanks for volunteering!

>
> Jim
>
> --
> You received this message because you are subscribed to the Google Groups "RISC-V Patches" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to patches+u...@groups.riscv.org.
> To post to this group, send email to pat...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/patches/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/patches/ec81c771-7f98-1166-f714-3a0c7a4f6be0%40sifive.com.
> For more options, visit https://groups.google.com/a/groups.riscv.org/d/optout.
Reply all
Reply to author
Forward
0 new messages