From patchwork Thu Mar 21 15:57:17 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: 1914521 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=nuYDCFLm; 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=r8seuVro; 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 4V0qqc1Qh0z23sN for ; Fri, 22 Mar 2024 02:58:01 +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=XjqiNPZtexXCw6nRVbUEA+QZ+cmKwwTcXtCt5oJb/78=; b=nuYDCFLmAjySNc tvI3JrhIkIq1XOEc+duCfrlkEUzJ/Iy9cWlkB4ns7Q9c8ShnlKbJpmRQH6zTJLqy0U7gnmgzRUjrw ixLf5qb3pb9ugg9Kk7S/4IPgCkLPqBvNDFpF4jh/9jccw0cfBwSoZd48+JmzS/0C8ySCvkttUFbgD aKDemzoFuBFEOkBuBv6kxcO7DEHku/mpM5tRgClat9NGaLcaweNJpwW4ivsxk22ExR4TWGA72zKbx TenJ2nhTqDNSs5cB/yoC2ITMVQIt8itFeSuIVZPebdNRetzBoNHsDnovlSlhW2+aoIrNFshrsUgD6 /e4sU5z6wlWSxV6KUtWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKnd-00000003fmz-3ymn; Thu, 21 Mar 2024 15:57:49 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKnZ-00000003fkb-2fWZ for opensbi@lists.infradead.org; Thu, 21 Mar 2024 15:57:47 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50e4e36c09cso370973e87.1 for ; Thu, 21 Mar 2024 08:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1711036661; x=1711641461; 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=IQnoj3FUiEJ099kF2zNJHPCILnrpMA6dg0SVky0Ldps=; b=r8seuVrouZcdUbJmOGfKBWP6OPVc9PA8vs7abgjsLtBeMco1R83R4x8l9PD/sQ1miz 2KQZmurzzz+YoxS2YyyA8k/19hWVLYpZnH3vK4dXsW0V/XzoGnyquTOnQfbzfOXRFlsg yKB1Jl4HXCs0zL2ezidRokgJJQVWrIl4BzFF2C6RoD/tTBesoGeJSbW3y2vETFS8PbCI m5qgCfgGuKZnvsM4MLTLLsfswMqtaoH93bg+ygZQiUcPz2WA5FcAjPcoksInCKfgEXXS beEpCipZQp4fVLb7R2VBbzFkcfZOM+ICDd8KZlIj3cvjpfUN4lJN1nVvzrSE9zrfWQjD /gXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036661; x=1711641461; 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=IQnoj3FUiEJ099kF2zNJHPCILnrpMA6dg0SVky0Ldps=; b=UJu26RxHBveqICNpKSNz//FTlCDz7O/ZCTnxO4/bCK9tstHdBGLDJmT/SJJ7V6cKHZ Y5AoohpDosFkdoHWTPx0cdBx2TvE3Ydoa4i3TSjnwtewUrYc9Sb4OLud+YfgVpAJTNcj EPkRuyZKr04bSOcWx7QjGlxoYprBbVMj3lvVtD+IWqOlz/X9WsvMCI2kC2SYwWuFGu4j K0VSaMYsUeDvcVezSYfjLJW2b3sx8PLBJMho6HSNFDLPMgwPGN/uPUW0rRspYw+H9Yn1 yZOgwoQD9+1RdtXUCqUr8fLDEB4EiP5AS84HAIJ1Iu6YlufV4DGBMijc+ab4WFh1mHTS 5C7Q== X-Gm-Message-State: AOJu0YxxQCKJGM5rCXGGD/P1q1nlhth+ubnRLa/NHZOvahGCPK/AFFk2 25nrRT0Iqjw6yXLh7Tx9LMptJESZrfda3soYeTtrDMFNfXPkoYKKODhST4piyBhPr0udpJoP1+3 B7rg= X-Google-Smtp-Source: AGHT+IEY71ymXj78raFrQnrFYHzJhNVgxaZCDnIatPQyVx353ZrgPJox+qPqZAxHjsg5WTgtFsdE5w== X-Received: by 2002:a2e:7a04:0:b0:2d6:2aff:7f57 with SMTP id v4-20020a2e7a04000000b002d62aff7f57mr3374356ljc.2.1711036661076; Thu, 21 Mar 2024 08:57:41 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:9b98:41b4:ceda:8f9]) by smtp.gmail.com with ESMTPSA id n20-20020a05600c4f9400b004140e701884sm160981wmq.22.2024.03.21.08.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 08:57:39 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: opensbi@lists.infradead.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , Deepak Gupta , Anup Patel , Himanshu Chauhan , Xiang W , Jessica Clarke Subject: [PATCH v3 2/3] lib: sbi: Implement SBI SSE extension Date: Thu, 21 Mar 2024 16:57:17 +0100 Message-ID: <20240321155720.1966860-3-cleger@rivosinc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240321155720.1966860-1-cleger@rivosinc.com> References: <20240321155720.1966860-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240321_085745_697931_CEFEA261 X-CRM114-Status: GOOD ( 13.60 ) X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__The_SBI_SSE_extension_defines_a_set_of?= =?unknown-8bit?q?_function_that_can_be?= =?unknown-8bit?q?_called_to_register_and_handle_supervisor_sofwtare_events?= =?unknown-8bit?q?=2E_This_patch_implements?= =?unknown-8bit?q?_all_of_the_functionality_defined_in_the_specification=2E_S?= =?unknown-8bit?q?igned-off-by=3A_Cl=C3=A9ment?= =?unknown-8bit?q?_L=C3=A9ger_=3Ccleger=40rivosinc=2Ecom=3E_---_lib/sbi/Kconf?= =?unknown-8bit?q?ig_=7C_4_+++_lib/sbi/objects=2Emk?= =?unknown-8bit?q?_=7C_3_+++_lib/sbi/sbi=5Fecall=5Fsse=2Ec_=7C_57_+++++++++++?= =?unknown-8bit?q?++++++++++++++++++++++++++++++?= =?unknown-8bit?b?IDMgZmlsZXMgY2hhbmdlZCwgNjQgaSBbLi4uXSA=?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C_no?= =?unknown-8bit?q?_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDoxMmYgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= 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 SSE extension defines a set of function that can be called to register and handle supervisor sofwtare events. This patch implements all of the functionality defined in the specification. Signed-off-by: Clément Léger Reviewed-by: Himanshu Chauhan > --- lib/sbi/Kconfig | 4 +++ lib/sbi/objects.mk | 3 +++ lib/sbi/sbi_ecall_sse.c | 57 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 lib/sbi/sbi_ecall_sse.c diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig index e3038ee..5db201d 100644 --- a/lib/sbi/Kconfig +++ b/lib/sbi/Kconfig @@ -54,4 +54,8 @@ config SBIUNIT bool "Enable SBIUNIT tests" default n +config SBI_ECALL_SSE + bool "SSE extension" + default y + endmenu diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index 2b9ac1f..b1c4a50 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -55,6 +55,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_VENDOR) += sbi_ecall_vendor.o carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_DBTR) += ecall_dbtr libsbi-objs-$(CONFIG_SBI_ECALL_DBTR) += sbi_ecall_dbtr.o +carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SSE) += ecall_sse +libsbi-objs-$(CONFIG_SBI_ECALL_SSE) += sbi_ecall_sse.o + libsbi-objs-y += sbi_bitmap.o libsbi-objs-y += sbi_bitops.o libsbi-objs-y += sbi_console.o diff --git a/lib/sbi/sbi_ecall_sse.c b/lib/sbi/sbi_ecall_sse.c new file mode 100644 index 0000000..cda96af --- /dev/null +++ b/lib/sbi/sbi_ecall_sse.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include + +static int sbi_ecall_sse_handler(unsigned long extid, unsigned long funcid, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) +{ + int ret; + + switch (funcid) { + case SBI_EXT_SSE_READ_ATTR: + ret = sbi_sse_read_attrs(regs->a0, regs->a1, regs->a2, regs->a3, + regs->a4); + break; + case SBI_EXT_SSE_WRITE_ATTR: + ret = sbi_sse_write_attrs(regs->a0, regs->a1, regs->a2, + regs->a3, regs->a4); + break; + case SBI_EXT_SSE_REGISTER: + ret = sbi_sse_register(regs->a0, regs->a1, regs->a2); + break; + case SBI_EXT_SSE_UNREGISTER: + ret = sbi_sse_unregister(regs->a0); + break; + case SBI_EXT_SSE_ENABLE: + ret = sbi_sse_enable(regs->a0); + break; + case SBI_EXT_SSE_DISABLE: + ret = sbi_sse_disable(regs->a0); + break; + case SBI_EXT_SSE_COMPLETE: + ret = sbi_sse_complete(regs, out); + break; + case SBI_EXT_SSE_INJECT: + ret = sbi_sse_inject_from_ecall(regs->a0, regs->a1, out); + break; + default: + ret = SBI_ENOTSUPP; + } + return ret; +} + +struct sbi_ecall_extension ecall_sse; + +static int sbi_ecall_sse_register_extensions(void) +{ + return sbi_ecall_register_extension(&ecall_sse); +} + +struct sbi_ecall_extension ecall_sse = { + .extid_start = SBI_EXT_SSE, + .extid_end = SBI_EXT_SSE, + .register_extensions = sbi_ecall_sse_register_extensions, + .handle = sbi_ecall_sse_handler, +};