From: Andrew Jones <andrew.jones@linux.dev>
To: kvm-riscv@lists.infradead.org
Subject: [kvm-unit-tests PATCH 09/13] efi: Add support for obtaining the boot hartid
Date: Wed, 28 Feb 2024 16:04:25 +0100 [thread overview]
Message-ID: <20240228150416.248948-24-andrew.jones@linux.dev> (raw)
In-Reply-To: <20240228150416.248948-15-andrew.jones@linux.dev>
riscv needs to use an EFI protocol to get the boot hartid.
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
lib/efi.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/lib/efi.c b/lib/efi.c
index edfcc80ef114..77cfbfac50ed 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);
@@ -422,6 +447,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
--
2.43.0
next prev parent reply other threads:[~2024-02-28 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 15:04 [kvm-unit-tests PATCH 00/13] Enable EFI support Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 01/13] riscv: Call abort instead of assert on unhandled exceptions Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 02/13] riscv: show_regs: Prepare for EFI images Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 03/13] treewide: lib/stack: Fix backtrace Andrew Jones
2024-02-28 17:33 ` Claudio Imbrenda
2024-02-29 3:31 ` Nicholas Piggin
2024-02-29 11:48 ` Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 04/13] treewide: lib/stack: Make base_address arch specific Andrew Jones
2024-02-29 3:49 ` Nicholas Piggin
2024-02-29 11:54 ` Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 05/13] riscv: Import gnu-efi files Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 06/13] riscv: Tweak the gnu-efi imported code Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 07/13] riscv: Enable building for EFI Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 08/13] riscv: efi: Switch stack in _start Andrew Jones
2024-02-28 15:04 ` Andrew Jones [this message]
2024-02-28 15:04 ` [kvm-unit-tests PATCH 10/13] riscv: Refactor setup code Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 11/13] riscv: Enable EFI boot Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 12/13] riscv: efi: Add run script Andrew Jones
2024-02-28 15:04 ` [kvm-unit-tests PATCH 13/13] riscv: efi: Use efi-direct by default Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240228150416.248948-24-andrew.jones@linux.dev \
--to=andrew.jones@linux.dev \
--cc=kvm-riscv@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox