Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp995002ybk; Wed, 13 May 2020 19:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsmqgB3P/CfRq2OqG/U0zvuFv3aQO0C/6FL4Hcs5AZsjgu1gXjGxiWnwMOH1LqnIUCNArL X-Received: by 2002:a50:c3c2:: with SMTP id i2mr2226668edf.227.1589424848040; Wed, 13 May 2020 19:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589424848; cv=none; d=google.com; s=arc-20160816; b=zKhdq5vKvykMF1DKDh26c//bRPw3I3E4CcxH1F16fm2YF3Mf21TtxgGLNZgVRmcB1q hnnstyccVYT1GpM/YldD6/qbB+BEFwGriPiljjLe3YzC1X9mE1U+FgNLL5gGAqYDByph dcOEC3aON0x7/nMUvKM9PFEMPaT5vsNdF2LDaxe6KvhZbecz3UligYVhSzkGgtfjOeEN e/eR4ZvBWZN5JYEDFTCu6WuaoNTxODBfF6ABM7E2wB+XXy+ND9rFCzPAZ4N2Eht0K4dU FQoBIdKa90BZ7lQ6ch/8Lr1IJ/ZZcDu3R4fJEigDq5jRgKdOXDLAH4aQFEFhUIWs9CDl Qn1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=RluM+yQK+xOpY5YHus0NtCagZdVL/MNnexkXbC1Zk10=; b=v3wCTVWL9w7zShXHUNOkl+zq8zRkmDalphVzLgnwCHk5iZwjT9/q6tMm0gmVzWOHhZ YGDa5lQdY1IyzE/tYKzowD3bMuisRw+9Hfx1iZ8i2hQpUm1DI2SU5i/MfcE6LScsq9C4 g62T6POh5sPf5dwqm0v7CYZL5H5nlwq6bdGWEWXQU57s5wqA36vpa/f4lk2kMF+HUGbf WH8SpgKqVZdfeqkFqQtD75JvOIwAI16XgBRB3XpZfUZw78zsSbojUGfKgkoRefA8OEfz KvgZLzTwKVSeIl/RqXnD4hYDOMxGclleghAtWYIVLqV/aKOg8b+45+bIBJUfDjmD91n1 V+yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=BrKd6shG; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k29si749636edj.567.2020.05.13.19.53.45; Wed, 13 May 2020 19:54:08 -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=@efficios.com header.s=default header.b=BrKd6shG; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726060AbgENCv4 (ORCPT + 99 others); Wed, 13 May 2020 22:51:56 -0400 Received: from mail.efficios.com ([167.114.26.124]:48868 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbgENCvz (ORCPT ); Wed, 13 May 2020 22:51:55 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 2F0EB2A1935; Wed, 13 May 2020 22:51:54 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id yAUOqIp6SuWL; Wed, 13 May 2020 22:51:53 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id C75892A16C4; Wed, 13 May 2020 22:51:53 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com C75892A16C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1589424713; bh=RluM+yQK+xOpY5YHus0NtCagZdVL/MNnexkXbC1Zk10=; h=Date:From:To:Message-ID:MIME-Version; b=BrKd6shGetVN8DFqTRaTV0b0y01VZ5+jyi98ZmwqkUhQzvrhVd568wRKKjZSH7j9/ AvT9ItTj5xV3WSSStHJd1QqoSA6dodY/jRt4rNSA8S855utitf0acbzEQ8odXNr8aJ OMXbmcgPx/BXFsrCOG4pSqISj5MYdPsckWcXba/RlpJXoggiRJXlVutgMfRvvcidaq 2VEvN4rA2qliKooc4AG3BjD1mq9MWtgYNVk3f9Kc/51bZxHnsv9bqidV97auYxV/MY 2pAYvBL/Sf0Ly/sydKn3LhJ1uPcxzdEA7cBuVtmS9KXFa4x20rrST80r5XCcRgAMKi QJUX4RuC3Gdvw== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nVsOAfApGQzI; Wed, 13 May 2020 22:51:53 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id B29C12A1737; Wed, 13 May 2020 22:51:53 -0400 (EDT) Date: Wed, 13 May 2020 22:51:53 -0400 (EDT) From: Mathieu Desnoyers To: Thomas Gleixner Cc: rostedt , 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 Message-ID: <1779765540.20682.1589424713646.JavaMail.zimbra@efficios.com> In-Reply-To: <87v9kzz862.fsf@nanos.tec.linutronix.de> References: <20200505131602.633487962@linutronix.de> <20200505134058.560059744@linutronix.de> <1970736614.19996.1589403401588.JavaMail.zimbra@efficios.com> <20200513171047.04c2c10e@gandalf.local.home> <87v9kzz862.fsf@nanos.tec.linutronix.de> Subject: Re: [patch V4 part 1 05/36] x86/entry: Flip _TIF_SIGPENDING and _TIF_NOTIFY_RESUME handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3928 (ZimbraWebClient - FF76 (Linux)/8.8.15_GA_3928) Thread-Topic: x86/entry: Flip _TIF_SIGPENDING and _TIF_NOTIFY_RESUME handling Thread-Index: 2EQzd3LgZ/4HR7uFV7jb8D0jmAXxWw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On May 13, 2020, at 8:12 PM, Thomas Gleixner tglx@linutronix.de wrote: [...] > >>> Mathieu Desnoyers wrote: > >>> 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 ? > > I'm surprised that you can't answer that question yourself. How did you > ever make rseq work and how did rseq_signal_deliver() end up in > setup_rt_frame()? > > Hint: Tracing might answer that question > > And to cut it short: > > Exit to user space happnes only through ONE channel, i.e. leaving > prepare_exit_to usermode(). > [...] Yes, I'm very well aware of this. But the patch commit message states: "Make sure task_work runs before any kind of userspace -- very much including signals -- is invoked." which seems to imply that "userspace" can be "invoked" before the task_work runs. Which makes no sense whatsoever. Hence my confused state. >>> 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. > > That's a purely academic problem. The order is completely > irrelevant. You have to handle any order anyway: Yes indeed, whether either a signal handler frame fixup or return IP fixup fires first (clearing the rseq_cs pointer in the process) is irrelevant, because they will have the effect on the user-space program's flow. And as you say, given it is run in a loop and can be preempted, any order can happen here, so we have to be prepared for it. This loop has caused me tons of headaches when stress-testing on NUMA machines by the way. > That said, even for the case Andy and Peter were looking at (MCE) the > ordering is completely irrelevant. Not sure about that, see Andy's follow up. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com