Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2666621pxb; Sun, 3 Oct 2021 02:14:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLdPF1A9LktaHXiU0J8hukaQXTrg7nUwXe39eXV7G16FSfdFB8gU75zZ1RaHNXxsHuSDm7 X-Received: by 2002:a17:902:a50f:b029:11a:cd45:9009 with SMTP id s15-20020a170902a50fb029011acd459009mr17950276plq.38.1633252485890; Sun, 03 Oct 2021 02:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633252485; cv=none; d=google.com; s=arc-20160816; b=SNUPq09x5hGSo129J5t2YYA0oPKqBW/XJQ/YPbSC04S+sGFYQsNjhJJq5+nxx0+ew3 bQjaTwUwyAmna3/K9v/towrWHI0KwritUPIT0HQHUUEQ7KKRj5aZb2YpdAE8l8s8llkt GmmhTgtpgsxHoG716bOz/XilxILNEjq68d30PJN7q5SgcBQqaaGfTZYgpXrzTxdqXIul VEFvr3HF8kR/59Gz30fbojyp52RTQCl4Itt0dmKPtCReg/AWu4BdXdBhT7un1zAbhOOH +AK0379IaSZ9WPHX7ndCAUwoLuW7eIh69W/RI3JW3ym+28j4wbQK3E10lRX4lPPD59oW C/ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JPleIos8zuocYDdWZp8SNu5UWPdQdIHw7rKBa26GVq8=; b=Dd9knpaAjp1pd4hOQRReHIP05V9ow4DIvv+KHTDU6/7kC0mFGobsJVZ5ITOSKwaMkJ ye84tSCQXtbX6KOouupCndHdyNwflDi6kV9IErpQ6dtwfUpJkaAvF6tuhVJYnGGURw5Y rlMnNx4lh+sQaGGqM/sVaqH6yzyLYvVuVEV+TFg0dYGHaGa/U7EbqnPdpl/w75b0q9g9 2u4n5y2AmXvarVlBU80uYjPDVwz2EtRVDP2PGIOzlAavYAwB35mK+ex6mlgF09rs2Z4m 2gp4AZ/EI8qo8bmKPXGwOniuRjuCLtk8Q1SS88Z5fGEwrd/3B/YfJqy34ck05wFeMsMq WVsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="V/pFiv8W"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si18191728plh.37.2021.10.03.02.14.33; Sun, 03 Oct 2021 02:14:45 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="V/pFiv8W"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbhJCJM5 (ORCPT + 99 others); Sun, 3 Oct 2021 05:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhJCJM5 (ORCPT ); Sun, 3 Oct 2021 05:12:57 -0400 Received: from mail-vk1-xa2d.google.com (mail-vk1-xa2d.google.com [IPv6:2607:f8b0:4864:20::a2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDC8C0613EC; Sun, 3 Oct 2021 02:11:10 -0700 (PDT) Received: by mail-vk1-xa2d.google.com with SMTP id u66so543857vku.4; Sun, 03 Oct 2021 02:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JPleIos8zuocYDdWZp8SNu5UWPdQdIHw7rKBa26GVq8=; b=V/pFiv8W0GUSl3MEfw9m5XmzXy4J28eDIm9TdnXbyqy5ibrfvn+1SqAfU1RXho4QP/ yLGqDkfegiQx9ZeYcIlTICQNhvtOy3knSN43E9dIrYObKk2cA4DoJoi09yb0G9909FhW Jqs0WUgBhZJT7yg/Or4pMSFxAJGQkbW6pTz+e5L2SNNq8ja3tJzPQOnAvT8eua1sDM4F jkECM8m1cbaksHsolQjlKk+zlqkcRIlGxlf+DDvIbKfUnItb+vIOA5foy/h9e0y8kN03 GwwVzfVCx97BRXRKZI49TqA/4GvFJ+MVE9Oop8cp/soiosqNt3ckHkha0o4C7xOcK8i8 LSiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JPleIos8zuocYDdWZp8SNu5UWPdQdIHw7rKBa26GVq8=; b=NiP1srNMLsI3pC7Eam9DkYxEMciqIAK3fj2Xy7RF2mRVIkIXWsu0LtlK+goEL36qbt zfjCK9G2pKaUA5m8aiZvMN9XJHnu+Q2zp9IRPhVadP6uNnl/Js5GQOJILeizQqh0Jtbw 0Pfaj58mBkTwVBJ5fxgEtD5PZW33RjFJ1l/bXWPTwF2WjtvuIfZdiQMZIhXirpfM1ArR zPYTFIUoRnPb0x4Zn4gD5cx22moxLooBeQ1fTqLCQmRSUU6fH3Hu8Jnyjw2YBp40OTF0 7VkOJaMEV2dnwWRIaZ5UvE59bR64dFzBvPHq3F8hF9p8NibgkCgxHgV1cUZ1kebbPYRI Yllw== X-Gm-Message-State: AOAM532vQkSmCpwQTZxky4Oz0aNipVkudjHT9C7BoU/XFsb72R8RLORf QkPr0d1BozPY3X+vj24J5f4kEAbUKx6uSvRpYQ4= X-Received: by 2002:a1f:2cd1:: with SMTP id s200mr12167838vks.3.1633252269396; Sun, 03 Oct 2021 02:11:09 -0700 (PDT) MIME-Version: 1.0 References: <20210927064300.624279-1-chenhuacai@loongson.cn> <20210927064300.624279-12-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Sun, 3 Oct 2021 17:10:58 +0800 Message-ID: Subject: Re: [PATCH V4 11/22] LoongArch: Add process management To: Al Viro Cc: Huacai Chen , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch , "open list:DOCUMENTATION" , LKML , Xuefeng Li , Yanteng Si , Jiaxun Yang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Al, On Sun, Oct 3, 2021 at 10:50 AM Al Viro wrote: > > 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? Sorry, the code derived from MIPS is wrong here, regs_return_value should simply return regs->regs[4]. Huacai