From patchwork Tue Dec 12 23:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 847663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gC6YnUtf"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yxGJ11vfdz9t2Z for ; Wed, 13 Dec 2017 10:29:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 065E2882F3; Tue, 12 Dec 2017 23:29:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vos-oDlg1xam; Tue, 12 Dec 2017 23:29:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 85CDA882E5; Tue, 12 Dec 2017 23:29:28 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 47AA31BF54B for ; Tue, 12 Dec 2017 23:29:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 42CCB2FC7A for ; Tue, 12 Dec 2017 23:29:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oug1sBPBvIwP for ; Tue, 12 Dec 2017 23:29:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by silver.osuosl.org (Postfix) with ESMTPS id 4F4BD2FC67 for ; Tue, 12 Dec 2017 23:29:26 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id q20so415963pgv.2 for ; Tue, 12 Dec 2017 15:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=4Y/+YTYqbqm4vJnF6vroIj5B5o2ZZDErgsvWJxK34Ts=; b=gC6YnUtf2+OZ7QUjHw4n2IIkRRpye7nmXAIKFTE02sddD5oyB0/xAHBzqiQR+meYb1 2v+YAkitzeThqeJfZiHWXVaQLP/SmwyvbjrSNjWEniJYdUQik0a+6DyjhdomJsAc5kQc kpD0lyLRRb7udOw2P+9JoJEpjIP1yCcgOQ/1jTrEzuEdyST8UwOJtMJZm5hoLmeNjuqZ 4Fs/4UafTx8xULlYStvg0oS9cWYuWpjbT32Hh0MbMeqKNg0iPAp4h9pPx2BcuFx+ifhE KRGjaG+NSgyNFPc6ACBBPa9c0q0HgNINpyoCq1QUR2o37Jj1UOQ+n/HeLj+DtEMbuAir xAmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=4Y/+YTYqbqm4vJnF6vroIj5B5o2ZZDErgsvWJxK34Ts=; b=kl8h97zWMT+JaGTZFA+VHpfno1itI7olqYPc4+8jAfkr+vztjnWw8vHi8Yr/A5AF8o 0LxlehDACfhbgkbeROIbUEdE+tJNg01PLy6fcdTP+XtL3/3UC0rpqnAi3K3sxFJWXCGc 0FBpDUiKqWOHpSykzhdIH5s9+lsvcm32DOACJ4/eJZj7EcLiHZfiDtekJ6yRumbZuM+Q PqA6zBVqcooqIoMBAeqF6UFHtGwZoTirwtbtX4Vcsxd/cD+bkzGuWUUe/dNJpB8UAXsq gvIZtuApp6PZ8Ktwo4NgM1IfluEJWMuGjhHSl9orS1uIOn4dz0QOi8HbyllTbVAV6ySq Y0dQ== X-Gm-Message-State: AKGB3mKdqx1kAYbz/YS/+rtDTRLkKjiqiX0DcQv7hTeAiuQRvebW0KcA LjYitRK/+KAiOP9BpVWq6MeWF8q5 X-Google-Smtp-Source: ACJfBos1f6m2RwOncv9W5oydcVJycZDvp/UXBiOdSTVNnGMB4HOoDx5WO9k8pImFybl25noquSs82Q== X-Received: by 10.84.201.6 with SMTP id u6mr3823549pld.51.1513121365035; Tue, 12 Dec 2017 15:29:25 -0800 (PST) Received: from aurora.jms.id.au ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id u90sm298467pfg.106.2017.12.12.15.29.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2017 15:29:23 -0800 (PST) Received: by aurora.jms.id.au (sSMTP sendmail emulation); Wed, 13 Dec 2017 09:59:16 +1030 From: Joel Stanley To: buildroot@buildroot.org Date: Wed, 13 Dec 2017 09:59:04 +1030 Message-Id: <20171212232904.23365-1-joel@jms.id.au> X-Mailer: git-send-email 2.14.1 Subject: [Buildroot] [PATCH] uclibc: Fix system calls on openrisc X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This adds a patch from the master branch that fixes userspace calling through uclibc when making system calls. Signed-off-by: Joel Stanley --- ...-or1k-syscall-Pass-arguments-on-the-stack.patch | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 package/uclibc/0001-or1k-syscall-Pass-arguments-on-the-stack.patch diff --git a/package/uclibc/0001-or1k-syscall-Pass-arguments-on-the-stack.patch b/package/uclibc/0001-or1k-syscall-Pass-arguments-on-the-stack.patch new file mode 100644 index 000000000000..14ed092bd714 --- /dev/null +++ b/package/uclibc/0001-or1k-syscall-Pass-arguments-on-the-stack.patch @@ -0,0 +1,80 @@ +From f764bcffed69d8c62625dc4b6c1a6af21bd6dbc2 Mon Sep 17 00:00:00 2001 +From: Joel Stanley +Date: Wed, 6 Dec 2017 12:26:21 +1030 +Subject: [PATCH] or1k: syscall: Pass arguments on the stack + +Busybox internally calls syscall(2). + + - in unistd.h defined something like + int syscall(nr, ....) + + - in syscall.c (common) implemented as + int syscall(nr, arg1, arg3, arg3, arg4, arg5, arg6) + +This will not work, busybox thinks syscall should have varargs calling +conventions. But it doesnt in the uclibc implementation so no args go through. + +Most architectures this will work. But on openrisc varargs are all sent on the +stack. Regular args are passed in registers. + +Commit message and idea from Stafford Horne . + +Signed-off-by: Joel Stanley +--- + libc/sysdeps/linux/or1k/Makefile.arch | 2 +- + libc/sysdeps/linux/or1k/syscall.c | 32 ++++++++++++++++++++++++++++++++ + 2 files changed, 33 insertions(+), 1 deletion(-) + create mode 100644 libc/sysdeps/linux/or1k/syscall.c + +diff --git a/libc/sysdeps/linux/or1k/Makefile.arch b/libc/sysdeps/linux/or1k/Makefile.arch +index f6758fa63fa3..191eebafde9d 100644 +--- a/libc/sysdeps/linux/or1k/Makefile.arch ++++ b/libc/sysdeps/linux/or1k/Makefile.arch +@@ -5,5 +5,5 @@ + # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + # + +-CSRC-y := __syscall_error.c __init_brk.c brk.c sbrk.c clone.c ++CSRC-y := __syscall_error.c __init_brk.c brk.c sbrk.c clone.c syscall.c + SSRC-y := __longjmp.S setjmp.S or1k_clone.S +diff --git a/libc/sysdeps/linux/or1k/syscall.c b/libc/sysdeps/linux/or1k/syscall.c +new file mode 100644 +index 000000000000..2f4356737cf8 +--- /dev/null ++++ b/libc/sysdeps/linux/or1k/syscall.c +@@ -0,0 +1,32 @@ ++/* ++ * Copyright (C) 2017 Joel Stanley ++ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. ++ */ ++ ++#include ++#include ++#include ++ ++long int syscall (long num, ...) ++{ ++ unsigned long arg1 = 0; ++ unsigned long arg2 = 0; ++ unsigned long arg3 = 0; ++ unsigned long arg4 = 0; ++ unsigned long arg5 = 0; ++ unsigned long arg6 = 0; ++ va_list arg; ++ ++ va_start (arg, num); ++ arg1 = va_arg (arg, unsigned long); ++ arg2 = va_arg (arg, unsigned long); ++ arg3 = va_arg (arg, unsigned long); ++ arg4 = va_arg (arg, unsigned long); ++ arg5 = va_arg (arg, unsigned long); ++ arg6 = va_arg (arg, unsigned long); ++ va_end (arg); ++ ++ __asm__ volatile ( "" ::: "memory" ); ++ ++ return INLINE_SYSCALL_NCS(num, 6, arg1, arg2, arg3, arg4, arg5, arg6); ++} +-- +2.14.1 +