From nobody Wed Feb 11 04:19:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1770656001; cv=none; d=zohomail.com; s=zohoarc; b=n7o9SPZ8ibEzdPa5jQEKd8idJrRZf53KwDIfeaTdTDg/L/I0hpddxAnkVbA375SuEZquYbSBSkQkA211uyG1Uxts6wq1oj9vVKChNWWNyvTxK2PogfCT7CD/4tYlOUg/JTy5Zly5fwVWv2Kez5jF/XhMbdzFNljedu8ECBU5nwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770656001; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q13SfGkfAmGOcNIHPBnLiB5Lf3crQ10q+6piREbgcus=; b=UYePI6eL35IN793bwWM2c0ad3+Xd3pv4C/ulgIVKnN7rDcR5bvf+qxdyrWIG7/A6LJFPZtqoAk615l3kBZzKXTCENtGzRUcRWVIVWr4ctJkadRJb2GWWEvUu/tV7K9v7LsiyGgC/UC4+QpqDtya8w52hQQnig2WSTp3FMRfA3IQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1770656001707500.3048653462812; Mon, 9 Feb 2026 08:53:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1225786.1532373 (Exim 4.92) (envelope-from ) id 1vpUV9-0007ty-RE; Mon, 09 Feb 2026 16:52:43 +0000 Received: by outflank-mailman (output) from mailman id 1225786.1532373; Mon, 09 Feb 2026 16:52:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpUV9-0007tr-OI; Mon, 09 Feb 2026 16:52:43 +0000 Received: by outflank-mailman (input) for mailman id 1225786; Mon, 09 Feb 2026 16:52:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vpUV8-0007Zo-Ja for xen-devel@lists.xenproject.org; Mon, 09 Feb 2026 16:52:42 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id bf2bce51-05d7-11f1-b162-2bf370ae4941; Mon, 09 Feb 2026 17:52:41 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-64bea6c5819so6739199a12.3 for ; Mon, 09 Feb 2026 08:52:40 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8edacf1564sm415776866b.52.2026.02.09.08.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 08:52:39 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bf2bce51-05d7-11f1-b162-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770655960; x=1771260760; darn=lists.xenproject.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=Q13SfGkfAmGOcNIHPBnLiB5Lf3crQ10q+6piREbgcus=; b=JJQcTvpghBmg+G46LfvQrwDma7uWBK3+q4Pxq/lcG3gVNxaqczJ3VfP6Z8mwWtw37U jlAzBJvmk0N6xIFy/qgRO76HtF+xiFpetH49DVA6X6//uxnHVtHA7PmNM5n3j5a7PxoS Jx15Ciighbk9yqoibGxJzt74KLqvI2UUtELXIC2vwAMMD71mBOy2Ph3WYEeZZFbC1Jcs mZ0skXEeEJi5MZZ7mnwNMHBe8jpU59VGB7yidMtDFh2Fg9FHgJcGw90R9StDPN5acbHv BhIxxtUSRCLMYNftWfGc9UcynKPGATb5iZwDU25utib48sLBpkAVHeqLnxQXAzLwRHp2 fN6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770655960; x=1771260760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q13SfGkfAmGOcNIHPBnLiB5Lf3crQ10q+6piREbgcus=; b=YCcfCG/2+ml9LKMTfrz1Rl0D53bETmpojrweadFBdx6iUKoxvy/JXruB9+ETzQUMFF t0XjuyrTUVez5I3eSKrUIqomIAp4kRmQzZbuxx3PU967UsonzQtHfpR+6tNttoTtfsRd hccal0RZWd4c5uZdms6B7mnVJQvIUC7TCOj2bFYR0DRrMz/d7OtJ0lupGqIbZY0ZXZJB fxXoRdEx/FZYlaNqg3nhuwhvc7LhJEO5EUuW4z8Zn0YC6rsvev37VwFg90GFbPfQgBlO 7waksulpb/ybD4rN4tst6jWmmCSs4Z+1ihnAFOGxFxXPrKGhZXMbrxvTvaEdMDII//h5 JQ6A== X-Gm-Message-State: AOJu0YyELK+Fho2EmVEZYDUkcIkJ6DP1u7s9LZ+B8G7xgFpHsPy/poUk jWeKJNz7TeN7tqpdrXR6//r3LgNWmYIUsWZeGmB2An7djD7FUp8RaCElx7GrjBEp X-Gm-Gg: AZuq6aKYlC1lZJrp5V2Hlku8T1nOAciE6C9IasOHenLy9DXVIgyWicEMFJqiDftmWd6 DROh+AnYrDXb374Yt8e7a8c3qo28CorM4RqGJ0Pu9m3NapytWhMWZ/pt5wMcHIDDSDzCekfq46v UpKLis1ujJAHvsKNAjQEYGr/Lpd7g2wwawWnYvd9nLooP7enzpqXx60l5/sMNm03XpPLkIPvKEX +hO62a4ZZVnweqwLiVf+S/FAv2GcUHh+QkqqEQGnQalivScLMcnmZVtD7pxq+0cRhDwS0bIuTvx F+xeKYUDgistdydUBymZlf2NZRAIu5Qm9zR69hVr5BVMW6a+sVnOoYYpJC8kameILHnrzHdE7XK lBW5RB/W+cUm3ze4PyYZ9R8aJNnPoUv9vKMu1lXtvyEBUS6YaHX17XP1h4V0Ywd4bUxkm0fNvlj Co8HdPaj68toljlbrdSYzN4ZvHUl5FxCDW1PQU0WZE6ZCLKpArYBL6Ug== X-Received: by 2002:a17:907:3d0c:b0:b8e:a1ae:8054 with SMTP id a640c23a62f3a-b8edf178627mr705971366b.2.1770655959738; Mon, 09 Feb 2026 08:52:39 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v3 02/16] xen/riscv: avoid reading hstateen0 when Smstateen is not implemented Date: Mon, 9 Feb 2026 17:52:15 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770656002842158500 Content-Type: text/plain; charset="utf-8" If the Smstateen extension is not implemented, the hstateen0 CSR is considered non-existent. Any attempt to access it will raise an illegal-instruction exception. Guard the hstateen0 dump with a runtime check for Smstateen support to avoid triggering traps when dumping CSRs on systems that do not implement this extension. Fixes: 3babc8d2e546 ("xen/riscv: dump GPRs and CSRs on unexpected traps") Signed-off-by: Oleksii Kurochko --- Changes in V3: - New patch --- xen/arch/riscv/cpufeature.c | 1 + xen/arch/riscv/include/asm/cpufeature.h | 1 + xen/arch/riscv/traps.c | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 02b68aeaa49f..03e27b037be0 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -137,6 +137,7 @@ const struct riscv_isa_ext_data __initconst riscv_isa_e= xt[] =3D { RISCV_ISA_EXT_DATA(zbb), RISCV_ISA_EXT_DATA(zbs), RISCV_ISA_EXT_DATA(smaia), + RISCV_ISA_EXT_DATA(smstateen), RISCV_ISA_EXT_DATA(ssaia), RISCV_ISA_EXT_DATA(svade), RISCV_ISA_EXT_DATA(svpbmt), diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/inclu= de/asm/cpufeature.h index b69616038888..ef02a3e26d2c 100644 --- a/xen/arch/riscv/include/asm/cpufeature.h +++ b/xen/arch/riscv/include/asm/cpufeature.h @@ -36,6 +36,7 @@ enum riscv_isa_ext_id { RISCV_ISA_EXT_zbb, RISCV_ISA_EXT_zbs, RISCV_ISA_EXT_smaia, + RISCV_ISA_EXT_smstateen, RISCV_ISA_EXT_ssaia, RISCV_ISA_EXT_svade, RISCV_ISA_EXT_svpbmt, diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index 34920f4e5693..c81a4f79a0d2 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -11,6 +11,7 @@ #include #include =20 +#include #include #include #include @@ -144,7 +145,12 @@ static void dump_csrs(const char *ctx) (v & HSTATUS_SPV) ? " SPV" : "", (v & HSTATUS_GVA) ? " GVA" : ""); X(hgatp, CSR_HGATP, "\n"); - X(hstateen0, CSR_HSTATEEN0, "\n"); + + if ( riscv_isa_extension_available(NULL, RISCV_ISA_EXT_smstateen) ) + { + X(hstateen0, CSR_HSTATEEN0, "\n"); + } + X(stvec, CSR_STVEC, " "); X(vstvec, CSR_VSTVEC, "\n"); X(sepc, CSR_SEPC, " "); X(vsepc, CSR_VSEPC, "\n"); X(stval, CSR_STVAL, " "); X(vstval, CSR_VSTVAL, "\n"); --=20 2.52.0