From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41F371FCFD6 for ; Mon, 27 Jan 2025 11:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737978283; cv=none; b=E/IjT8jHUMBHrRt0FJdzVVRCw7K5KTvif0vPmZMUYJnlSTm1TGY3Qs58xFRhXB7VBH2no+KruakkqhooHt4KvA8HZnG6zTbmnPQ9eHXZCzT3LUbddBgr+yeLUgMKJBfqfEOZ1N8gFVsNu3hLS8DjGhTLLufngg7qqu3LzmnD9Cs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737978283; c=relaxed/simple; bh=1Pbo7NQi3JJvZ5SE0oK5MvbncoM9TKGr7wtFvU+HUes=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cypLTeQIQcVJLHEzBHR//XhK6nV1CuURRRG3J6x9SdiDGyIhJ/V9FOHg8ThdPjYxraPA1L6g9+Ihb6apwlmAxLw54niNJWKArffwYi0izWn9tTJ8K+wdfz901FXNxeYzl51tE9rW71g8fN2FZ9BuoQl7E/Yu7piNJ1x/GugoKpE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 0CEEE72C8CC; Mon, 27 Jan 2025 14:44:40 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id EF77A7CCB3A; Mon, 27 Jan 2025 13:44:39 +0200 (IST) Date: Mon, 27 Jan 2025 13:44:39 +0200 From: "Dmitry V. Levin" To: Christophe Leroy 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 Subject: Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value() Message-ID: <20250127114439.GC29522@strace.io> 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7e7c7659-5cf7-42e9-81d6-b91963d8c892@csgroup.eu> 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. > 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. -- ldv