From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Peter Mamonov <pmamonov@gmail.com>,
Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, Jules Maselbas <jmaselbas@kalray.eu>,
Stafford Horne <shorne@gmail.com>
Subject: Re: [PATCH v2 10/11] mips: Implement setjmp/longjmp/initjmp
Date: Wed, 10 Mar 2021 09:17:06 +0100 [thread overview]
Message-ID: <60f45ac4-7cd1-3358-7edc-476633047537@pengutronix.de> (raw)
In-Reply-To: <20210307120056.GD1407@chr>
Hello Peter,
On 07.03.21 13:00, Peter Mamonov wrote:
> On Thu, Mar 04, 2021 at 09:38:11AM +0100, Sascha Hauer wrote:
>> Hi Peter,
>>
>> On Wed, Mar 03, 2021 at 01:19:26AM +0300, Peter Mamonov wrote:
>>> Hi, Sascha and Ahmad,
>>>
>>> On Mon, Mar 01, 2021 at 12:01:05PM +0100, Ahmad Fatoum wrote:
>>>> From: Sascha Hauer <s.hauer@pengutronix.de>
>>>>
>>>> The header has been taken from glibc, the implementation itself is based
>>>> on the newlib implementation.
>>>>
>>>> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>>>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>>>> ---
>>>> arch/mips/Kconfig | 1 +
>>>> arch/mips/include/asm/setjmp.h | 32 ++++++++++++++++++++++
>>>> arch/mips/lib/Makefile | 1 +
>>>> arch/mips/lib/setjmp.S | 50 ++++++++++++++++++++++++++++++++++
>>>> 4 files changed, 84 insertions(+)
>>>> create mode 100644 arch/mips/include/asm/setjmp.h
>>>> create mode 100644 arch/mips/lib/setjmp.S
>>>>
>>>> ...
>>>>
>>>> diff --git a/arch/mips/lib/setjmp.S b/arch/mips/lib/setjmp.S
>>>> new file mode 100644
>>>> index 000000000000..b09a7c55293c
>>>> --- /dev/null
>>>> +++ b/arch/mips/lib/setjmp.S
>>>> @@ -0,0 +1,50 @@
>>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>>> +
>>>> +#include <asm/regdef.h>
>>>> +#include <asm/asm.h>
>>>> +#include <linux/linkage.h>
>>>> +
>>>> +/* int setjmp (jmp_buf); */
>>>> +LEAF(setjmp)
>>>> + sw ra, (0 * 4)(a0)
>>>> + sw sp, (1 * 4)(a0)
>>>> + sw s0, (2 * 4)(a0)
>>>> + sw s1, (3 * 4)(a0)
>>>> + sw s2, (4 * 4)(a0)
>>>> + sw s3, (5 * 4)(a0)
>>>> + sw s4, (6 * 4)(a0)
>>>> + sw s5, (7 * 4)(a0)
>>>> + sw s6, (8 * 4)(a0)
>>>> + sw s7, (9 * 4)(a0)
>>>> + sw fp, (10 * 4)(a0)
>>>> + move v0, zero
>>>> + j ra
>>>> +END(setjmp)
>>>> +
>>>> +/* volatile void longjmp (jmp_buf, int); */
>>>> +LEAF(longjmp)
>>>> + lw ra, (0 * 4)(a0)
>>>> + lw sp, (1 * 4)(a0)
>>>> + lw s0, (2 * 4)(a0)
>>>> + lw s1, (3 * 4)(a0)
>>>> + lw s2, (4 * 4)(a0)
>>>> + lw s3, (5 * 4)(a0)
>>>> + lw s4, (6 * 4)(a0)
>>>> + lw s5, (7 * 4)(a0)
>>>> + lw s6, (8 * 4)(a0)
>>>> + lw s7, (9 * 4)(a0)
>>>> + lw fp, (10 * 4)(a0)
>>>> + bne a1, zero, 1f
>>>> + li a1, 1
>>>> +1:
>>>> + move v0, a1
>>>> + j ra
>>>> +END(longjmp)
>>>> +
>>>> +/* int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top); */
>>>> +LEAF(initjmp)
>>>> + sw a1, (0 * 4)(a0)
>>>> + sw a2, (1 * 4)(a0)
>>>> + move v0, zero
>>>> + j ra
>>>> +END(initjmp)
>>>
>>> I would suggest using `REG_S/REG_L r, (n * SZREG)(a0)` here for the sake of
>>> MIPS64 targets. See arch/mips/include/asm/asm.h:272.
>>
>> I agree with you, but barebox doesn't support MIPS64 currently and I
>> wasn't confident enough to add such things when I can't test them.
>
> Well, what can possibly go wrong? =) Actually you've used this approach for RV:
> http://lists.infradead.org/pipermail/barebox/2021-March/035173.html.
>
>> Maybe we can add a
>>
>> #if SZREG != 4
>> #error setjmp/longjmp currently only supports 32bit targets
>> #endif
>
> Definitely it's better than random fails after context switch in runtime.
I changed the select to happen only from the 32-bit symbols for RISC-V and MIPS.
>
> Regards,
> Peter
>
>> Sascha
>>> -- > 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 |
>
--
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
next prev parent reply other threads:[~2021-03-10 8:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 11:00 [PATCH v2 00/11] common: introduce bthreads, co-operative Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 01/11] console: unconditionally run poller_call in ctrlc() Ahmad Fatoum
2021-03-03 10:20 ` [PATCH] fixup! common: introduce bthreads, co-operative barebox threads Ahmad Fatoum
2021-03-04 8:49 ` Sascha Hauer
2021-03-04 9:17 ` Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 02/11] " Ahmad Fatoum
2021-03-01 12:42 ` Peter Korsgaard
2021-03-02 8:56 ` Ahmad Fatoum
2021-03-02 8:56 ` [PATCH] fixup! " Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 03/11] ARM: asm: setjmp: annotate setjmp/longjmp for GCC Ahmad Fatoum
2021-03-01 11:00 ` [PATCH v2 04/11] ARM: asm: setjmp: implement coroutine dependency initjmp() Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 05/11] sandbox: asm: implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 06/11] riscv: Add asm/asm.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 07/11] riscv: Add asm/linkage.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 08/11] riscv: Implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 09/11] mips: Add linkage.h Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 10/11] mips: Implement setjmp/longjmp/initjmp Ahmad Fatoum
2021-03-02 22:19 ` Peter Mamonov
2021-03-04 8:38 ` Sascha Hauer
2021-03-07 12:00 ` Peter Mamonov
2021-03-10 8:17 ` Ahmad Fatoum [this message]
2021-03-14 12:40 ` Ahmad Fatoum
2021-03-01 11:01 ` [PATCH v2 11/11] powerpc: Implement initjmp/setjmp/longjmp Ahmad Fatoum
2021-03-03 12:15 ` [PATCH v2 00/11] common: introduce bthreads, co-operative Stafford Horne
2021-03-03 13:35 ` Stafford Horne
2021-03-03 13:58 ` Ahmad Fatoum
2021-03-03 15:12 ` Sascha Hauer
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=60f45ac4-7cd1-3358-7edc-476633047537@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jmaselbas@kalray.eu \
--cc=pmamonov@gmail.com \
--cc=s.hauer@pengutronix.de \
--cc=shorne@gmail.com \
/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