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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5FD66C0218A for ; Tue, 28 Jan 2025 16:10:09 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Yj9H35Hjmz3050; Wed, 29 Jan 2025 03:10:07 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=194.107.17.57 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1738080607; cv=none; b=Nx2gdXS/rbqOcSApoW1y3s2fBJGKrnULqXdP9YP6XoeKhHwB25YOt+tNBmuOjej1lwJmZET9QvqoxKNQn9Or8UZcobL3U5hYW7BQ0nBOdGBL+G/Bqa6g6tKEAEMxBp1DqpFlaEgKVn/nHDi8Cipz2e0usJzB2Rl+m0vHm1tMj1MPEp9lqLZtboTbzJYofcxqVQYNmPqK/A807lBpVmJ8y+Qz3S7T13CjILyeq2h29wXO8+hUG5hxNivsxODQcM1dJBaJAqkaTDx5eLOPJP+in1TR30SlOHDkW9RViJ8np9z3gDKYgWVA0Se1YC8XYmkkUusl1pFszoSBHI+ePoUMaA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1738080607; c=relaxed/relaxed; bh=ZRW0DJvv1aL2UIwpLJ210yYwqLusL5dfV8xJgBO6BFg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PU52veo4gWxk2+4k8gvmP7xSoMsjbJA7Tj/XTEdOOVCwWzo74aTOeyYcNU5v2uAAFA7UZwdvrd2PVjC5gX5qV2E0LZkOPvwhu9gISmilMjjnXUwyyvPgoRiPIgRoXIt6mfkwblhS8UYSKLAyIDlwuHwWDxVYq2NCIzW1JTMSgawsf0xL0P4vE9Rj0AIFUL0KkaXy35Bvi42cwaSPaFOyBiaS3UAJafEuvPW3F1mTKzPE5QnhWnZlNlosg0zaSULavHcZDlf87Nk4vH4C2dpAdK+VrWs93DviB5FK8PU7ysP9M0U+v8IKMot6IjKxLL4ZZJ+epKkH0DeYtoC5H4S45Q== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass (client-ip=194.107.17.57; helo=vmicros1.altlinux.org; envelope-from=ldv@altlinux.org; receiver=lists.ozlabs.org) smtp.mailfrom=altlinux.org Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=altlinux.org (client-ip=194.107.17.57; helo=vmicros1.altlinux.org; envelope-from=ldv@altlinux.org; receiver=lists.ozlabs.org) Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4Yj9H26CQdz304Z for ; Wed, 29 Jan 2025 03:10:06 +1100 (AEDT) Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 61DF872C8CC; Tue, 28 Jan 2025 19:10:05 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 530D37CCB3A; Tue, 28 Jan 2025 18:10:05 +0200 (IST) Date: Tue, 28 Jan 2025 18:10:05 +0200 From: "Dmitry V. Levin" To: Christophe Leroy Cc: Michael Ellerman , Alexey Gladkov , Eugene Syromyatnikov , Oleg Nesterov , Madhavan Srinivasan , Nicholas Piggin , Naveen N Rao , linuxppc-dev@lists.ozlabs.org, strace-devel@lists.strace.io, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] powerpc: properly negate error in syscall_set_return_value() in sc case Message-ID: <20250128161005.GC11869@strace.io> References: <20250127181322.GA1373@strace.io> <20250128155201.GA11869@strace.io> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , 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: On Tue, Jan 28, 2025 at 05:00:31PM +0100, Christophe Leroy wrote: > Le 28/01/2025 à 16:52, Dmitry V. Levin a écrit : > > On Tue, Jan 28, 2025 at 03:59:29PM +0100, Christophe Leroy wrote: > >> Le 27/01/2025 à 19:13, Dmitry V. Levin a écrit : > >>> According to the Power Architecture Linux system call ABI documented in > >>> [1], when the syscall is made with the sc instruction, both a value and an > >>> error condition are returned, where r3 register contains the return value, > >>> and cr0.SO bit specifies the error condition. When cr0.SO is clear, the > >>> syscall succeeded and r3 is the return value. When cr0.SO is set, the > >>> syscall failed and r3 is the error value. This syscall return semantics > >>> was implemented from the very beginning of Power Architecture on Linux, > >>> and syscall tracers and debuggers like strace that read or modify syscall > >>> return information also rely on this ABI. > >> > >> I see a quite similar ABI on microblaze, mips, nios2 and sparc. Do they > >> behave all the same ? > > > > Yes, also on alpha. I don't think microblaze should be in this list, > > though. > > Microblaze has > > static inline void syscall_set_return_value(struct task_struct *task, > struct pt_regs *regs, > int error, long val) > { > if (error) > regs->r3 = -error; > else > regs->r3 = val; > } > > So it has a positive error setting allthough it has no flag to tell it > is an error. Wondering how it works at the end. It's a bug, but given that microblaze doesn't enable CONFIG_HAVE_ARCH_TRACEHOOK, most likely this function is unused there. > Alpha I'm not sure, I see nothing obvious in include/asm/ptrace.h or > include/asm/syscall.h Alpha doesn't enable CONFIG_HAVE_ARCH_TRACEHOOK, it just lacks the necessary interfaces, but it uses a3 register for this purpose, see arch/alpha/kernel/entry.S for details. -- ldv