mailing list of musl libc
 help / color / mirror / code / Atom feed
From: erny hombre <hombre67@gmx.at>
To: musl@lists.openwall.com
Subject: [musl] clone(),sys_clone() arguments
Date: Sat, 27 Jun 2020 14:36:20 +0200	[thread overview]
Message-ID: <trinity-8342f794-8d6e-4046-bd20-2afef4490861-1593261380184@3c-app-gmx-bs50> (raw)

Hello,

I am writing an operating system for an ARM processor (Cortex-A9). For the user programs I want to use musl libc.
I am adding a layer between musl and my os to translate linux system calls into native system calls.
For pthread_create the syscall sys_clone is used. This syscall is not called directly. The library
function clone() is used instead. The arguments of clone() and the raw system call sys_clone differ:
int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...
          /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );
long sys_clone(unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs);

Musl uses __clone to reorder clone() arguments to the arguments expected by sys_clone:
/musl-1.2.0/src/thread/arm/clone.s:
__clone:
	stmfd sp!,{r4,r5,r6,r7}
	mov r7,#120
	mov r6,r3
	mov r5,r0
	mov r0,r2
	and r1,r1,#-16
	ldr r2,[sp,#16]
	ldr r3,[sp,#20]
	ldr r4,[sp,#24]
	svc 0				; sys_clone system call
	...

I think that the last two arguments for sys_clone (r3..ctid, r4..regs) are taken in the wrong
order from the clone parameters ([sp,#20]..tls, [sp,#24]..ctid).
Do I miss something or is this a bug ?


             reply	other threads:[~2020-06-27 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-27 12:36 erny hombre [this message]
2020-06-27 19:58 ` Rich Felker

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=trinity-8342f794-8d6e-4046-bd20-2afef4490861-1593261380184@3c-app-gmx-bs50 \
    --to=hombre67@gmx.at \
    --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).