From patchwork Thu Feb 28 18:32:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 159426 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp987826oce; Thu, 28 Feb 2019 10:32:42 -0800 (PST) X-Google-Smtp-Source: APXvYqz2S1SoCMufm2sm79WA1Da0zIJCn/EW6/iOSKGVTh79gBL5DlojtKQ7dA/gj0OgdYE6WILk X-Received: by 2002:a63:5a5e:: with SMTP id k30mr499014pgm.345.1551378762738; Thu, 28 Feb 2019 10:32:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378762; cv=none; d=google.com; s=arc-20160816; b=kmwZVXBV6cu4W96LGycK5VQrrBc/fIWCOnkyPcd8C6hhpoVR60VMxou8ZztlkgFN1F 8qtvUZ9pSAR6XVFe2OS6bSRX4N4gXtIHVomKVlt4q3BmZilsVhm2jyi4w2Ih05f2YeyO MqA6HoHx4LEHB/HFRkvpvmn8nm4a5G6ltdXJk696fNECZC1H4/InSm2aEqyRdHkZvw5k iuTPIJ9d0xo5bPwS4Ul8w6oVcDDlvM/KvmQ6D6UFp71dt7khwKCoDqjSgxh0qrs5rEXH 5EuCJTVzkGxp1ph/0McotcCIWwAwYM6b7lmA8dpXy+mvSRmr/eQ/6Xu1Da5NNfM/fQzR EFKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=N+55Ubr8avT5uyxaBxho2pYETM+TH/SRUuscP2L1KN4=; b=VR2lvRt2pP5ZapuOSTtQDW7SMPflWpVJaJsoOI7INsqBmkO67ahXF8ODZtyIFB39IA BETbuWjaQE8XFCZptc0Tl2H5r5ew67GOksszr9MoSgCCRhtZoAaaLgjCW/0C05CzfBqT RPh6Q6t7vdq63pAIeGECuzGfiyq6DIXJ/X6tZ9K2UWTcd1gU7NyFkKu3AVQAfeSWbVM6 HD1pqdiZRaGwYNvYUFpZXkWQAJ6HB90daR6mvzeIC8h2kHe9ogTjE/nwPzKeArmMl4sX a54LBxmAAOp8ae/L02cUMxesUJqmKuUqOfBLfCvhQlmXiuZznl8tanSPMXCdHV7I2Z/N jjjA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 26si18242274pgq.348.2019.02.28.10.32.41; Thu, 28 Feb 2019 10:32:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387658AbfB1Sck (ORCPT + 31 others); Thu, 28 Feb 2019 13:32:40 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52918 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732645AbfB1Sci (ORCPT ); Thu, 28 Feb 2019 13:32:38 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2508416A3; Thu, 28 Feb 2019 10:32:38 -0800 (PST) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0DDEE3F5C1; Thu, 28 Feb 2019 10:32:34 -0800 (PST) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu , Andy Lutomirski , Borislav Petkov Subject: [PATCH 3/6] x86: clean up _TIF_SYSCALL_EMU handling using ptrace_syscall_enter hook Date: Thu, 28 Feb 2019 18:32:17 +0000 Message-Id: <20190228183220.15626-4-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228183220.15626-1-sudeep.holla@arm.com> References: <20190228183220.15626-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a new hook ptrace_syscall_enter that can be called from syscall entry code and it handles PTRACE_SYSEMU in generic code, we can do some cleanup using the same in syscall_trace_enter. Further the extra logic to find single stepping PTRACE_SYSEMU_SINGLESTEP in syscall_slow_exit_work seems unnecessary. Let's remove the same. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Signed-off-by: Sudeep Holla --- arch/x86/entry/common.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 7bc105f47d21..36457c1f87d2 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -70,22 +70,16 @@ static long syscall_trace_enter(struct pt_regs *regs) struct thread_info *ti = current_thread_info(); unsigned long ret = 0; - bool emulated = false; u32 work; if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) BUG_ON(regs != task_pt_regs(current)); - work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY; - - if (unlikely(work & _TIF_SYSCALL_EMU)) - emulated = true; - - if ((emulated || (work & _TIF_SYSCALL_TRACE)) && - tracehook_report_syscall_entry(regs)) + if (unlikely(ptrace_syscall_enter(regs))) return -1L; - if (emulated) + work = READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY; + if ((work & _TIF_SYSCALL_TRACE) && tracehook_report_syscall_entry(regs)) return -1L; #ifdef CONFIG_SECCOMP @@ -227,15 +221,7 @@ static void syscall_slow_exit_work(struct pt_regs *regs, u32 cached_flags) if (cached_flags & _TIF_SYSCALL_TRACEPOINT) trace_sys_exit(regs, regs->ax); - /* - * If TIF_SYSCALL_EMU is set, we only get here because of - * TIF_SINGLESTEP (i.e. this is PTRACE_SYSEMU_SINGLESTEP). - * We already reported this syscall instruction in - * syscall_trace_enter(). - */ - step = unlikely( - (cached_flags & (_TIF_SINGLESTEP | _TIF_SYSCALL_EMU)) - == _TIF_SINGLESTEP); + step = unlikely((cached_flags & _TIF_SINGLESTEP)); if (step || cached_flags & _TIF_SYSCALL_TRACE) tracehook_report_syscall_exit(regs, step); }