Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp824608ybk; Wed, 13 May 2020 14:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznZi2mEXg0GrII9L1A/f4OeZPq/mJk+a2JcpU4fmFf86Ojk5gwvwRD2Tb8D46EeNoed0Re X-Received: by 2002:a05:6402:221b:: with SMTP id cq27mr1493316edb.65.1589404359561; Wed, 13 May 2020 14:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589404359; cv=none; d=google.com; s=arc-20160816; b=ILf8tC6wREBNTVHDcr/Ou+ikHPeWvkjo2N8+6fJB/b+NNgddI7fxkL3kYD7qyRbRfx mT0g5sIRYC+yoOeBXO4/3xc7otLk5lOMTNrjcTYcX5oBtekhW/O1Lxgod0G0tKm8lOuW 0uBeoJKnni/CP6SM4cAh2SeV+ZN8dkoKPlPt/E0jt0YcjryXN9+JuTQqgQ/OsO1vqOEw p0Jsu96h88vurj7sYYDdIcF5e+SopPaFzKyvMqDBFrBs6sCCENeSGe9jsd6b5jl+zusc 8WnUWqMijXCecr7uEWaOeLnVb5qjwMUjs+uNkaeanua6Hg//3+sXze4Al107Nr8jeQFE uZSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=AW0+AyzgHBrURohzyr7yHqlS7uFC5lm1/iy6e6/iIY8=; b=TIJfyzJHtqk72J2wOt+c73aqj3gHWBWpjcTMU0TdGSirIM+hwaSjp+TL2Mx0uzR+UU tgBCWXkUbb5GL62a4jOZyE3Chu9NVLzCHpwqksMaGAGeCyJqAgSd4wIHROOTx+rdoTUt WD1TYHBQQUF2ql0wq+DRsE25LKhS30O3ssG+8yAWluR9bQYgcZIChYVK6fKfmsUyxduY ZjYlmHOz1A2DQZYcIsFZXLer3TjURyNclej5QVjeYEtAyO6y34412OEPsZ0qeEWwvYTJ zN2r+EJ/iJ77Ub8MOmyDOmewmsJyqPMnYPAwPsAy+vFvTm5V/1tNMb53eBhZRpJwnuKX ai6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si514072eds.355.2020.05.13.14.12.16; Wed, 13 May 2020 14:12:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgEMVKv (ORCPT + 99 others); Wed, 13 May 2020 17:10:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:33028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgEMVKu (ORCPT ); Wed, 13 May 2020 17:10:50 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 007AF20575; Wed, 13 May 2020 21:10:48 +0000 (UTC) Date: Wed, 13 May 2020 17:10:47 -0400 From: Steven Rostedt To: Mathieu Desnoyers Cc: Thomas Gleixner , linux-kernel , x86 , paulmck , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , "Joel Fernandes, Google" , Boris Ostrovsky , Juergen Gross , Brian Gerst , Josh Poimboeuf , Will Deacon , Peter Zijlstra Subject: Re: [patch V4 part 1 05/36] x86/entry: Flip _TIF_SIGPENDING and _TIF_NOTIFY_RESUME handling Message-ID: <20200513171047.04c2c10e@gandalf.local.home> In-Reply-To: <1970736614.19996.1589403401588.JavaMail.zimbra@efficios.com> References: <20200505131602.633487962@linutronix.de> <20200505134058.560059744@linutronix.de> <1970736614.19996.1589403401588.JavaMail.zimbra@efficios.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 May 2020 16:56:41 -0400 (EDT) Mathieu Desnoyers wrote: > ----- On May 5, 2020, at 9:16 AM, Thomas Gleixner tglx@linutronix.de wrote: > > > Make sure task_work runs before any kind of userspace -- very much > > including signals -- is invoked. > > What is missing from this patch description is: _why_ is this deemed > useful ? > > Also, color me confused: is "do_signal()" actually running any user-space, > or just setting up the user-space stack for eventual return to signal handler ? > > Also, it might be OK, but we're changing the order of two things which > have effects on each other: restartable sequences abort fixup for preemption > and do_signal(), which also have effects on rseq abort. > > Because those two will cause the abort to trigger, I suspect changing > the order might be OK, but we really need to think this through. > > Thanks, > > Mathieu > > > > > Suggested-by: Andy Lutomirski > > Signed-off-by: Peter Zijlstra (Intel) > > Signed-off-by: Thomas Gleixner > > --- > > arch/x86/entry/common.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > --- a/arch/x86/entry/common.c > > +++ b/arch/x86/entry/common.c > > @@ -156,16 +156,16 @@ static void exit_to_usermode_loop(struct > > if (cached_flags & _TIF_PATCH_PENDING) > > klp_update_patch_state(current); > > > > - /* deal with pending signal delivery */ > > - if (cached_flags & _TIF_SIGPENDING) > > - do_signal(regs); > > - > > if (cached_flags & _TIF_NOTIFY_RESUME) { > > clear_thread_flag(TIF_NOTIFY_RESUME); > > tracehook_notify_resume(regs); > > rseq_handle_notify_resume(NULL, regs); > > } > > > > + /* deal with pending signal delivery */ > > + if (cached_flags & _TIF_SIGPENDING) > > + do_signal(regs); Looking deeper into this, it appears that do_signal() can freeze or kill the task. That is, it wont go back to user space here, but simply schedule out (being traced) or even exit (killed). Before the resume hooks would never be called in such cases, and now they are. -- Steve > > + > > if (cached_flags & _TIF_USER_RETURN_NOTIFY) > > fire_user_return_notifiers(); >