From patchwork Tue Dec 19 11:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1877843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4SvZGf64sYz240D for ; Tue, 19 Dec 2023 22:29:30 +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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PahSGHVrYPGqSy7gXJkPW5y+mSw2Gm2si6rY2cxK3PA=; b=nb4Io8M1x9V7Ed fzsnGG9UfFXuWb35W9rhwXzV72TJrnmIyZ4B8ucgME1sylNqoqsxBbbT4baLe58uqoWE/FQenHC1I 9H0pJzOaVcolzqM2GUtT1Yv/qbKMo8nne95CKNp+7aypi/H4Cd1VGWVYIWQtHRlnTtlVzI70iilzV Y9aguH5XWX8jITrlOlE49JUHk6owIFu7/tNQNsvYN2okMAI19LxdiJJpAevYTJD2IW0bZ+GDO4eB3 1OGUQcKac2ExGy1yMd+nm9Xau8WzqbofR+ddBrN0EDxqiA32rMhCsgV7Hd7X5Zsx1C+Iztr9Hizwf iaGFta1Ii7Pi80tDELHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFYHn-00Dk61-25; Tue, 19 Dec 2023 11:29:19 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFYHi-00DjzH-33 for opensbi@lists.infradead.org; Tue, 19 Dec 2023 11:29:16 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6d5e7664f8dso210774b3a.0 for ; Tue, 19 Dec 2023 03:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702985351; x=1703590151; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=l+k/Y5AcQt5h9JiWIwBhIugY+NrnMqn9hh4LxuQ3rqk=; b=Dk9HpAGPe6pxcS0dU2M54NZF9m/pRTzcuGy9bbvYvrPlaeZz3E6+55CPMMIjPm2bhb gjFsR08eOLr5jg8GCIFYaQkedlw1FuMV78LcUtFWTEDpVcqe26hFTJYaqrPiSVie6/g3 coCU1Qu8BGpAt02s/r+nyYgzL4VaBZTuV2tC9T3v6S8fs7JRN8BINLjFYgdkZOrOEEvW 5U/2WbuYXHN2iTPbNenS46ti/CzUM5hq00ZdaxwPgk2DjEF7KRksfUvoPIiKV2vv3gZV khqrxN0pg+1u0t3Az2urb3BzEMCHpoP28XkjSQ4H/SQPsGpTz5znkXgFVHPN19tLksrt LNFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702985351; x=1703590151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l+k/Y5AcQt5h9JiWIwBhIugY+NrnMqn9hh4LxuQ3rqk=; b=ZWf7u/FLVAexngRO/JwCkGqgFR2JliGbYTgItd9hYPmLRX6sXaDxRHy7CAFUZGxBw7 Rm5mKLW3Q0zQYDyo2e9g/op+QpLkIE0xxfofTjrQwQRdidWOgvniS6RXVLaqTMIBx3wj lnRSGdjuXxwFcdY0kCHLM5B52bBGSF7rycttObYViW1/7R4XKXFRkYAcn/0D2W+lDtXp 9MhZxqh9s5RUSL0a0Ww1Cx8GypKRS8zcaQ7hoMU8d4/Gsj8HxYGZSwZ43Nkn8RIEBA0H Cwpiveoc2/p4nQX1Wqcmr+pRfsMgmyEHzHGOnJKSKGr46xNz1kPVIrXYlb1KnJtNBdqx 7n7g== X-Gm-Message-State: AOJu0YzjpyhjNb3ENny7aPdOYulCLjRLXLNGBcGdCmAieUARZ9DQTk+m bzbKglz4G4rQSNYQWol+R62nCHKZ/0EN1sHO93J0RA== X-Google-Smtp-Source: AGHT+IEVfRsIN9I7UyO01/I9qTyIbXyu01DQApG8W/Aw9JdoQ+YulEJGxHkzEDNhT9Ken1fW/TW1qg== X-Received: by 2002:a05:6a20:8f0d:b0:185:a0eb:8574 with SMTP id b13-20020a056a208f0d00b00185a0eb8574mr37699044pzk.5.1702985350887; Tue, 19 Dec 2023 03:29:10 -0800 (PST) Received: from brahaspati.localdomain ([49.37.250.213]) by smtp.gmail.com with ESMTPSA id pi17-20020a17090b1e5100b0028b4488f3e7sm1315519pjb.13.2023.12.19.03.29.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 03:29:10 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Subject: [PATCH v1 6/7] lib: sbi: Introduce ecall handler for SBI debug trigger extension Date: Tue, 19 Dec 2023 16:58:55 +0530 Message-Id: <20231219112856.3865827-7-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231219112856.3865827-1-hchauhan@ventanamicro.com> References: <20231219112856.3865827-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_032914_996272_7BB8C7DF X-CRM114-Status: GOOD ( 15.27 ) 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: This patch adds functions to register ecalls for debug triggers and handler to handle the debug trigger function IDs. Signed-off-by: Himanshu Chauhan --- lib/sbi/Kconfig | 4 +++ lib/sbi/objects.mk | 3 ++ lib/sbi/sbi_ecall_dbtr.c | 74 ++++++++++++++++++++++++++++++++++++++++ 3 files changed [...] 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 [2607:f8b0:4864:20:0:0:0:42d 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 Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 This patch adds functions to register ecalls for debug triggers and handler to handle the debug trigger function IDs. Signed-off-by: Himanshu Chauhan --- lib/sbi/Kconfig | 4 +++ lib/sbi/objects.mk | 3 ++ lib/sbi/sbi_ecall_dbtr.c | 74 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 lib/sbi/sbi_ecall_dbtr.c diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig index 477775e..81dd2db 100644 --- a/lib/sbi/Kconfig +++ b/lib/sbi/Kconfig @@ -46,4 +46,8 @@ config SBI_ECALL_VENDOR bool "Platform-defined vendor extensions" default y +config SBI_ECALL_DBTR + bool "Debug Trigger Extension" + default y + endmenu diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index c7de150..0a50e95 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -52,6 +52,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_LEGACY) += sbi_ecall_legacy.o carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor 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 + 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_dbtr.c b/lib/sbi/sbi_ecall_dbtr.c new file mode 100644 index 0000000..0b589b2 --- /dev/null +++ b/lib/sbi/sbi_ecall_dbtr.c @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Ventana Micro Systems Inc. + * + * Author(s): + * Himanshu Chauhan + */ + +#include +#include +#include +#include +#include +#include + +static int sbi_ecall_dbtr_handler(unsigned long extid, unsigned long funcid, + const struct sbi_trap_regs *regs, + unsigned long *out_val, + struct sbi_trap_info *out_trap) +{ + unsigned long smode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >> + MSTATUS_MPP_SHIFT; + const struct sbi_domain *dom = sbi_domain_thishart_ptr(); + int ret = 0; + + switch (funcid) { + case SBI_EXT_DBTR_NUM_TRIGGERS: + ret = sbi_dbtr_num_trig(regs->a0, out_val); + break; + case SBI_EXT_DBTR_SETUP_SHMEM: + ret = sbi_dbtr_setup_shmem(dom, smode, regs->a0, regs->a1); + break; + case SBI_EXT_DBTR_TRIGGER_READ: + ret = sbi_dbtr_read_trig(dom, smode, regs->a0, regs->a1); + break; + case SBI_EXT_DBTR_TRIGGER_INSTALL: + ret = sbi_dbtr_install_trig(dom, smode, regs->a0, out_val); + break; + case SBI_EXT_DBTR_TRIGGER_UNINSTALL: + ret = sbi_dbtr_uninstall_trig(regs->a0, regs->a1); + break; + case SBI_EXT_DBTR_TRIGGER_ENABLE: + ret = sbi_dbtr_enable_trig(regs->a0, regs->a1); + break; + case SBI_EXT_DBTR_TRIGGER_UPDATE: + ret = sbi_dbtr_update_trig(dom, smode, regs->a0, regs->a1); + break; + case SBI_EXT_DBTR_TRIGGER_DISABLE: + ret = sbi_dbtr_disable_trig(regs->a0, regs->a1); + break; + default: + ret = SBI_ENOTSUPP; + }; + + return ret; +} + +struct sbi_ecall_extension ecall_dbtr; + +static int sbi_ecall_dbtr_register_extensions(void) +{ + if (!sbi_dbtr_supported()) + return 0; + + return sbi_ecall_register_extension(&ecall_dbtr); +} + +struct sbi_ecall_extension ecall_dbtr = { + .extid_start = SBI_EXT_DBTR, + .extid_end = SBI_EXT_DBTR, + .handle = sbi_ecall_dbtr_handler, + .register_extensions = sbi_ecall_dbtr_register_extensions, +};