From patchwork Mon Jan 9 07:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028115wrt; Sun, 8 Jan 2023 23:57:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXsd3vpdmHEUheUtQELMhCcWQ139VqbABqXpbbAhlljqKjoO3EKhDtYbKSV78KMfYZPifR7Z X-Received: by 2002:aa7:9489:0:b0:583:4801:76f0 with SMTP id z9-20020aa79489000000b00583480176f0mr11035070pfk.23.1673251025989; Sun, 08 Jan 2023 23:57:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251025; cv=none; d=google.com; s=arc-20160816; b=T+mJ17XDqbod19sqPUO5SJKvcBnF6FRpMPhUGfbnC3q+YQ1MONN58SaX6f1NSxZesG 9L4dG0yOLVVSakO0lHzkbzS9mT61gt40NdWp9NaXXOWRQ//OTPCiZGel+VVJ4QkBoJef SFXnadr/YLhVuJJB12GrG4Dx7oXVnkhz86+j6gsXO2Ip7BzDBiwWJXJrDhyhteecKKHa IYjT/LxQRm1gbZKbr4/awX00EtdcOw+IYp2R1hgkspazfo+UHTkYwpPBVbvxT+SuBMEs V40NSCea+10Bg5fcfoT7LkAEU7skDmCtpV3RXePNq0Hrpgno5dkzAxReBLJEYyM1zNch PQUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=QN9tgjDL8SMGWMiYylsCxXhnyKzSSZF1VH1EwnvKqI0=; b=pO1g9Tgz/QKr3vrC5Za9whDAC1IPSrF3siSX8Qcpg4iRx0v/PYoyycULnt1Ws35F++ SYTTS9N32P7k//KOiMWh5rfAWoxJGTXEf3R7w7jSXL8TM+yiBb2bfdvirA6uDQZAoqoe VRpiyxJKt3ZMd+76W6AIf4IWn00nsXY1oXuLeXTUVIBN+nfZsrDGambeRkaaOp6+i/gI ugQR1lzJd+/rw8mo4mQR66jf+pSR0ydUGE0SZ3qR3619/63ztdmjkiuSlxI/UNl0PHj/ XbTuYKLqwcyXeYGB1Ku0TjOczw/y7GTwL6i8MAR3aRtu7chScbEulHk6/Ur8tmh0kP7X ttQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a056a00150f00b00576950b449asi6993754pfu.351.2023.01.08.23.56.53; Sun, 08 Jan 2023 23:57:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234293AbjAIHzW (ORCPT + 99 others); Mon, 9 Jan 2023 02:55:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233735AbjAIHzG (ORCPT ); Mon, 9 Jan 2023 02:55:06 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 153BADF3B for ; Sun, 8 Jan 2023 23:55:04 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097sn4s026015; Mon, 9 Jan 2023 08:54:49 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Sven Schnelle , Willy Tarreau Subject: [PATCH 1/6] nolibc: fix fd_set type Date: Mon, 9 Jan 2023 08:54:37 +0100 Message-Id: <20230109075442.25963-2-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754530868087820527?= X-GMAIL-MSGID: =?utf-8?q?1754530868087820527?= From: Sven Schnelle The kernel uses unsigned long for the fd_set bitmap, but nolibc use u32. This works fine on little endian machines, but fails on big endian. Convert to unsigned long to fix this. Signed-off-by: Sven Schnelle Signed-off-by: Willy Tarreau --- tools/include/nolibc/types.h | 53 ++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 959997034e55..300e0ff1cd58 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -89,39 +89,46 @@ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 +#define FD_SETIDXMASK (8 * sizeof(unsigned long)) +#define FD_SETBITMASK (8 * sizeof(unsigned long)-1) + /* for select() */ typedef struct { - uint32_t fd32[(FD_SETSIZE + 31) / 32]; + unsigned long fds[(FD_SETSIZE + FD_SETBITMASK) / FD_SETIDXMASK]; } fd_set; -#define FD_CLR(fd, set) do { \ - fd_set *__set = (set); \ - int __fd = (fd); \ - if (__fd >= 0) \ - __set->fd32[__fd / 32] &= ~(1U << (__fd & 31)); \ +#define FD_CLR(fd, set) do { \ + fd_set *__set = (set); \ + int __fd = (fd); \ + if (__fd >= 0) \ + __set->fds[__fd / FD_SETIDXMASK] &= \ + ~(1U << (__fd & FX_SETBITMASK)); \ } while (0) -#define FD_SET(fd, set) do { \ - fd_set *__set = (set); \ - int __fd = (fd); \ - if (__fd >= 0) \ - __set->fd32[__fd / 32] |= 1U << (__fd & 31); \ +#define FD_SET(fd, set) do { \ + fd_set *__set = (set); \ + int __fd = (fd); \ + if (__fd >= 0) \ + __set->fds[__fd / FD_SETIDXMASK] |= \ + 1 << (__fd & FD_SETBITMASK); \ } while (0) -#define FD_ISSET(fd, set) ({ \ - fd_set *__set = (set); \ - int __fd = (fd); \ - int __r = 0; \ - if (__fd >= 0) \ - __r = !!(__set->fd32[__fd / 32] & 1U << (__fd & 31)); \ - __r; \ +#define FD_ISSET(fd, set) ({ \ + fd_set *__set = (set); \ + int __fd = (fd); \ + int __r = 0; \ + if (__fd >= 0) \ + __r = !!(__set->fds[__fd / FD_SETIDXMASK] & \ +1U << (__fd & FD_SET_BITMASK)); \ + __r; \ }) -#define FD_ZERO(set) do { \ - fd_set *__set = (set); \ - int __idx; \ - for (__idx = 0; __idx < (FD_SETSIZE+31) / 32; __idx ++) \ - __set->fd32[__idx] = 0; \ +#define FD_ZERO(set) do { \ + fd_set *__set = (set); \ + int __idx; \ + int __size = (FD_SETSIZE+FD_SETBITMASK) / FD_SETIDXMASK;\ + for (__idx = 0; __idx < __size; __idx++) \ + __set->fds[__idx] = 0; \ } while (0) /* for poll() */ From patchwork Mon Jan 9 07:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028202wrt; Sun, 8 Jan 2023 23:57:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXsR0dCmW7MqmKVXA69x3/2YxqqzRbGPc9hJaJOjiYIeAFluweZ5yKPdfsPyYmMQIYP3yFxw X-Received: by 2002:a17:907:c48d:b0:7c0:aafa:6dc0 with SMTP id tp13-20020a170907c48d00b007c0aafa6dc0mr42661953ejc.25.1673251042167; Sun, 08 Jan 2023 23:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251042; cv=none; d=google.com; s=arc-20160816; b=WNR0rJAbOT9ec9Ad2fPXp94Za2KqP4Vp0O++21NLjWPWpeWBVHU3eZkSqCUJ2UagBD Tphu66cMtHPlYxLJsZmYlvpA8iTpTUJJQ3XtZKtNCX4a9q5vRqXUoIuodoCtKAYxJsLp 7dkNq88Hy1mKPzxxMj+ZfDCA7QlIJP13aptcKKeFsm+kWdgYaQ6Kb/ol95UkfKvEXKyo dB5tlTldJAjdh4YB+EtZjVntscSUwkAVgOCHV/ZX6mcJP3NrXBJpk/n7vPmcrgudoABM IiE5+zkggVemi/od72a6dmRZPROWGZ2I5F97WJVw9TX95Rfy5npNr+w80Qkeguvjly55 gY+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=JDYL89Q5GUgmBQuPMiIAC3auyZxcbG2S6dcv46Yl8sw=; b=A2EQf77qDU7/gadoCJjBzuMWFSoZI9hFO0Q740RaSByTMnvPe6ZIEbaxvmUHU0elzJ RPapS3Ot4ESptx9Ot7l1z1Lo4HbFmAi8ijg03Ewaj9hRSQ/AjD0Ad6EfMz7BvM/W4Qe7 SqR4PP/Bp8JO0Fk8lUrX63ZrCcfzbZQHhHEyHZXeWhIUyA8OS5hINPR4YlwxVpDTGH9J 6xQN9yvK/P5KccL/EjlWcKvOq6AzfzT39VJd5q91prMY5iOqmZij6OCgWiRzLnuG3I6o 1jJhnBjmA/8FeMkX4pLkUTNCIFUQojt3uIPLIf6mW8F02oaGF1zDRwkgWZEomCacw9YI obZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a1709066d5500b0078db1343eedsi7051584ejt.774.2023.01.08.23.56.59; Sun, 08 Jan 2023 23:57:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234221AbjAIHzd (ORCPT + 99 others); Mon, 9 Jan 2023 02:55:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236181AbjAIHzZ (ORCPT ); Mon, 9 Jan 2023 02:55:25 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D128913DE9 for ; Sun, 8 Jan 2023 23:55:15 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097sos7026016; Mon, 9 Jan 2023 08:54:50 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Warner Losh , Willy Tarreau Subject: [PATCH 2/6] tools/nolibc: Fix S_ISxxx macros Date: Mon, 9 Jan 2023 08:54:38 +0100 Message-Id: <20230109075442.25963-3-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754530884571273375?= X-GMAIL-MSGID: =?utf-8?q?1754530884571273375?= From: Warner Losh The mode field has the type encoded as an value in a field, not as a bit mask. Mask the mode with S_IFMT instead of each type to test. Otherwise, false positives are possible: eg S_ISDIR will return true for block devices because S_IFDIR = 0040000 and S_IFBLK = 0060000 since mode is masked with S_IFDIR instead of S_IFMT. These macros now match the similar definitions in tools/include/uapi/linux/stat.h. Signed-off-by: Warner Losh Signed-off-by: Willy Tarreau --- tools/include/nolibc/types.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 300e0ff1cd58..f1d64fca7cf0 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -26,13 +26,13 @@ #define S_IFSOCK 0140000 #define S_IFMT 0170000 -#define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) -#define S_ISCHR(mode) (((mode) & S_IFCHR) == S_IFCHR) -#define S_ISBLK(mode) (((mode) & S_IFBLK) == S_IFBLK) -#define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG) -#define S_ISFIFO(mode) (((mode) & S_IFIFO) == S_IFIFO) -#define S_ISLNK(mode) (((mode) & S_IFLNK) == S_IFLNK) -#define S_ISSOCK(mode) (((mode) & S_IFSOCK) == S_IFSOCK) +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) +#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) /* dirent types */ #define DT_UNKNOWN 0x0 From patchwork Mon Jan 9 07:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028203wrt; Sun, 8 Jan 2023 23:57:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXvf9NT0tfdKURUs0ugAhDt+T+FgdQMQj23W5fti8NvTWDPS3Ax+CP61H6qv49/pzHwT4cBC X-Received: by 2002:a17:906:d217:b0:7c1:6fc:6048 with SMTP id w23-20020a170906d21700b007c106fc6048mr51666268ejz.24.1673251042392; Sun, 08 Jan 2023 23:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251042; cv=none; d=google.com; s=arc-20160816; b=TfAx2GT9bxeDLyM4uqDrFYeEodPXodtd9RpQdXl/UvU2cToe0Szm4pB8f7tZ7tslBk KUz+YgiCmaPNi4OraJvI+q/lAbPcJmTIzSwUqO3WSoL2vJk7WuPEtK59BreTy051NsOn RkEIzygiWtIrrugFe/Fsy0Egl8M21vUmWhdFYqCiud966Sy+5/vNowb5djmbKkmwXRX2 1mCAZ6/E2or8qjh394kx4fsvYsUXjgKpWMsouyTJzFMKZ6P8evMJQNYpqMh4MREkM4He WeU64x+nAxy24IbhLW8U3nNDHCZWwkjyXLKMBxlXxlWAmNJgPsKRyx2nctkSOzcOQ9Ns U6gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=qMvOXmjYVrX9jQomSokd6YO83sksTD8p/f61cr4ob04=; b=Z0oWkde7Qc5JoULxr4K3PGoGTEYEH0Ek89PRJU1sbyxf3uZp7AZ+9TkKOxb5eHHbsa ldkBXGEzMgpqmwFiAZ6psgBVcNIde/PZs/z6/JBHLE5u6j/jXU374CPBEM/pEQ3vuuKA CiFN6HE16W/DqSxB5zhpEA2hGSL2M2GC1TzbtUb6suwhLJT9SpUjSc5WkRnKJqquGzeQ /zwqJKaxBKsIn25qHFBHKcw0WwUEwBLbo8B7bhp8vpQK4NhV28J2suwO1b7XjVn5fUNH 57y/FHnnfWLci/BAKixJX8IhKoOA4IK6v1sx8DkwRDRz+oST6HMOLEMQCJpYc+4qsBDG Hs3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe6-20020a170907318600b00780488c11bbsi8968786ejb.388.2023.01.08.23.56.59; Sun, 08 Jan 2023 23:57:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233367AbjAIHz5 (ORCPT + 99 others); Mon, 9 Jan 2023 02:55:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235659AbjAIHz3 (ORCPT ); Mon, 9 Jan 2023 02:55:29 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A844FDF3B for ; Sun, 8 Jan 2023 23:55:20 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097sot6026017; Mon, 9 Jan 2023 08:54:50 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 3/6] tools/nolibc: restore mips branch ordering in the _start block Date: Mon, 9 Jan 2023 08:54:39 +0100 Message-Id: <20230109075442.25963-4-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754530885278349338?= X-GMAIL-MSGID: =?utf-8?q?1754530885278349338?= Depending on the compiler used and the optimization options, the sbrk() test was crashing, both on real hardware (mips-24kc) and in qemu. One such example is kernel.org toolchain in version 11.3 optimizing at -Os. Inspecting the sys_brk() call shows the following code: 0040047c : 40047c: 24020fcd li v0,4045 400480: 27bdffe0 addiu sp,sp,-32 400484: 0000000c syscall 400488: 27bd0020 addiu sp,sp,32 40048c: 10e00001 beqz a3,400494 400490: 00021023 negu v0,v0 400494: 03e00008 jr ra It is obviously wrong, the "negu" instruction is placed in beqz's delayed slot, and worse, there's no nop nor instruction after the return, so the next function's first instruction (addiu sip,sip,-32) will also be executed as part of the delayed slot that follows the return. This is caused by the ".set noreorder" directive in the _start block, that applies to the whole program. The compiler emits code without the delayed slots and relies on the compiler to swap instructions when this option is not set. Removing the option would require to change the startup code in a way that wouldn't make it look like the resulting code, which would not be easy to debug. Instead let's just save the default ordering before changing it, and restore it at the end of the _start block. Now the code is correct: 0040047c : 40047c: 24020fcd li v0,4045 400480: 27bdffe0 addiu sp,sp,-32 400484: 0000000c syscall 400488: 10e00002 beqz a3,400494 40048c: 27bd0020 addiu sp,sp,32 400490: 00021023 negu v0,v0 400494: 03e00008 jr ra 400498: 00000000 nop Fixes: 66b6f755ad45 ("rcutorture: Import a copy of nolibc") #5.0 Signed-off-by: Willy Tarreau --- tools/include/nolibc/arch-mips.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h index 5fc5b8029bff..7380093ba9e7 100644 --- a/tools/include/nolibc/arch-mips.h +++ b/tools/include/nolibc/arch-mips.h @@ -192,6 +192,7 @@ struct sys_stat_struct { __asm__ (".section .text\n" ".weak __start\n" ".set nomips16\n" + ".set push\n" ".set noreorder\n" ".option pic0\n" ".ent __start\n" @@ -210,6 +211,7 @@ __asm__ (".section .text\n" "li $v0, 4001\n" // NR_exit == 4001 "syscall\n" ".end __start\n" + ".set pop\n" ""); #endif // _NOLIBC_ARCH_MIPS_H From patchwork Mon Jan 9 07:54:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028184wrt; Sun, 8 Jan 2023 23:57:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQmaquJFlRNHvQp82JhdJBfrXXZYJzhBZzZjhhaaVkvryMwgk0Qt2hUB1FoPvZFK9b7x0l X-Received: by 2002:a17:90a:ae04:b0:226:8bbf:1c6b with SMTP id t4-20020a17090aae0400b002268bbf1c6bmr24080092pjq.7.1673251038475; Sun, 08 Jan 2023 23:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251038; cv=none; d=google.com; s=arc-20160816; b=G2mf+qLVsE6jrtuUzHmmxuL4/pa8m4jftW34FF+PUuZasi1n46s9sUF7SWnKZ+vLEx K8UzLqg/aD2+5qyScfqXiELI6ptQkk1VngEPL2uJOqNLGs8eIk7lWApz7bBOpJ8tQXKs c7P5vR7AqX2TIogO76FTqaOQnlqy0kjwxtIwnNqz4bbwakoEnx3VO/mnPcFBkoBKXPlS baLuMNoqVWwH1o2olTR6DD6GMujnaWc6wzqg7j1JdQK1cHiKMzYdL/AY43qJW/LMwbyi 2CyTsauQgMp7ULkz4yq4X1wELMfVAdPORlTuE1q6+6PoS9BsUjpX567bw4qziwP7rylK kskw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=zlzlpHWk38a2ur5/pFyqWFd8I8Ved/ykZt2Qzk4+ZGM=; b=ErE7lDeWHi1RpF4Re+LNHA7hcuz0FpT4cQR7bbhMa6h5+1bIrdaY5oIV3X3Z65IIiW z8bvIWV0srYQDZi9E+chXdNq7aWDx3ynf3VAeMjpwa5CyBZyVZM9IazbcOKcLngLzuHS bn4subRPehdGhbgYoGZDa8LW4AChifw9+qOqSgF47g97m/FhpwqVXbDzkxqt+MikMfjx efsEFP4AHkG0AJN0CWfmvIJJpu6eOCA47/pHQULPHPgX+zMxLqBQdrnws40rKppSCe7i KPc4aQ8xVicaG47ePtXHhOG3Dn0FU1vGkKcBP7gqKl1J4untCn16BO3h4KqEX/7snq+h OFyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63cf49000000b004a7a73eb62esi9114210pgj.100.2023.01.08.23.57.06; Sun, 08 Jan 2023 23:57:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236276AbjAIH4D (ORCPT + 99 others); Mon, 9 Jan 2023 02:56:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235736AbjAIHza (ORCPT ); Mon, 9 Jan 2023 02:55:30 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B04213E0F for ; Sun, 8 Jan 2023 23:55:28 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097so3v026018; Mon, 9 Jan 2023 08:54:50 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 4/6] tools/nolibc: fix missing includes causing build issues at -O0 Date: Mon, 9 Jan 2023 08:54:40 +0100 Message-Id: <20230109075442.25963-5-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754530880882857890?= X-GMAIL-MSGID: =?utf-8?q?1754530880882857890?= After the nolibc includes were split to facilitate portability from standard libcs, programs that include only what they need may miss some symbols which are needed by libgcc. This is the case for raise() which is needed by the divide by zero code in some architectures for example. Regardless, being able to include only the apparently needed files is convenient. Instead of trying to move all exported definitions to a single file, since this can change over time, this patch takes another approach consisting in including the nolibc header at the end of all standard include files. This way their types and functions are already known at the moment of inclusion, and including any single one of them is sufficient to bring all the required ones. Signed-off-by: Willy Tarreau --- tools/include/nolibc/ctype.h | 3 +++ tools/include/nolibc/errno.h | 3 +++ tools/include/nolibc/signal.h | 3 +++ tools/include/nolibc/stdio.h | 3 +++ tools/include/nolibc/stdlib.h | 3 +++ tools/include/nolibc/string.h | 3 +++ tools/include/nolibc/sys.h | 2 ++ tools/include/nolibc/time.h | 3 +++ tools/include/nolibc/types.h | 3 +++ tools/include/nolibc/unistd.h | 3 +++ 10 files changed, 29 insertions(+) diff --git a/tools/include/nolibc/ctype.h b/tools/include/nolibc/ctype.h index e3000b2992d7..6f90706d0644 100644 --- a/tools/include/nolibc/ctype.h +++ b/tools/include/nolibc/ctype.h @@ -96,4 +96,7 @@ int ispunct(int c) return isgraph(c) && !isalnum(c); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_CTYPE_H */ diff --git a/tools/include/nolibc/errno.h b/tools/include/nolibc/errno.h index 06893d6dfb7a..9dc4919c769b 100644 --- a/tools/include/nolibc/errno.h +++ b/tools/include/nolibc/errno.h @@ -24,4 +24,7 @@ static int errno; */ #define MAX_ERRNO 4095 +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_ERRNO_H */ diff --git a/tools/include/nolibc/signal.h b/tools/include/nolibc/signal.h index ef47e71e2be3..137552216e46 100644 --- a/tools/include/nolibc/signal.h +++ b/tools/include/nolibc/signal.h @@ -19,4 +19,7 @@ int raise(int signal) return sys_kill(sys_getpid(), signal); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_SIGNAL_H */ diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index a3cebc4bc3ac..96ac8afc5aee 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -303,4 +303,7 @@ void perror(const char *msg) fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STDIO_H */ diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h index 92378c4b9660..a24000d1e822 100644 --- a/tools/include/nolibc/stdlib.h +++ b/tools/include/nolibc/stdlib.h @@ -419,4 +419,7 @@ char *u64toa(uint64_t in) return itoa_buffer; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STDLIB_H */ diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index ad97c0d522b8..0932db3817d2 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -285,4 +285,7 @@ char *strrchr(const char *s, int c) return (char *)ret; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_STRING_H */ diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index ce3ee03aa679..78473d34e27c 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1243,5 +1243,7 @@ ssize_t write(int fd, const void *buf, size_t count) return ret; } +/* make sure to include all global symbols */ +#include "nolibc.h" #endif /* _NOLIBC_SYS_H */ diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h index d18b7661fdd7..84655361b9ad 100644 --- a/tools/include/nolibc/time.h +++ b/tools/include/nolibc/time.h @@ -25,4 +25,7 @@ time_t time(time_t *tptr) return tv.tv_sec; } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_TIME_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index f1d64fca7cf0..fbbc0e68c001 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -209,4 +209,7 @@ struct stat { }) #endif +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_TYPES_H */ diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h index 1c25e20ee360..1cfcd52106a4 100644 --- a/tools/include/nolibc/unistd.h +++ b/tools/include/nolibc/unistd.h @@ -51,4 +51,7 @@ int tcsetpgrp(int fd, pid_t pid) return ioctl(fd, TIOCSPGRP, &pid); } +/* make sure to include all global symbols */ +#include "nolibc.h" + #endif /* _NOLIBC_UNISTD_H */ From patchwork Mon Jan 9 07:54:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028648wrt; Sun, 8 Jan 2023 23:59:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXulbxPdzkEri5sQONzVj5iPXkWrS6oeGiBhEGa0jQMkFpWfRANiB+0AiBti9Bkkk7ttQ3DQ X-Received: by 2002:a17:906:f193:b0:84d:3403:f4f4 with SMTP id gs19-20020a170906f19300b0084d3403f4f4mr5616073ejb.64.1673251140075; Sun, 08 Jan 2023 23:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251140; cv=none; d=google.com; s=arc-20160816; b=WHQHzj4YUCesdV/cTxrOCZ+fNXMRVAMmg2YPaXK1t7z83oD2yfTGyhmusCTtF6yHpm I5SToBrQbJLE5QZvhS2gL6PAbKy7itjdJusWtTSh15BzXnVrDDeD/lLy/bebzF+6ggPX 02SSW//oqSvi5lz8f7WiRokV+7mFCPGEJO3B3hufb4VZfA6eU2CIR03nkNPZDjZdrLqF CmqLn4mzuO0FcJ7VHkv1EKAw6B/9tPiCdjBa0NAer5LIfRoIqdGB5U23TDI2JMf+ByTW 00dcQ7HJlqGjgqYlAP2OSyzAzR0ZADuGCvFi5r88aBB+OH6BebNi02NH07CzX+aD8shH ggnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=3KvA6ZdtTsA9I+74gLWq626tR9b5QMxIDmk8SmIaqDs=; b=kw/Jo13OvjSRmvWvvTZrG199R2I8UB6jh5yJlmp/rWZbmTbtUNVU/C34GM5tGNe4uC mKVC3waKp9VIRFiHIYYrLOPggglKn5FkRQ5BDpX65/2XBXKirOyqGPxX5K2j7Y3Yxp2c w8uRbu+fWubsCirvEZ8THWI8lq5lo2nvfBjgAKb4Pekxs20IIgYj+5Z8kBJ/bszwgynR Xkq/Bis7rO3tb0vNphKubfjYyCv8Dwm0AOEPpxBXD+SclyxLAMcds1RXhgtsf4t2H+ZA 1JJ/VBVv46nbcnjr0ivfpdCSXftc7n9+cCDGgH+U84+zNm/7MFdZ+g2XjUIM1RIP6khu Kx1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb41-20020a1709076da900b0084c70300a30si9864298ejc.697.2023.01.08.23.58.36; Sun, 08 Jan 2023 23:59:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236413AbjAIH4G (ORCPT + 99 others); Mon, 9 Jan 2023 02:56:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236320AbjAIHzh (ORCPT ); Mon, 9 Jan 2023 02:55:37 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6BF3F13D55 for ; Sun, 8 Jan 2023 23:55:36 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097soBf026019; Mon, 9 Jan 2023 08:54:50 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 5/6] tools/nolibc: prevent gcc from making memset() loop over itself Date: Mon, 9 Jan 2023 08:54:41 +0100 Message-Id: <20230109075442.25963-6-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754530987304088412?= X-GMAIL-MSGID: =?utf-8?q?1754530987304088412?= When building on ARM in thumb mode with gcc-11.3 at -O2 or -O3, nolibc-test segfaults during the select() tests. It turns out that at this level, gcc recognizes an opportunity for using memset() to zero the fd_set, but it miscompiles it because it also recognizes a memset pattern as well, and decides to call memset() from the memset() code: 000122bc : 122bc: b510 push {r4, lr} 122be: 0004 movs r4, r0 122c0: 2a00 cmp r2, #0 122c2: d003 beq.n 122cc 122c4: 23ff movs r3, #255 ; 0xff 122c6: 4019 ands r1, r3 122c8: f7ff fff8 bl 122bc 122cc: 0020 movs r0, r4 122ce: bd10 pop {r4, pc} Simply placing an empty asm() statement inside the loop suffices to avoid this. Signed-off-by: Willy Tarreau --- tools/include/nolibc/string.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/string.h b/tools/include/nolibc/string.h index 0932db3817d2..fffdaf6ff467 100644 --- a/tools/include/nolibc/string.h +++ b/tools/include/nolibc/string.h @@ -88,8 +88,11 @@ void *memset(void *dst, int b, size_t len) { char *p = dst; - while (len--) + while (len--) { + /* prevent gcc from recognizing memset() here */ + asm volatile(""); *(p++) = b; + } return dst; } From patchwork Mon Jan 9 07:54:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 40693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2028723wrt; Sun, 8 Jan 2023 23:59:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8NOiNB73iQmDYIVmfA/KKp0ddEyaoZN5H60V5vne0VkpWA0KKThbu8wGbxY9ZCkYt8yyL X-Received: by 2002:a17:906:e11a:b0:84d:13ac:2fd4 with SMTP id gj26-20020a170906e11a00b0084d13ac2fd4mr11069929ejb.17.1673251155371; Sun, 08 Jan 2023 23:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673251155; cv=none; d=google.com; s=arc-20160816; b=KkdJdNAgqISfGz1VZxvI4Q25bqPN8/1qpd/uDvsua1FvhnTVuKFljBV+A5XTmUdC6v F080QdpmVUHSUcmtYJiUwrxKJLMi/zuBmVZn75xwcZE8QQJ1eKkOK2KjkMafKbG1Gy9i bXQMMiCX0453rx00kKzkmgXckuY9Kv6Egv5IqFppnS+pQEQM9rNK7Ot7/g1JvZQsRci7 e59ObcCm+5eWbtvShUxTs8djraACIIiLLk0qkYEphmYNUgBT7O0TlNcMKwKaBbxvgrGk uxfvSXX8xBV5H1eI+C+kGzdQ+jjDqSmSMYNaBAy0hCSrxRV52E1aoDPmoQTYwHVyQCdU 42Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=SwXfuNGe5tHMXHYzVyzz70UcvQU983z2gioWzWiiQdA=; b=haN8dyq7pADnX3QKiAdxQwie0UQD21HHks2RPzEka8jQc2G/AWS09DWfF2VlNzwgCn 272PdqtdRGTNdxnG59dIUjbJ75pDAeK3Ir6pKkyIMovO/QNxXxzEq3j+PPqp20KxLjjL iohSEYWu/YMzsk5JVpVHS5vYRTnSX3vSqn+3CiTYVNVssNL1W+TVRczwDcOG3nne5LC/ 56cBI+S0EfBx8NDS3/+YdhJlTv/5avGPr408lA89WbXVfxxge9j5J80cfA5kNJkVFFyR zufuj0Yz0OJEFQmhgKfhQADtNBpI8srSlRWFm6BUuK8O9voZsTGE8oSAUjZlVhezRtK7 1UiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs38-20020a1709072d2600b0084ca065e9f4si10495368ejc.568.2023.01.08.23.58.52; Sun, 08 Jan 2023 23:59:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234347AbjAIH4b (ORCPT + 99 others); Mon, 9 Jan 2023 02:56:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236516AbjAIHzq (ORCPT ); Mon, 9 Jan 2023 02:55:46 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F46013D64 for ; Sun, 8 Jan 2023 23:55:44 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3097soGv026020; Mon, 9 Jan 2023 08:54:50 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 6/6] tools/nolibc: fix the O_* fcntl/open macro definitions for riscv Date: Mon, 9 Jan 2023 08:54:42 +0100 Message-Id: <20230109075442.25963-7-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109075442.25963-1-w@1wt.eu> References: <20230109075442.25963-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754531003138425434?= X-GMAIL-MSGID: =?utf-8?q?1754531003138425434?= When RISCV port was imported in 5.2, the O_* macros were taken with their octal value and written as-is in hex, resulting in the getdents64() to fail in nolibc-test. Fixes: 582e84f7b779 ("tool headers nolibc: add RISCV support") #5.2 Signed-off-by: Willy Tarreau --- tools/include/nolibc/arch-riscv.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/include/nolibc/arch-riscv.h b/tools/include/nolibc/arch-riscv.h index ba04771cb3a3..a3bdd9803f8c 100644 --- a/tools/include/nolibc/arch-riscv.h +++ b/tools/include/nolibc/arch-riscv.h @@ -11,13 +11,13 @@ #define O_RDONLY 0 #define O_WRONLY 1 #define O_RDWR 2 -#define O_CREAT 0x100 -#define O_EXCL 0x200 -#define O_NOCTTY 0x400 -#define O_TRUNC 0x1000 -#define O_APPEND 0x2000 -#define O_NONBLOCK 0x4000 -#define O_DIRECTORY 0x200000 +#define O_CREAT 0x40 +#define O_EXCL 0x80 +#define O_NOCTTY 0x100 +#define O_TRUNC 0x200 +#define O_APPEND 0x400 +#define O_NONBLOCK 0x800 +#define O_DIRECTORY 0x10000 struct sys_stat_struct { unsigned long st_dev; /* Device. */