From nobody Sat May 30 17:44:12 2026 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=1779677005; cv=none; d=zohomail.com; s=zohoarc; b=Um3pv7S6ZYdi8r38c1YsPwxKAe/bS4ff9azvWnDahOEneI/mEmOpVOLUwitqFZGCle7ir65G3yy5mvtgoGvzObb6COt7U25H0eWJuF/ZTPhTzzN/i3W0DKljge9g3dLx2YCV84cPT34AsHGhPzdp8p1loCL37IskqDpuEy/kSWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779677005; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5C8ZLi+jzOwclay2/HrAK2Y78iK5fLfoChmN3/la8PM=; b=TVuwxu4IC+0oHdt6pFGeUCsItZGQPBExD5iZm6v2ZY88aAJcm9UEas1SxXvconzqxQaNOL0UrgLxKlK4z2Hl5nngnYKN/cPtraaX8zh5wvtjzY1c13Xx3+ahYRxyQU72+CTY9m488QGMQXKHgtauN3zUe4zk2wtIFzjQfI+vGMw= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779677005112103.25197114061245; Sun, 24 May 2026 19:43:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRLHD-0004IB-P9; Sun, 24 May 2026 22:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRLHB-0004Ht-Te for qemu-devel@nongnu.org; Sun, 24 May 2026 22:42:45 -0400 Received: from mail-dl1-x1244.google.com ([2607:f8b0:4864:20::1244]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wRLHA-0002MR-BL for qemu-devel@nongnu.org; Sun, 24 May 2026 22:42:45 -0400 Received: by mail-dl1-x1244.google.com with SMTP id a92af1059eb24-135e88b8e55so6941171c88.0 for ; Sun, 24 May 2026 19:42:43 -0700 (PDT) Received: from openkylin-pc.lan (ec2-3-101-81-203.us-west-1.compute.amazonaws.com. [3.101.81.203]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1366aba39d7sm5037078c88.14.2026.05.24.19.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2026 19:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779676962; x=1780281762; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5C8ZLi+jzOwclay2/HrAK2Y78iK5fLfoChmN3/la8PM=; b=lHI3A0F0iyEhWUqjPWOXpYnnC+/ABQiPJEO5qMSbO7LfhhvFVActEm61fvBY3N3JvG +lYeKiUH0pNTJ9BTJgOErURkRAI26xvm9gdG86oot+ecLatWwsyz6F+2ItBykVPyZhv8 o11yL3DfPd//Fg/kcfoaS0mFEQblG/oXCfkCE2o+cm14+uuEAa25bINaNg75sz6sxUqM ZqzwHmf71Ue+UdQSFN9mkZnVppxc812lBqz77CrDOcaii9B+Zn6rEcWksOV6UPEf2NwX M76JDj3OMsZBW9wmNVUbp1NqtMDg1YLhDHA4zklAebPtdX4V2HDAaAAFENt15YdIPnDv EjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779676962; x=1780281762; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5C8ZLi+jzOwclay2/HrAK2Y78iK5fLfoChmN3/la8PM=; b=JEgikeDAsYERKsFD+UdiEaYQyd+q6/+xDegp0qvSU61UCUUwc5uQj+FUIxsKBIU9hZ Hl3eEbjuR4iHnqtzopIJpb77KqhHQj4r/xTZXhGuu/YuLzn2xsvONFm5X0T+v0ibX+fO sJ1LroNrzaJxRbyx5x3Kd4kI1tzJZfRMSKIW93KH4EP5TdBRPbZwZylyulcqmBe0Pu1J n30AxXpS5tpDmwEWM0GpoKEpOO4UhkNabSHR4pke1Vx2bQoDWZxJ/8D7ybcgLlJTvnj7 eJATPqyXIrdn+TUFOT9xvO+tQbEdhLmRGp/lQ9Q679zi0Uk0Q+pZwNN1xxn/bbjM4nuK n9Ew== X-Gm-Message-State: AOJu0YwCe+jqW2jBbBCgmi4q71FgudzN8oz1NPkHOvrsCJVqqwfZZ7e0 uIXOrEVKMmEfigwoauvdVBKhYL9EOzWfA6g/Gq/T+Xf/Qr6jLTY3SGoium0BGOQNNbM+Lg== X-Gm-Gg: Acq92OGtEF6JtS22OVnJhanpCpxWCXEWhVlykQ0PuW51hg/7TqQbWzAhb5EPOnyZTtC N3sIs315dwBpSCeJ2eCnVVrBOprHGvgttX2uRQVpPjNFWUuCjxnXl08HS+C/+gu7ngwH8CuZD1N tigbuezGAfbFm1QjmIjj+slm/LwzwEsKfI3kYf0FCJOHowOq69H9UrnU4xZ4N2VbfzEm/EYs8RV zVMM63LpCLz8mqFpbGqj9wSQbcVYpKa2r9EmHZeKb648sBoPYYDABg8K3sORxB3RpaNpkvSfvlE C5KyMsZ27E1Nu50Y5XDCN+5Wqz4LrZukX+jQr3UdvfKgFrN7rgL/lwf8XN4MrX8LbYooVV53PCE pKPbMPn6gDDOgSYPLj63pUqRTtoCzYbpYcjRh4Kt9v+0bl5PXWKNl0vyN0yUfecFgSjYfmKSkDz ga+ywAhtADf+eQCkaujvbrQuRXdHrMkl2mrXYsO3OgtpUG+GRQ7BjUg1CBv4xc5ToQU1EeKAeW6 zxFoSAFaBfiHBOVEMNSwTcAwbl5 X-Received: by 2002:a05:7022:671f:b0:12d:d972:b96e with SMTP id a92af1059eb24-1365fb3f882mr4251601c88.20.1779676961879; Sun, 24 May 2026 19:42:41 -0700 (PDT) From: Zephyr Li To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com, alistair.francis@wdc.com, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, chao.liu.zevorn@gmail.com, daniel.barboza@oss.qualcomm.com Subject: [PATCH] target/riscv: Do not hide Sstc CSRs from gdbstub Date: Mon, 25 May 2026 10:42:20 +0800 Message-ID: <20260525024220.39027-1-fritchleybohrer@gmail.com> X-Mailer: git-send-email 2.43.0 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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1244; envelope-from=fritchleybohrer@gmail.com; helo=mail-dl1-x1244.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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: qemu development 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: 1779677007430158500 Content-Type: text/plain; charset="utf-8" The Sstc predicate currently checks both ext_sstc and rdtime_fn. This causes the gdbstub CSR XML generation to skip Sstc CSRs when rdtime_fn has not been initialized yet, even if the CPU supports Sstc. As a result, GDB reports $stimecmp as void with a CPU that exposes the sstc extension. Only use ext_sstc for the early existence check, and keep the rdtime_fn check for non-debugger accesses. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3496 Signed-off-by: Zephyr Li Reviewed-by: Alistair Francis Reviewed-by: Chao Liu --- Testing: Start QEMU with: qemu-system-riscv64 -M virt,aclint=3Don -cpu max,sstc=3Dtrue -s -S = -nographic Before: (gdb) p $stimecmp $1 =3D void After: (gdb) p $stimecmp $1 =3D 0 target/riscv/csr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index da366cf562..c17df147f7 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -586,7 +586,7 @@ static RISCVException sstc(CPURISCVState *env, int csrn= o) { bool hmode_check =3D false; =20 - if (!riscv_cpu_cfg(env)->ext_sstc || !env->rdtime_fn) { + if (!riscv_cpu_cfg(env)->ext_sstc) { return RISCV_EXCP_ILLEGAL_INST; } =20 @@ -603,6 +603,10 @@ static RISCVException sstc(CPURISCVState *env, int csr= no) return RISCV_EXCP_NONE; } =20 + if (!env->rdtime_fn) { + return RISCV_EXCP_ILLEGAL_INST; + } + if (env->priv =3D=3D PRV_M) { return RISCV_EXCP_NONE; } --=20 2.43.0