From patchwork Thu Mar 21 00:01:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2310621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id BDC74DF24C for ; Thu, 21 Mar 2013 00:05: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 1UISxi-0005tV-CO; Thu, 21 Mar 2013 00:02:30 +0000 Received: from mail-pb0-f46.google.com ([209.85.160.46]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UISxN-0005oK-Ro for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2013 00:02:11 +0000 Received: by mail-pb0-f46.google.com with SMTP id uo15so1755192pbc.33 for ; Wed, 20 Mar 2013 17:02:08 -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:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=FcyR3ocdJovd6sGZasVLbFCV8dPAaSdP9FT4fEbxSoU=; b=EeZ/nbwT+ItDJzByM9ebAdB2wK6vWRHr4/ACiZG9OTJvxd03LjgEG3DoPGcjXvqSB3 bjtaKuFznPp1QjzUmsL1opV5BDkXrmlOLO32k4Ylt2hr5LfbFLpFyO5LFA+5LTGbS9LI 5LmIpZEGHuXZ3sF+j+YRQ02icYneNawLV7XQFTOSw+aByit8uBqLSMYoXKGeXdIeZyQn 0cdYkphTPIBxY1TM24Yiu7eHN3rjM8ov+zW2m1ertDcWdYSgHHqVwmgJb3c7xv8fS3Hf ffdn+g4ekAXlQqJyy9XBdsIgn4b3Um2fJJudN83kqJuhFdfQFN1O/JQN3Gu3wdB9wOmh pYNQ== X-Received: by 10.68.137.42 with SMTP id qf10mr11715363pbb.80.1363824128081; Wed, 20 Mar 2013 17:02:08 -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 cy4sm3751159pbc.13.2013.03.20.17.02.06 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 20 Mar 2013 17:02:07 -0700 (PDT) From: Kevin Hilman To: Frederic Weisbecker , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] ARM: context tracking: add exception support Date: Wed, 20 Mar 2013 17:01:58 -0700 Message-Id: <1363824121-26169-2-git-send-email-khilman@linaro.org> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1363824121-26169-1-git-send-email-khilman@linaro.org> References: <1363824121-26169-1-git-send-email-khilman@linaro.org> X-Gm-Message-State: ALoCoQmGIlyIv0mZ7deu0KjVYFk32y6SW34Tk5Y8iFdDdyBU7saMQAzFeYn0IpmYSX51nfFn7+UT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130320_200210_072060_5D387827 X-CRM114-Status: GOOD ( 16.31 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.46 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Mats Liljegren , Paul McKenney , linaro-kernel@lists.linaro.org, 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Cc: Mats Liljegren Signed-off-by: Kevin Hilman --- arch/arm/kernel/traps.c | 18 +++++++++++++++++- arch/arm/mm/fault.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 1c08911..0e5f9fa 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -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); } asmlinkage void do_unexp_fiq (struct pt_regs *regs) { + enum ctx_state prev_state; + + prev_state = exception_enter(); printk("Hmm. Unexpected FIQ received, but trying to continue\n"); printk("You may have a hardware problem...\n"); + exception_exit(prev_state); } /* @@ -467,6 +477,9 @@ asmlinkage void do_unexp_fiq (struct pt_regs *regs) */ asmlinkage void bad_mode(struct pt_regs *regs, int reason) { + enum ctx_state prev_state; + + prev_state = exception_enter(); console_verbose(); printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]); @@ -746,7 +759,9 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs) { unsigned long addr = instruction_pointer(regs); siginfo_t info; + enum ctx_state prev_state; + prev_state = exception_enter(); #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_BADABORT) { printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n", @@ -762,6 +777,7 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs) info.si_addr = (void __user *)addr; arm_notify_die("unknown data abort code", regs, &info, instr, 0); + exception_exit(prev_state); } void __readwrite_bug(const char *fn) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 5dbf13f..759b70d 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -424,9 +425,15 @@ do_translation_fault(unsigned long addr, unsigned int fsr, pgd_t *pgd, *pgd_k; pud_t *pud, *pud_k; pmd_t *pmd, *pmd_k; - - if (addr < TASK_SIZE) - return do_page_fault(addr, fsr, regs); + enum ctx_state prev_state; + + prev_state = exception_enter(); + if (addr < TASK_SIZE) { + int ret; + ret = do_page_fault(addr, fsr, regs); + exception_exit(prev_state); + return ret; + } if (user_mode(regs)) goto bad_area; @@ -472,10 +479,12 @@ do_translation_fault(unsigned long addr, unsigned int fsr, goto bad_area; copy_pmd(pmd, pmd_k); + exception_exit(prev_state); return 0; bad_area: do_bad_area(addr, fsr, regs); + exception_exit(prev_state); return 0; } #else /* CONFIG_MMU */ @@ -494,7 +503,12 @@ do_translation_fault(unsigned long addr, unsigned int fsr, static int do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { + enum ctx_state prev_state; + + prev_state = exception_enter(); do_bad_area(addr, fsr, regs); + exception_exit(prev_state); + return 0; } @@ -542,9 +556,11 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { const struct fsr_info *inf = fsr_info + fsr_fs(fsr); struct siginfo info; + enum ctx_state prev_state; + prev_state = exception_enter(); if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs)) - return; + goto out; printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n", inf->name, fsr, addr); @@ -554,6 +570,8 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs) info.si_code = inf->code; info.si_addr = (void __user *)addr; arm_notify_die("", regs, &info, fsr, 0); +out: + exception_exit(prev_state); } void __init @@ -574,9 +592,11 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs) { const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr); struct siginfo info; + enum ctx_state prev_state; + prev_state = exception_enter(); if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs)) - return; + goto out; printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n", inf->name, ifsr, addr); @@ -586,6 +606,8 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs) info.si_code = inf->code; info.si_addr = (void __user *)addr; arm_notify_die("", regs, &info, ifsr, 0); +out: + exception_exit(prev_state); } #ifndef CONFIG_ARM_LPAE