From patchwork Tue Jan 9 17:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1884523 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=CF67ZV62; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=YqlIJNWT; 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 4T8cdc3TF1z1yPk for ; Wed, 10 Jan 2024 04:01:08 +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=XWTsh6i6fsTQYbbaDobbi5mRBJEXCkGykx3C27H3JeQ=; b=CF67ZV62aE120r ajS8ZzM5xwdH0qcj9VYjlhxDdOVLv7eMJJ48QrhhGlsMDpnq3cPlEEp870Z23EZsVRpFnVewuR8wx Hf1hex+SYfdqJt/0rqi8aTHurFFg+oiOdSmMgyEH2fFYLVLtsWCgid/fGpKKIFjVKZVIntIjsow2c vu+hrIZQmKy2PZnZOpNGc3phgYn+F7AQMr5OvlmHqEzcAsMWeEQUXS4jofziykgqbnNTzOAT7t1q7 Bs/WZhdMGXgbcZCznAo99xvqBeDxr/KBxfe97u08uhSSqj4PaG5Gisn9x/aSWNEe7GsGesLanHiri xwd9j9bqss+Mh2z7l3qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNFT0-008w5z-2U; Tue, 09 Jan 2024 17:00:42 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNFSx-008w4K-18 for opensbi@lists.infradead.org; Tue, 09 Jan 2024 17:00:40 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d3ae9d1109so6336055ad.0 for ; Tue, 09 Jan 2024 09:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1704819636; x=1705424436; 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=RGdSWWeukO17taffK1aqWDgJlyUDzJj6ev23CE8fLas=; b=YqlIJNWTYyKb7dYJouzA9DuYplXgV+t3f4gEsEqLGXLT8HxLzAylVSHCIY/H9MRKpt mFIGnV5zv0gFhLfYoHHgAop6nN6Qy3IY7vkYdnwW/AWztcNtRsNtmMWPAxIEZX0US269 wgfTO7mtpj6GsSI9GExZMiKiXIDf03gUuLOnnyc/hSCY20Gr2EuRJr3C/d9sSSho25q0 BeStMtQ8AXOt5jFpyMBQ58GbZRHbSmJOV83USL0geoL/kIys5vohN29KhyTkJugzkOMh W29aGFtCHlYOxsjsxMEQxwPLhiU+NMIwoUUDOkrXJFvNOJxiw0klXxRihDrrtqITsNDX O+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704819636; x=1705424436; 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=RGdSWWeukO17taffK1aqWDgJlyUDzJj6ev23CE8fLas=; b=f6hBZXlsTNLwMpJ5JjieyIeioDGtKAdD3yrZq0USraTR2vJYgpLsbx+bTDZr1QrsLw R/kWPfInAQuxXXmzG/+TTBNHGzAX1mpCn1qx2afYzLrnyN0l7OI345ddSBj4sdUh/k6u vheipNyCPcWHTnJQLiM/TEr0o3fuV9DrO7/mUnUNGH5CKVUV+dol1UGcr4/1difQwOJt 4/Fe5Iz3OFyucjfb641TYilHZ4MFT9LPXlC691vg3au5xbfuvGCaJVA4+5Vm6kRDg0jf fbwcCYhanoEl4qHmWx3U186mA4YsMKfv1dUYEJ4/O5m9lV+X+5LB8VK+jy9c2NKK1GP7 T0vg== X-Gm-Message-State: AOJu0YxDtmb95gROw0usw3ccBpyfaFTE1nCJAtoY8LFgLWTjPSWz1IU6 S9qy+dDhEh7x7mYfrVTjpys2eUZvs/uLbeOZ3zcI1Bw9qcA= X-Google-Smtp-Source: AGHT+IHOk+I9VqdpTsAcoueg/OoYadmaJjhb/AO7f7/5NrwVqD7mkemyo45Kt4E3feM9fbKKyk36RA== X-Received: by 2002:a17:902:8682:b0:1d4:e308:d6fb with SMTP id g2-20020a170902868200b001d4e308d6fbmr11539677plo.5.1704819636418; Tue, 09 Jan 2024 09:00:36 -0800 (PST) Received: from brahaspati.localdomain ([49.37.250.161]) by smtp.gmail.com with ESMTPSA id w8-20020a170902a70800b001d3dff2575fsm2024086plq.52.2024.01.09.09.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 09:00:36 -0800 (PST) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Anup Patel Subject: [PATCH v3 7/8] lib: sbi: Implement SBI debug trigger extension Date: Tue, 9 Jan 2024 22:30:19 +0530 Message-Id: <20240109170020.1731282-8-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240109170020.1731282-1-hchauhan@ventanamicro.com> References: <20240109170020.1731282-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240109_090039_435292_3FA39199 X-CRM114-Status: GOOD ( 15.70 ) 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 Reviewed-by: Anup Patel --- lib/sbi/Kconfig | 4 +++ lib/sbi/objects.mk | 3 ++ lib/sbi/sbi_ecall_dbtr.c | 73 ++++++++++ [...] 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:62b 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 Reviewed-by: Anup Patel --- lib/sbi/Kconfig | 4 +++ lib/sbi/objects.mk | 3 ++ lib/sbi/sbi_ecall_dbtr.c | 73 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 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..2765320 --- /dev/null +++ b/lib/sbi/sbi_ecall_dbtr.c @@ -0,0 +1,73 @@ +/* + * 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, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) +{ + 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->value); + 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->value); + 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_get_total_triggers() == 0) + 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, +};