From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19285C433ED for ; Wed, 19 May 2021 13:10:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98D5C61353 for ; Wed, 19 May 2021 13:10:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98D5C61353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lWY4t7Vl+Lxb46x4iqwNZnptasGfn2zEke9qoQfGHqo=; b=XatdlQoblnIBHhwiMI2S32S/vT j9gWBcPaMAEnSjHUmiyOrCObsZa3w7wG0e2lyQTI/vvoBvOJkKR2BI3OhnLLIG+JYhvoG7EjXQfL+ xiLn8n7yY2/lG4fHiNisM1dWp6rki+RdctL1x8k5tERHElc/bZ2MWkybrcfEXhYKokGGk91R9Odop DcEyQ8nKOO+aGEYdPfI/PTCG28WSf8bsltEH871jUVHg4G7L3hALgGKiqJx+QQnL42L2Mg6FYWoBC Ce5wBlnsEeHbKGJ7EmEduN7huc5Q7iiGFT8rBKr0arKNi+LJx0Q5EGMDULtErqB9dYU+k8Twmtyiv 8myArlKQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljLvy-0042Q8-0o; Wed, 19 May 2021 13:08:22 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljLVu-003wVk-29 for linux-arm-kernel@desiato.infradead.org; Wed, 19 May 2021 12:41:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=xYLNDdht/Xw/6QPSpy2x93GjkhAg2/xOiaUSpxseyK0=; b=djm9Cmj6f/+yYAgM3Ihwtrhjk1 Wd3EK2I7N0SzawRLHGZzUg46efbATigireNVl1KWFWRpdJs+Eh3wyi9B3QyZgmxKHUhkiZnNqEcCC rwlMAslCvgxDKDEBngJlIaIvWJIvH25CR7DilMGrXbLxldVLkJHpqrcRfLSwZxUdeWqBPimXCemNJ usRJlY3QAXCmbNMz32BrnBxTT/YZjoiP1ogW3PbpAn9heWj5EplGDlo9p0hbL69uoRc6fydTk3i1H 17rdtBDO8JaOFgSfv1tNjqvTpzUWukUtnDXu/Uxx2POR9XJn8ORQd3WEocR8JburyzEQAnSCuGkYs erYj2NsQ==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ljLVr-00FSox-9y for linux-arm-kernel@lists.infradead.org; Wed, 19 May 2021 12:41:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3332101E; Wed, 19 May 2021 05:41:22 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E2E193F73B; Wed, 19 May 2021 05:41:21 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, will@kernel.org, joey.gouly@arm.com Subject: [PATCH v2 12/19] arm64: entry: improve bad_mode() Date: Wed, 19 May 2021 13:38:55 +0100 Message-Id: <20210519123902.2452-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210519123902.2452-1-mark.rutland@arm.com> References: <20210519123902.2452-1-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210519_054123_411117_AD4FFD32 X-CRM114-Status: GOOD ( 14.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Our use of bad_mode() has a few rough edges: * AArch64 doesn't use the term "mode", and refers to "Execution states", "Exception levels", and "Selected stack pointer". * We log the exception type (SYNC/IRQ/FIQ/SError), but not the actual "mode" (though this can be deocded from the SPSR value). * We use bad_mode() as a second-level handler for unexpected synchronous exceptions, where the "mode" is legitimate, but the specific exception is not. * We dump the ESR value, but call this "code", and so it's not clear to all readers that this is the ESR. ... and all of this can be someqhat opaque to those who aren't extremely familiar with the code. Let's make this a bit clearer by having bad_mode() log "Unhandled ${TYPE} exception" rather than "Bad mode in ${TYPE} handler", using "ESR" rather than "code", and having the final panic() log "Unhandled exception" rather than "Bad mode". In future we'd like to log the specific architectural vector rather than just the type of exception, so we also split the core of basd_mode() out into a helper called __panic_unhandled(), which takes the vector as a string argument. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Marc Zyngier Cc: Will Deacon --- arch/arm64/kernel/entry-common.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 25531a0b547e..b43ef1a918a4 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -160,31 +160,32 @@ static void do_interrupt_handler(struct pt_regs *regs, extern void (*handle_arch_irq)(struct pt_regs *); extern void (*handle_arch_fiq)(struct pt_regs *); -/* - * bad_mode handles the impossible case in the exception vector. This is always - * fatal. - */ -asmlinkage void noinstr bad_mode(struct pt_regs *regs, int reason, unsigned int esr) +static void noinstr __panic_unhandled(struct pt_regs *regs, const char *vector, + unsigned int esr) { - const char *handler[] = { - "Synchronous Abort", - "IRQ", - "FIQ", - "Error" - }; - arm64_enter_nmi(regs); console_verbose(); - pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n", - handler[reason], smp_processor_id(), esr, + pr_crit("Unhandled %s exception on CPU%d, ESR 0x%08x -- %s\n", + vector, smp_processor_id(), esr, esr_get_class_string(esr)); __show_regs(regs); - panic("bad mode"); + panic("Unhandled exception"); } +asmlinkage void noinstr bad_mode(struct pt_regs *regs, int reason, unsigned int esr) +{ + const char *handler[] = { + "Synchronous Abort", + "IRQ", + "FIQ", + "Error" + }; + + __panic_unhandled(regs, handler[reason], esr); +} #ifdef CONFIG_ARM64_ERRATUM_1463225 static DEFINE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa); -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel