From nobody Sat Nov 15 09:10:29 2025 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=1753837574; cv=none; d=zohomail.com; s=zohoarc; b=bTtyyG0QJvTZqvYPdNWwCyOX0C/lssYbi6jy+NXonko+MroVBbDRa58f5FA/fXs+52uMrMNQVj+XbAnx99QP3iTTePdh+i95zFRpsIje1KSZIeHDuztvHGzclC5Dnzz0X3YoAv+e4MFmy3ryTHgK2/C8ZcSO/Kt/RyJb4Vr90Zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753837574; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HABKAT3UkQpkDi28bQ9RXNj8MoECQzmBVWqJiF0ZqcQ=; b=Y+klKsKHrsl3F9FMLSgvju/16RN/HoRVj/zaGaogOJ0UKfl/rE/ge54FPaRWvCOsiEdARmrmqZD8NRN/NAaKxClCOk7KIc2YF15LUYxcnVGJlneluYdo/V7bmrAKOqGVuv9QBFhWChX7iHzFGTgDhbSjFsmUF9xbld7q3aH1CVI= 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 1753837574407667.8861804568531; Tue, 29 Jul 2025 18:06:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ugvGe-0001la-W8; Tue, 29 Jul 2025 21:06:05 -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 1ugvCl-0003h8-M2 for qemu-devel@nongnu.org; Tue, 29 Jul 2025 21:02:03 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ugvCj-0004ny-Lr for qemu-devel@nongnu.org; Tue, 29 Jul 2025 21:02:03 -0400 Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-31f314fe0aaso1514631a91.0 for ; Tue, 29 Jul 2025 18:02:01 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31f63df5adfsm343253a91.25.2025.07.29.18.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 18:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753837320; x=1754442120; 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=HABKAT3UkQpkDi28bQ9RXNj8MoECQzmBVWqJiF0ZqcQ=; b=X8rnJGKQ7gpn4RTQpfyabhg0ztNZKHm9DpZNjed6P9t4IAL5lA7unC0M2O4jSRdx7y Lq6aD/1Izic5H+AZMXPHXL2+/7+DSPqa4EMDJvxs6d4ibWDY/aIeUn/xoGBAb8UHW2j6 OFtNMBY8aw99fqVqUmHWpKNou+TPhVU63D69rCt3834fRWJWWTon3nDhBVLAfOu20Sdh rlWT4kbelld3pmetPIcYtH9Okp6SZj/EjjHHwu3KEv4wtVpoV+MSXcbFfbTwALyfLaMZ sPSlqQtNKCZF+egmbROeDbZ4PGRhxaRFSouLUookeXPjXgHos/wBdZYgi26pkai0d7zR 37Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753837320; x=1754442120; 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=HABKAT3UkQpkDi28bQ9RXNj8MoECQzmBVWqJiF0ZqcQ=; b=LPaQZ7OlnYUvSjlL9NN14E6tQObD4h9csAhkUMMejPheyoy3jxac+aTZHDwS0HhFdq mUmco8iNK3UAF0ytVrRmUjDjPj3y8uIsZn6RygCDqPzpWBFWN51TM9Dd9hxmEVvO6yXX mrt4uR/pPcqiS/9PbBOXaJVyww/N1G+o694mrI0Qp17KYurDWPa8XLFnJXO5TU4Dt/+M 5Emdx5f/uTw39IsyUihuhG8HtAZb1FtATgBorfRWgIfM6y7BtMa9AGc4LWJTxGwG6IfO D+0zk0eTPksw7ZQTuq+eXB9emgqOFivqE6S4FrsjS8nmYJi2FRru9uhkWxXdl7sGSjuV dCWA== X-Gm-Message-State: AOJu0YxpadFjeCUhxATNwiFZLJY9dLFKIJ9SlwwOlJNLcuAcygWfHOBc PJHOqi768mL5VR++juCSWxIbRuyb70axUQVKeDoTzIT1MNYSM8lhfvOeMSJv1w== X-Gm-Gg: ASbGncti2UYnvR0S5I9SjtcUSaa6I4ZX5b5Z7UUeaxaHUZhUTdBzHIj4EFU8UBqmLt5 fgz9TZps9NpNXDwQ/MIRqG1SJvk5eFS2ib3EQAb47RB4FHLf1RfMQsV1YUlyYzZsFVXKqmLrHlh 3s2LgctYD2eZJHKLyjY78unSZ5dl4j6ibqvIVfWw+STmfJlx8jMTz92zoExlFE8qlQT6N0ni3D4 KI7TNj0cC0GjAJYgIEZLIdZsuTzO7NITDcoq1pqjuJysapns03cYknULjv8WrPPVHP490jrB8Qm st0WdnljvvP8Nscd8D83JQBugMSenVr8jTwCBcjKd7PfzTaRCPO5nrfMPp3PEz7zeqikyJp8YGq dkmKvej8SLwruAQxbHh522+eVxDHNLnSblMeLS8QOzXffeHegzbe7hdY6I2qYCa6LjaD+4yA6ay KgRtd+poz4AnV890rV9tRryp20y9/CkcNSu6rlfg== X-Google-Smtp-Source: AGHT+IGqFd6I92IqpqMUzDt/cG4+sQ0Dv6Wd4esDulAW4OGs4hAbFqqp4Jg060iTi0pPzTZVTJLsFg== X-Received: by 2002:a17:90b:39c5:b0:311:ea13:2e70 with SMTP id 98e67ed59e1d1-31f5de3ceb7mr1960249a91.14.1753837319809; Tue, 29 Jul 2025 18:01:59 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Xu Lu , Anup Patel , Nutty Liu , Alistair Francis Subject: [PULL 09/11] target/riscv: Fix exception type when VU accesses supervisor CSRs Date: Wed, 30 Jul 2025 11:01:20 +1000 Message-ID: <20250730010122.4193496-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250730010122.4193496-1-alistair.francis@wdc.com> References: <20250730010122.4193496-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::1029; envelope-from=alistair23@gmail.com; helo=mail-pj1-x1029.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: 1753837576492116600 Content-Type: text/plain; charset="utf-8" From: Xu Lu When supervisor CSRs are accessed from VU-mode, a virtual instruction exception should be raised instead of an illegal instruction. Fixes: c1fbcecb3a (target/riscv: Fix csr number based privilege checking) Signed-off-by: Xu Lu Reviewed-by: Anup Patel Reviewed-by: Nutty Liu Message-ID: <20250708060720.7030-1-luxu.kernel@bytedance.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 8631be97c5..9bebfae3f0 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -5577,7 +5577,7 @@ static inline RISCVException riscv_csrrw_check(CPURIS= CVState *env, =20 csr_priv =3D get_field(csrno, 0x300); if (!env->debugger && (effective_priv < csr_priv)) { - if (csr_priv =3D=3D (PRV_S + 1) && env->virt_enabled) { + if (csr_priv <=3D (PRV_S + 1) && env->virt_enabled) { return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } return RISCV_EXCP_ILLEGAL_INST; --=20 2.50.0