mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: build musl for armv7m
Date: Tue, 14 Jun 2016 10:38:25 -0400	[thread overview]
Message-ID: <20160614143825.GF10893@brightrain.aerifal.cx> (raw)
In-Reply-To: <805971fb5f9b1ee12edab9b7f3e86114@codeaurora.org>

On Tue, Jun 14, 2016 at 01:49:40AM -0700, weimingz@codeaurora.org wrote:
> diff --git a/src/setjmp/arm/longjmp.s b/src/setjmp/arm/longjmp.s
> index e28d8f3..5c85cba 100644
> --- a/src/setjmp/arm/longjmp.s
> +++ b/src/setjmp/arm/longjmp.s
> @@ -7,8 +7,11 @@ _longjmp:
>  longjmp:
>  	mov ip,r0
>  	movs r0,r1
> +  it eq
>  	moveq r0,#1
> -	ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp,sp,lr}
> +	ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
> + ldr sp, [ip]!
> + ldr lr, [ip]!

Small note: your indention is inconsistent -- using a single space
instead of a tab.

In my earlier work trying to get an all-thumb build working, I had
tried doing this as:

+       ldmia ip!, {r2,v1,v2,v3,v4,v5,v6,sl,fp,lr}
+       mov sp,r2

which might be marginally faster but of course it reorders the fields
in the jmp_buf. Nothing should be depending on them anyway but I like
your version better I think. Likewise for setjmp.

> diff --git a/src/thread/arm/atomics.s b/src/thread/arm/atomics.s
> index 673fc03..05fd9b9 100644
> --- a/src/thread/arm/atomics.s
> +++ b/src/thread/arm/atomics.s
> @@ -49,6 +49,7 @@ __a_cas_dummy:
>  	mov r3,r0
>  	ldr r0,[r2]
>  	subs r0,r3,r0
> + it eq
>  	streq r1,[r2]
>  	bx lr
>  .global __a_cas_v6
> @@ -58,6 +59,7 @@ __a_cas_v6:
>  	mcr p15,0,r0,c7,c10,5
>  1:	.word 0xe1920f9f        /* ldrex r0,[r2] */
>  	subs r0,r3,r0
> + itt eq
>  	.word 0x01820f91        /* strexeq r0,r1,[r2] */
>  	teqeq r0,#1
>  	beq 1b

You're ignoring that the .word-encoded instruction is not valid thumb,
and that the two 'eq' conditions are independent. The second one
(teqeq) is using the result of the strexeq, not the result of the
subs. But there are much deeper reasons this file cannot work as thumb
without significant changes: the arithmetic on pc is not
thumb-compatible.

> @@ -70,6 +72,7 @@ __a_cas_v7:
>  	.word 0xf57ff05b        /* dmb ish */
>  1:	.word 0xe1920f9f        /* ldrex r0,[r2] */
>  	subs r0,r3,r0
> + itt eq
>  	.word 0x01820f91        /* strexeq r0,r1,[r2] */
>  	teqeq r0,#1
>  	beq 1b

Same here.

There's also the matter of the code to read the thread pointer, which
requires a special CP15 register that cortex-m's lack, I think. I
don't see any alternate way to do this functionality (and it would be
ABI-incompatible anyway) so I think the kernel (or bare-metal
undefined instruction exception trap) needs to just trap and emulate
it.

Rich


  parent reply	other threads:[~2016-06-14 14:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14  8:49 weimingz
2016-06-14 13:00 ` Rich Felker
2016-06-14 16:12   ` Zhao, Weiming
2016-06-14 16:32     ` Szabolcs Nagy
2016-06-14 16:58       ` Zhao, Weiming
2016-06-14 17:40         ` Zhao, Weiming
2016-06-16 18:34           ` Zhao, Weiming
2016-06-20 19:58             ` Rich Felker
2016-06-22 19:08               ` Zhao, Weiming
2016-06-22 19:19                 ` Rich Felker
2016-06-22 20:37                   ` Zhao, Weiming
2016-06-22 23:26                     ` Rich Felker
2016-06-23  0:21                       ` Zhao, Weiming
2016-06-23  4:22                         ` Rich Felker
2016-06-23  6:04                           ` weimingz
2016-06-23  9:57                             ` Szabolcs Nagy
2016-06-23 14:22                               ` weimingz
2016-07-05 20:08                         ` Rich Felker
2016-06-20 17:17           ` Zhao, Weiming
2016-06-14 14:38 ` Rich Felker [this message]
2016-06-14 16:35   ` Zhao, Weiming

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=20160614143825.GF10893@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).