From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2094.outbound.protection.outlook.com [40.92.75.94]) by sourceware.org (Postfix) with ESMTPS id E9D6E3858C42 for ; Fri, 26 Apr 2024 07:47:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9D6E3858C42 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E9D6E3858C42 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.75.94 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1714117647; cv=pass; b=C/jcNswJcfEm8DjU/vvolRrOzlkpge3v3AmnQbnXM0sY16kOAA/a4yh9U4cQcAEcPkNnTtOj2m80xviEsmmJr0Q1U1a0jzUfUp8U/DEOpYEbJf2PHm8uoB8qYaVKLr2QYDIa3yrPO9QXqCGaYHLumiERs6O2EfEi7GvLvD32zZw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1714117647; c=relaxed/simple; bh=HQhxvyIpogLQwNwi9GWXFXRF4D97HkR0r3bXGY3B1+0=; h=DKIM-Signature:Message-ID:Date:From:Subject:To:MIME-Version; b=AI8IX9tlYcAy6tujbQD9MKAIvwzlRJGJIFOi87ikHE3vVlsT/sm/KUmM9nkYoUKjrIaALwz7CVPaX/o4ZR5+h6MPUw2+FtyDvEka6zdxbsuD3+u53OqnluJGjD91Fa40BfmF62g+oaLgT6LIQEKvPb0/VZQXzUHUH1PsqW7hvKM= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OmuJsnNf54sZvfKFmegCN8Y3Ucx27HsqEMVpDFq8gPetZKfE5vYFSqvbBi2Wxb3PXZR6xDtieInamUlU0Mhspa2b4uI839/vnhxagOTeSoTzQDx/gCQGp4RJvtpG48+Ho7KrgprfungqocUBnq9ABd40rgXVKuEaoqB+8GcHSP9RzoR0Vm93tOOKiGT7pMyWU6BzRJV9GZdCQIdt2e1GIzfi/r+aRUnSfQ2bci3I13hcjh5Kalq21v/SkaYEJNZsJH07qAZXJYIouY2h6uOd4xyiAfvXzBF0XnUF5e1x7otQzICNYhV3ly3qM1WejB0fvlJjNaIX3po011gaM0Zi7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5hvIcknhl+FW1FVzfwOA7QDwy+TEpXYlVbqiBl054WA=; b=bWqYmAUDQAuBFOCElk9TfoN/pLiOpC09yEkrY6LJc+jGAXW5QQP8gVaPQy7kYF9y7xd20yEL4Xzhp/8bufI08wEwRY1+r/4zjsSOKdRw992He6MfJkAey3w+wqU69nga3YebaghoIs2RtsIAoVUqWw9FByacOcals/QhW686n3CwKGxZGAtBRsnAD5Uc4PAbBTcp90DIiaVX+9/YqhUAdnblOAIUnY6FgVHoNkFQtbzkH8YErCBzLmcKdrwJmxM/z12MkSZ/BcnY/EYUBqUJe+zSjbGHLdBKfZpqdSrWdkTtyeayZy0ppq1RXSKZDOLsp/lrTN+yCq19EM1lXp1XLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=HOTMAIL.DE; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5hvIcknhl+FW1FVzfwOA7QDwy+TEpXYlVbqiBl054WA=; b=SxDMmOWgOm80vV4EztdV7o8+PhOg+NhyrHiQm5EojbYA1cAdhn+/86znDBkSlTXb5rN2yPkvsNVLid0gyAAjjQdJlsjj4o/qZ1ty+wa93A3+nuaBurHcqNvi+3Kgaksr/9bTt9BmahTFz3U3t2y3dYxwx+2a4DdDnDitYdPCH8IZZROF2udFkAz/RGLq1C+rAkarAakgE2KFso76Ub0MdKOhwU5JYJgSD3Wih4LbC01xRyC2KruuxKJuMHhp4nYhBXR6mt5oqgn4+AVf+Sm+9p11B1CpCZx6m721ieZsWhVNJHh2We+/pdAIEZ/aPZt4IGPBAtKowhJ0ULE0/8os+g== Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) by VI1P193MB0558.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:152::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Fri, 26 Apr 2024 07:47:22 +0000 Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::e65d:5dd2:5662:c61f]) by AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::e65d:5dd2:5662:c61f%4]) with mapi id 15.20.7472.045; Fri, 26 Apr 2024 07:47:22 +0000 Message-ID: Date: Fri, 26 Apr 2024 09:49:20 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Bernd Edlinger Subject: [PATCH v3] sim: riscv: Fix some issues with class-a instructions To: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TMN: [lRTw28k9NnmHKjR/S4LGygKAWDPXrUrv8G1x5Hw20G0YUIvTNUqM+jCCGKfUi/Rh] X-ClientProxiedBy: FR5P281CA0033.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f3::10) To AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) X-Microsoft-Original-Message-ID: <0262e010-39af-484f-92c1-d5d819173b93@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P193MB1285:EE_|VI1P193MB0558:EE_ X-MS-Office365-Filtering-Correlation-Id: 75f3638c-a79c-45a0-89ba-08dc65c51b31 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|3412199016|440099019; X-Microsoft-Antispam-Message-Info: ebSM+wHhULuYBtfJIV4YfiJL0e7Xl5FtXdKJ+YC7GHEFy+T3YdLNlarXft4I2ZSKzeur66TXlLrHwj7d5UXU8anM9NEXvqPaCNRTrMJ9elWlDwLUN/T1ro8SlTfeFvayaEZ1SJE3TUKp04T02fIs7fefEMX4sl2YaV0v4xQ6Aye9001QBAEoqAPTS+Y60aDX5lvEsHjQ5XsaHKgSIWkmy1Oty9kv5bqlhM++ZY61FhQHOErv+4FIYflr1nhxAr63nnphwSbYM7/bZ5BoTrlSIDStCFTXt29tzDQ1lS70T5GcVC9FQltUwkxtc0w+Y2aF5EDHj99scxG95+SGRzsY1XHUP1pzU9nBcm7e1+s5S3EvUoPSvIMdV5bpNb3zKTFgR29AACcr535IAnk48S0RVVQNW7oxDD2TF3FVT+YlMxdOfi9TY/9i9ciC3rf77gJLMTdZF+OX4hBloBdMXBO8YH72KquBAvxYdD+FHvUZfBtREun4yZay3VCsDHX0CBkqz1MihwgBg9xejzLXR08huXGgU8MEP3k8F6LtQIQQHdCx9xmsNq2oHpqe//QtOQD5 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NFR4SVpFRmVwblpPc2tFS25jN0h0YVFkUTF3ZCtyMmVZUFhQWVJpMmI1c3Vm?= =?utf-8?B?dGR2TlJMbUw0SUQrbEduRm1TUHdHUGFJTy9NeHYxTDFNWHdBSzY3UHppKzNH?= =?utf-8?B?ZW1HblRMK2hQcHFSZklrWHBqaWpPS09QVmN3eWNoZnE4ZVlNUGRkVTBtMmQz?= =?utf-8?B?VFRhNzNGWG5qdkcwSEg2czhrMXVMcHR4RVVqN1p2dkwyY2FodnRqK2NYUytX?= =?utf-8?B?ZDRyc3Y3cWp5VitJbythaDYxWFpwZGhMQmgzbU5OZFhmencxSXBDckZwUjFp?= =?utf-8?B?Nk1PZURacEhqUEYwS0x0bmVVYlNROWNLYnRDdlU0Tk5UK01QdjdKV21WWlh4?= =?utf-8?B?S0ExSVFrbTJBYkxrakpJNjBnOUsxaVdZNVdKN0hRUmdZRE5kcUpnZ3kvUmtV?= =?utf-8?B?dGU5OXo5RW40RUc5enZvcW44TjRickMzKy9uZUw0Skl2a0VLNkdZWHZ2UjFW?= =?utf-8?B?cmVBUytLNHhNZS9UWlhxSU9ad01MRWhEaDRKSUxMODdzMld3SGlKM1dNcXRY?= =?utf-8?B?ZlY3aWZjT2FsT1c5TlN3VllmV1R3eFl1R1pQdzdLbEllVVZUcE91TG5UaXY3?= =?utf-8?B?WWNYd1M5NDhIcE43WEFyeGY4MUppQitQMjU1UEhmbE15M3FSYkRlakpZWjFM?= =?utf-8?B?OXpzNFFpUW1oeDdFdmRCUW9sczBZd1FGTjRRWW5HbmNCbFVweXdmSnRLZjdu?= =?utf-8?B?UVVQYlVzcWlVTU5hc0NTUTNhaVc5bkd2OFlCWjdyNnhXYzNKWjU3dk9yTk42?= =?utf-8?B?cWNRSW5jdVUzRWtzdjMva1BVN0RjY0lYSlIrMzVINHZGNjVVQVFYdG9xeklZ?= =?utf-8?B?akhrQ1dwNlpFbmNtTS9zU2FnZjh0SnFSTDlVSmk1S1hFRzlyN0JMNG85Ulpi?= =?utf-8?B?Z2RsOUtLZUhYWTNaSVZ5TDR4L053R3pZa0d0ZHRxTS9HTXVLNWJtc3hteHRU?= =?utf-8?B?ZnQrWGJFMFZYMXQrdkhBWk81UkQ0UHhicHZNb3MxT01MQUd3bmlvbEl6TElG?= =?utf-8?B?Tm1pOUhHNzRXbUpBWTFqSGhzTDJ1cTUvYUZBbnZGaVVKMEExNE1CbzZtWEtY?= =?utf-8?B?ZHV3TGNRSXFYRzdOUWhQdlZnTzAvOHZSdi9LUE1OditHOTdXWEkzOXFRbUVU?= =?utf-8?B?TEtmMVh5aDZHZGs4TmpCNktCbUVIN3N3ZlI3ZEwxR1RFeUF2YnVIV0VCU1g5?= =?utf-8?B?S1NDVjFTalhhZ21LTmZyT1d1SVQ1WUpFa3NLdWs1REhid3RkbWpIcE5mdW9T?= =?utf-8?B?ZEkxYThDVnFlZ0xBbzArOGY1ZUttSi8zSkhiUUxtNW9BVlU0TGd4VG9FTGZ4?= =?utf-8?B?b2xrUUY0VWJtYmQwOVFON3pmYUlqdDd5eGZCU3ppNGRjWnYvY3lJRHVyL3du?= =?utf-8?B?ZTdHUkdVVGtSVFZ2bTZKZ2U3bExQWVdLNnpnazNrc1lmdFpXUlFqRGdNTThs?= =?utf-8?B?UktmNGZSaVBNNGI5eU1rNWZUQnA5V1R0QjJvOEtOdUs1U1k4V24xdXhBemgz?= =?utf-8?B?SmxnVExra0hIRitVQzBUN2tnLzRFc0JsQkVEbzdoeU9oWWJGbXV5QlZoUWcx?= =?utf-8?B?Wlc5UEZEZjduNmg5eDExRkRQUDl6WmU2QUJvaVl4TDViYTdGY1N1aE93OTZH?= =?utf-8?B?K0RhMmQ0T2lIS0kxQmlQR3RBOHlYR09EZDhObVJtN08velU3MlhBV2lQcHIv?= =?utf-8?B?cmxGS240VFU0cnBCbFZSWW1xcEE2T3BYVC8zWXpDbTkrb0pNZ2tYV3p3Tm1P?= =?utf-8?Q?YRACPQ5NcJkRS+HbADmE3OXyqvuwiS8cttZa/j1?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-80ceb.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 75f3638c-a79c-45a0-89ba-08dc65c51b31 X-MS-Exchange-CrossTenant-AuthSource: AS8P193MB1285.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 07:47:22.1239 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1P193MB0558 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This fixes some issues with atomic instruction handling. First the instructions may have AQ and/or RL bits set, but the emulator has no such concept, so we have to ignore those. According to the spec the memory must be naturally aligned, otherwise an exception shall be thrown, so do the sim_core read/write aligned. In the case of riscv64 target, there were the LR_D and SC_D 64bit load and store instructions missing, so add those. Additionally the LR_W instruction was missing the sign extension. Also the AMOMIN/AMOMAX[U]_W instructions were not correct for riscv64 because the upper half word of the input registers were not ignored as they should, so use explicit type-casts to uint32_t and int32_t for those. Furthermore the read value was written directly to the rd register, but that can overwrite the value in rs1 or rs2. In that case the previous value must be still available and used instead. And finally make the class-a instruction set only executable if a riscv cpu model with A extension is selected. --- sim/riscv/sim-main.c | 84 ++++++++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 27 deletions(-) v2: use sim_core_read/write_unaligned, but override current_alignment, to raise an exception when the address is not aligned. v3: fix an issue with instructions where the output value overwrites the input register when both are the same register. Typically seen with instructions like amoswap.w a0, a0, (a1) diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index e4b15b533ba..f6f6e2384e8 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -841,6 +841,9 @@ execute_m (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) static sim_cia execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) { + unsigned_word mask_aq = OP_MASK_AQ << OP_SH_AQ; + unsigned_word mask_rl = OP_MASK_RL << OP_SH_RL; + unsigned_word mask_aqrl = mask_aq | mask_rl; struct riscv_sim_cpu *riscv_cpu = RISCV_SIM_CPU (cpu); SIM_DESC sd = CPU_STATE (cpu); struct riscv_sim_state *state = RISCV_SIM_STATE (sd); @@ -851,17 +854,25 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) const char *rs1_name = riscv_gpr_names_abi[rs1]; const char *rs2_name = riscv_gpr_names_abi[rs2]; struct atomic_mem_reserved_list *amo_prev, *amo_curr; - unsigned_word tmp; + unsigned_word tmp, res; sim_cia pc = riscv_cpu->pc + 4; + int prev_alignment = current_alignment; + + if (current_alignment != FORCED_ALIGNMENT) + current_alignment = STRICT_ALIGNMENT; /* Handle these two load/store operations specifically. */ - switch (op->match) + switch (op->match & ~mask_aqrl) { + case MATCH_LR_D: case MATCH_LR_W: TRACE_INSN (cpu, "%s %s, (%s);", op->name, rd_name, rs1_name); - store_rd (cpu, rd, - sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map, - riscv_cpu->regs[rs1])); + if (op->xlen_requirement == 64) + res = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map, + riscv_cpu->regs[rs1]); + else + res = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map, + riscv_cpu->regs[rs1])); /* Walk the reservation list to find an existing match. */ amo_curr = state->amo_reserved_list; @@ -878,6 +889,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) amo_curr->next = state->amo_reserved_list; state->amo_reserved_list = amo_curr; goto done; + case MATCH_SC_D: case MATCH_SC_W: TRACE_INSN (cpu, "%s %s, %s, (%s);", op->name, rd_name, rs2_name, rs1_name); @@ -889,15 +901,20 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) if (amo_curr->addr == riscv_cpu->regs[rs1]) { /* We found a reservation, so operate it. */ - sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map, - riscv_cpu->regs[rs1], - riscv_cpu->regs[rs2]); - store_rd (cpu, rd, 0); + if (op->xlen_requirement == 64) + sim_core_write_unaligned_8 (cpu, riscv_cpu->pc, write_map, + riscv_cpu->regs[rs1], + riscv_cpu->regs[rs2]); + else + sim_core_write_unaligned_4 (cpu, riscv_cpu->pc, write_map, + riscv_cpu->regs[rs1], + riscv_cpu->regs[rs2]); if (amo_curr == state->amo_reserved_list) state->amo_reserved_list = amo_curr->next; else amo_prev->next = amo_curr->next; free (amo_curr); + res = 0; goto done; } amo_prev = amo_curr; @@ -905,7 +922,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) } /* If we're still here, then no reservation exists, so mark as failed. */ - store_rd (cpu, rd, 1); + res = 1; goto done; } @@ -913,46 +930,49 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) TRACE_INSN (cpu, "%s %s, %s, (%s);", op->name, rd_name, rs2_name, rs1_name); if (op->xlen_requirement == 64) - tmp = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map, + res = sim_core_read_unaligned_8 (cpu, riscv_cpu->pc, read_map, riscv_cpu->regs[rs1]); else - tmp = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map, + res = EXTEND32 (sim_core_read_unaligned_4 (cpu, riscv_cpu->pc, read_map, riscv_cpu->regs[rs1])); - store_rd (cpu, rd, tmp); - switch (op->match) + switch (op->match & ~mask_aqrl) { case MATCH_AMOADD_D: case MATCH_AMOADD_W: - tmp = riscv_cpu->regs[rd] + riscv_cpu->regs[rs2]; + tmp = res + riscv_cpu->regs[rs2]; break; case MATCH_AMOAND_D: case MATCH_AMOAND_W: - tmp = riscv_cpu->regs[rd] & riscv_cpu->regs[rs2]; + tmp = res & riscv_cpu->regs[rs2]; break; case MATCH_AMOMAX_D: + tmp = max ((signed_word) res, (signed_word) riscv_cpu->regs[rs2]); + break; case MATCH_AMOMAX_W: - tmp = max ((signed_word) riscv_cpu->regs[rd], - (signed_word) riscv_cpu->regs[rs2]); + tmp = max ((int32_t) res, (int32_t) riscv_cpu->regs[rs2]); break; case MATCH_AMOMAXU_D: + tmp = max ((unsigned_word) res, (unsigned_word) riscv_cpu->regs[rs2]); + break; case MATCH_AMOMAXU_W: - tmp = max ((unsigned_word) riscv_cpu->regs[rd], - (unsigned_word) riscv_cpu->regs[rs2]); + tmp = max ((uint32_t) res, (uint32_t) riscv_cpu->regs[rs2]); break; case MATCH_AMOMIN_D: + tmp = min ((signed_word) res, (signed_word) riscv_cpu->regs[rs2]); + break; case MATCH_AMOMIN_W: - tmp = min ((signed_word) riscv_cpu->regs[rd], - (signed_word) riscv_cpu->regs[rs2]); + tmp = min ((int32_t) res, (int32_t) riscv_cpu->regs[rs2]); break; case MATCH_AMOMINU_D: + tmp = min ((unsigned_word) res, (unsigned_word) riscv_cpu->regs[rs2]); + break; case MATCH_AMOMINU_W: - tmp = min ((unsigned_word) riscv_cpu->regs[rd], - (unsigned_word) riscv_cpu->regs[rs2]); + tmp = min ((uint32_t) res, (uint32_t) riscv_cpu->regs[rs2]); break; case MATCH_AMOOR_D: case MATCH_AMOOR_W: - tmp = riscv_cpu->regs[rd] | riscv_cpu->regs[rs2]; + tmp = res | riscv_cpu->regs[rs2]; break; case MATCH_AMOSWAP_D: case MATCH_AMOSWAP_W: @@ -960,7 +980,7 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) break; case MATCH_AMOXOR_D: case MATCH_AMOXOR_W: - tmp = riscv_cpu->regs[rd] ^ riscv_cpu->regs[rs2]; + tmp = res ^ riscv_cpu->regs[rs2]; break; default: TRACE_INSN (cpu, "UNHANDLED INSN: %s", op->name); @@ -975,6 +995,8 @@ execute_a (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) riscv_cpu->regs[rs1], tmp); done: + store_rd (cpu, rd, res); + current_alignment = prev_alignment; return pc; } @@ -1307,7 +1329,15 @@ execute_one (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) switch (op->insn_class) { case INSN_CLASS_A: - return execute_a (cpu, iw, op); + /* Check whether model with A extension is selected. */ + if (riscv_cpu->csr.misa & 1) + return execute_a (cpu, iw, op); + else + { + TRACE_INSN (cpu, "UNHANDLED EXTENSION: %d", op->insn_class); + sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_signalled, + SIM_SIGILL); + } case INSN_CLASS_C: /* Check whether model with C extension is selected. */ if (riscv_cpu->csr.misa & 4) -- 2.39.2