From patchwork Fri Nov 9 01:53:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Haibo Xu (Arm Technology China)" X-Patchwork-Id: 10675237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C60D11057 for ; Fri, 9 Nov 2018 01:54:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0D1A2EA60 for ; Fri, 9 Nov 2018 01:54:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4A642EA7A; Fri, 9 Nov 2018 01:54:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8579F2EA60 for ; Fri, 9 Nov 2018 01:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rexdScjzhTP0mreXY8jBKk48mSyQCY1cyEkNMxCgtlM=; b=Z/YLnLMcWghqJK gd0KD3Hcm6wGE+dVM2Xvc0zqabDvcPZFEJFqzoQd+1rpHu3s+BE1cN/uEyJeTjFvnR+xeEQebSmKU GLrBMkQGL/ER8OYVU/0xC6xw3l+4vf2JPsZwreLUpsohs+q20BGXJ/O/b4ruOHvSSYxIjgn6jc7ul jstxLd4uGjSucjpS5lPt7TEZNGXsm9W720Z5IhU6hqfODXpM5CzTF2STX3pExv9HbPCMMtBEAeufY DPg8qDRWeTOFRNwsNiubyy4IDLiNtiVvM1KZk2tM0vYqJz5CzV/pP0ysolG2cC+A4XLRFcb7rS5Lz U7KJj0nALWhtpkr8wDpw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKw02-0001qx-UY; Fri, 09 Nov 2018 01:54:18 +0000 Received: from mail-am5eur03on061f.outbound.protection.outlook.com ([2a01:111:f400:fe08::61f] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKvzz-0001p1-40 for linux-arm-kernel@lists.infradead.org; Fri, 09 Nov 2018 01:54:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WuhcPb67nUa0jQOzUXkGnkHLiv6XJtKP5idexthoZy4=; b=qabgw0so7QWV8RdF9J5o0zMxbNXE45VgLHbJRBC+f850qDOb19VcCzyQl4t1AoSpXFXmm/95S+/ulCZ5C5A40zc06gq+0kFLH3ybobBdiJGZRS+2bbLka5Fba4qQA7yWRu3WlPsK2v1n5NAOacsPW2259veNo6uJusCFSCUsPWg= Received: from HE1PR08CA0064.eurprd08.prod.outlook.com (2603:10a6:7:2a::35) by HE1PR0802MB2505.eurprd08.prod.outlook.com (2603:10a6:3:df::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.25; Fri, 9 Nov 2018 01:53:41 +0000 Received: from DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by HE1PR08CA0064.outlook.office365.com (2603:10a6:7:2a::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1294.21 via Frontend Transport; Fri, 9 Nov 2018 01:53:41 +0000 Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT041.mail.protection.outlook.com (10.152.21.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1339.10 via Frontend Transport; Fri, 9 Nov 2018 01:53:41 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Fri, 9 Nov 2018 01:53:40 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Fri, 9 Nov 2018 01:53:39 +0000 Received: from haibo-VirtualBox (10.169.109.24) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2 via Frontend Transport; Fri, 9 Nov 2018 01:53:37 +0000 Date: Fri, 9 Nov 2018 09:53:28 +0800 From: Haibo.Xu To: , , Subject: [PATCH V2] arm64/ptrace: add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support Message-ID: <20181109015320.GA29354@haibo-VirtualBox> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:40.67.248.234; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(136003)(396003)(39860400002)(346002)(376002)(2980300002)(438002)(40434004)(199004)(189003)(106466001)(33656002)(186003)(336012)(23726003)(47776003)(106002)(4326008)(126002)(316002)(110136005)(476003)(54906003)(426003)(58126008)(2201001)(97736004)(1076002)(53936002)(6666004)(356004)(55016002)(50466002)(86362001)(46406003)(9686003)(478600001)(72206003)(68736007)(305945005)(8936002)(5660300001)(5024004)(2906002)(33896004)(81166006)(14444005)(33716001)(97756001)(77096007)(8676002)(26005)(6346003)(81156014)(486006)(8746002)(18370500001)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0802MB2505; H:nebula.arm.com; FPR:; SPF:Pass; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT041; 1:S7NUpaQs5SubSqEIBzIBFWDBBHzm4RUM834bZ/CnSYF3fvry5cUZJWHb35igtFPq06c4kZT2o0MZ4wyjcO34sg18fwuDALVQqeE5aPflcjfRZseqsz+xIxSqu/oC1QfX X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f585e11-b379-4eac-d53c-08d645e62cbc X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4608076)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060); SRVR:HE1PR0802MB2505; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2505; 3:BQULCY2pgkeskUNcXs48KNbsOMV3JCQfRlLeHumf6GmAhCVALbx/eOT0f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yBMP1j7/K+QQoOlmauA4sbXMZZEISVqgqeTnBNhTSvgjf6lNVPPHzoXgHe2+CLKKDX4rHQnREHJNDhpvPWlQ87CmJqbMlE0gcMrSHrMXVI4Zq7sIErVrZQn2MDrEK7hF/CXH6BOG+VqT/Mxd1uFe3UtuBgrRzrlSIz/Eom5P8YB8ovbqWFUQBB6dsjajL1cSnfULi7C0a7ughItDHNQiTBQp2u3vVPP7g3sACBn3/HEqNr8p8lVttLDD1nIZpTz9tmMCBznb3ouhAnIbCkrox0sg0pawK+U/keAE9jDmf/Uf8rfl/UiDnYLYUn5S83eK85OuVJkrk6SKlQrjdlB4vqErsvTNVCc8oVzIGza9DBmOmqIqrpg50f5yeIohmLMN2HUhWRuW X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193)(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93004095)(3231382)(944501410)(52105095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:HE1PR0802MB2505; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2505; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2505; 4:padOjG0GNphLURUlj4jayBEIyz06FenVuZW8Mdg2QlKMjeWtCO6xgR+bW3W8EfUelERtZTcWlwkofYT9oSFuSqDtmkLAgBMDIZ6eBGR6LhfU5kS8poEQnqJBWKjYwTDeMZasvkxuGaK9LS4haTwXS2PRH3+nQ0DaftYsz/v2kiwQK/pMbboc7pMRHOzaHto9LalAp/Q0n5lH+S8SoyDUOD0JAMX9EIpixfaMYLivSibR23wdlBLrvziNc0yS+/FRilcxyXgL/u0DiMC7ktfhG4i/c0uxlfhyYTolY4BuEEml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/OsToB+3za+x+wlVYDloRhe3oGVRJFOR0Ln0wpinTnAQIrAD4/D9/zqHh5HIvh1s54ClvZ7l8LLWKO5rbwUZermfAHwLbGgR/hlTNcSvstH9U0y1yfUAvKU+Yzw6MkT3VSZvDgjpbR+FvpoP2spa3e1I2Yg+dm2JhKHfS3Bxbhe3mHTQ==; 5:kvNN6u7ck2laIVeqltW2lql/o+rmgv6Xxi0i+SEvndSQSvPJp6uU+eFFIaoW+KV8dNdNCNWGAON6di/in2YPvbF47T+xjyNwCq9XJsMqmSBkvbzebF1I4DOqA4T8mN4+rmcmey78a6T+SOetouXyphQXbn3Kneb4H74h45XPO+8=; 7:boyCRaGmb28ytg5ir2rSq/TdqkakC5NXJGCRApLqles3NBNsmX6AlVo/MwT8WONuehvOb8nLwpM9K0neI3TevBQQUQmjGR4xXhFG9ClsJhYc1HJH6z23ZgU164G54BHGArna5p6ajht3tFPpqoaczg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2018 01:53:41.4871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f585e11-b379-4eac-d53c-08d645e62cbc X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[40.67.248.234]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2505 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181108_175415_772144_4E0FC070 X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard@nod.at, nd@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support on arm64. This follows the x86 semantics for invoking ptrace hooks, and has been verified on an arm64 test machine. This functionality is used by the Gvisor project, for running in ptrace mode. On arm64 we will need ptrace mode rather than kvm mode for situations where we are already running inside a virtual machine (as nested virtualisation will only be available in newer cores). Signed-off-by: Haibo.Xu Signed-off-by: Bin.Lu Reviewed-by: Steve Capper --- arch/arm64/include/asm/thread_info.h | 5 ++++- arch/arm64/include/uapi/asm/ptrace.h | 2 ++ arch/arm64/kernel/ptrace.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) -- 2.7.4 IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 46c3b93..5060d2d 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -75,6 +75,7 @@ struct thread_info { * TIF_SYSCALL_TRACE - syscall trace active * TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace * TIF_SYSCALL_AUDIT - syscall auditing + * TIF_SYSCALL_EMU - syscall emulation active * TIF_SECOMP - syscall secure computing * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary @@ -91,6 +92,7 @@ struct thread_info { #define TIF_SYSCALL_AUDIT 9 #define TIF_SYSCALL_TRACEPOINT 10 #define TIF_SECCOMP 11 +#define TIF_SYSCALL_EMU 12 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 #define TIF_RESTORE_SIGMASK 20 @@ -106,6 +108,7 @@ struct thread_info { #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) +#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU) #define _TIF_UPROBE (1 << TIF_UPROBE) #define _TIF_32BIT (1 << TIF_32BIT) @@ -115,7 +118,7 @@ struct thread_info { #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \ - _TIF_NOHZ) + _TIF_NOHZ | _TIF_SYSCALL_EMU) #endif /* __KERNEL__ */ #endif /* __ASM_THREAD_INFO_H */ diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h index b5c3933..04ab06f 100644 --- a/arch/arm64/include/uapi/asm/ptrace.h +++ b/arch/arm64/include/uapi/asm/ptrace.h @@ -23,6 +23,8 @@ #include +#define PTRACE_SYSEMU 31 +#define PTRACE_SYSEMU_SINGLESTEP 32 /* * PSR bits diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index fc35e06..ff3e322 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -165,6 +165,9 @@ void ptrace_disable(struct task_struct *child) * is likely to cause regressions on obscure architectures. */ user_disable_single_step(child); +#ifdef TIF_SYSCALL_EMU + clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); +#endif } #ifdef CONFIG_HAVE_HW_BREAKPOINT @@ -1351,6 +1354,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs) if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); + if (test_thread_flag(TIF_SYSCALL_EMU)) { + tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); + return -1; + } + /* Do the secure computing after ptrace; failures should be fast. */ if (secure_computing(NULL) == -1) return -1; @@ -1373,6 +1381,15 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs) if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); + + /* + * We only get here because of TIF_SINGLESTEP, + * for PTRACE_SYSEMU_SINGLESTEP, we already reported + * the syscall instruction in syscall_trace_enter(). + */ + if (test_thread_flag(TIF_SINGLESTEP) && + !test_thread_flag(TIF_SYSCALL_EMU)) + tracehook_report_syscall_exit(regs, 1); } /*