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 5194E232437 for ; Tue, 14 Jan 2025 13:48:46 +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=1736862528; cv=none; b=TfOKuyzdB8ylYp1MKqduxQ2k8hncyE2zj6zGqUGQE0yTLCfT8G3N4AXD715CIUYArwDsrqlz5Ir98dkQr0F7bfrZWLMri1z0sBTNYEmW0m8GG+S73Etox6frCOmlbFTuASDFOnUI4fPwKr8NQuzzp5dC5TNkjfmURWC3WvwiF34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736862528; c=relaxed/simple; bh=lHYPMwjF4KMUURuLmzK4VXUdiqaw1H7TuoDXNxNJqYA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tjwRYXHbzdno77R2St8uDEZRIsVd2lp72E1b2+EdabWfuGUfa+SoLUC2BwbQDopzysTDf3aggESUjtyumWZFdCo5aSjwkA90JsIVGFRt9BFp69t8ySPefxHn6t/H2MJQvsvQUxVWo4Dsz9sZ+M3BfnJma2uxavpdklf3dw9LKVo= 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 2113A72C8CC; Tue, 14 Jan 2025 16:48:45 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 0DD4B7CCB3A; Tue, 14 Jan 2025 15:48:44 +0200 (IST) Date: Tue, 14 Jan 2025 15:48:44 +0200 From: "Dmitry V. Levin" To: Alexey Gladkov Cc: Oleg Nesterov , Michael Ellerman , Eugene Syromyatnikov , Mike Frysinger , Renzo Davoli , Davide Berardi , strace-devel@lists.strace.io, Madhavan Srinivasan , Nicholas Piggin , Christophe Leroy , 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: <20250114134844.GA10630@strace.io> References: <20250113170925.GA392@strace.io> <20250113171054.GA589@strace.io> 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=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jan 14, 2025 at 02:00:16PM +0100, Alexey Gladkov wrote: > On Mon, Jan 13, 2025 at 07:10:54PM +0200, Dmitry V. Levin wrote: > > Bring syscall_set_return_value() in sync with syscall_get_error(), > > and let upcoming ptrace/set_syscall_info selftest pass on powerpc. > > > > This reverts commit 1b1a3702a65c ("powerpc: Don't negate error in > > syscall_set_return_value()"). > > > > Signed-off-by: Dmitry V. Levin > > --- > > arch/powerpc/include/asm/syscall.h | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h > > index 3dd36c5e334a..422d7735ace6 100644 > > --- a/arch/powerpc/include/asm/syscall.h > > +++ b/arch/powerpc/include/asm/syscall.h > > @@ -82,7 +82,11 @@ static inline void syscall_set_return_value(struct task_struct *task, > > */ > > if (error) { > > regs->ccr |= 0x10000000L; > > - regs->gpr[3] = error; > > + /* > > + * In case of an error regs->gpr[3] contains > > + * a positive ERRORCODE. > > + */ > > + regs->gpr[3] = -error; > > After this change the syscall_get_error() will return positive value if > the system call failed. Since syscall_get_error() still believes > regs->gpr[3] is still positive in case !trap_is_scv(). > > Or am I missing something? syscall_get_error() does the following in case of !trap_is_scv(): /* * If the system call failed, * regs->gpr[3] contains a positive ERRORCODE. */ return (regs->ccr & 0x10000000UL) ? -regs->gpr[3] : 0; That is, in !trap_is_scv() case it assumes that regs->gpr[3] is positive and is going to return a negative value (-ERRORCODE). > It looks like the selftest you mentioned in the commit message doesn't > check the !trap_is_scv() branch. The selftest is architecture-agnostic, it just executes syscalls and checks whether the data returned by PTRACE_GET_SYSCALL_INFO meets expectations. Do you mean that syscall() is not good enough for syscall invocation from coverage perspective on powerpc? See also commit d72500f99284 ("powerpc/64s/syscall: Fix ptrace syscall info with scv syscalls"). -- ldv