From patchwork Wed Mar 27 10:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 1916662 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=wDqwD26m; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=vrull.eu header.i=@vrull.eu header.a=rsa-sha256 header.s=google header.b=kQvj+ZOy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V4MsY47Nmz1yYW for ; Wed, 27 Mar 2024 21:11:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tErR/+pzEFY5mE/cHHVGsUFD9DMywGiq4zcJjepNunE=; b=wDqwD26mfFm9m8 i+L8HHk9whdUx3mNp12HP8bzveDOt9oBoy5znqV/taaH1bnPyam/RuPjBBfndN+GBUPjH/y75I+y/ EtaRB/K7s/824KiNTFX79Zw1MEjHJNc7LYWUDVPI9cNsdQGXWDfthqmKY/Dfxwh40vY8cMTeT3B4F 07sOwlYveuE3k4K4Vcll6uawauJ6EHn2A9zAnyQs9HZYswrwYDwHMFsJK2XagELw+xfcufdvH42Su qsNGa0HCQ31JBt4O7QCucobn9cQYF87RpOr3wZ//QRlfc+AdEDDIeR0ZzH8EB/r54rQqDQsRIvxP0 JIgXueWvMYg7avKOdZyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG6-00000008MAI-0PqF; Wed, 27 Mar 2024 10:11:50 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG2-00000008M8R-32Yn for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:48 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-56bdf81706aso6906757a12.2 for ; Wed, 27 Mar 2024 03:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534302; x=1712139102; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/kJlpo1I8ft42uS0k4ZUD+WvURZMMcMdzv5LS8qVIKI=; b=kQvj+ZOyVhAbNVpghI7AVApJ976Dk8HDkYVMQ4AQ+TM61lZmMLABfOGtirLgyzFk54 6wdXhc0hxfTZJglmkzkXxoZYPoM2SZFKHSB8eUqMYNtrbju/ESPPd9+VgdqRwVvWfD5g 9HcREcMkcJb6ocwh/WMTdokb/3i+/B/cApTGjqLFkULlRnWlPjgL1pxJmoUzUJEfAyIp q/SsUJES5gS/RgQSCORVOP3S1hatViMxIBl8RhFPleo2PKBaptmw2xu3Wr0UDFyp8wn/ koZHfFPIcvxNFkZ/tvCFRlKY4hVAkpc/QjnUkPOQl1ImPQXAiiJsJZ/vt2yEICLPt8UN F74g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534302; x=1712139102; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/kJlpo1I8ft42uS0k4ZUD+WvURZMMcMdzv5LS8qVIKI=; b=BB0gT7fGfcwh8QYtfLWV3x4h4szklIfpNl70IYY0gQ45kpSE8SUOxcgU0Vral1Ls6m z2Lq8JxcHBxMpwAzpXxLlwI9LrBd4hZcXCOV2FhIlU5l2QhStHKocTmMHamu82pGa60W NpHnyTgs6FRxqPAQtmjijsIGOecxwQBvwcgHz8+rYW3lKkBUQlOyeYwUZb0qipDGqvQC 70iUkheyVGn1YPazFCvrgJLmyJyqJ7rkByklrl3X1CvJFZu4ujJXaL6SepAzMiJYJ/Lm BwpVH4UcPFHA/AD8mN7jfK+HC18PfAm/EWnSpjmr0yJuWmaOlLN5+NvHE8ICSLI7EOzB RMXg== X-Gm-Message-State: AOJu0Ywub9HYc6PECWTn57ZiJ92Fnr47su3taxJG++/cCIrs29pgeV+K 8O5KiyGgHix8HPNnhObN94pZxBmWnPDTKawT5uWu50ZhVG77X933S9YG4vpxrHGoBMzvHfiT6Tw HQ/E= X-Google-Smtp-Source: AGHT+IFr1HwKqohyWpOhRgDSCyfZj8j3bnrRD1vPzQ96WN1kwK5aWxdCZzib0e4F1AQslshGDC5GoQ== X-Received: by 2002:a50:99d8:0:b0:568:b3bf:409c with SMTP id n24-20020a5099d8000000b00568b3bf409cmr2453986edb.16.1711534302520; Wed, 27 Mar 2024 03:11:42 -0700 (PDT) Received: from antares.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id dh16-20020a0564021d3000b0056c1c4b870asm2451653edb.16.2024.03.27.03.11.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:41 -0700 (PDT) From: =?utf-8?q?Christoph_M=C3=BCllner?= To: opensbi@lists.infradead.org, Philipp Tomsich , Cooper Qu , Zhiwei Liu , Huang Tao , Alistair Francis Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH 0/9] T-Head: Allow read access to th.mxstatus CSR Date: Wed, 27 Mar 2024 11:11:28 +0100 Message-ID: <20240327101137.3644359-1-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_031146_812989_B530C31F X-CRM114-Status: GOOD ( 11.34 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On T-Head C9xx harts, the th.mxstatus CSR provides valuable information about the available vendor extensions. As this CSR is only accessible in M-mode, we need to provide a mechanism for other modes [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On T-Head C9xx harts, the th.mxstatus CSR provides valuable information about the available vendor extensions. As this CSR is only accessible in M-mode, we need to provide a mechanism for other modes to access this information. This patchset solves this by extending the existing platform abstraction such that platforms (or platform overrides) can provide a CSR read/write handler. A CSR read-handler for th.mxstatus is then added that is utilized by the Allwinner D1, the T-Head TH1520, and the Sophgo SG2042. Further, a generic mvendorid-based platform override is added that also enables the CSR read-handler for th.mxstatus (needed for QEMU). The CSR is documented here: https://github.com/T-head-Semi/thead-extension-spec/pull/45 For QEMU this patch depends on https://lists.gnu.org/archive/html/qemu-devel/2024-03/msg06368.html Christoph Müllner (9): sbi_platform: Add mechanism to handle CSR reads/writes in platform platform: generic: Add mechanism to handle CSR reads/writes in overrides lib: sbi_emulate_csr: Utilize platform hooks for unknown CSRs platform: generic: thead: Add CSR read handler for T-Head C9xx {allwinner/sun20i-d1,sophgo/sg2042,thead-generic}: Enable T-Head CSR read access platform: thead: Rename thead-generic to thead-th1520 platform: generic: Add mechanism to match via mvendorid platform: generic: thead: Add definition of T-Head's vendor ID platform: generic: Add generic T-Head override include/sbi/sbi_platform.h | 48 +++++++++++++++ lib/sbi/sbi_emulate_csr.c | 8 ++- platform/generic/Kconfig | 12 +++- platform/generic/allwinner/sun20i-d1.c | 2 + platform/generic/configs/defconfig | 3 +- platform/generic/include/platform_override.h | 5 ++ platform/generic/include/thead/c9xx_csr.h | 16 +++++ .../generic/include/thead/c9xx_encoding.h | 2 + platform/generic/platform.c | 58 ++++++++++++++++++- platform/generic/sophgo/sg2042.c | 2 + platform/generic/thead/Kconfig | 4 ++ platform/generic/thead/objects.mk | 9 ++- platform/generic/thead/thead-generic.c | 42 +++----------- platform/generic/thead/thead-th1520.c | 55 ++++++++++++++++++ platform/generic/thead/thead_c9xx_csr.c | 30 ++++++++++ 15 files changed, 252 insertions(+), 44 deletions(-) create mode 100644 platform/generic/include/thead/c9xx_csr.h create mode 100644 platform/generic/thead/thead-th1520.c create mode 100644 platform/generic/thead/thead_c9xx_csr.c