git: 848e2719af50 - main - x86/xen: remove parameter from fixup_console()

From: Roger Pau Monné <royger_at_FreeBSD.org>
Date: Thu, 22 Feb 2024 10:31:21 UTC
The branch main has been updated by royger:

URL: https://cgit.FreeBSD.org/src/commit/?id=848e2719af508516452b447047ddf6642ce42d0f

commit 848e2719af508516452b447047ddf6642ce42d0f
Author:     Roger Pau Monné <royger@FreeBSD.org>
AuthorDate: 2024-02-02 08:32:15 +0000
Commit:     Roger Pau Monné <royger@FreeBSD.org>
CommitDate: 2024-02-22 10:08:04 +0000

    x86/xen: remove parameter from fixup_console()
    
    And instead fetch the metadata inside of the function.
    
    This is done in preparation for changing the call site of fixup_console(),
    which will no longer have the kernel metedata pointer in context.
    
    No functional change intended.
    
    Sponsored by: Cloud Software Group
    Reviewed by: markj
    Differential revision: https://reviews.freebsd.org/D43931
---
 sys/x86/xen/pv.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c
index 9ea276caee81..75c345ff3a2c 100644
--- a/sys/x86/xen/pv.c
+++ b/sys/x86/xen/pv.c
@@ -335,7 +335,7 @@ xen_pvh_parse_symtab(void)
 #endif
 
 static void
-fixup_console(caddr_t kmdp)
+fixup_console(void)
 {
 	struct xen_platform_op op = {
 		.cmd = XENPF_get_dom0_console,
@@ -346,10 +346,19 @@ fixup_console(caddr_t kmdp)
 		struct vbe_fb vbe;
 	} *fb = NULL;
 	int size;
+	caddr_t kmdp;
+
+	kmdp = preload_search_by_type("elf kernel");
+	if (kmdp == NULL)
+		kmdp = preload_search_by_type("elf64 kernel");
+	if (kmdp == NULL) {
+		xc_printf("Unable to find kernel metadata\n");
+		return;
+	}
 
 	size = HYPERVISOR_platform_op(&op);
 	if (size < 0) {
-		xc_printf("Failed to get dom0 video console info: %d\n", size);
+		xc_printf("Failed to get video console info: %d\n", size);
 		return;
 	}
 
@@ -486,7 +495,7 @@ xen_pvh_parse_preload_data(uint64_t modulep)
 		else
 		    strlcpy(bootmethod, "BIOS", sizeof(bootmethod));
 
-		fixup_console(kmdp);
+		fixup_console();
 	} else {
 		/* Parse the extra boot information given by Xen */
 		if (start_info->cmdline_paddr != 0)