From patchwork Mon Feb 14 09:59:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Stezenbach X-Patchwork-Id: 12745413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EBD7C433EF for ; Mon, 14 Feb 2022 11:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc: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=VasJ77ucVKGwM3ZW4yH99NS5+66dYxcTxQjbfuYVMwg=; b=q9pX5u8oRegKD0 cbl/c2foH6f4C/SuSz6HsAZwJFWVKuRDG/OVK2UGk7PPs+6Y+681Ml7YJ5oxmY8WagnPKSlf1I9ax clCEn0mZPZYoDbtjR/H+DM91aFvlKR4slgjbJvzLssJaw3XC2BSazccQzSb6QelgYAcjSlKes3RTo UeRz/rl13DDzCQac2TiQuNNYfqo3M71/QiZjbeQQcowcIXH6mP05QG3FeegLrsnKNSiTfNNaE8YaY zkczEE3Ik4SRJyyNMnSHP5SpDDzlqkEQIvIRa4m5D4Jvm6zRm1GV0BO+dGvMH4x+b7a9CJIJ/wAfM xFsF9Ep6GyniBKtTTGJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJZKW-00EkQz-1J; Mon, 14 Feb 2022 11:15:40 +0000 Received: from mail.sig21.net ([217.197.84.222]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJY9j-00ENiy-J2 for linux-arm-kernel@lists.infradead.org; Mon, 14 Feb 2022 10:00:29 +0000 Received: from localhorst ([127.0.0.1]) by mail.sig21.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJY97-0001Cx-FY ; Mon, 14 Feb 2022 10:59:49 +0100 Received: from js by abc.local with local (Exim 4.95) (envelope-from ) id 1nJY97-000490-1L; Mon, 14 Feb 2022 10:59:49 +0100 Date: Mon, 14 Feb 2022 10:59:49 +0100 From: Johannes Stezenbach To: Russell King Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm kgdb: fix breakpoint for thumb2 Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220214_020027_670665_50068E60 X-CRM114-Status: GOOD ( 11.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Entering kdb via SysRq-G with CONFIG_THUMB2_KERNEL=y on Cortex-A7 in Qemu results in an Ooops, and it is not possible to continue because of "Catastrophic error detected". The root cause is using an arm breakpoint instruction in thumb code. For the breakpoint instruction I used this reference: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdbserver/linux-aarch32-low.cc#l31 0xf7fxaxxx are UDF encoding T2 instructions (32bit, permanently undefined). Signed-off-by: Johannes Stezenbach --- Wrt arm GDB_BREAKINST maybe it is also needed to use something like #ifdef CONFIG_AEABI #define GDB_BREAKINST 0xe7f001f0 #else #define GDB_BREAKINST 0xef9f0001 #endif but I could not test if it makes a difference diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h index 8de1100d1067..7e6ed3171b54 100644 --- a/arch/arm/include/asm/kgdb.h +++ b/arch/arm/include/asm/kgdb.h @@ -34,16 +34,22 @@ * make our lives much much simpler. :) */ #define BREAK_INSTR_SIZE 4 +#ifdef CONFIG_THUMB2_KERNEL +#define GDB_BREAKINST 0xf7f0a000 +#define KGDB_BREAKINST 0xf7f0a001 +#define KGDB_COMPILED_BREAK 0xf7f0a002 +#else #define GDB_BREAKINST 0xef9f0001 #define KGDB_BREAKINST 0xe7ffdefe #define KGDB_COMPILED_BREAK 0xe7ffdeff +#endif #define CACHE_FLUSH_IS_SAFE 1 #ifndef __ASSEMBLY__ static inline void arch_kgdb_breakpoint(void) { - asm(__inst_arm(0xe7ffdeff)); + asm(__inst_arm_thumb32(KGDB_COMPILED_BREAK, KGDB_COMPILED_BREAK)); } extern void kgdb_handle_bus_error(void);