Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2654288imu; Mon, 17 Dec 2018 05:47:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/XPq3fU/bazeMiYZTXOlIbjy4K4ZIn2EQeufaSZTVLybh2TkDaKVq+9LwQHBu7P13hOW9gu X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12mr12944979plb.0.1545054448393; Mon, 17 Dec 2018 05:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545054448; cv=none; d=google.com; s=arc-20160816; b=N31OZC9CZ9R+/8jTQX+hC0dqbmvUKrOVqzZj2ULEmEs6grmKc94qcz8GZSRWZ2zYPd pCvgA1lZIAupJnt0+szH0GSdc9rxmSum1BYKNabaBYzDnsNZTpDdEh7nktEx+S+2ygF2 Bg7d44XZsuYithNcd40AA0kzcH4UcJw5dsfwL9UkFoimzTObDbs2mGKGKlGig2OdD5cI 2BLPaipacTKI4R0l7s7Q2JVU/DYPXALPVfo8T/ekW7qZv0SbvWdcAlueqy0OR+8cXANF Lm49whgFYm2f7WG9ps+vodiXBbhlaiu3AK6nPQGWQCVNINWZd4dnkBUSH8BVo492w1cC R1Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gXLIHiIVp7RItYm2otyVwDP+Xx4vWuxMpQ0FxtVxbYY=; b=XyToK+/9qoxzpK2bNw7sBVP/P6VsaGj60q7qhi0PYdlsud0avkLjWX/Hq0UECFmpMq m9nWFblkCo3ogdQpIpQ7SB6bFfmp8JHx67CilNsoDYBCW1PaxBTqkEDER37dcotm85WR dXB1FXdPaKheRP1pOQHC2aM/Wn+o+jk0wVq8NeNhIEGLXCsqUtgciJhhN2wy4t7tuI8z BhkrAlbHAH9h8mRrofWKFC/EBFgU+eNe+KHkWGGPqLprD+JhAxhVysP9r9dabnYZePRZ ialM+PbS45zwqvFL45X0TRExyTlsn06UYNKaUOtoFE4Sahq8gvRmbbjkTdANZo3/jBro REbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si11075894pgq.535.2018.12.17.05.47.11; Mon, 17 Dec 2018 05:47:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731697AbeLQL1d (ORCPT + 99 others); Mon, 17 Dec 2018 06:27:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38111 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726981AbeLQL1d (ORCPT ); Mon, 17 Dec 2018 06:27:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 357F9C0495B4; Mon, 17 Dec 2018 11:27:33 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.131]) by smtp.corp.redhat.com (Postfix) with SMTP id 2DF1C60F8D; Mon, 17 Dec 2018 11:27:32 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 17 Dec 2018 12:27:32 +0100 (CET) Date: Mon, 17 Dec 2018 12:27:31 +0100 From: Oleg Nesterov To: "Dmitry V. Levin" Cc: Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/ptrace: cleanup do_syscall_trace_enter Message-ID: <20181217112730.GA25465@redhat.com> References: <87efbe166y.fsf@concordia.ellerman.id.au> <20181203031823.GE11573@altlinux.org> <20181207011946.GA18558@altlinux.org> <87y391k2tq.fsf@concordia.ellerman.id.au> <20181207154255.GA28964@altlinux.org> <20181207155605.GB28964@altlinux.org> <20181207185226.GB31278@altlinux.org> <20181210132806.GA4177@redhat.com> <20181210133655.GH11942@altlinux.org> <20181216172828.GA25359@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181216172828.GA25359@altlinux.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Dec 2018 11:27:33 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/16, Dmitry V. Levin wrote: > > long do_syscall_trace_enter(struct pt_regs *regs) > { > + u32 cached_flags; > + > user_exit(); > > - if (test_thread_flag(TIF_SYSCALL_EMU)) { > - /* > - * A nonzero return code from tracehook_report_syscall_entry() > - * tells us to prevent the syscall execution, but we are not > - * going to execute it anyway. > - * > - * Returning -1 will skip the syscall execution. We want to > - * avoid clobbering any register also, thus, not 'gotoing' > - * skip label. > - */ > - if (tracehook_report_syscall_entry(regs)) > - ; > - return -1; > - } > + cached_flags = READ_ONCE(current_thread_info()->flags) & > + (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE); > > - /* > - * The tracer may decide to abort the syscall, if so tracehook > - * will return !0. Note that the tracer may also just change > - * regs->gpr[0] to an invalid syscall number, that is handled > - * below on the exit path. > - */ > - if (test_thread_flag(TIF_SYSCALL_TRACE) && > - tracehook_report_syscall_entry(regs)) > - goto skip; > + if (cached_flags) { > + int rc = tracehook_report_syscall_entry(regs); > + > + if (unlikely(cached_flags & _TIF_SYSCALL_EMU)) { > + /* > + * A nonzero return code from > + * tracehook_report_syscall_entry() tells us > + * to prevent the syscall execution, but > + * we are not going to execute it anyway. > + * > + * Returning -1 will skip the syscall execution. > + * We want to avoid clobbering any register also, > + * thus, not 'gotoing' skip label. > + */ > + return -1; > + } > + > + if (rc) { > + /* > + * The tracer decided to abort the syscall. > + * Note that the tracer may also just change > + * regs->gpr[0] to an invalid syscall number, > + * that is handled below on the exit path. > + */ > + goto skip; > + } > + } Looks good to me, Oleg.