Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2500761pxb; Sat, 2 Oct 2021 19:56:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFha/Zd12/0YoLWVSYbAhXuIOJSc6fiGKejgW/wom1EwNizhM0cssit9ZKKAfkZVwa3YVj X-Received: by 2002:a05:6402:1848:: with SMTP id v8mr5583546edy.0.1633229809255; Sat, 02 Oct 2021 19:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633229809; cv=none; d=google.com; s=arc-20160816; b=djmSoUzSig97b5allmktRjzgbeA5+9rEhbpMdfp0hJuOSpaFpPyGWM5/35vqUKmzY0 oh8DDTyjktYohtVD62VK05mBHfzy3o3agZV/CW+BR57XtwudRjXkkQBoVhPkUXojHbiT 8OiCpEUE3VEXGQry++5LoA01xg+NpEZ0HRAMisPaKWJlZxhZDcA4ikgVp/3xHUzBGrpg H/cIC8edlHzyuNSqgXk3kV1epwln08Hxhbvc1fpaOID9uVNVGkuwYyAn+dJRwG6Bfp/w zp4MQ4S2Deh6brsTwMM8m1m5919aXlCan6kzSIrHKX0zP5Aent/rXZSak0379OH0qQ4d lprA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mSdg+/iKt5fpoyUP4VDzqVAi5lfunYy/oblgn5rcATI=; b=QOxlRWuJOVvpM+PDjO8+X4NbnLFgPctHp9PbRUFJNy45BOwlOoYtuNh8W8zd+5JcH8 83m758i6izvY96DVnmFoWncvbM+FNIfL0CRAI/1k3eBGtSnoiejy1SUEVEz61FQpU6lH 00KmxQzZOnCWVbyxqu0V10SNMCBhamH1c8GqSTUhMY3ivsRjRlh3eIDOGSvKS6d3XHp9 PvNMENDi7KC8aT/+n/vsEpyzVeg7Oc7mJ+NVBNpF1Jv9I80rQb59/oyS03VpcMK5B92U EdvF9LgbevZoIzWI0qR6IxBqcUAqNNTaUATVDm2HAP6e8dl8SkU0sD7+M4wbAQ7wbRA6 9q2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o7si5469853edc.251.2021.10.02.19.56.12; Sat, 02 Oct 2021 19:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbhJCCwT (ORCPT + 99 others); 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-kernel@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?