FreeBSD Bugzilla – Attachment 252140 Details for
Bug 277200
emulators/xen-kernel Dom0 built with FreeBSD 14 fails to boot
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix candidate for 14
0001-xen-pvh-fix-initialization-of-environment.patch (text/plain), 5.56 KB, created by
Roger Pau Monné
on 2024-07-18 09:47:35 UTC
(
hide
)
Description:
Fix candidate for 14
Filename:
MIME Type:
Creator:
Roger Pau Monné
Created:
2024-07-18 09:47:35 UTC
Size:
5.56 KB
patch
obsolete
>From 591311d36d619051e78ad2780d42fce2d94ef8ff Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <royger@FreeBSD.org> >Date: Thu, 18 Jul 2024 11:44:17 +0200 >Subject: [PATCH] xen/pvh: fix initialization of environment > >Xen PVH entry point requires to modify the environment passed from the boot >loader, so that the ACPI RSDP is re-written to use the Xen generated RSDP >instead of the native one. > >The current logic in the PVH entry point reserves a single page (4K) in order >to copy the contents of the environment passed from the boot loader, so that >the bootloader provided "acpi.rsdp" is dropped and a Xen specific one is added >afterwards. > >This however doesn't scale well, as it's possible for the environment to be >bigger than 4K. Bumping the buffer, or attempting to peek at the size of the >metadata all seem to just add more complexity to a sensitive path. Instead >introduce a new ACPI hook that allows setting the RSDP address directly, and >use it from the PVH entry point so set the position of the Xen generated RSDP. > >This allows to reduce the logic in the PVH metadata processing, as there's no >need to parse and filter the bootloader provided environment. > >Sponsored by: Cloud Software Group >PR: 277200 >--- > sys/x86/acpica/OsdEnvironment.c | 8 ++++ > sys/x86/include/acpica_machdep.h | 2 + > sys/x86/xen/pv.c | 68 +++----------------------------- > 3 files changed, 15 insertions(+), 63 deletions(-) > >diff --git a/sys/x86/acpica/OsdEnvironment.c b/sys/x86/acpica/OsdEnvironment.c >index 6d6448fbcf0f..3f3b0448b35d 100644 >--- a/sys/x86/acpica/OsdEnvironment.c >+++ b/sys/x86/acpica/OsdEnvironment.c >@@ -78,6 +78,14 @@ acpi_get_root_from_memory(void) > return (0); > } > >+void >+acpi_set_root(vm_paddr_t addr) >+{ >+ >+ KASSERT(acpi_root_phys == 0, ("ACPI root pointer already set")); >+ acpi_root_phys = addr; >+} >+ > ACPI_PHYSICAL_ADDRESS > AcpiOsGetRootPointer(void) > { >diff --git a/sys/x86/include/acpica_machdep.h b/sys/x86/include/acpica_machdep.h >index b4811e4bd30c..2592b47ae1c1 100644 >--- a/sys/x86/include/acpica_machdep.h >+++ b/sys/x86/include/acpica_machdep.h >@@ -84,6 +84,8 @@ void madt_parse_interrupt_values(void *entry, > extern int madt_found_sci_override; > extern int (*apei_nmi)(void); > >+void acpi_set_root(vm_paddr_t addr); >+ > #endif /* _KERNEL */ > > #endif /* __ACPICA_MACHDEP_H__ */ >diff --git a/sys/x86/xen/pv.c b/sys/x86/xen/pv.c >index c9537d153820..f19f93bfcb75 100644 >--- a/sys/x86/xen/pv.c >+++ b/sys/x86/xen/pv.c >@@ -60,6 +60,7 @@ > > #include <machine/_inttypes.h> > #include <machine/intr_machdep.h> >+#include <x86/acpica_machdep.h> > #include <x86/apicvar.h> > #include <x86/init.h> > #include <machine/pc/bios.h> >@@ -161,7 +162,6 @@ hammer_time_xen(vm_paddr_t start_info_paddr) > struct hvm_modlist_entry *mod; > struct xen_add_to_physmap xatp; > uint64_t physfree; >- char *kenv; > int rc; > > if (isxen()) { >@@ -225,15 +225,6 @@ hammer_time_xen(vm_paddr_t start_info_paddr) > physfree += PAGE_SIZE; > } > >- /* >- * Init a static kenv using a free page. The contents will be filled >- * from the parse_preload_data hook. >- */ >- kenv = (void *)(physfree + KERNBASE); >- physfree += PAGE_SIZE; >- bzero_early(kenv, PAGE_SIZE); >- init_static_kenv(kenv, PAGE_SIZE); >- > /* Set the hooks for early functions that diverge from bare metal */ > init_ops = xen_pvh_init_ops; > hvm_start_flags = start_info->flags; >@@ -244,52 +235,6 @@ hammer_time_xen(vm_paddr_t start_info_paddr) > > /*-------------------------------- PV specific -------------------------------*/ > >-/* >- * When booted as a PVH guest FreeBSD needs to avoid using the RSDP address >- * hint provided by the loader because it points to the native set of ACPI >- * tables instead of the ones crafted by Xen. The acpi.rsdp env variable is >- * removed from kenv if present, and a new acpi.rsdp is added to kenv that >- * points to the address of the Xen crafted RSDP. >- */ >-static bool reject_option(const char *option) >-{ >- static const char *reject[] = { >- "acpi.rsdp", >- }; >- unsigned int i; >- >- for (i = 0; i < nitems(reject); i++) >- if (strncmp(option, reject[i], strlen(reject[i])) == 0) >- return (true); >- >- return (false); >-} >- >-static void >-xen_pvh_set_env(char *env, bool (*filter)(const char *)) >-{ >- char *option; >- >- if (env == NULL) >- return; >- >- option = env; >- while (*option != 0) { >- char *value; >- >- if (filter != NULL && filter(option)) { >- option += strlen(option) + 1; >- continue; >- } >- >- value = option; >- option = strsep(&value, "="); >- if (kern_setenv(option, value) != 0 && isxen()) >- xc_printf("unable to add kenv %s=%s\n", option, value); >- option = value + strlen(value) + 1; >- } >-} >- > #ifdef DDB > /* > * The way Xen loads the symtab is different from the native boot loader, >@@ -414,7 +359,6 @@ xen_pvh_parse_preload_data(uint64_t modulep) > vm_ooffset_t off; > vm_paddr_t metadata; > char *envp; >- char acpi_rsdp[19]; > > TSENTER(); > if (start_info->modlist_paddr != 0) { >@@ -478,9 +422,9 @@ xen_pvh_parse_preload_data(uint64_t modulep) > > boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); > envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); >- if (envp != NULL) >- envp += off; >- xen_pvh_set_env(envp, reject_option); >+ if ( envp != NULL ) >+ envp += off; >+ init_static_kenv(envp, 0); > > if (MD_FETCH(kmdp, MODINFOMD_EFI_MAP, void *) != NULL) > strlcpy(bootmethod, "UEFI", sizeof(bootmethod)); >@@ -500,9 +444,7 @@ xen_pvh_parse_preload_data(uint64_t modulep) > > boothowto |= boot_env_to_howto(); > >- snprintf(acpi_rsdp, sizeof(acpi_rsdp), "%#" PRIx64, >- start_info->rsdp_paddr); >- kern_setenv("acpi.rsdp", acpi_rsdp); >+ acpi_set_root(start_info->rsdp_paddr); > > #ifdef DDB > xen_pvh_parse_symtab(); >-- >2.45.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 277200
:
248646
|
248661
| 252140