mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: barebox@lists.infradead.org, Yann Sionneau <ysionneau@kalray.eu>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: Re: [PATCH v2 1/5] kvx: Implement setjmp/longjmp/initjmp
Date: Mon, 15 Mar 2021 09:35:14 +0100	[thread overview]
Message-ID: <20210315083514.GL23724@pengutronix.de> (raw)
In-Reply-To: <20210305183327.29753-1-jmaselbas@kalray.eu>

On Fri, Mar 05, 2021 at 07:33:23PM +0100, Jules Maselbas wrote:
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> changes v1 -> v2: nothing
> ---
>  arch/kvx/Kconfig              |  1 +
>  arch/kvx/include/asm/setjmp.h | 15 +++++++
>  arch/kvx/lib/Makefile         |  2 +-
>  arch/kvx/lib/setjmp.S         | 85 +++++++++++++++++++++++++++++++++++
>  4 files changed, 102 insertions(+), 1 deletion(-)
>  create mode 100644 arch/kvx/include/asm/setjmp.h
>  create mode 100644 arch/kvx/lib/setjmp.S

Applied, thanks

Sascha

> 
> diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
> index 3327021e1..8483ae6e6 100644
> --- a/arch/kvx/Kconfig
> +++ b/arch/kvx/Kconfig
> @@ -11,6 +11,7 @@ config KVX
>  	select ELF
>  	select FLEXIBLE_BOOTARGS
>  	select GENERIC_FIND_NEXT_BIT
> +	select HAS_ARCH_SJLJ
>  	select LIBFDT
>  	select MFD_SYSCON
>  	select OF_BAREBOX_DRIVERS
> diff --git a/arch/kvx/include/asm/setjmp.h b/arch/kvx/include/asm/setjmp.h
> new file mode 100644
> index 000000000..3cfc698d9
> --- /dev/null
> +++ b/arch/kvx/include/asm/setjmp.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* SPDX-FileCopyrightText: 2021 Jules Maselbas <jmaselbas@kalray.eu>, Kalray Inc. */
> +
> +#ifndef _ASM_KVX_SETJMP_H_
> +#define _ASM_KVX_SETJMP_H_
> +
> +#include <linux/types.h>
> +
> +typedef u64 jmp_buf[22];
> +
> +int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top);
> +int setjmp(jmp_buf jmp) __attribute__((returns_twice));
> +void longjmp(jmp_buf jmp, int ret) __attribute__((noreturn));
> +
> +#endif /* _ASM_KVX_SETJMP_H_ */
> diff --git a/arch/kvx/lib/Makefile b/arch/kvx/lib/Makefile
> index 6e56462da..cee08b0fa 100644
> --- a/arch/kvx/lib/Makefile
> +++ b/arch/kvx/lib/Makefile
> @@ -3,4 +3,4 @@
>  # Copyright (C) 2019 Kalray Inc.
>  #
>  
> -obj-y	+= cpuinfo.o board.o dtb.o poweroff.o bootm.o
> +obj-y	+= cpuinfo.o board.o dtb.o poweroff.o bootm.o setjmp.o
> diff --git a/arch/kvx/lib/setjmp.S b/arch/kvx/lib/setjmp.S
> new file mode 100644
> index 000000000..829299711
> --- /dev/null
> +++ b/arch/kvx/lib/setjmp.S
> @@ -0,0 +1,85 @@
> +/* SPDX-License-Identifier: LGPL-2.1 */
> +/* SPDX-FileCopyrightText: 2021 Jules Maselbas <jmaselbas@kalray.eu>, Kalray Inc. */
> +
> +#define REG_SIZE 8
> +
> +#include <linux/linkage.h>
> +
> +/* jmp_buf layout:
> + * [0]  = $ra,  $sp,  $cs,  $r14,
> + * [4]  = $r20, $r21, $r22, $r23,
> + * [8]  = $r24, $r25, $r26, $r27,
> + * [12] = $r28, $r29, $r30, $r31,
> + * [16] = $r18, $r19,
> + * [18] = $lc,  $le,  $ls,  xxxx
> + */
> +
> +/**
> + * int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top);
> + */
> +ENTRY(initjmp)
> +	/* store $ra */
> +	sd (0 * REG_SIZE)[$r0] = $r1
> +	;;
> +	/* store $sp */
> +	sd (1 * REG_SIZE)[$r0] = $r2
> +	make $r0 = 0
> +	ret
> +	;;
> +ENDPROC(initjmp)
> +
> +/**
> + * int setjmp(jmp_buf jmp);
> + */
> +ENTRY(setjmp)
> +	sq (16 * REG_SIZE)[$r0] = $r18r19
> +	get $r40 = $ra
> +	copyd $r41 = $sp
> +	;;
> +	so (4 * REG_SIZE)[$r0] = $r20r21r22r23
> +	get $r42 = $cs
> +	copyd $r43 = $r14
> +	;;
> +	so (0 * REG_SIZE)[$r0] = $r40r41r42r43
> +	get $r40 = $lc
> +	;;
> +	so (8 * REG_SIZE)[$r0] = $r24r25r26r27
> +	get $r41 = $le
> +	;;
> +	so (12 * REG_SIZE)[$r0] = $r28r29r30r31
> +	get $r42 = $ls
> +	;;
> +	so (18 * REG_SIZE)[$r0] = $r40r41r42r43
> +	make $r0 = 0
> +	ret
> +	;;
> +ENDPROC(setjmp)
> +
> +/**
> + * void longjmp(jmp_buf jmp, int ret);
> + */
> +ENTRY(longjmp)
> +	lo $r40r41r42r43 = (0 * REG_SIZE)[$r0]
> +	;;
> +	lo $r44r45r46r47 = (18 * REG_SIZE)[$r0]
> +	set $ra = $r40
> +	copyd $sp = $r41
> +	;;
> +	lo $r20r21r22r23 = (4 * REG_SIZE)[$r0]
> +	set $cs = $r42
> +	copyd $r14 = $r43
> +	;;
> +	lo $r24r25r26r27 = (8 * REG_SIZE)[$r0]
> +	set $lc = $r44
> +	;;
> +	lo $r28r29r30r31 = (12 * REG_SIZE)[$r0]
> +	set $le = $r45
> +	;;
> +	lq $r18r19 = (16 * REG_SIZE)[$r0]
> +	set $ls = $r46
> +	;;
> +	/* According to man, if retval is equal to 0, then we should return 1 */
> +	maxud $r0 = $r1, 1
> +	ret
> +	;;
> +ENDPROC(longjmp)
> -- 
> 2.17.1
> 
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      parent reply	other threads:[~2021-03-15  8:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 18:33 Jules Maselbas
2021-03-05 18:33 ` [PATCH v2 2/5] kvx: Implement dcache invalidation primitive Jules Maselbas
2021-03-05 18:33 ` [PATCH v2 3/5] kvx: Implement dma handling primitives Jules Maselbas
2021-05-17 10:42   ` Ahmad Fatoum
2021-05-17 10:56     ` Jules Maselbas
2021-03-05 18:33 ` [PATCH v2 4/5] kvx: Request enough privilege to boot Linux Jules Maselbas
2021-03-05 18:33 ` [PATCH v2 5/5] kvx: lib: dtb: Remove unused variable Jules Maselbas
2021-03-15  8:35 ` Sascha Hauer [this message]

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=20210315083514.GL23724@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jmaselbas@kalray.eu \
    --cc=ysionneau@kalray.eu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox