Message ID | 20230116073834.333129-3-bjorn@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1066477wrn; Sun, 15 Jan 2023 23:44:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAqG4QwhXjyRLTs8LWAyeTGlhRiU0FI5gjByks2A5MUjAU9V2WuO9HS1gf4bt8jw1BZjWi X-Received: by 2002:a17:902:cf4b:b0:194:88a3:6e28 with SMTP id e11-20020a170902cf4b00b0019488a36e28mr6602915plg.51.1673855051745; Sun, 15 Jan 2023 23:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673855051; cv=none; d=google.com; s=arc-20160816; b=F0EnZY718Aq6eRm4F32brs35TUFHbg0pAKdnO1yc4JnkCMMY/Sv6wtoK6BHkOyoDcY 3GIQfnkacklj0dMWhDAxrb0ok9dPclKfoY0YYF+pwVGT6QIlNidCa8CHE69w2s6RAMJB ckrZ8YulYPZD9IHPLXQGTdnMmJiWtnzXUuuajqmlSKaP7RKVBiswACxxnL7RzqyI/SX1 YXdZxGD3s7mWgGEc/as5OAoTeTVcP1syLynTqkf57DyJZ6erZPikDt4FzGXH5QbL8o6y vif2cFsf5QOvF05oGVPuhmMGENqtJzSg7ZLhOL4mRghdzC0VWEhLMg7upUm4RI2aBTRM wIag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6+u8DAF1w+3pnxqxuJXeWq0Mmzl/CHOTAxv9x3qeBzQ=; b=pWZ5Se/hwTlNgHTrAeHIWgenvpM2iPMOTrq7igC2wz3fkdtDJv00RZkqrNUYghOE5O XG/Dun0Dco1PhTjLcDmr1J9NcyA01ufUdQrOgwMRy0ryPRAr2uv5CPv6D2ZT+oRlwET4 maamBtFq37owNyDsGKi6jWwK/Q7PzlniYOIy0UCshdbnPwmeWzGcfl0TIY+wgQ8JFz+x 4vDErS2V0Uf2i+Hn5IQBKkeanehwCO1iHje4FAM9MNOXWfy5RF4VO5fa7LCAMjDdQn/C D34pJbW4FDQjtTaYXyR9VBy0N9vDuj/1lYj9XNIcv6fckq3VfCAZrFZ8BvxbTNkSh87u VQ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a0KS4Som; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a170903301500b0017486813f81si25716971pla.528.2023.01.15.23.44.00; Sun, 15 Jan 2023 23:44:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a0KS4Som; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbjAPHjH (ORCPT <rfc822;stefanalexe802@gmail.com> + 99 others); Mon, 16 Jan 2023 02:39:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbjAPHjB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Jan 2023 02:39:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C211855BA for <linux-kernel@vger.kernel.org>; Sun, 15 Jan 2023 23:39:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5E93A60ED1 for <linux-kernel@vger.kernel.org>; Mon, 16 Jan 2023 07:39:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D8E5C433EF; Mon, 16 Jan 2023 07:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673854739; bh=PBE0PpRXIlt2qCDFtsjgADfP4kD6JxkZrkUXxW7Tmuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a0KS4Som77Rg8W9H4kxDYF8K/8s1ZXqdHiwy5QKfjFXMKjjnP3Wfj6Mprg6eePZoK kwSWMB6qR4dw8LL3oK7mBpskdaaabxaC3aRc92oh866vejtqph36qGUvLRmh4ZPqTL ShJVLQh1AstWDoVGeqPaydfXBaHcl2zbcDOXuiH6jc7eI0vaY6RjIqb74dyKHWv3ja QnbDoj4hcEljYRDncvDOVhoMLoS3V4o4mfvUSlKQdcaPtE1p7CZwNTzPLzBpft2qy8 Uj4WvlnIBC0OWDtSlrpnKBP0f0ewUYKC8aF2xUKi0JuVKiSxEk6GjQVXNKHUfSWp0T 3/W7lPGAJjL7Q== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@kernel.org> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, linux-riscv@lists.infradead.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@rivosinc.com>, Andreas Schwab <schwab@linux-m68k.org>, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] scripts/decodecode: Add support for RISC-V Date: Mon, 16 Jan 2023 08:38:34 +0100 Message-Id: <20230116073834.333129-3-bjorn@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116073834.333129-1-bjorn@kernel.org> References: <20230116073834.333129-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755164234685087511?= X-GMAIL-MSGID: =?utf-8?q?1755164234685087511?= |
Series |
riscv: Dump faulting instructions in oops handler
|
|
Commit Message
Björn Töpel
Jan. 16, 2023, 7:38 a.m. UTC
From: Björn Töpel <bjorn@rivosinc.com> RISC-V has some GNU disassembly quirks, e.g. it requires '-D' to properly disassemble .2byte directives similar to Arm [1]. Further, GNU objdump groups RISC-V instruction by 2 or 4 byte chunks, instead doing byte-for-byte. Add the required switches, and translate from short/word to bytes when ARCH is "riscv". An example how to invoke decodecode for RISC-V: $ echo 'Code: bf45 f793 1007 f7d9 50ef 37af d541 b7d9 7097 00c8 (80e7) 6140' | AFLAGS="-march=rv64imac_zicbom_zihintpause" \ ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- ./scripts/decodecode Code: bf45 f793 1007 f7d9 50ef 37af d541 b7d9 7097 00c8 (80e7) 6140 All code ======== 0: bf45 c.j 0xffffffffffffffb0 2: 1007f793 andi a5,a5,256 6: f7d9 c.bnez a5,0xffffffffffffff94 8: 37af50ef jal ra,0xf5382 c: d541 c.beqz a0,0xffffffffffffff94 e: b7d9 c.j 0xffffffffffffffd4 10: 00c87097 auipc ra,0xc87 14:* 614080e7 jalr ra,1556(ra) # 0xc87624 <-- trapping instruction Code starting with the faulting instruction =========================================== 0: 614080e7 jalr ra,1556(ra) [1] https://sourceware.org/bugzilla/show_bug.cgi?id=10263 Signed-off-by: Björn Töpel <bjorn@rivosinc.com> --- scripts/decodecode | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/scripts/decodecode b/scripts/decodecode index b28fd2686561..8fe71c292381 100755 --- a/scripts/decodecode +++ b/scripts/decodecode @@ -93,6 +93,11 @@ disas() { ${CROSS_COMPILE}strip $t.o fi + if [ "$ARCH" = "riscv" ]; then + OBJDUMPFLAGS="-M no-aliases --section=.text -D" + ${CROSS_COMPILE}strip $t.o + fi + if [ $pc_sub -ne 0 ]; then if [ $PC ]; then adj_vma=$(( $PC - $pc_sub )) @@ -126,8 +131,13 @@ get_substr_opcode_bytes_num() do substr+="$opc" + opcode="$substr" + if [ "$ARCH" = "riscv" ]; then + opcode=$(echo $opcode | tr ' ' '\n' | tac | tr -d '\n') + fi + # return if opcode bytes do not match @opline anymore - if ! echo $opline | grep -q "$substr"; + if ! echo $opline | grep -q "$opcode"; then break fi