Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3392626pxp; Tue, 22 Mar 2022 19:28:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcnx8+0CPZOfEZbu3ZQ1iZXBH5OFLgIyDtGgheTXj7zKHU2i0oonA0S1LApg9sDiJg0/XN X-Received: by 2002:a05:6a00:1582:b0:4f7:63da:dfea with SMTP id u2-20020a056a00158200b004f763dadfeamr32439800pfk.27.1648002506004; Tue, 22 Mar 2022 19:28:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648002505; cv=none; d=google.com; s=arc-20160816; b=g4kqG0PZU0vBNe6KxjKKodgGLUMw+tF9GVIYWAVda1Qf5odeVxapfPV4unhPZrd3Ii YucHY3qxhgTezCxeDmAnnvzD2obTq+bnxVB1vwlpJTIfn3WA+f9aZOD8VJ5tP0h+nwPk KXWUfWuX4mHr/KR/Ii7VI/rje7vePl2Jr9QOkTLd5rvnTweypQ/txWwpNoAaACmzuo1U U/hGpEsSwdxxKJ859iSeomlVfR9P2fyu5Wr2NSPyGkMUF+De3hQANPosgJFHCCJg49nT xw+FvzfbTYAot4TSMPv5cGt/Eq+4WSodapBr3JfrqcaJJF8OQU/bX4N0zIvKJbcL0aBe DgBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=LBdn+rhvGi+ozQMHOLj9UxL+r/56vN4YN4SANh5q1XE=; b=iGzA+XU/YiEINKh5d9bEtN6hFiuf7XZDCXG5V7uEvaGNEGcN3qf1Ws8vOiFhmxYBvy ZGKVcdn4Os3l185RLbwu+O17DcCXO2IxKtIkcnCU6tUJQZ6TaywePfbOX/xuAP9UwMlZ EN89KQDtyoTNV+qiOk3wregnYpao1Xjs+tZtoH6xcGpi1fKbkKt5lg3wqOPNHOhzppIl mosmxyPvkosXyV0p0Q1N/UEz2lPID/ag2ivqxvug+ynaM9DKc7gaeseJxenk5pQKVNy0 wDuLpG3a2VAVd2XH/VPb+FZ4KEbOPhuEtYoo7XSvf8CEa3/ZXKV6yY7KqMNtAMCT2H3g STfA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp11-20020a17090afb8b00b001bd14e030e4si3830453pjb.188.2022.03.22.19.28.13; Tue, 22 Mar 2022 19:28:25 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234433AbiCVNj0 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 22 Mar 2022 09:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234214AbiCVNjZ (ORCPT ); Tue, 22 Mar 2022 09:39:25 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 74B8C273E for ; Tue, 22 Mar 2022 06:37:56 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-268-V_ky3gfUOuOFokGV86_QzA-1; Tue, 22 Mar 2022 13:37:54 +0000 X-MC-Unique: V_ky3gfUOuOFokGV86_QzA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 22 Mar 2022 13:37:54 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.033; Tue, 22 Mar 2022 13:37:54 +0000 From: David Laight To: 'Willy Tarreau' , Ammar Faizi CC: "Paul E. McKenney" , Alviro Iskandar Setiawan , Nugraha , "Linux Kernel Mailing List" , GNU/Weeb Mailing List , "x86@kernel.org" , "llvm@lists.linux.dev" Subject: RE: [RFC PATCH v2 3/8] tools/nolibc: i386: Implement syscall with 6 arguments Thread-Topic: [RFC PATCH v2 3/8] tools/nolibc: i386: Implement syscall with 6 arguments Thread-Index: AQHYPdalMvftIu2CIkSH1LImoy2kmazLRP7AgAAL3z2AABVNYA== Date: Tue, 22 Mar 2022 13:37:54 +0000 Message-ID: <22fd9709b3a64a548226741b682ca155@AcuMS.aculab.com> References: <20220322102115.186179-1-ammarfaizi2@gnuweeb.org> <20220322102115.186179-4-ammarfaizi2@gnuweeb.org> <8653f6784a9b4272a59a75a530663567@AcuMS.aculab.com> <20220322121338.GD10306@1wt.eu> In-Reply-To: <20220322121338.GD10306@1wt.eu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 From: Willy Tarreau > Sent: 22 March 2022 12:14 > > On Tue, Mar 22, 2022 at 07:02:53PM +0700, Ammar Faizi wrote: > > I propose the > > following macro (this is not so much different with other my_syscall macro), > > expect the 6th argument can be in reg or mem. > > > > The "rm" constraint here gives the opportunity for the compiler to use %ebp > > instead of memory if -fomit-frame-pointer is turned on. > > > > #define my_syscall6(num, arg1, arg2, arg3, arg4, arg5, arg6) \ > > ({ \ > > long _ret; \ > > register long _num asm("eax") = (num); \ > > register long _arg1 asm("ebx") = (long)(arg1); \ > > register long _arg2 asm("ecx") = (long)(arg2); \ > > register long _arg3 asm("edx") = (long)(arg3); \ > > register long _arg4 asm("esi") = (long)(arg4); \ > > register long _arg5 asm("edi") = (long)(arg5); \ > > long _arg6 = (long)(arg6); /* Might be in memory */ \ > > \ > > asm volatile ( \ > > "pushl %[_arg6]\n\t" \ > > "pushl %%ebp\n\t" \ > > "movl 4(%%esp), %%ebp\n\t" \ > > "int $0x80\n\t" \ > > "popl %%ebp\n\t" \ > > "addl $4,%%esp\n\t" \ > > : "=a"(_ret) \ > > : "r"(_num), "r"(_arg1), "r"(_arg2), "r"(_arg3), \ > > "r"(_arg4),"r"(_arg5), [_arg6]"rm"(_arg6) \ > > : "memory", "cc" \ > > ); \ > > _ret; \ > > }) > > > > What do you think? > > Hmmm indeed that comes back to the existing constructs and is certainly > more in line with the rest of the code (plus it will not be affected by > -O0). I'd add an 'always_inline' to the function. That will force inline even with -O0. > I seem to remember a register allocation issue which kept me away from > implementing it this way on i386 back then, but given that my focus was > not as much on i386 as it was on other platforms, it's likely that I have > not insisted too much and not tried this one which looks like the way to > go to me. dunno, 'asm' register variables are rather more horrid and should probably only be used (for asm statements) when there aren't suitable register constraints. (I'm sure there is a comment about that in the gcc docs.) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)