Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9286417rwp; Thu, 20 Jul 2023 02:31:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYWLSKjNSZRyp5PckRkJpRC0R7GQqDiGRQSNbI/RFVMU5quKodLhdsGpne4BXjy6+NHMZr X-Received: by 2002:a05:6512:746:b0:4fa:5255:4fa3 with SMTP id c6-20020a056512074600b004fa52554fa3mr1982953lfs.5.1689845467798; Thu, 20 Jul 2023 02:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689845467; cv=none; d=google.com; s=arc-20160816; b=QEpoqxaR7ajgqT9rCowYer+mVvn3lbHK2TY+IhrVMDyX6sqnIzP0UHAwsf0f3brdMD Ee4V0/2K0+tGRhaBpiFYfPzZptppI/nmlugeFNPcUScOpjZJO9rhhMti6uhE0L6YCgoL Be9rHgx8fgX/IyjJTdz6vdSEAsL3d4GnK7AVLGCoLBicD4ZhVhVDiFyrqAFAp6LpZ6VB tSEc3f85VEFgKnWbUkcMA6CKbVv7RZSIIC/BUavahY6dAvHSqqa9m1GX4A+0SVzt39GC YUKckr/TtIq3ano8IljrIoNQb4VY0lcLiCFhaIykiuxUyUbTT/Sy/obKy9zbavyxqEKi dCWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=l2VyLPvg0bgUxibpjKCX7Hvp7vb2UGKyJSjPV3NSgCc=; fh=pX8WXRSQK24Sy3o7OMKAH51nzt1rXdbbeinHh//h9O4=; b=HWZQb3Pz/4WYMqBsSkr5TpGyiPJzL84i3WWC0b4qNFbOzRVlMwhmNEnZDuMhBxYhzh KAwMLPppr5weUWtg0NfmI7E+ujw66/eF2ZvpGg9yeOW6pbboEF7lPwzGOjGFdT+5McnN 2COEzXyCgh6jJGaVsOMMkZyKsNCyH7d7EgG5/39YVwtpQy5+8dD5hIxnvA4YTlctR1yl cKsFxOoYzIds8vaSeljJs4bLiymSS7/xgCZHWue1IkfSKPEOyb+HbkdY8q05m7ZyKTtA Hd4rPrU2vuZI4hl7K19DiOk8amRcspmA11SPV1+Cg6IleF21cBSFYMcvdmyxufc6FTUY J1Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DyY8a9Zf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xo11-20020a170907bb8b00b00993a4cd974esi430836ejc.287.2023.07.20.02.30.42; Thu, 20 Jul 2023 02:31:07 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DyY8a9Zf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbjGTJ0D (ORCPT + 99 others); Thu, 20 Jul 2023 05:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjGTJZv (ORCPT ); Thu, 20 Jul 2023 05:25:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97B7E2E153 for ; Thu, 20 Jul 2023 02:09:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33E0B6192A for ; Thu, 20 Jul 2023 09:08:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5704C433C8; Thu, 20 Jul 2023 09:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689844120; bh=7vwFcJOK2o2ICUdblT8hzETcmg2FeUVLkIn7N0rywqM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DyY8a9Zf8fGL/VPrimuDKR41GKnAtY7C1jKKvU2roErbYtGFI6ilB4gch6VPg3IOk NTxq7dgvKiWSmy/ZHq8UGLzJ12f0aijd9/rYauzgFG7VUxZFs1ju+/J7/Lo/3F69gy yMyhZT8TMHyLz/I/1NkLuViQsY020M99Q6WS0mTwkxg0tdgkVCDtnL2LvImxb4GrJu +TEL5+adOFo+bfNRpPoehSnZkrVd3DCCw6grd457EFuKBESkbu0TdE6WOBsP0BiRrw kjC4VVd2F3FtUwtDO6gCUdYEsEXce8bm0FaI8DU2JY/O2bPnTPXAPapRQ7nIFktGiY xno4ZTNlBVJXQ== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Celeste Liu , Andreas Schwab Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Guo Ren , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Felix Yan , Ruizhe Pan , Shiqi Zhang Subject: Re: [PATCH v3] riscv: entry: set a0 = -ENOSYS only when syscall != -1 In-Reply-To: <54D8BFF7-C4D2-417E-B18C-62B5DB17B51B@gmail.com> References: <20230718210037.250665-1-CoelacanthusHex@gmail.com> <878rbbkgqo.fsf@all.your.base.are.belong.to.us> <54D8BFF7-C4D2-417E-B18C-62B5DB17B51B@gmail.com> Date: Thu, 20 Jul 2023 11:08:37 +0200 Message-ID: <87wmyvq7ai.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 Celeste Liu writes: > On July 20, 2023 12:28:47 AM GMT+08:00, "Bj=C3=B6rn T=C3=B6pel" wrote: >>Andreas Schwab writes: >> >>> On Jul 19 2023, Celeste Liu wrote: >>> >>>> @@ -308,7 +312,7 @@ asmlinkage __visible __trap_section void do_trap_e= call_u(struct pt_regs *regs) >>>>=20=20 >>>> if (syscall < NR_syscalls) >>>> syscall_handler(regs, syscall); >>>> - else >>>> + else if ((long)syscall !=3D -1L) >>> >>> You can also use syscall !=3D -1UL or even syscall !=3D -1. >> >>The former is indeed better for the eyes! :-) The latter will get a >>-Wsign-compare warning, no? >> >> >>Bj=C3=B6rn > > Well, that's true. And I just found out that by C standards, converting > ulong to long is implementation-defined behavior, unlike long to ulong > which is well-defined. So it is really better than (long)syscall !=3D -1L. If you're respinning, I suggest you use David's suggestion: * Remove the comment I suggest you to add * Use (signed) long * Add syscall >=3D 0 && * else if (syscall !=3D -1) Which is the least amount of surprises IMO.