Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp596358pxf; Wed, 24 Mar 2021 11:09:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZukzOmrX9TZaLHQjpPiDNnEkOMN/Zq2q/MYtE3DhKzhSwgZMLqcGGHiBX0TgfrAIW/PvP X-Received: by 2002:a05:6402:1103:: with SMTP id u3mr4775625edv.205.1616609344782; Wed, 24 Mar 2021 11:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616609344; cv=none; d=google.com; s=arc-20160816; b=cyuRf4LdZSGpVlkPvOjYzTGs/8rkfBGc6wbDwFONqR0vuS89jr7XnL4cEXr2TxcHQv sZn6SFA05iuirYsKM/r4QO8OykiG8zNs3xEI7l5yEyxZgEFtV3PIKQPVLBzMH+8MR2n2 cyzjtzRFVKhiMM6EsOinIdT4GYt1gMMmsXfYXKRW3By8L0bpI6bK79NtnPHFO+96s6HF euRFa+Be6b/pFy136tWJT7rZdxNbd9wjBLAUH5b0AkqlW7Fzd6PpRIZv/VjPE8FyqaWw feV+Cj8FzznP1TvGBh8Y/q9c3P7ARuc8p+MtzQrIKw1Nvl//DnBY4EwIvqBGtlh8JLi7 BFGA== 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=Du4gu0kAmfrp2pVeRv1B8yQazMIyWyXKWQYhTMyk0gs=; b=P7CCiJMCWrXlE4Zq6F4Fq8/Hpxyb0qsJaEOw10b/GNCmomzEUU5S2ofA6SVYH9Q2XX wcJCb0hLjgVvETSk2RZRs4w2Y4r/CUfM0CBXEqUtf3xj0pFID2jhQmg4LUJn/6GGXsc7 lk0UwRkVSr9vMdNqJTCoHCHmXsLCFJbZMmTBoeI+ayoZCuWWblcAjpKPCQ8/ANUmvXRk PO4yOHSn1MAsNmmwZbfEUOxb6J1SwfyO89hAtgDywVSWvYx68IuEH01zhlwrJgTB2cmo bcWavIc4lO8oRPMZukRTe3qpFH6fntgpfaZSIlnxkvb+9wSp5r1urZIgN75CXsFhRXEV qMaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JLUte6mB; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj11si2308244ejb.589.2021.03.24.11.08.40; Wed, 24 Mar 2021 11:09:04 -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=@kernel.org header.s=k20201202 header.b=JLUte6mB; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237381AbhCXSH1 (ORCPT + 99 others); Wed, 24 Mar 2021 14:07:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:38276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236683AbhCXSHI (ORCPT ); Wed, 24 Mar 2021 14:07:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F1B161A24 for ; Wed, 24 Mar 2021 18:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616609227; bh=rntKfLiZjIJur0cJE9GfWsqklpTRAWKt+oAJMuQR90k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JLUte6mBidZkeN/akNI+rinyYjj1gEpTLC2YfAWVIvHBUAzaCZnPGjWUEHPm//jqb JFOWMkLu+BQtDOZ7VWREkNc+gk4UYfVxqFppY6fGvnsz2iP5D7FhbxAw1s061Ps6wI lipcm4BN7sFbqSwopH5Nllhxo8XeJzzxU4Me6qm+HJXjgr4L1bGfA4XW909ZRDEXBI 2SvPBqbSGF8BYQtJ8HJHoloN2CpEajQi0dwsi/4ilIf8CW1d8nhKzu2ldQwa/EYzsF i9WZ4htR545gDIFtjLXejP6SZMQpkhVqx80LKSJBqb2PMbSstxqkaDYUlrmtniEGeU jOvFtErrApokw== Received: by mail-ed1-f42.google.com with SMTP id z1so28745155edb.8 for ; Wed, 24 Mar 2021 11:07:07 -0700 (PDT) X-Gm-Message-State: AOAM5312XmAMyaxv76OrEtg5rG8IYWFoYrLyzyrnWsQdahKz5MFfHLGB JY7sdRJC2zGIexsY7xEaL7/PkbrmWOqZVZssH/sViQ== X-Received: by 2002:aa7:da98:: with SMTP id q24mr5005159eds.84.1616609225868; Wed, 24 Mar 2021 11:07:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Wed, 24 Mar 2021 11:06:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Is s390's new generic-using syscall code actually correct? To: Vasily Gorbik Cc: Andy Lutomirski , Sven Schnelle , X86 ML , linux-arch , Mark Rutland , LKML , Heiko Carstens , Christian Borntraeger Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 24, 2021 at 10:39 AM Vasily Gorbik wrote: > > Hi Andy, > > On Sat, Mar 20, 2021 at 08:48:34PM -0700, Andy Lutomirski wrote: > > Hi all- > > > > I'm working on my kentry patchset, and I encountered: > > > > commit 56e62a73702836017564eaacd5212e4d0fa1c01d > > Author: Sven Schnelle > > Date: Sat Nov 21 11:14:56 2020 +0100 > > > > s390: convert to generic entry > > > > As part of this work, I was cleaning up the generic syscall helpers, > > and I encountered the goodies in do_syscall() and __do_syscall(). > > > > I'm trying to wrap my head around the current code, and I'm rather confused. > > > > 1. syscall_exit_to_user_mode_work() does *all* the exit work, not just > > the syscall exit work. So a do_syscall() that gets called twice will > > do the loopy part of the exit work (e.g. signal handling) twice. Is > > this intentional? If so, why? > > > > 2. I don't understand how this PIF_SYSCALL_RESTART thing is supposed > > to work. Looking at the code in Linus' tree, if a signal is pending > > and a syscall returns -ERESTARTSYS, the syscall will return back to > > do_syscall(). The work (as in (1)) gets run, calling do_signal(), > > which will notice -ERESTARTSYS and set PIF_SYSCALL_RESTART. > > Presumably it will also push the signal frame onto the stack and aim > > the return address at the svc instruction mentioned in the commit > > message from "s390: convert to generic entry". Then __do_syscall() > > will turn interrupts back on and loop right back into do_syscall(). > > That seems incorrect. > > > > Can you enlighten me? My WIP tree is here: > > https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/log/?h=x86/kentry > > > > For all the details to that change we'd have to wait for Sven, who is back > next week. > > > Here are my changes to s390, and I don't think they're really correct: > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/diff/arch/s390/kernel/syscall.c?h=x86/kentry&id=58a459922be0fb8e0f17aeaebcb0ac8d0575a62c > > Couple of things: syscall_exit_to_user_mode_prepare is static, > and there is another code path in arch/s390/kernel/traps.c using > enter_from_user_mode/exit_to_user_mode. > > Anyhow I gave your branch a spin and got few new failures on strace test > suite, in particular on restart_syscall test. I'll try to find time to > look into details. I refreshed the branch, but I confess I haven't compile tested it. :) I would guess that the new test case failures are a result of the buggy syscall restart logic. I think that all of the "restart" cases except execve() should just be removed. Without my patch, I suspect that signal delivery with -ERESTARTSYS would create the signal frame, do an accidental "restarted" syscall that was a no-op, and then deliver the signal. With my patch, it may simply repeat the original interrupted signal forever. --Andy