From patchwork Thu Jan 11 05:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaydeep Patil X-Patchwork-Id: 83823 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 F23A13857C45 for ; Thu, 11 Jan 2024 05:29:22 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mx08-00376f01.pphosted.com (mx08-00376f01.pphosted.com [91.207.212.86]) by sourceware.org (Postfix) with ESMTPS id DBD803858D38 for ; Thu, 11 Jan 2024 05:28:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBD803858D38 Authentication-Results: sourceware.org; dmarc=pass (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 DBD803858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=91.207.212.86 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704950929; cv=none; b=QNHh8nOrhNUkiKS/0ZX5m2Z7wze3JhHCWMyD1ymlyfqnjoG8PJt46gVB2T5+9PV3Vyj28Ob8tgKZcRSoSWjB2sekUMZQMN7aDrR5XQvBcxP57E9+x/yWIpzjVmDQnSdnXCtzSnBbIIeMuXvGwbYAVtum1lWUMv9naar4CUH5mWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704950929; c=relaxed/simple; bh=yQh8YOfblWRNKWO5DDJpy+wm6MgaSpSyrsCJIijoYS0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JkHpBdHmOxs1j12Cp8bvNmbPysUDjOuv+Xy6PNvR86PvceXa7/67n+aZOebD6KQM3BS5Py5azbtwm30ICW90Ios9hGQElbAXYjRehBiEBy1TInEeoG95geQTTLV5XKN9asZvVaoaJ3idfxGhXXI9ChVNSAqtFjhvel7zd75EqVE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0168888.ppops.net [127.0.0.1]) by mx08-00376f01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40B5Sauj032002; Thu, 11 Jan 2024 05:28:36 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=bK9a/wEtmhieHqzNqVep4kjXycyUH7YTa8dCsVZZUKc=; b=cpl buiYEkVIA0p8nYNnF7uIFrS1kDhqC3pIb6pRQ/23FmROfGduQ7Dghd3R74WWyWIC xZuj/X7gxsoNk+Aoz4tTQ0xffOSFHRgqJSpvtj8FYrViraAWPwUq5mGj3ds6AWtR RhFm2+FREKP1XUXoi/+3t0Aj6uuXGtxAVsZRNlAAmiLFVeKqvtkiQqL93MvL2g15 g/r8PFUPL5QXeINBoEIO8ISJt1yR6EW0VFwC2EtlW6OiuIuMsRgtZExaitYhSJng MsMiXRTtPHJYfNlJ4e/B5U1vrtJJ4FuBZpAafgBdVT2NGBWMibb0q/SnAuETbsMn 4vGlEiwl8U6riCh4Cwg== Received: from hhmail05.hh.imgtec.org ([217.156.249.195]) by mx08-00376f01.pphosted.com (PPS) with ESMTPS id 3vj6rd02f0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 11 Jan 2024 05:28:36 +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; Thu, 11 Jan 2024 05:28:34 +0000 From: To: CC: , , , , Subject: [PATCH v6 1/2] sim: riscv: Fix crash during instruction decoding Date: Thu, 11 Jan 2024 05:28:21 +0000 Message-ID: <20240111052822.1576345-2-jaydeep.patil@imgtec.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240111052822.1576345-1-jaydeep.patil@imgtec.com> References: <20240111052822.1576345-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-ORIG-GUID: WZV2JzxPa9K9MQ-TAPtPAxui3sVfib33 X-Proofpoint-GUID: WZV2JzxPa9K9MQ-TAPtPAxui3sVfib33 X-Spam-Status: No, score=-10.6 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 --- sim/riscv/sim-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index b04d12c0de1..25dc9b41412 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -1040,7 +1040,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)