From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 110C2C433FE for ; Sun, 3 Oct 2021 02:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1F4F61AF0 for ; Sun, 3 Oct 2021 02:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbhJCCwT (ORCPT ); Sat, 2 Oct 2021 22:52:19 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:41542 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbhJCCwS (ORCPT ); Sat, 2 Oct 2021 22:52:18 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mWrXy-009Wzm-I7; Sun, 03 Oct 2021 02:48:14 +0000 Date: Sun, 3 Oct 2021 02:48:14 +0000 From: Al Viro To: Huacai Chen Cc: Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , Yanteng Si , Huacai Chen , Jiaxun Yang Subject: Re: [PATCH V4 11/22] LoongArch: Add process management Message-ID: References: <20210927064300.624279-1-chenhuacai@loongson.cn> <20210927064300.624279-12-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210927064300.624279-12-chenhuacai@loongson.cn> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Mon, Sep 27, 2021 at 02:42:48PM +0800, Huacai Chen wrote: > +/* > + * Does the process account for user or for system time? > + */ > +#define user_mode(regs) (((regs)->csr_prmd & PLV_MASK) == PLV_USER) > + > +static inline int is_syscall_success(struct pt_regs *regs) > +{ > + return !regs->regs[7]; > +} > > +static inline long regs_return_value(struct pt_regs *regs) > +{ > + if (is_syscall_success(regs) || !user_mode(regs)) > + return regs->regs[4]; > + else > + return -regs->regs[4]; > +} Huh??? That looks like you've copied those from MIPS, but on MIPS we have things like li t0, -EMAXERRNO - 1 # error? sltu t0, t0, v0 sd t0, PT_R7(sp) # set error flag beqz t0, 1f ld t1, PT_R2(sp) # syscall number dnegu v0 # error sd t1, PT_R0(sp) # save it for syscall restarting 1: sd v0, PT_R2(sp) # result right after the call of sys_...(), along with the restart logics looking like if (regs->regs[0]) { switch(regs->regs[2]) { case ERESTART_RESTARTBLOCK: case ERESTARTNOHAND: IOW, syscall return values from -EMAXERRNO to -1 are negated, with regs[7] set accordingly. Nothing of that sort is done in your patchset after syscall, and if it had been, your restart logics in signal handling would've been wrong anyway. What's going on there?