From patchwork Tue Mar 5 17:09:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1908387 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=esAO0s85; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ox5edQsP; 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 4Tq29S1b4Xz23cb for ; Wed, 6 Mar 2024 04:09:32 +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=KemwCcwFEe5UyWWwUKftxJhcSk58jX8iY099cmj1DkE=; b=esAO0s850xx2JS TtK3nNzP/SetO4j2vlaDQjzlQx3LHscKM7qssF7tUySVvZIxHIuTUvQbQH3M+dJjkhgYYWWgoVYwz SP1E/Q90eSsXPYXrl1btEjEC9t2nN/gdylyVxoAASJsQNvYw2IO/ZQwGCG75OtYuPDgroQUc+ducb C0FdehkQaLAuqB790H/eYuyNok1QMCB+q18xzpJN/ajne3M1fb3pPC+swcDVObkLW4qfjICP4k6df OxkYzLh0r6a9QtfAUr8Q84vMiPmya24k533cWcfY1MXnoB58RtYSf2Nm2ssRkfGS9dQj61mAfeAsf KKQBDcMaS1W+94XwOpyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhYIE-0000000Ecrn-2ybb; Tue, 05 Mar 2024 17:09:30 +0000 Received: from out-180.mta0.migadu.com ([2001:41d0:1004:224b::b4]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhYIC-0000000EcnO-03Tn for kvm-riscv@lists.infradead.org; Tue, 05 Mar 2024 17:09:29 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709658564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=93j558n2c9M/wnd4Gl+GXqrjA0pFzvhNpPqZFAfZ8b4=; b=ox5edQsP4fReVT1V3AREl0nJmBkXszE9KZAr8+enA6Qkas/hdHhDRh+nvIiLc70P3cXtTA +VGvAelPsLiqHfTRWlOBuVFy7TbiS3lqkQEVduPdPENy2nA+gV+8qSKXYF+8mj662eeCS9 DLu4DhSn2+Spmk5+8dG4Ca6qCRpBvPw= From: Andrew Jones To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: pbonzini@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v2 09/13] efi: Add support for obtaining the boot hartid Date: Tue, 5 Mar 2024 18:09:08 +0100 Message-ID: <20240305170858.395836-24-andrew.jones@linux.dev> In-Reply-To: <20240305170858.395836-15-andrew.jones@linux.dev> References: <20240305170858.395836-15-andrew.jones@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_090928_239767_425BB9F1 X-CRM114-Status: UNSURE ( 9.77 ) X-CRM114-Notice: Please train this message. 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: riscv needs to use an EFI protocol to get the boot hartid. Signed-off-by: Andrew Jones --- lib/efi.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/efi.c b/lib/efi.c index 12c66c6ffd1f..5314eaa81e66 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -29,6 +29,31 @@ extern int main(int argc, char **argv, char **envp); Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 riscv needs to use an EFI protocol to get the boot hartid. Signed-off-by: Andrew Jones --- lib/efi.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/efi.c b/lib/efi.c index 12c66c6ffd1f..5314eaa81e66 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -29,6 +29,31 @@ extern int main(int argc, char **argv, char **envp); efi_system_table_t *efi_system_table = NULL; +#ifdef __riscv +#define RISCV_EFI_BOOT_PROTOCOL_GUID EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, 0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf) + +unsigned long boot_hartid; + +struct riscv_efi_boot_protocol { + u64 revision; + efi_status_t (*get_boot_hartid)(struct riscv_efi_boot_protocol *, + unsigned long *boot_hartid); +}; + +static efi_status_t efi_get_boot_hartid(void) +{ + efi_guid_t boot_protocol_guid = RISCV_EFI_BOOT_PROTOCOL_GUID; + struct riscv_efi_boot_protocol *boot_protocol; + efi_status_t status; + + status = efi_bs_call(locate_protocol, &boot_protocol_guid, NULL, + (void **)&boot_protocol); + if (status != EFI_SUCCESS) + return status; + return efi_call_proto(boot_protocol, get_boot_hartid, &boot_hartid); +} +#endif + static void efi_free_pool(void *ptr) { efi_bs_call(free_pool, ptr); @@ -421,6 +446,14 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) goto efi_main_error; } +#ifdef __riscv + status = efi_get_boot_hartid(); + if (status != EFI_SUCCESS) { + printf("Failed to get boot haritd\n"); + goto efi_main_error; + } +#endif + /* * Exit EFI boot services, let kvm-unit-tests take full control of the * guest