From nobody Thu Nov 28 10:41:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1694153276; cv=none; d=zohomail.com; s=zohoarc; b=hZlHuwNHKWixq+OhelxmKZr+JLooaKwdW3G3yVTIp9VLp2/FJq6LksRd1ghj7/MchwS76YgzleL9rLYVbOU+jWSWYndOUXhfVH05Gm4gkPz2nivI5gld7j9l9NQRucWT1OfMnZYfeZ/8W//qVUYSHQb5O7ogJHX49kFyCiNN81I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153276; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=UM7lgM0vBGMWQ6ZCBgYwg2158VZ9Y1lpxpK10JzulFT1DwwyWUEIgyD3sllI5ndQhYpN/6XzeIvHklcpXs5EKx7Ge/So22FytKgxt12VoA1juTTwJw3a10CIh/UJA1MAYnASXANbNTi4lXT2YFf77dzY1O0PCaNBPKs/H7bcFkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1694153276534547.3778341339458; Thu, 7 Sep 2023 23:07:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUej-0000kJ-1e; Fri, 08 Sep 2023 02:07:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeUei-0000cF-2M for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:48 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUef-00081u-JZ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:47 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-565334377d0so1426091a12.2 for ; Thu, 07 Sep 2023 23:07:45 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153264; x=1694758064; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=GE6Jd1GgGDOe+3d6YpA2aLT5vJ4lYdO7t6rCsO5OsnFyvkdC6T0MhewkimTlhVEQNj tNv0dZO7/Udrt3mPTRaK5X7quS4IwZpZSNHqk/uvkXSizYhdc/AHea6Kdvd61GQUWhPs Eq1z9bkAKfeXySHpnZ2qZMkN7tyGfoxzXUYRxdFjH4loxuVX6uGBAACk6SV0xVYxSX/M iA/Y5wMhN8QPRD7Cxn+9OwUrMorYc/9I7z4gGeb0PSwXbWMKpSjlt7/HKpOeEtj81bnZ 8G3ksyLT0WSLnMcs0OcfOyBB34q29j0M/e8rba9s8u5cUGt6DOuaSqg145T3vzaLAGbc vBMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153264; x=1694758064; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=bz787jr2ZlOp310jgLFEosN93snjMu+BoX/84jjr4aUQQz0eQ2Ktf7a0+gb7RRh6nh ka9Pq8p+xecxUf+sknGI1npBWW+KmgPuJiOp0Ydh5kx0slDPv0izGnusllx2G3cpMjvY itAsxaTV5QqiAtayHcf+XA9t+ZtqXnXBDIa3GgqLE/I6cbn9Q4vX+N6T2/5tw7L2YTM9 U2qFdxza5lYihvPnDxml3it5Z+H/ncjdV0EBjIZuui2QHXPzY4dHApJrrVKpyN/5Wl4W sgIVhfJGHja3YsocyedwLhi0YfQ8vAVZRDFk7NQnZvxHIgFHSiz0TqSLIA6660WeC93+ l2Ng== X-Gm-Message-State: AOJu0Yy6SVQGUSwsZJITY2mfWRWrYbBq9YKfahofekJKUHgBiLp3wFkc 0qsZwY7M615pIZJopIRiSxjjS+J2H7Sf/vrb X-Google-Smtp-Source: AGHT+IGRijk7AxuqhJNptjrx84tSuCq7e4vJcX+YUpXeQNk66EqLJfsaZWa/DPY4ydZhI8N9l4V6Cw== X-Received: by 2002:a05:6a20:7d84:b0:132:ff57:7fab with SMTP id v4-20020a056a207d8400b00132ff577fabmr2404840pzj.2.1694153263827; Thu, 07 Sep 2023 23:07:43 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Tommy Wu , Frank Chang , Alistair Francis Subject: [PULL 44/65] target/riscv: Align the AIA model to v1.0 ratified spec Date: Fri, 8 Sep 2023 16:04:10 +1000 Message-ID: <20230908060431.1903919-45-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52f.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1694153277329100001 Content-Type: text/plain; charset="utf-8" From: Tommy Wu According to the new spec, when vsiselect has a reserved value, attempts from M-mode or HS-mode to access vsireg, or from VS-mode to access sireg, should preferably raise an illegal instruction exception. Signed-off-by: Tommy Wu Reviewed-by: Frank Chang Message-ID: <20230816061647.600672-1-tommy.wu@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index b8e0d0cb4c..4a0f6a89be 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1684,7 +1684,7 @@ static int rmw_iprio(target_ulong xlen, static int rmw_xireg(CPURISCVState *env, int csrno, target_ulong *val, target_ulong new_val, target_ulong wr_mask) { - bool virt; + bool virt, isel_reserved; uint8_t *iprio; int ret =3D -EINVAL; target_ulong priv, isel, vgein; @@ -1694,6 +1694,7 @@ static int rmw_xireg(CPURISCVState *env, int csrno, t= arget_ulong *val, =20 /* Decode register details from CSR number */ virt =3D false; + isel_reserved =3D false; switch (csrno) { case CSR_MIREG: iprio =3D env->miprio; @@ -1738,11 +1739,13 @@ static int rmw_xireg(CPURISCVState *env, int csrno,= target_ulong *val, riscv_cpu_mxl_bits(env)), val, new_val, wr_mask); } + } else { + isel_reserved =3D true; } =20 done: if (ret) { - return (env->virt_enabled && virt) ? + return (env->virt_enabled && virt && !isel_reserved) ? RISCV_EXCP_VIRT_INSTRUCTION_FAULT : RISCV_EXCP_ILLEGAL_INST; } return RISCV_EXCP_NONE; --=20 2.41.0