From patchwork Wed Mar 13 08:46:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 1911562 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=eoui90n+; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=kwUZRWfm; 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=kvm-riscv-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 4Tvkdv1w52z23qj for ; Wed, 13 Mar 2024 19:46:59 +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=SoonpveD/3+X71eXn7TpiIrcdt52zrc8X3of8OK4mms=; b=eoui90n+dNeN4r bvGfly8a79nHeDHFo/pEneMKSpYnPgByfc7VXiKRWeFE/ZpBIgkZlzGTqgAXaNUx5RX6LYZF9H4Ud dgTp9hiyrtaYnJeEB+1whIPKvUjv+LweUm3200Q2SUc0sOmUXlawhtkJvREB8b1Kw4LagllIip018 PJ+4LH0fAndHmGW/DuaBLxgH/EKrAKQCVl3lZNz88kdnb/RjFV5rxOPgD6d5DC/65KrL5enKvKAQB cyzxxuRRor7ZG390GYLkg2txS2xx5MwtT2hWSHUxxRGLCKgqW/zN1eR8vHN6v47quu3e/tF5uxfDs BCWQpHbuTY2u8sPWi38g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkKGH-00000009MxW-27Rw; Wed, 13 Mar 2024 08:46:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkKGD-00000009MvR-3Xg9 for kvm-riscv@lists.infradead.org; Wed, 13 Mar 2024 08:46:56 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B1FB76132C; Wed, 13 Mar 2024 08:46:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6802AC433F1; Wed, 13 Mar 2024 08:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710319612; bh=WSjKHg1dEERQr+qnBfIDt3HswsznsK37MrTirTMTisw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kwUZRWfmCuzR1nZAwd9sN0uUlTGirdGcWWY40UP4xAQSazUs9+S/qaPcVjoeBTxg4 AviWNHGYQCqqFmqq994Z7UcVUdPpCVM3pZrEvS7up/AjFhlkglYB9yaA7LmMvSJZlN LbBpf6a74MZ6fUZXCDl1GQOnQ1s8Skt3nyC33equr4Yvaoq3r3wAl/o7ucP9eAcZSI oba4DWCy8TOG5lPwP6GsS0phM/728UUEQB6VfOL/gePm70VOHWTqeGQADheAtkyRkd rQuXJT47+DqKppnPhXXKKs74oY48lyG3X7bCoVq5BO1nPyVlBhLf1ChJAeducvyMv1 YqaNeVzs31xhg== From: cem@kernel.org To: kvm-riscv@lists.infradead.org Cc: ajones@ventanamicro.com, tech-prs@lists.riscv.org Subject: [PATCH V2 1/6] riscv: Add test to probe SBI Extension Date: Wed, 13 Mar 2024 09:46:19 +0100 Message-ID: <20240313084644.277426-2-cem@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313084644.277426-1-cem@kernel.org> References: <20240313084644.277426-1-cem@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_014653_971971_13D08953 X-CRM114-Status: GOOD ( 11.70 ) X-Spam-Score: -3.5 (---) 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: From: Carlos Maiolino Factor out vendor id test to a new helper, and add a new test for probing the SBI extension. Compare the retrieved value against an environment variable, as the implementation can return any non-zero [...] Content analysis details: (-3.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2604:1380:4641:c500:0:0:0:1 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_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.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.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Carlos Maiolino Factor out vendor id test to a new helper, and add a new test for probing the SBI extension. Compare the retrieved value against an environment variable, as the implementation can return any non-zero value. Signed-off-by: Carlos Maiolino Reviewed-by: Andrew Jones --- V2: - change sbi_ecall()'s format, to fit a single line. - Make PROBE_EXT envvar optional, as suggested by Drew. This prevents the test to bail if the envvar is not set. riscv/sbi.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/riscv/sbi.c b/riscv/sbi.c index ffb07a25..1d73d8f1 100644 --- a/riscv/sbi.c +++ b/riscv/sbi.c @@ -14,28 +14,49 @@ static void help(void) puts("An environ must be provided where expected values are given.\n"); } -int main(int argc, char **argv) +static void check_base(void) { struct sbiret ret; long expected; - if (argc > 1 && !strcmp(argv[1], "-h")) { - help(); - exit(0); - } - - report_prefix_push("sbi"); + report_prefix_push("base"); if (!getenv("MVENDORID")) { report_skip("mvendorid: missing MVENDORID environment variable"); - goto done; + return; } + + report_prefix_push("mvendorid"); expected = strtol(getenv("MVENDORID"), NULL, 0); ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_MVENDORID, 0, 0, 0, 0, 0, 0); - report(!ret.error, "mvendorid: no error"); - report(ret.value == expected, "mvendorid"); -done: + report(!ret.error, "no sbi.error"); + report(ret.value == expected, "expected sbi.value"); + report_prefix_pop(); + + report_prefix_push("probe_ext"); + expected = getenv("PROBE_EXT") ? strtol(getenv("PROBE_EXT"), NULL, 0) : 1; + + ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, SBI_EXT_BASE, 0, 0, 0, 0, 0); + + report(!ret.error, "no sbi.error"); + report(ret.value == expected, "expected sbi.value"); + report_prefix_pop(); + + report_prefix_pop(); +} + +int main(int argc, char **argv) +{ + + if (argc > 1 && !strcmp(argv[1], "-h")) { + help(); + exit(0); + } + + report_prefix_push("sbi"); + check_base(); + return report_summary(); }