From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BB101FCFC1 for ; Mon, 27 Jan 2025 12:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737980405; cv=none; b=s5/y7ZBNG6qjxRsH+hpARmUOwxeyhNKnT7QIV9sZS80NfnHDcrLZ9naPfKo4CNWpIAvNWwqjG4SmGfBXGKOgKY0u0HMc3ivAfID8gB/iCmAfctYBroA14xqiJGu1hIw1/FSJmnQfuMHgktoeh/MIsDxLKiptKULIZD3ReXG5O/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737980405; c=relaxed/simple; bh=AINOap5/zJqh0/E0TxhVlmUin5htIkSofDJhOigc8HI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kvHXbC4SS31ZMVuvq5HGN0h9//ToO7ynedJ1E9yRfQ3QyhploA01Qqu1vTFKHDxOv+cpZoDtKYpO5kchYF3PcYRY8uMqqBogIroIxDoypQjNDqzcA6G4k/EJs69dFzG5+jWEe/0ZeuJcsob5YQ0lyjFiY3szu/RutS3oRxAVcsI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4YhRt43yRDz9sPd; Mon, 27 Jan 2025 13:04:28 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dkqekuMgvYx2; Mon, 27 Jan 2025 13:04:28 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4YhRt436qHz9rvV; Mon, 27 Jan 2025 13:04:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5740B8B765; Mon, 27 Jan 2025 13:04:28 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id KmMv5MXtq3JP; Mon, 27 Jan 2025 13:04:28 +0100 (CET) Received: from [192.168.235.99] (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id ACE468B763; Mon, 27 Jan 2025 13:04:27 +0100 (CET) Message-ID: <63aec56f-9ade-48d1-854b-bd72f8313a9f@csgroup.eu> Date: Mon, 27 Jan 2025 13:04:27 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value() To: "Dmitry V. Levin" Cc: Alexey Gladkov , Oleg Nesterov , Michael Ellerman , Eugene Syromyatnikov , Mike Frysinger , Renzo Davoli , Davide Berardi , strace-devel@lists.strace.io, Madhavan Srinivasan , Nicholas Piggin , Naveen N Rao , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20250113171054.GA589@strace.io> <6558110c-c2cb-4aa3-9472-b3496f71ebb8@csgroup.eu> <20250114170400.GB11820@strace.io> <20250123182815.GA20994@strace.io> <86079b5c-e124-489b-8136-05ae5700cb61@csgroup.eu> <20250127112023.GB29522@strace.io> <7e7c7659-5cf7-42e9-81d6-b91963d8c892@csgroup.eu> <20250127114439.GC29522@strace.io> Content-Language: fr-FR From: Christophe Leroy In-Reply-To: <20250127114439.GC29522@strace.io> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 27/01/2025 à 12:44, Dmitry V. Levin a écrit : > On Mon, Jan 27, 2025 at 12:36:53PM +0100, Christophe Leroy wrote: >> Le 27/01/2025 à 12:20, Dmitry V. Levin a écrit : >>> On Thu, Jan 23, 2025 at 11:07:21PM +0100, Christophe Leroy wrote: >>> [...] >>>> To add a bit more to the confusion, >>> >>> Looks like there is no end to it: >>> >>> static inline long regs_return_value(struct pt_regs *regs) >>> { >>> if (trap_is_scv(regs)) >>> return regs->gpr[3]; >>> >>> if (is_syscall_success(regs)) >>> return regs->gpr[3]; >>> else >>> return -regs->gpr[3]; >>> } >>> >>> static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) >>> { >>> regs->gpr[3] = rc; >>> } >>> >>> This doesn't look consistent, does it? >>> >>> >> >> That regs_set_return_value() looks pretty similar to >> syscall_get_return_value(). > > Yes, but here similarities end, and differences begin. > >> regs_set_return_value() documentation in asm-generic/syscall.h >> explicitely says: This value is meaningless if syscall_get_error() >> returned nonzero >> >> Is it the same with regs_set_return_value(), only meaningfull where >> there is no error ? > > Did you mean syscall_set_return_value? No, it explicitly has two > arguments, "int error" and "long val", so it can be used to either > clear or set the error condition as specified by the caller. Sorry, I mean syscall_get_return_value() here. static inline long syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) { return regs->gpr[3]; } Versus static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) { regs->gpr[3] = rc; } > >> By the way, why have two very similar APIs, one in syscall.h one in >> ptrace.h ? > > I have no polite answer to this, sorry. > >