From patchwork Tue Jul 30 06:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Raphael Tiovalen X-Patchwork-Id: 1966319 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=qtskxwzj; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=TtpHzveU; 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 4WY4mb084Bz20G6 for ; Tue, 30 Jul 2024 16:18:38 +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=fo6ZcxIZxFG6fUUX6YlgaAet0el/BDOYSdljK2JbZ/U=; b=qtskxwzj0y+SN8 msT4yy9y2jGMTrAZPpLAag12hmTyLylf0JFYH87oxwAxgfDU8DMffLxwPiSoPhyRg1Tnb4sA9IKWd HFNnwe638hWXnbMELZfjDPNP1ZKNcGKN4ukZkpa2xbQS9ljmUpDqTGWuHtLeJE/9+sOSuV6zATk4o NEpeJJ1vksxFGwtIqWmcly0yxZkRKaIptOkG4V7zK8/Q6+v3FpmEyXobj5AD/Hqzw5iDw1LcVn8cT FTNu+nUFR27BBfPJ1+T+Oq2lYgZmo1jAo9BjpqA4+UxGEZA1Ie7J4J+NptC9c3z1FlGl251QzRfFM cdaljdeqbKCXWZyX6Tcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYgBx-0000000DoVe-2MbV; Tue, 30 Jul 2024 06:18:37 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYgBv-0000000DoUF-0p4v for kvm-riscv@lists.infradead.org; Tue, 30 Jul 2024 06:18:36 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70d18d4b94cso2908294b3a.2 for ; Mon, 29 Jul 2024 23:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722320314; x=1722925114; 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=BEiXZ1Hftnd13V7cSXtmzxOOQFtbwN2az/SPk33hWyc=; b=TtpHzveUit4PQiRqSVaEc+E3vZ8azePIyIdMQMZyvXHvBNdS8DdiN0P1Gtg6jhvmFY PwQv8eYANs7O6NXLFSbXTrlWUy50CRBefj03vet7p/2WUzMrDsf8KQ0IRZ63hUkCDQEH NEqgbdFlsg5Wb4brWJswUyOCj4f6insZKR0tGZzEvMXfjrfnLRO3/1SXmijz0ON7d6H5 NZOHXVBnqHGre/LTjmLKTtUrRVRGPfhRX9rUUaKLr83C33WGTjWDaAytgu1W9r38uKuA +U8cFyA6MwbH7gDgxor8S6chVkSzhVgm33UUKf0g5jDdEoI1UyYunJxZn1SBKbvlKEU5 AcXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722320314; x=1722925114; 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=BEiXZ1Hftnd13V7cSXtmzxOOQFtbwN2az/SPk33hWyc=; b=rgg5mEqY/XVogsm03X9EP2FxTKc3JAM9+R1Zdz2w50WL7zfQ+2HwnF4ENwvD+/k9lv pUT/5xUh3kvQyXqmQtxX0a8qtrX6AG9aPfHjROZVjCkvWZwc8UYsQ9xfEDFTwayoLgxO ObRO76rjpLTQnOTXNFqQ+wsLJAJq+lYcOEQBqlXvUUBxyGA4OQg41fFAY0Tu3anLlEKu 0FmDYbrScYfurD7SzYHeAR0e91ZGmiCEGgWMv6wKc9ISBPr4JRzC13A/CJqIJ5vYvdW0 +1egquHFQA0OOwkWt6Nf6E9VnFsMOqbFJOkeDAu/CbV/65GVTfu8AY634Pc9DiC/IbEo l5RA== X-Forwarded-Encrypted: i=1; AJvYcCVgd2eTmaesi7hX4TbXYutvwTyL2TfmgZJbL4XZZqJ2hZF4Di6swhfQdnPurfOhW2IvG9UeOhHTkVT5v00k9tffQuTiHLTSVRV995+9CQ== X-Gm-Message-State: AOJu0YyewIbEvi0EtnxGpDDMVDcKksKvNOD0ZjxtO+VTuJ4PhE3R2w2w ZKlf4PVPM5TH5pIy+zXIQd4haoNrquIijqICZh3BF7jS5YC8Q0aP X-Google-Smtp-Source: AGHT+IHEOGQoMzw6uwNYgIfG5QWUNtOH7qO1sK3jwBwHoTREqCpBgVGPtSWJwiAOfdutPlMvqnSdKw== X-Received: by 2002:a05:6a20:9e4b:b0:1be:c2f7:275 with SMTP id adf61e73a8af0-1c4a153355fmr8735392637.50.1722320313931; Mon, 29 Jul 2024 23:18:33 -0700 (PDT) Received: from JRT-PC.. ([202.166.44.78]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead6e161dsm7732781b3a.42.2024.07.29.23.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 23:18:33 -0700 (PDT) From: James Raphael Tiovalen To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: andrew.jones@linux.dev, atishp@rivosinc.com, cade.richard@berkeley.edu, James Raphael Tiovalen Subject: [kvm-unit-tests PATCH v6 3/5] riscv: Add method to probe for SBI extensions Date: Tue, 30 Jul 2024 14:18:18 +0800 Message-ID: <20240730061821.43811-4-jamestiotio@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730061821.43811-1-jamestiotio@gmail.com> References: <20240730061821.43811-1-jamestiotio@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_231835_240802_FBE2D4D1 X-CRM114-Status: GOOD ( 10.08 ) X-Spam-Score: -2.1 (--) 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: Add a `sbi_probe` helper method that can be used by SBI extension tests to check if a given extension is available. Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: James Raphael Tiovalen --- lib/riscv/asm/sbi.h | 1 + lib/riscv/sbi.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) Content analysis details: (-2.1 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:436 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_EF Message has a valid DKIM or DK signature from envelope-from domain -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_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jamestiotio(at)gmail.com] 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 Add a `sbi_probe` helper method that can be used by SBI extension tests to check if a given extension is available. Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: James Raphael Tiovalen --- lib/riscv/asm/sbi.h | 1 + lib/riscv/sbi.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/riscv/asm/sbi.h b/lib/riscv/asm/sbi.h index d82a384d..5e1a674a 100644 --- a/lib/riscv/asm/sbi.h +++ b/lib/riscv/asm/sbi.h @@ -49,6 +49,7 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, void sbi_shutdown(void); struct sbiret sbi_hart_start(unsigned long hartid, unsigned long entry, unsigned long sp); +long sbi_probe(int ext); #endif /* !__ASSEMBLY__ */ #endif /* _ASMRISCV_SBI_H_ */ diff --git a/lib/riscv/sbi.c b/lib/riscv/sbi.c index f39134c4..3d4236e5 100644 --- a/lib/riscv/sbi.c +++ b/lib/riscv/sbi.c @@ -38,3 +38,16 @@ struct sbiret sbi_hart_start(unsigned long hartid, unsigned long entry, unsigned { return sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_START, hartid, entry, sp, 0, 0, 0); } + +long sbi_probe(int ext) +{ + struct sbiret ret; + + ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, 0, 0, 0, 0, 0, 0); + assert(!ret.error && ret.value >= 2); + + ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, ext, 0, 0, 0, 0, 0); + assert(!ret.error); + + return ret.value; +}