From patchwork Sat Apr 15 21:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13212662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8820C77B70 for ; Sat, 15 Apr 2023 21:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbjDOV2x (ORCPT ); Sat, 15 Apr 2023 17:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjDOV2w (ORCPT ); Sat, 15 Apr 2023 17:28:52 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F2326BB; Sat, 15 Apr 2023 14:28:50 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1681594128; bh=CZhCYpNg6uTpr8ZWTgKMWLkEe3rYuevwpfUwwonzaWk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PcywB2y0z0iNDHNCs9VywljvSdQG2Nf16KN2ym/OCk8ABkmfoXUrSyYL1Z20J2x0W UuHvT+4bIO6HElmv37TvJLz7TOXcsI3smT6QL7WBhOGvn8SdFhOgSU6B7sJZyA6SVH mPRDfe4sL8wngoEIoUcMgaOgHZukj82JcUwELmeE= Date: Sat, 15 Apr 2023 23:28:47 +0200 Subject: [PATCH 1/2] tools/nolibc: s390: provide custom implementation for sys_fork MIME-Version: 1.0 Message-Id: <20230415-nolibc-fork-v1-1-9747c73651c5@weissschuh.net> References: <20230415-nolibc-fork-v1-0-9747c73651c5@weissschuh.net> In-Reply-To: <20230415-nolibc-fork-v1-0-9747c73651c5@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681594127; l=1606; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=CZhCYpNg6uTpr8ZWTgKMWLkEe3rYuevwpfUwwonzaWk=; b=hD1G6hgf9pqOmGf4Ntf0OGWFeXHPFB9vAqPAyQNtEqtgOf52tpnC/4SnTJ8toLNxHPC4OitDO xW6fgOK8tnlA2shaegJnpmX4hiVvWwcnQKooqvRjqsZJ/DCFR+RsLnw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On s390 the first two arguments to the clone() syscall are swapped, as documented in clone(2). Signed-off-by: Thomas Weißschuh Acked-by: Sven Schnelle --- tools/include/nolibc/arch-s390.h | 8 ++++++++ tools/include/nolibc/sys.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h index 6b0e54ed543d..db4ea51a4dbb 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -5,6 +5,7 @@ #ifndef _NOLIBC_ARCH_S390_H #define _NOLIBC_ARCH_S390_H +#include #include /* The struct returned by the stat() syscall, equivalent to stat64(). The @@ -223,4 +224,11 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, return (void *)my_syscall1(__NR_mmap, &args); } #define sys_mmap sys_mmap + +static __attribute__((unused)) +pid_t sys_fork(void) +{ + return my_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0); +} +#define sys_fork sys_fork #endif // _NOLIBC_ARCH_S390_H diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index bea9760dbd16..f5a450153a63 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -336,6 +336,7 @@ void exit(int status) * pid_t fork(void); */ +#ifndef sys_fork static __attribute__((unused)) pid_t sys_fork(void) { @@ -351,6 +352,7 @@ pid_t sys_fork(void) #error Neither __NR_clone nor __NR_fork defined, cannot implement sys_fork() #endif } +#endif static __attribute__((unused)) pid_t fork(void)