From patchwork Wed Jun 19 09:42:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 1949606 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=MT4ygP/A; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=UcJipxX4; 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 4W3zFw34LGz20Wb for ; Wed, 19 Jun 2024 19:43:32 +1000 (AEST) 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=xnoyJkmNacpSLnxkodWrRFf+eMAVd88srijqbFdF0sM=; b=MT4ygP/AXNlV6K rU1GkhOp4+yQ+2Nal3/CyoBLSMAn6kKLoDpZU3HO/cUDv6REuqu3/EOx15yTNVdtLrndr56+LYt88 gkIW1hc8x69D1v3KyhUYuicEmdteljfSJWlcmK2blJQvEneiJaTM/dT7rRRMZCDS+ZxNkwIZbIusz n6+Txwe1KW+d6Uz/3AWhHhDA0AL1JpHZt4al30TIxSFafRUePKTuLnvyEZLlDI2GMdxfupGRsN6uQ nnjwWFI3C5cseZg2Ene34HM/yOoiv1tzxCAraT75ovTL6EGON+qQitFRZQTZrnkqCMAxX3LE9+2ce mp1hvr++yDwqgBNpILzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJrqg-00000000dH8-1odb; Wed, 19 Jun 2024 09:43:26 +0000 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJrqc-00000000dDg-21Nm for opensbi@lists.infradead.org; Wed, 19 Jun 2024 09:43:24 +0000 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-254976d3327so486373fac.1 for ; Wed, 19 Jun 2024 02:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718790200; x=1719395000; 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=v1xHjbFk0bmx3tuzfB9+yj0XxWTa/UGzDUGubo0vbjM=; b=UcJipxX4fhW6vcRJMYxnCKOWeOSXVx1kdqFGwtFPpHRkwnOUXqLCJm1wbqN8i5Jy+f 3VZpjj+VRawcqFw4L8wB4bPQR0jyZ+YHvZbz+VTS/ii8pCAtC+QVKG+7QuFvafSLLnFt K7hYO7zY3TpmPDOw/L5Y1QZB0PKH+Aap+zjy8j+m0LPU07ydfADoCle1j/2ZYEPTqco/ 6mGSE30a+nCl7VtpphgJndHmnoDKmmoikkncOodfL4tpdBf2iOIOyDKbvp6AQT1AORBi ebU7Cv6eAmQZBzhF1XmmbFhlVEKzln3I/kOWglqZmlXchGuRf/W8IlcB+azbwLd9S75y q6Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718790200; x=1719395000; 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=v1xHjbFk0bmx3tuzfB9+yj0XxWTa/UGzDUGubo0vbjM=; b=vP7q69w+GqyaEbmCH4bLbRkpdOU0zW+Xvo2citBSIxGPCFbLBLrsfH0HiJUv0gyfim v7XtEu2JBleANL7mlS4qhGKz1DKAR6Nucx7xo76quob73vH2MPIYb6jj75HaasDC8zYS dHD0qoeA5iTfH4Lv3UuM2FjkjmaubztYTHswnIMVD1FKEJVv/q45vo81H7Z/LFYs48vZ GrdhiZ5bb4FzI9vPxSjCeaA4K3peMNrehZykRjaMOX6yBTOCwngnwPEzDNHuMTa0myKN S95tDjrCxiHDrECcxIKgDLqGveXz8WtENioLjdFk85YaQHj9u0jesliUiUBnWzNptEYA bXJQ== X-Gm-Message-State: AOJu0Yx85d7fAquJWbLdGoGLvbG3JL5U8S9cLLit7eFfiC+IYkTVskfJ UHczTB5ZtJfXVN6PspGyK541Z3H5FWE6KRmOp2kVSuZVq9PszAxArjkqvDo2ze925guhwARd9g0 ZFSw= X-Google-Smtp-Source: AGHT+IHX/FSYw4h030VDORPNmTPyQ6KtG6IYMQvsgxUSjHB2XMY40jzs0KNubaNMC/zQck25PXkkdw== X-Received: by 2002:a05:6870:819e:b0:24f:e599:9168 with SMTP id 586e51a60fabf-25c948fe195mr2209573fac.1.1718790200457; Wed, 19 Jun 2024 02:43:20 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:b69:7f57:35a2:8f92]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc97af20sm10259067b3a.70.2024.06.19.02.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 02:43:19 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: opensbi@lists.infradead.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Anup Patel , Atish Patra Subject: [PATCH v3 4/4] lib: sbi: implement SBI FWFT extension Date: Wed, 19 Jun 2024 11:42:42 +0200 Message-ID: <20240619094244.603628-5-cleger@rivosinc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240619094244.603628-1-cleger@rivosinc.com> References: <20240619094244.603628-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240619_024322_570699_E4BC666B X-CRM114-Status: GOOD ( 14.71 ) X-Spam-Score: -0.0 (/) 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: The SBI FWFT extension defines a set of function that can be called to control the configuration of some platform features (misaligned trap delegation, etc). This patch implements sbi_fwft_set() and s [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:4860:4864:20:0:0:0:30 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 The SBI FWFT extension defines a set of function that can be called to control the configuration of some platform features (misaligned trap delegation, etc). This patch implements sbi_fwft_set() and sbi_fwft_get() as defined in the specification [1]. Link: https://lists.riscv.org/g/tech-prs/message/924 [1] Signed-off-by: Clément Léger Reviewed-by: Anup Patel --- lib/sbi/Kconfig | 4 ++++ lib/sbi/objects.mk | 3 +++ lib/sbi/sbi_ecall_fwft.c | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 lib/sbi/sbi_ecall_fwft.c diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig index cc8e031..6cf54ce 100644 --- a/lib/sbi/Kconfig +++ b/lib/sbi/Kconfig @@ -38,6 +38,10 @@ config SBI_ECALL_CPPC bool "CPPC extension" default y +config SBI_ECALL_FWFT + bool "Firmware Feature extension" + default y + config SBI_ECALL_LEGACY bool "SBI v0.1 legacy extensions" default y diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index 221e72c..211abad 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -46,6 +46,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_DBCN) += sbi_ecall_dbcn.o carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_CPPC) += ecall_cppc libsbi-objs-$(CONFIG_SBI_ECALL_CPPC) += sbi_ecall_cppc.o +carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_FWFT) += ecall_fwft +libsbi-objs-$(CONFIG_SBI_ECALL_FWFT) += sbi_ecall_fwft.o + carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy libsbi-objs-$(CONFIG_SBI_ECALL_LEGACY) += sbi_ecall_legacy.o diff --git a/lib/sbi/sbi_ecall_fwft.c b/lib/sbi/sbi_ecall_fwft.c new file mode 100644 index 0000000..267cbab --- /dev/null +++ b/lib/sbi/sbi_ecall_fwft.c @@ -0,0 +1,49 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Rivos Inc. + * + * Authors: + * Clément Léger + */ + +#include +#include +#include +#include +#include + +static int sbi_ecall_fwft_handler(unsigned long extid, unsigned long funcid, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) +{ + int ret = 0; + + switch (funcid) { + case SBI_EXT_FWFT_SET: + ret = sbi_fwft_set(regs->a0, regs->a1, regs->a2); + break; + case SBI_EXT_FWFT_GET: + ret = sbi_fwft_get(regs->a0, &out->value); + break; + default: + ret = SBI_ENOTSUPP; + break; + } + + return ret; +} + +struct sbi_ecall_extension ecall_fwft; + +static int sbi_ecall_fwft_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_fwft); +} + +struct sbi_ecall_extension ecall_fwft = { + .extid_start = SBI_EXT_FWFT, + .extid_end = SBI_EXT_FWFT, + .register_extensions = sbi_ecall_fwft_register_extensions, + .handle = sbi_ecall_fwft_handler, +};