Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp779177ybj; Tue, 5 May 2020 07:26:33 -0700 (PDT) X-Google-Smtp-Source: APiQypIQWI4GVsCqLtTfnCkOkhKL4SF5gMAlleBTIvGQ0Rkmr5vLJRllWsyMSzEME2QutBo5VdgD X-Received: by 2002:a50:9f4a:: with SMTP id b68mr2902065edf.108.1588688793492; Tue, 05 May 2020 07:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588688793; cv=none; d=google.com; s=arc-20160816; b=wlu/4J+BGblhuqO2BAP+Ji+DErKTlYVWjzlWzjs2nXrA7bstHA38YQLvhdxLaDRqjC Ix1m5ze9Acbc04gRpNKLMtQXbxrH0KsDreClHKGiZkNEGG6BHfOKnlikZD6sD7QVPaXV imGG+wcIgcEAsDNlvhNveBO7A7wqAhYLm0blLqMI752Wz3i5pZ3f1VZ3xuQ22sriOFKc iCyUoPNTcvbstVqVzT76DvUAt0Tks93DntNYptGLve4rpJ/uGLcSgteNNCqa5T/skSHF +wDOSTkbg7QyjT0upm0Npptsc+CqO1PdeuTX2MoqOmdA4lnD5DS4Lcu0W4uJ/IrGhiwE 58lg== 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:subject:cc:to:from:date:user-agent:message-id; bh=aVqAMbQSAD0edSzUebU4+4DFzUN/T7yBHlYPDubwCwE=; b=XIGZvmGCZeoSAELhdnB3i8jcuALV3AVbqvIwOCLNA7yjtGB5YzLe9Z3zOERvUmMqTd DQnwh8+qcOa31QW02pJiHOLPr3cz2zCL8zEEc7UAr4tx9dUG/HQXT3LIOuARbPaJ8IMl zj8NfZvpnjWFMRgrX4YFyJEKZseO8clgw0mueriPMoLJ/D293og10zFXZpg8W8KToknu IIa0Um/m4IOa4onu5rrpJ1eZ5Fu+MjjQjbolmxshjc8eb29ybcE0n4e79yfCD3FJHdA8 AAVVqSxFPAUAHDwaIAptw8936bA5xRs9Afl5ybCtc9sBCSziGsXivYevolD69YLkHnB0 sFjg== 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 p15si1223246edy.132.2020.05.05.07.26.09; Tue, 05 May 2020 07:26:33 -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 S1729437AbgEEONw (ORCPT + 99 others); Tue, 5 May 2020 10:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729372AbgEEONt (ORCPT ); Tue, 5 May 2020 10:13:49 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04CEC061A10 for ; Tue, 5 May 2020 07:13:48 -0700 (PDT) Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jVyK0-0000LM-Eb; Tue, 05 May 2020 16:13:20 +0200 Received: from nanos.tec.linutronix.de (localhost [IPv6:::1]) by nanos.tec.linutronix.de (Postfix) with ESMTP id E3E31FFC8D; Tue, 5 May 2020 16:13:19 +0200 (CEST) Message-Id: <20200505134058.560059744@linutronix.de> User-Agent: quilt/0.65 Date: Tue, 05 May 2020 15:16:07 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, "Paul E. McKenney" , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon , "Peter Zijlstra (Intel)" Subject: [patch V4 part 1 05/36] x86/entry: Flip _TIF_SIGPENDING and _TIF_NOTIFY_RESUME handling References: <20200505131602.633487962@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure task_work runs before any kind of userspace -- very much including signals -- is invoked. 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); + if (cached_flags & _TIF_USER_RETURN_NOTIFY) fire_user_return_notifiers();