From patchwork Wed Mar 27 10:11:30 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: 1916664 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=XWx6Kkhm; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=LRD+V2M1; 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=Ifva4PAF; 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 4V4Msd6LnDz1yXq for ; Wed, 27 Mar 2024 21:12:05 +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:References:In-Reply-To: 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: List-Owner; bh=kvhYfZ62KH1F6ZpsrgMCGVqaP7q+XNDNT0yc2LSWJvA=; b=XWx6KkhmXVuLxh Ti5w3EiO760y82Od72NOL1HnJ+hhikonZ2mIa2wca3ifAJXu4D99k0kVLnJFTBlVICH+OcDC8xphn 6LL3agO/ASzCR8A1G2XjmCDer7maKABJU2H+7cEdz3zdeJQ/L8nm6+WuB0tsdUn1koylu+ElV3GNQ 6E9Ew8/YHkZ1whj6At2I8EXVEJMs90A/Ny0yh9tSXtg8RYgc2k/KYlSj6ENn8UgcV/6Fq9fWK3+wl ZU6asuA94zcd+4VeV8BydjzQzkI7RaPXD06fCK3kkqCeSc3EbqukZX6D5g5taay2t0qbj8NhYmL/D q3GEjK+Rr4eYqzSWbY1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGD-00000008MFI-2Kn1; Wed, 27 Mar 2024 10:11:57 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQGB-00000008MCu-0meo for opensbi@bombadil.infradead.org; Wed, 27 Mar 2024 10:11:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=LRD+V2M1m58k7Qsy5gaIEQNna4 ll9Jgp1TFcHhVWwEoSlXXDKrikw6yErolMPnHTLAoP0hPmrQl9fvO5lhaBm+qFq+eDhJPtDE2Pw0l TLcqJ5AEUuskW2SrIbL6zg74BET6f+xo/z+Z83RiXo7moolVsWYTQkePGDD27am/fn4B5g2RX87YQ Y1PYr5CoWR1onGxDyieC4eQFRnC5u5PKlc1uQJpvuk6ljj4Swh3Tl9YGQDhq/4XeThXM4wePvWZkH 5K/e8MMlYQ7EQ3bkQoBEc6WNc4HUoUdX8kD8dydzmXqDXQeCTIyYuoprFRBNvAB0crZdcZkPtS2G6 +nWgYpMA==; Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpQG4-00000000AE9-2Dgz for opensbi@lists.infradead.org; Wed, 27 Mar 2024 10:11:51 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a46de423039so376423066b.0 for ; Wed, 27 Mar 2024 03:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1711534305; x=1712139105; darn=lists.infradead.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=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=Ifva4PAFlqy6WIqfnI6HtXxsigQm290STITHaAVEUzfs7G1kbfPL3P28OIfz/Oa14J 8SiVaGzDq14uDtNJAILL92ercnZI3LjYlcecJGLnXg9qI1OoY/fOcaMmJGLTEwBjIJKr xEBVs61eoFb0mtbzA7RTC8eBoM5coYRlavsJqseMGsHdWT5I2efAzbU6VRIlxcAUoaLi TVbkd1Q7tGP/FWyd3zDSN47OYdPHCu5U5MvTK5fhE2YzmN0Qb3gTFHZrVUFXUVuC44Fk zBo5z47PyuzCXlY1AOlU6U1Pvxyj6cotpK0+S4ufxZf4tY7qgCiXD6NjYczZ8BgPvfs3 2OGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711534305; x=1712139105; 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=KDmDl/1PKT+igpYbEhegBIxLzOiwrzrRPLnM7H4bwm0=; b=HIPfi5JZgLzAt5slAMUaA5W9frWjP+UXzEw4l4Y+Y5xK7ZCpSPyGgp1Wf6dwBPWiHv yQmJsrwiL1goTJHT/3QnP3firQHGenTi+Tnooqa/c1IK08bYvRY0h0Anv5xi3gKiTEOI 9HCFSG6BxZtC09kma9u1venhYbvBnEYHr0V0r9mKnbdzKpphJHhx2b4AcbScsvYnHPBA yrYUvXeyrM+R9Z/2MqK9plZvQPQzQTtn42VrcqYZRCiXKqd137dg5y5wI3QHuLctz+oG MwiEC6xB/d4UZ1L3cal39UGa/Q8JAgSMmJtmoz0Nwl1b6ZyrOQszdlXITp/t+f8tYyyv uAaw== X-Gm-Message-State: AOJu0YxsBTX7qPbyRixekrw++shRJfkNWlKBqUSLRJsGb+enRijs37tH FQief0dweoMaaP5sW0LujV0xMMfrm11wGd8yxGj4hTt79ORkwqpzP4iOqigtu+bLT/UsV6rCl68 IVHA= X-Google-Smtp-Source: AGHT+IEBNjKgESYF86f9EukHDiN2sOGOmlYratxBxPptwLWPauL/m5Bqk2QDZyvu5IQ1js8d6UTMZw== X-Received: by 2002:a50:d61b:0:b0:56b:a8ea:9642 with SMTP id x27-20020a50d61b000000b0056ba8ea9642mr2212446edi.14.1711534305127; Wed, 27 Mar 2024 03:11:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:11:44 -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 2/9] platform: generic: Add mechanism to handle CSR reads/writes in overrides Date: Wed, 27 Mar 2024 11:11:30 +0100 Message-ID: <20240327101137.3644359-3-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327101137.3644359-1-christoph.muellner@vrull.eu> References: <20240327101137.3644359-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_101149_389519_FF0B8066 X-CRM114-Status: GOOD ( 11.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: Overrides may want to provide access to custom CSRs. Let's add a layer that allows platform overrides to implement CSR read/write handlers, where custom CSRs can be accessed. This utilizes the corresp [...] 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:633 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 Overrides may want to provide access to custom CSRs. Let's add a layer that allows platform overrides to implement CSR read/write handlers, where custom CSRs can be accessed. This utilizes the corresponding platform hooks to access CSRs. Signed-off-by: Christoph Müllner --- platform/generic/include/platform_override.h | 4 ++++ platform/generic/platform.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/platform/generic/include/platform_override.h b/platform/generic/include/platform_override.h index b0585c2..6802126 100644 --- a/platform/generic/include/platform_override.h +++ b/platform/generic/include/platform_override.h @@ -34,6 +34,10 @@ struct platform_override { struct sbi_trap_regs *regs, struct sbi_ecall_return *out, const struct fdt_match *match); + int (*read_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val); + int (*write_csr)(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val); }; #endif diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 1f46b76..07fa9cc 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -273,6 +273,24 @@ static int generic_vendor_ext_provider(long funcid, generic_plat_match); } +static int generic_read_csr(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val) +{ + if (generic_plat && generic_plat->read_csr) + return generic_plat->read_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + +static int generic_write_csr(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val) +{ + if (generic_plat && generic_plat->write_csr) + return generic_plat->write_csr(csr_num, regs, csr_val); + + return SBI_ENOTSUPP; +} + static void generic_early_exit(void) { if (generic_plat && generic_plat->early_exit) @@ -408,6 +426,8 @@ const struct sbi_platform_operations platform_ops = { .timer_exit = fdt_timer_exit, .vendor_ext_check = generic_vendor_ext_check, .vendor_ext_provider = generic_vendor_ext_provider, + .read_csr = generic_read_csr, + .write_csr = generic_write_csr, }; struct sbi_platform platform = {