From patchwork Tue Jul 18 21:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704213 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 7C46CEB64DC for ; Tue, 18 Jul 2023 21:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjGRVLC (ORCPT ); Tue, 18 Jul 2023 17:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjGRVLC (ORCPT ); Tue, 18 Jul 2023 17:11:02 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDAAEC; Tue, 18 Jul 2023 14:10:59 -0700 (PDT) X-QQ-mid: bizesmtp70t1689714650ti363d26 Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:10:49 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: wPivafIDGPPEvqeYZTPmewPyvVWylqcAja+mkp8ND6UqgiOzbaRKXCiHoclg8 YoxnLzcOckWPg+3DMm7n5F/IXhD2CKmcsZAgst044DG4HdtnJCC4VZig0bEEnMhzKVHsfxw kqaMdtSytK+0A8csmqqHPK1lGDEfp+38E3v5G7CflcJCUIzIqbN4O65TDlbjHXxnXq5oaaX 6gZo2u3yyKD46zQO7GvOw9+0WD7nV2lgw6xPJd2wqjP+jQkr2/3AZpmXYSUL69GXuvZJghl YX7sYBRQMrp0apBHoWlUWwyfL7stsDO1hIMNn+X/Rqh+3zRHS9w4dePUoUZ0R1McY+kJ1Ty qsd7+IA+jLKWO6NIAxnsi+n7E4cVqvxgrjPZNtKTEQsVpol+9xlzMZx1+h6FA== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 7805254917606532531 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 1/8] tools/nolibc: add support for powerpc Date: Wed, 19 Jul 2023 05:10:48 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Both syscall declarations and _start code definition are added for powerpc to nolibc. Like mips, powerpc uses a register (exactly, the summary overflow bit) to record the error occurred, and uses another register to return the value [1]. So, the return value of every syscall declaration must be normalized to easier the __sysret helper, return -value when there is an error, otheriwse, return value directly. Glibc and musl use different methods to check the summary overflow bit, glibc (sysdeps/unix/sysv/linux/powerpc/sysdep.h) saves the cr register to r0 at first, and then check the summary overflow bit in cr0: mfcr r0 r0 & (1 << 28) ? -r3 : r3 --> 10003c14: 7c 00 00 26 mfcr r0 10003c18: 74 09 10 00 andis. r9,r0,4096 10003c1c: 41 82 00 08 beq 0x10003c24 10003c20: 7c 63 00 d0 neg r3,r3 Musl (arch/powerpc/syscall_arch.h) directly checks the summary overflow bit with the 'bns' instruction: /* no summary overflow bit means no error, return value directly */ bns+ 1f /* otherwise, return negated value */ neg r3, r3 1: --> 10000418: 40 a3 00 08 bns 0x10000420 1000041c: 7c 63 00 d0 neg r3,r3 The later one is smaller, here applies it. arch/powerpc/include/asm/vdso/gettimeofday.h file uses the smaller method for do_syscall_2() too. [1]: https://man7.org/linux/man-pages/man2/syscall.2.html Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-powerpc.h | 156 ++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 tools/include/nolibc/arch-powerpc.h diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h new file mode 100644 index 000000000000..100ec0f412dc --- /dev/null +++ b/tools/include/nolibc/arch-powerpc.h @@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * PowerPC specific definitions for NOLIBC + * Copyright (C) 2023 Zhangjin Wu + */ + +#ifndef _NOLIBC_ARCH_POWERPC_H +#define _NOLIBC_ARCH_POWERPC_H + +#include "compiler.h" +#include "crt.h" + +/* Syscalls for PowerPC : + * - stack is 16-byte aligned + * - syscall number is passed in r0 + * - arguments are in r3, r4, r5, r6, r7, r8, r9 + * - the system call is performed by calling "sc" + * - syscall return comes in r3, and the summary overflow bit is checked + * to know if an error occurred, in which case errno is in r3. + * - the arguments are cast to long and assigned into the target + * registers which are then simply passed as registers to the asm code, + * so that we don't have to experience issues with register constraints. + */ + +#define _NOLIBC_SYSCALL_CLOBBERLIST \ + "memory", "cr0", "r9", "r10", "r11", "r12" + +#define my_syscall0(num) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3"); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "=r"(r3) \ + :: "r4", "r5", "r6", "r7", "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + +#define my_syscall1(num, arg1) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3) \ + :: "r4", "r5", "r6", "r7", "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + + +#define my_syscall2(num, arg1, arg2) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + register long r4 __asm__ ("r4") = (long)(arg2); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3), \ + "+r"(r4) \ + :: "r5", "r6", "r7", "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + + +#define my_syscall3(num, arg1, arg2, arg3) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + register long r4 __asm__ ("r4") = (long)(arg2); \ + register long r5 __asm__ ("r5") = (long)(arg3); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3), \ + "+r"(r4), "+r"(r5) \ + :: "r6", "r7", "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + + +#define my_syscall4(num, arg1, arg2, arg3, arg4) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + register long r4 __asm__ ("r4") = (long)(arg2); \ + register long r5 __asm__ ("r5") = (long)(arg3); \ + register long r6 __asm__ ("r6") = (long)(arg4); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3), \ + "+r"(r4), "+r"(r5), "+r"(r6) \ + :: "r7", "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + + +#define my_syscall5(num, arg1, arg2, arg3, arg4, arg5) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + register long r4 __asm__ ("r4") = (long)(arg2); \ + register long r5 __asm__ ("r5") = (long)(arg3); \ + register long r6 __asm__ ("r6") = (long)(arg4); \ + register long r7 __asm__ ("r7") = (long)(arg5); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3), \ + "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7) \ + :: "r8", _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + +#define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ +({ \ + register long r0 __asm__ ("r0") = (num); \ + register long r3 __asm__ ("r3") = (long)(arg1); \ + register long r4 __asm__ ("r4") = (long)(arg2); \ + register long r5 __asm__ ("r5") = (long)(arg3); \ + register long r6 __asm__ ("r6") = (long)(arg4); \ + register long r7 __asm__ ("r7") = (long)(arg5); \ + register long r8 __asm__ ("r8") = (long)(arg6); \ + \ + __asm__ volatile ( \ + "sc; bns+ 1f; neg %1, %1; 1:\n" \ + : "+r"(r0), "+r"(r3), \ + "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7), "+r"(r8) \ + :: _NOLIBC_SYSCALL_CLOBBERLIST \ + ); \ + r3; \ +}) + +/* startup code */ +void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) +{ + __asm__ volatile ( + "mr 3, 1\n" /* save stack pointer to r3, as arg1 of _start_c */ + "clrrwi 1, 1, 4\n" /* align the stack to 16 bytes */ + "li 0, 0\n" /* zero the frame pointer */ + "stwu 1, -16(1)\n" /* the initial stack frame */ + "bl _start_c\n" /* transfer to c runtime */ + ); + __builtin_unreachable(); +} + +#endif /* _NOLIBC_ARCH_POWERPC_H */ From patchwork Tue Jul 18 21:11:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704210 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 3EBA6EB64DD for ; Tue, 18 Jul 2023 21:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231231AbjGRVMY (ORCPT ); Tue, 18 Jul 2023 17:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbjGRVMT (ORCPT ); Tue, 18 Jul 2023 17:12:19 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7821FEE; Tue, 18 Jul 2023 14:12:05 -0700 (PDT) X-QQ-mid: bizesmtp67t1689714716ty3d409i Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:11:55 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: znfcQSa1hKbIWy9/nudIS6dweUsnw6YVkjkrjXVuU+TODYlb+AgCL6pXkl2Fl tSsRaDf72WXJcU3KEzH9E4XSY2yEuk3T/diWm8Ne5HqGX0DrjpE477mcQpG4G5DFd9ODAOv uaikbHrw6qk530JkQ8AXJcHgiIds6d+3aJefPFODPpZsURPJhdgFwh0jQjZ/vmKkYggOmvg aszaovcQXFBHNKeguR9bBylNG6atlyI7bfvZaKxSTY+3RBNZwLkFtoz5htQh0d6mbj20RuF K+5rrb2HGie6OTmRGi4ibC/KnE/f91NZCFgxKvguB/uEmc1BehQ7DhvhA7zqSZvkzSXxWHD 9PT7i9S5yx9Zpsyo+xynEYrc3KrTZZkfVU5bd7OV511CmwkmBLBB7D8q7X6YQ== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11373982133652074623 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 2/8] tools/nolibc: add support for powerpc64 Date: Wed, 19 Jul 2023 05:11:54 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This follows the 64-bit PowerPC ABI [1], refers to the slides: "A new ABI for little-endian PowerPC64 Design & Implementation" [2] and the musl code in arch/powerpc64/crt_arch.h. Firstly, stdu and clrrdi are used instead of stwu and clrrwi for powerpc64. Second, the stack frame size is increased to 32 bytes for powerpc64, 32 bytes is the minimal stack frame size supported described in [2]. Besides, the TOC pointer (GOT pointer) must be saved to r2. This works on both little endian and big endian 64-bit PowerPC. [1]: https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.pdf [2]: https://www.llvm.org/devmtg/2014-04/PDFs/Talks/Euro-LLVM-2014-Weigand.pdf Signed-off-by: Zhangjin Wu --- tools/include/nolibc/arch-powerpc.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/include/nolibc/arch-powerpc.h b/tools/include/nolibc/arch-powerpc.h index 100ec0f412dc..7b28ebcfcc23 100644 --- a/tools/include/nolibc/arch-powerpc.h +++ b/tools/include/nolibc/arch-powerpc.h @@ -143,6 +143,19 @@ /* startup code */ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void) { +#ifdef __powerpc64__ + /* On 64-bit PowerPC, save TOC/GOT pointer to r2 */ + extern char TOC __asm__ (".TOC."); + register volatile long r2 __asm__ ("r2") = (void *)&TOC - (void *)_start; + + __asm__ volatile ( + "mr 3, 1\n" /* save stack pointer to r3, as arg1 of _start_c */ + "clrrdi 1, 1, 4\n" /* align the stack to 16 bytes */ + "li 0, 0\n" /* zero the frame pointer */ + "stdu 1, -32(1)\n" /* the initial stack frame */ + "bl _start_c\n" /* transfer to c runtime */ + ); +#else __asm__ volatile ( "mr 3, 1\n" /* save stack pointer to r3, as arg1 of _start_c */ "clrrwi 1, 1, 4\n" /* align the stack to 16 bytes */ @@ -150,6 +163,7 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_ "stwu 1, -16(1)\n" /* the initial stack frame */ "bl _start_c\n" /* transfer to c runtime */ ); +#endif __builtin_unreachable(); } From patchwork Tue Jul 18 21:13:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704803 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 AD132EB64DC for ; Tue, 18 Jul 2023 21:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231249AbjGRVNh (ORCPT ); Tue, 18 Jul 2023 17:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbjGRVNg (ORCPT ); Tue, 18 Jul 2023 17:13:36 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B245219B4; Tue, 18 Jul 2023 14:13:13 -0700 (PDT) X-QQ-mid: bizesmtp63t1689714782trzjin3e Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:13:01 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: l1AKOOPZQsd2aCFsuejlNygv+phjrrzDIHE36qpwYCRFFVPb7T6TNOUd714WZ V+Eq9b0Q7T1QA85+NfBHTpJmI/t3DNgUsEnfwX+9uSeZ8DVVMD1MoCVJAmEirVXb5bnycmX IG0S/sAWuKOgLuoMLpCJyCAKbgSX6/7Y2B3/g9Y+o7Bkqcq4KwKEnsFyrdLRRI5plgb5pcw cb3RIj/J84BRFBYO+sknqb4qbSrT7OqAyYsh7elnNOEFikxelUCPbOHg1LxZtbQc4pNubRA yZCQulxaGRRjMkCQj+vPoh0+N8meAJrdfnx05uyQv3XpV8BT5rsMcBG7CjJ97NU6LQxC8Si BVa5fjFX2BLJAc8qXfML/PYZrQceL2pQnH5rq98cHk+0x/n2Z+x2VUjLkY0Qw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2481483960197194193 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 3/8] selftests/nolibc: select_null: fix up for big endian powerpc64 Date: Wed, 19 Jul 2023 05:13:01 +0800 Message-Id: <56e91281fde98fb3b2e34986d96870d76ebc3238.1689713175.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The following error reported while running nolibc-test on the big endian 64-bit PowerPC kernel compiled with powerpc64le-linux-gnu-gcc in Ubuntu 20.04. 56 select_nullinit[1]: illegal instruction (4) at 100042a8 nip 100042a8 lr 100042a8 code 1 in init[10000000+10000] init[1]: code: 7c6307b4 7c234840 4081f580 7c6300d0 907d0000 3860ffff 4bfff570 3ca2fffe init[1]: code: 38800038 38a5d547 7fc3f378 4bffcd65 <1000038c> 38c10060 38a00000 38800000 Let's explicitly initialize all of the timeval members to zero. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 03b1d30f5507..ec2c7774522e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -858,7 +858,7 @@ int run_syscall(int min, int max) CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(rmdir_blah); EXPECT_SYSER(1, rmdir("/blah"), -1, ENOENT); break; CASE_TEST(sched_yield); EXPECT_SYSZR(1, sched_yield()); break; - CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv = { 0 }; select(0, NULL, NULL, NULL, &tv); })); break; + CASE_TEST(select_null); EXPECT_SYSZR(1, ({ struct timeval tv = { 0, 0 }; select(0, NULL, NULL, NULL, &tv); })); break; CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL, NULL, 0), -1, EFAULT); break; CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &stat_buf), -1, ENOENT); break; From patchwork Tue Jul 18 21:14:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704209 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 5D265EB64DC for ; Tue, 18 Jul 2023 21:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjGRVOV (ORCPT ); Tue, 18 Jul 2023 17:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjGRVOV (ORCPT ); Tue, 18 Jul 2023 17:14:21 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F4A6C0; Tue, 18 Jul 2023 14:14:19 -0700 (PDT) X-QQ-mid: bizesmtp76t1689714848tywoz5oa Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:14:07 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: tJPajVdBfNIK2jxArdUWYFT16jn6ztkWRncwJYA/LCJCGKduhgveUNIZLG4JM n2oXYzi9kWKFTKTs66un9clianapv6W7HqIAE3p9mJvLcb2yRSJYREt+J04+h2Tbj8FRt66 XqqfSoAIxuRyxtOWChZqbONtmAf0R9vp041dPA0/5wFaHxSE+OE3fEbaA1lEAc3/x8fU9IB 9bBZUiTMU9XdJy+Clz/WobmhLn//ADk+ZKbcXG8+FhQB9LVNOfRkWJB2PtnMwZq2Hr5RJ7X HooTWAdGrYAP7eGfD2NAzaosBmpLE/P4gARAo6Pm7rzkP9i7ZwPSl/7/ukTdU/4HexqkeCg jeg24Wq3PI6R352t53XZSSli+8EbjgKgCqeVy93AovVbfa2CJfOOu/NiGcPriOACoXIsX62 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 12934479316635104382 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Th?= =?utf-8?q?omas_Wei=C3=9Fschuh?= Subject: [PATCH v1 4/8] selftests/nolibc: add extra config file customize support Date: Wed, 19 Jul 2023 05:14:07 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The default DEFCONFIG_ may not always work for all architectures, some architectures require to add extra kernel config options, this adds a new 'extconfig' target for this requirement. It allows to customize extra kernel config options via the common common.config and the architecture specific .config, at last trigger 'allnoconfig' to let them take effect with missing config options as disabled. The scripts/kconfig/merge_config.sh tool is used to merge the extra config files. Suggested-by: Thomas Weißschuh Link: https://lore.kernel.org/lkml/67eb70d4-c9ff-4afc-bac7-7f36cc2c81bc@t-8ch.de/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index f42adef87e12..08a5ca5f418b 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -39,6 +39,9 @@ DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig DEFCONFIG = $(DEFCONFIG_$(ARCH)) +# extra kernel config files under configs/, include common + architecture specific +EXTCONFIG = common.config $(ARCH).config + # optional tests to run (default = all) TEST = @@ -162,6 +165,10 @@ initramfs: nolibc-test defconfig: $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) mrproper $(DEFCONFIG) prepare +extconfig: + $(Q)$(srctree)/scripts/kconfig/merge_config.sh -O "$(srctree)" -m "$(srctree)/.config" $(foreach c,$(EXTCONFIG),$(wildcard $(CURDIR)/configs/$c)) + $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) KCONFIG_ALLCONFIG="$(srctree)/.config" allnoconfig + kernel: initramfs $(Q)$(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) $(IMAGE_NAME) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/initramfs From patchwork Tue Jul 18 21:15:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704802 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 DA679EB64DD for ; Tue, 18 Jul 2023 21:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbjGRVP1 (ORCPT ); Tue, 18 Jul 2023 17:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjGRVP0 (ORCPT ); Tue, 18 Jul 2023 17:15:26 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8121EC0; Tue, 18 Jul 2023 14:15:24 -0700 (PDT) X-QQ-mid: bizesmtp91t1689714915t194m5qj Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:15:13 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: lO87fmWkX3FnwSGm+p0pup/4ktDW2xqng3XU6uxahpZJpMrHSZkTO/ZQMQKyN UPuxfSq2bT+YWZH8/JoUGxD+9G4acuQLNRp+qxc//cgvPEs5ciLw66XWiRK6yOZO6GK+pdC VqNLE6cAOhHSErPFNvNUtD8uSfxg5uNMNKGRb04urZdjpxUUlDI29ZJLnhZVDBM5IkBkPWt +l7wWNU3VvOqy8p7rVML4Z9szsWyS3l+Q+p1RflMALejBKs/W5+/i245VHuVLToacNizW7U OOtveNPOw3Gs2p8xqw6UM1mgxuYPsoWt9ewH6BzFJdYm4IsXviKAfbpEUPXGalUxPpebOlI C4uyKdE7KancNwnMomkEL3dSAbDJjgSTgB/WASQ8BOJwBj9PIREimeXPGB7cw== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 5940336848902200637 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 5/8] selftests/nolibc: add XARCH and ARCH mapping support Date: Wed, 19 Jul 2023 05:15:13 +0800 Message-Id: <90c1d88dabf73e100dc840965fbdfe3ad5dc550f.1689713175.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org To test the architectures not directly supported by kernel, let's add a new XARCH as our own test input and map between XARCH and ARCH to make sure pass a right ARCH to kernel for a XARCH input and also configure a default XARCH for ARCH. ARCH is a subset of XARCH, to test more architectures than the ARCH variable directly supported by kernel, the old architecture specific variables used by our test are converted to use XARCH instead of ARCH. Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/20230702171715.GD16233@1wt.eu/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 34 +++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 08a5ca5f418b..b17a82efe6de 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -14,6 +14,13 @@ include $(srctree)/scripts/subarch.include ARCH = $(SUBARCH) endif +# XARCH and ARCH mapping +# XARCH is specified by user +XARCH ?= $(or $(XARCH_$(ARCH)),$(ARCH)) + +# ARCH is supported by kernel +ARCH := $(or $(ARCH_$(XARCH)),$(XARCH)) + # kernel image names by architecture IMAGE_i386 = arch/x86/boot/bzImage IMAGE_x86_64 = arch/x86/boot/bzImage @@ -24,7 +31,7 @@ IMAGE_mips = vmlinuz IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi -IMAGE = $(IMAGE_$(ARCH)) +IMAGE = $(IMAGE_$(XARCH)) IMAGE_NAME = $(notdir $(IMAGE)) # default kernel configurations that appear to be usable @@ -37,10 +44,10 @@ DEFCONFIG_mips = malta_defconfig DEFCONFIG_riscv = defconfig DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig -DEFCONFIG = $(DEFCONFIG_$(ARCH)) +DEFCONFIG = $(DEFCONFIG_$(XARCH)) # extra kernel config files under configs/, include common + architecture specific -EXTCONFIG = common.config $(ARCH).config +EXTCONFIG = common.config $(XARCH).config # optional tests to run (default = all) TEST = @@ -55,7 +62,7 @@ QEMU_ARCH_mips = mipsel # works with malta_defconfig QEMU_ARCH_riscv = riscv64 QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 -QEMU_ARCH = $(QEMU_ARCH_$(ARCH)) +QEMU_ARCH = $(QEMU_ARCH_$(XARCH)) # QEMU_ARGS : some arch-specific args to pass to qemu QEMU_ARGS_i386 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $(TEST:%=NOLIBC_TEST=%)" @@ -67,7 +74,7 @@ QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" -QEMU_ARGS = $(QEMU_ARGS_$(ARCH)) $(QEMU_ARGS_EXTRA) +QEMU_ARGS = $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_EXTRA) # OUTPUT is only set when run from the main makefile, otherwise # it defaults to this nolibc directory. @@ -84,7 +91,7 @@ CFLAGS_mips = -EL CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ $(call cc-option,-fno-stack-protector) \ - $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR) + $(CFLAGS_$(XARCH)) $(CFLAGS_STACKPROTECTOR) LDFLAGS := -s REPORT ?= awk '/\[OK\][\r]*$$/{p++} /\[FAIL\][\r]*$$/{if (!f) printf("\n"); f++; print;} /\[SKIPPED\][\r]*$$/{s++} \ @@ -99,24 +106,25 @@ help: @echo " sysroot create the nolibc sysroot here (uses \$$ARCH)" @echo " nolibc-test build the executable (uses \$$CC and \$$CROSS_COMPILE)" @echo " libc-test build an executable using the compiler's default libc instead" - @echo " run-user runs the executable under QEMU (uses \$$ARCH, \$$TEST)" + @echo " run-user runs the executable under QEMU (uses \$$XARCH, \$$TEST)" @echo " initramfs prepare the initramfs with nolibc-test" - @echo " defconfig create a fresh new default config (uses \$$ARCH)" - @echo " kernel (re)build the kernel with the initramfs (uses \$$ARCH)" - @echo " run runs the kernel in QEMU after building it (uses \$$ARCH, \$$TEST)" - @echo " rerun runs a previously prebuilt kernel in QEMU (uses \$$ARCH, \$$TEST)" + @echo " defconfig create a fresh new default config (uses \$$XARCH)" + @echo " kernel (re)build the kernel with the initramfs (uses \$$XARCH)" + @echo " run runs the kernel in QEMU after building it (uses \$$XARCH, \$$TEST)" + @echo " rerun runs a previously prebuilt kernel in QEMU (uses \$$XARCH, \$$TEST)" @echo " clean clean the sysroot, initramfs, build and output files" @echo "" @echo "The output file is \"run.out\". Test ranges may be passed using \$$TEST." @echo "" @echo "Currently using the following variables:" @echo " ARCH = $(ARCH)" + @echo " XARCH = $(XARCH)" @echo " CROSS_COMPILE = $(CROSS_COMPILE)" @echo " CC = $(CC)" @echo " OUTPUT = $(OUTPUT)" @echo " TEST = $(TEST)" - @echo " QEMU_ARCH = $(if $(QEMU_ARCH),$(QEMU_ARCH),UNKNOWN_ARCH) [determined from \$$ARCH]" - @echo " IMAGE_NAME = $(if $(IMAGE_NAME),$(IMAGE_NAME),UNKNOWN_ARCH) [determined from \$$ARCH]" + @echo " QEMU_ARCH = $(if $(QEMU_ARCH),$(QEMU_ARCH),UNKNOWN_ARCH) [determined from \$$XARCH]" + @echo " IMAGE_NAME = $(if $(IMAGE_NAME),$(IMAGE_NAME),UNKNOWN_ARCH) [determined from \$$XARCH]" @echo "" all: run From patchwork Tue Jul 18 21:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704208 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 65FA0EB64DC for ; Tue, 18 Jul 2023 21:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231277AbjGRVQf (ORCPT ); Tue, 18 Jul 2023 17:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbjGRVQd (ORCPT ); Tue, 18 Jul 2023 17:16:33 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0AFC0; Tue, 18 Jul 2023 14:16:30 -0700 (PDT) X-QQ-mid: bizesmtp64t1689714981twgbl5jf Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:16:20 +0800 (CST) X-QQ-SSF: 01200000000000D0X000000A0000000 X-QQ-FEAT: rZJGTgY0+YMsNn0tiH5GxXHDHMTndtl7NbvdEtTMLGzjdqSAfitYAYhrVd6EZ baHRqA5DNH5svwEJ5bD3QJG0h66n7aQdSH/X3KBDUIJ22MhRZuf16kRymoZYYB+tEkFZ+/y DJencGX8HQllTd8CI3W50ssf6GJFjtKjYnRQvEuoxGFPASGko1jyo9h2aMj1pHl2bfJ2COI jlkdCwk7VOkbmjTTKPUV37SfynaULuvrG/R198MIx9wVQbPPjuPvtUm69ctskRY1yFwiQs6 PECDHee3muS9yLaSPb4QAjN0dTw5f9Chxtqk8/MVZJFnspIGcNQSUIGZq2E2u2Ub8U26Ogp Jb758x18DEVk5zMFBFSuIwYhhkfR/HYj7seXroVmVn2fxBL+DxHeS0C/kALaO9+gxpLlUG4 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 8636731950875008413 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 6/8] selftests/nolibc: add test support for powerpc Date: Wed, 19 Jul 2023 05:16:19 +0800 Message-Id: <548df83f58d7d6e2f9278b05239dd57501aa3603.1689713175.git.falcon@tinylab.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The default qemu-system-ppc g3beige machine [1] is used to run 32-bit powerpc kernel. The pmac32_defconfig is used with extra PMACZILOG console options to enable normal print. Note, zImage doesn't boot due to "qemu-system-ppc: Some ROM regions are overlapping" error, so, vmlinux is used instead. [1]: https://qemu.readthedocs.io/en/latest/system/ppc/powermac.html Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 4 ++++ tools/testing/selftests/nolibc/configs/powerpc.config | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 tools/testing/selftests/nolibc/configs/powerpc.config diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index b17a82efe6de..9c375fab84e5 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -28,6 +28,7 @@ IMAGE_x86 = arch/x86/boot/bzImage IMAGE_arm64 = arch/arm64/boot/Image IMAGE_arm = arch/arm/boot/zImage IMAGE_mips = vmlinuz +IMAGE_powerpc = vmlinux IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi @@ -41,6 +42,7 @@ DEFCONFIG_x86 = defconfig DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig +DEFCONFIG_powerpc = pmac32_defconfig DEFCONFIG_riscv = defconfig DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig @@ -59,6 +61,7 @@ QEMU_ARCH_x86 = x86_64 QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig +QEMU_ARCH_powerpc = ppc QEMU_ARCH_riscv = riscv64 QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 @@ -71,6 +74,7 @@ QEMU_ARGS_x86 = -M pc -append "console=ttyS0,9600 i8042.noaux panic=-1 $( QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_powerpc = -M g3beige -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" diff --git a/tools/testing/selftests/nolibc/configs/powerpc.config b/tools/testing/selftests/nolibc/configs/powerpc.config new file mode 100644 index 000000000000..b1975f8253f7 --- /dev/null +++ b/tools/testing/selftests/nolibc/configs/powerpc.config @@ -0,0 +1,3 @@ +CONFIG_SERIAL_PMACZILOG=y +CONFIG_SERIAL_PMACZILOG_TTYS=y +CONFIG_SERIAL_PMACZILOG_CONSOLE=y From patchwork Tue Jul 18 21:17:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704801 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 4B0F3EB64DC for ; Tue, 18 Jul 2023 21:17:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbjGRVRj (ORCPT ); Tue, 18 Jul 2023 17:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjGRVRj (ORCPT ); Tue, 18 Jul 2023 17:17:39 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB69C0; Tue, 18 Jul 2023 14:17:36 -0700 (PDT) X-QQ-mid: bizesmtp63t1689715047trdiu2ha Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:17:26 +0800 (CST) X-QQ-SSF: 00200000000000D0X000000A0000000 X-QQ-FEAT: dS+JUNSIibflfvQUqHphixHe9mxdIAUVUxmHwzGtcQgITEbA7xfHe3zzgA1HA xRrNTac7cs4ZtM0o+4x3EOE9R4Qb0zWh+NO9OxqzotIpkzVAf4+21FIrDBGK7Yiwgco6rh8 2m0sRNggyK3JBscnUP3S7HE8nsG3j475H3wxR38WjWv3Qx6MMNWMX0rUg1EgcT+0ffFlwe1 ewuJreu66wiUwG1w8G9FKsoLkmb/USYlSbryqK0M5r4QPvVJdHqoWBors3ltLorWzlW73OQ SdLXm57yRYmK6Zqm7VTl+hQXBeiAWft1bR6ECWtxoy5lgSV5ROcm47X2o2TeoiXMHaJ16BO cdLZ4eBmDX46qINKj9cdPHaZGbuuUdniiq/QHpxrCXDf3dyk/q7K/+d0b0jeSHU/D3kKaaE X-QQ-GoodBg: 0 X-BIZMAIL-ID: 15862837177121662062 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 7/8] selftests/nolibc: add test support for powerpc64le Date: Wed, 19 Jul 2023 05:17:26 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Here adds test support for little endian 64-bit PowerPC. The powernv machine of qemu-system-ppc64le is used for there is just a working powernv_defconfig. As the document [1] shows: PowerNV (as Non-Virtualized) is the “bare metal” platform using the OPAL firmware. It runs Linux on IBM and OpenPOWER systems and it can be used as an hypervisor OS, running KVM guests, or simply as a host OS. [1]: https://qemu.readthedocs.io/en/latest/system/ppc/powernv.html Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index 9c375fab84e5..fbdf7fd9bf96 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -19,6 +19,7 @@ endif XARCH ?= $(or $(XARCH_$(ARCH)),$(ARCH)) # ARCH is supported by kernel +ARCH_powerpc64le = powerpc ARCH := $(or $(ARCH_$(XARCH)),$(XARCH)) # kernel image names by architecture @@ -29,6 +30,7 @@ IMAGE_arm64 = arch/arm64/boot/Image IMAGE_arm = arch/arm/boot/zImage IMAGE_mips = vmlinuz IMAGE_powerpc = vmlinux +IMAGE_powerpc64le= arch/powerpc/boot/zImage IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi @@ -43,6 +45,7 @@ DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig DEFCONFIG_powerpc = pmac32_defconfig +DEFCONFIG_powerpc64le= powernv_defconfig DEFCONFIG_riscv = defconfig DEFCONFIG_s390 = defconfig DEFCONFIG_loongarch = defconfig @@ -62,6 +65,7 @@ QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig QEMU_ARCH_powerpc = ppc +QEMU_ARCH_powerpc64le= ppc64le QEMU_ARCH_riscv = riscv64 QEMU_ARCH_s390 = s390x QEMU_ARCH_loongarch = loongarch64 @@ -75,6 +79,7 @@ QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_powerpc = -M g3beige -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_powerpc64le= -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" @@ -90,6 +95,7 @@ else Q=@ endif +CFLAGS_powerpc64le = -m64 -mlittle-endian -Wl,-EL,-melf64ppc CFLAGS_s390 = -m64 CFLAGS_mips = -EL CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) From patchwork Tue Jul 18 21:18:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 704207 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 E394EEB64DC for ; Tue, 18 Jul 2023 21:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbjGRVS5 (ORCPT ); Tue, 18 Jul 2023 17:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbjGRVSt (ORCPT ); Tue, 18 Jul 2023 17:18:49 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91D4A1992; Tue, 18 Jul 2023 14:18:43 -0700 (PDT) X-QQ-mid: bizesmtp62t1689715113t4aqmkoo Received: from linux-lab-host.localdomain ( [119.123.130.39]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 19 Jul 2023 05:18:32 +0800 (CST) X-QQ-SSF: 00200000000000D0X000B00A0000000 X-QQ-FEAT: eTp2eCgHrZnVchQBQHtIq1r0Chl0Y2QbztCX0TuLdQWRfW6TBfD0oOxr2ZGUl yeDiNZSVENj5aynfdi2NOfwTm0jEDkw5naUuGrqduIBj7DrVxkjq7hzmqe466uOcMmQ4Pwu UheYGug3IvwmwqNhO0f54gtD5CS3BqKxSYZsenHMTFf/s4z03vCgj7ZUqzXY8eRywSO+OWS I2bbHl1rsY8vhO5wagJxT4zU80r57W2C8xG3Prz2vxWKEQyWYDNwLPmwlY/0oa7JPlIi6Ct NLQlRXtazcamKO4G51OA+NdQE9LFeIj3+wi2vuM0ZaQc3OwR6Tzwjo44z5oybS/0jggoEeX c84ZB+ZfpFDm5HG45ZE7Np6rreJ6+cp9ChpV7qRly3xGJeCnGVwbYqt6fpZ1zrfZJofeqbY eLYGk1HeKtk= X-QQ-GoodBg: 0 X-BIZMAIL-ID: 11777367648574905451 From: Zhangjin Wu To: w@1wt.eu Cc: thomas@t-8ch.de, arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 8/8] selftests/nolibc: add test support for powerpc64 Date: Wed, 19 Jul 2023 05:18:32 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Here adds test support for big endian 64-bit PowerPC. The powernv machine of qemu-system-ppc64 is used with powernv_be_defconfig. As the document [1] shows: PowerNV (as Non-Virtualized) is the “bare metal” platform using the OPAL firmware. It runs Linux on IBM and OpenPOWER systems and it can be used as an hypervisor OS, running KVM guests, or simply as a host OS. Note, differs from little endian 64-bit PowerPC, vmlinux is used instead of zImage, because big endian zImage [2] only boot on qemu with x-vof=on (added from qemu v7.0) and a fixup patch [3] for qemu v7.0.51: [1]: https://qemu.readthedocs.io/en/latest/system/ppc/powernv.html [2]: https://github.com/linuxppc/issues/issues/402 [3]: https://lore.kernel.org/qemu-devel/20220504065536.3534488-1-aik@ozlabs.ru/ Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index fbdf7fd9bf96..cced1d60ecf9 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -19,6 +19,7 @@ endif XARCH ?= $(or $(XARCH_$(ARCH)),$(ARCH)) # ARCH is supported by kernel +ARCH_powerpc64 = powerpc ARCH_powerpc64le = powerpc ARCH := $(or $(ARCH_$(XARCH)),$(XARCH)) @@ -30,6 +31,7 @@ IMAGE_arm64 = arch/arm64/boot/Image IMAGE_arm = arch/arm/boot/zImage IMAGE_mips = vmlinuz IMAGE_powerpc = vmlinux +IMAGE_powerpc64 = vmlinux IMAGE_powerpc64le= arch/powerpc/boot/zImage IMAGE_riscv = arch/riscv/boot/Image IMAGE_s390 = arch/s390/boot/bzImage @@ -45,6 +47,7 @@ DEFCONFIG_arm64 = defconfig DEFCONFIG_arm = multi_v7_defconfig DEFCONFIG_mips = malta_defconfig DEFCONFIG_powerpc = pmac32_defconfig +DEFCONFIG_powerpc64 = powernv_be_defconfig DEFCONFIG_powerpc64le= powernv_defconfig DEFCONFIG_riscv = defconfig DEFCONFIG_s390 = defconfig @@ -65,6 +68,7 @@ QEMU_ARCH_arm64 = aarch64 QEMU_ARCH_arm = arm QEMU_ARCH_mips = mipsel # works with malta_defconfig QEMU_ARCH_powerpc = ppc +QEMU_ARCH_powerpc64 = ppc64 QEMU_ARCH_powerpc64le= ppc64le QEMU_ARCH_riscv = riscv64 QEMU_ARCH_s390 = s390x @@ -79,6 +83,7 @@ QEMU_ARGS_arm64 = -M virt -cpu cortex-a53 -append "panic=-1 $(TEST:%=NOLIBC QEMU_ARGS_arm = -M virt -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_mips = -M malta -append "panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_powerpc = -M g3beige -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" +QEMU_ARGS_powerpc64 = -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_powerpc64le= -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" QEMU_ARGS_s390 = -M s390-ccw-virtio -m 1G -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" @@ -95,6 +100,7 @@ else Q=@ endif +CFLAGS_powerpc64 = -m64 -mbig-endian -mmultiple -Wl,-EB,-melf64ppc CFLAGS_powerpc64le = -m64 -mlittle-endian -Wl,-EL,-melf64ppc CFLAGS_s390 = -m64 CFLAGS_mips = -EL