From patchwork Fri Dec 22 05:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaydeep Patil X-Patchwork-Id: 82739 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A096386188F for ; Fri, 22 Dec 2023 05:27:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) by sourceware.org (Postfix) with ESMTPS id 84CD73858C5E for ; Fri, 22 Dec 2023 05:27:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84CD73858C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=imgtec.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=imgtec.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 84CD73858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703222843; cv=none; b=O1D7KuauupUWPz3l07WY8s3JQBPE7WOBQR0/JxkN4PT2f//I0xHaMth3znpZeQVUaBWSWEfio+jYs9CMYlPUvKI/kFRQtQwkKFKReHoV2BEbGbAN8wqo+3a12JLO4nazlufPDDCr7L8XvptNgH4vUOPAxdFokJmiQ4jvDdfReE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703222843; c=relaxed/simple; bh=3z9g5aEwoNwUheD1/h1DWvsuiO6GUpjCeIHLJwrP5fQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SPybijkjtZdRUMq4aIcLHOwvb/fZ7gr0EbmRheJMG7eTSXt6h11+kjWCUEpNuhwPRzV/ptCNBUi13qg/0fUGXVVO4Q0un/b1Q9ORzwN9STKP1DoBnWdU35zTgDuG+TXpRncIhSbO40InAmY0Sls0eA+BAO5GMULCBK14POID3RA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BM5K2jv027799; Fri, 22 Dec 2023 05:27:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= dk201812; bh=ZMEF2IHKE9FtWzLLeHH84e9od1IWI4cmiskn+iz/Ojo=; b=tgp xP79XkUwcC3+Lr7h+Um5lmRFlek4WvSK8RrvCaImtP7lcGqwi3E/6O4zrjmDARIr VTQhaQV8fBfELjqdtKh+BKDk8Ua7HA43dvtFMOIv9YWpi8zSbkhpWYSf6EoIElOy 2ofzXaDs39weW7M3F0HCJY5dxf+zxFAO7D0WOW426gza641Rrqo+ao9sgdrWLOeN RVOc/igodvLmmmlOQgb/WelR/PzFxnn/kdUTsTq+ihWJh9TI7ykA5cEFrxdlGa4f e/LIlyv9Pn/XBhLdTj4FQyPZbGIzgpddTvLJWrcITyy0XErid4lHQ7/jSMDV/8PM BXve+ronmhHcETFBotw== Received: from hhmail05.hh.imgtec.org ([217.156.249.195]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 3v2kvk30ma-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 22 Dec 2023 05:27:10 +0000 (GMT) Received: from hhjpatil.hh.imgtec.org (10.100.136.70) by HHMAIL05.hh.imgtec.org (10.100.10.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 22 Dec 2023 05:27:09 +0000 From: To: CC: , , , , Subject: [PATCH v5 1/2] [sim/riscv] Fix crash during instruction decoding Date: Fri, 22 Dec 2023 05:26:57 +0000 Message-ID: <20231222052658.2102802-2-jaydeep.patil@imgtec.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231222052658.2102802-1-jaydeep.patil@imgtec.com> References: <20231222052658.2102802-1-jaydeep.patil@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.100.136.70] X-ClientProxiedBy: HHMAIL05.hh.imgtec.org (10.100.10.120) To HHMAIL05.hh.imgtec.org (10.100.10.120) X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Proofpoint-GUID: 7zo90d4WbNE_GVldwprAwz55__2t2XIt X-Proofpoint-ORIG-GUID: 7zo90d4WbNE_GVldwprAwz55__2t2XIt X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org From: Jaydeep Patil The match_never() function has been removed and thus step_once() crashes during instruction decoding. Fixed it by checking for null pointer before invoking function attached to match_func member of riscv_opcode structure. --- opcodes/riscv-dis.c | 2 +- sim/riscv/sim-main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 68674380797..a89ebdd32ac 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -818,7 +818,7 @@ riscv_disassemble_insn (bfd_vma memaddr, if (op->pinfo == INSN_MACRO) continue; /* Does the opcode match? */ - if (! (op->match_func) (op, word)) + if (! op->match_func || ! (op->match_func) (op, word)) continue; /* Is this a pseudo-instruction and may we print it as such? */ if (no_aliases && (op->pinfo & INSN_ALIAS)) diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index 4d205345395..65c0ea245b2 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -1042,7 +1042,7 @@ void step_once (SIM_CPU *cpu) for (; op->name; op++) { /* Does the opcode match? */ - if (! op->match_func (op, iw)) + if (! op->match_func || ! op->match_func (op, iw)) continue; /* Is this a pseudo-instruction and may we print it as such? */ if (op->pinfo & INSN_ALIAS)