From patchwork Tue Mar 26 00:28:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2334081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 156913FC54 for ; Tue, 26 Mar 2013 00:33:13 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UKHkc-0001xe-Tt; Tue, 26 Mar 2013 00:28:30 +0000 Received: from mail-da0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UKHkZ-0001xL-Nj for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2013 00:28:28 +0000 Received: by mail-da0-f45.google.com with SMTP id v40so3421871dad.32 for ; Mon, 25 Mar 2013 17:28:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-gm-message-state; bh=Bby8s5BOpT2m71HfZZ8+dvCbb70TiNImcK3IbUgZ3Co=; b=INnqYD+Du6tjeknooZneYhKclqqDXepThWuP+Pd04fN761i4kC/vn61wPAnS2XHhJK sMszoi37teub5jXfrr+ZUcBarI68QReX9VRrgvoSlu0nMYSuU4vcei+i2D4B7sSIGa5O Z35mEQMEOJYwTbw1WJEx1HXbasGVEk5Ocbf9io46FKpIbPcKmsBh+GjZGMkVxzqn1euY K83lG2x2PGoDsNFdUGUYyKmtUcS7UFOArpJLt1NcMyyWl6t6gt0y4DVSyntrob9ClOss Yw12TMLMgni5ddQFkEWf2PDBgYECE1Vqbq2CLtsQB4b7IfriaylLtXAoOWkthxVXN/tA gf+Q== X-Received: by 10.68.254.69 with SMTP id ag5mr20057679pbd.31.1364257705068; Mon, 25 Mar 2013 17:28:25 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id gf1sm15166993pbc.24.2013.03.25.17.28.22 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Mar 2013 17:28:23 -0700 (PDT) From: Kevin Hilman To: Russell King - ARM Linux Subject: Re: [PATCH 1/4] ARM: context tracking: add exception support References: <1363824121-26169-1-git-send-email-khilman@linaro.org> <1363824121-26169-2-git-send-email-khilman@linaro.org> <20130321214908.GU4977@n2100.arm.linux.org.uk> Date: Mon, 25 Mar 2013 17:28:21 -0700 In-Reply-To: <20130321214908.GU4977@n2100.arm.linux.org.uk> (Russell King's message of "Thu, 21 Mar 2013 21:49:08 +0000") Message-ID: <871ub39f8a.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQluWKLIezZW+WsNyI4lLxB138lfJB1MWaRxuTjc7KN+5WDUQfp/VgnJGtXk1EY6cEGvkCjo X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130325_202827_859683_BB9A9C4C X-CRM114-Status: GOOD ( 19.24 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, Frederic Weisbecker , linux-kernel@vger.kernel.org, Mats Liljegren , Paul McKenney , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Hi Russell, Russell King - ARM Linux writes: > On Wed, Mar 20, 2013 at 05:01:58PM -0700, Kevin Hilman wrote: >> Add ARM support for the context tracking subsystem by instrumenting >> exception entry/exit points. >> >> Special thanks to Mats Liljegren for testing, collaboration and adding >> support for exceptions/faults that were missing in early test versions. [...] >> @@ -405,7 +406,9 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs) >> unsigned int instr; >> siginfo_t info; >> void __user *pc; >> + enum ctx_state prev_state; >> >> + prev_state = exception_enter(); >> pc = (void __user *)instruction_pointer(regs); >> >> if (processor_mode(regs) == SVC_MODE) { >> @@ -433,8 +436,10 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs) >> goto die_sig; >> } >> >> - if (call_undef_hook(regs, instr) == 0) >> + if (call_undef_hook(regs, instr) == 0) { >> + exception_exit(prev_state); >> return; >> + } >> >> die_sig: >> #ifdef CONFIG_DEBUG_USER >> @@ -451,12 +456,17 @@ die_sig: >> info.si_addr = pc; >> >> arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6); >> + exception_exit(prev_state); > > So, FP emulation and VFP support happens via a separate path. Does this > also need to be instrumented? Looking a little closer at how FP/VFP support are handled along with the rest of the exceptions, I wondered if it might be simpler to do something like the patch below. It instruments the assembly directly using the existing usr_entry macro, and the ret_to_user path. Doing that would replace instrumenting the various handlers (do_DataAbort/do_PrefetchAbort), and would handle the FP emulation VFP support as well. If this looks OK, I can probably rework the syscall support as well. This approach covers the slow syscall return path already. Instead of forcing the slowpath on all syscalls, I would just need to instrument the syscall entry and fast syscall return. Kevin diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 0f82098..050472c 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -396,6 +396,9 @@ ENDPROC(__pabt_svc) #ifdef CONFIG_IRQSOFF_TRACER bl trace_hardirqs_off #endif +#ifdef CONFIG_CONTEXT_TRACKING + bl user_exit +#endif .endm .macro kuser_cmpxchg_check diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 3248cde..3bef99b 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -74,6 +74,9 @@ no_work_pending: #if defined(CONFIG_IRQSOFF_TRACER) asm_trace_hardirqs_on #endif +#if defined(CONFIG_CONTEXT_TRACKING) + bl user_enter +#endif /* perform architecture specific actions before user return */ arch_ret_to_user r1, lr