* [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader
@ 2025-01-05 17:16 Dmytro Maluka
2025-01-05 17:16 ` [PATCH 1/2] x86/of: Don't use DTB for SMP setup if ACPI is enabled Dmytro Maluka
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dmytro Maluka @ 2025-01-05 17:16 UTC (permalink / raw)
To: Thomas Gleixner, Rob Herring
Cc: Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Saravana Kannan, Saurabh Sengar, Usama Arif, Stephen Boyd,
Frank Rowand, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
Pierre-Clément Tosi, Shikha Panwar, Will Deacon, Keir Fraser,
Michal Mazurek, Bartłomiej Grzesik, Tomasz Nowicki,
Grzegorz Jaszczyk, Dmytro Maluka
There are cases when the bootloader provides information to the kernel
in both ACPI and DTB, not interchangeably. One such use case is virtual
machines in Android. When running on x86, the Android Virtualization
Framework (AVF) boots VMs with ACPI like it is usually done on x86 (i.e.
the virtual LAPIC, IOAPIC, HPET, PCI MMCONFIG etc are described in ACPI)
but also passes various AVF-specific boot parameters in DTB. This allows
reusing the same implementations of various AVF components on both
arm64 and x86. (Note that on arm64 AVF uses DT only, no ACPI.)
Commit 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
removed the possibility to do that, since among other things
it introduced forcing emptying the bootloader-provided DTB if ACPI is
enabled (probably assuming that if ACPI is available, a DTB can only be
useful for applying overlays to it afterwards, for testing purposes).
So restore this possibility. At the same time, since on x86 the
aforementioned recently introduced restriction is actually useful for
preventing conflicts between ACPI and DT for LAPIC/IOAPIC/HPET setup,
don't remove this restriction completely but relax it: unflatten the
bootloader supplied DTB but don't try to use it for SMP setup.
Note that on arm64 currently ACPI and DT are not used together in any
case (setup_arch() enforces that), and this series doesn't change that.
v1 -> v2:
Split the patch into two, to separate the x86 part from the common part.
Dmytro Maluka (2):
x86/of: Don't use DTB for SMP setup if ACPI is enabled
of/fdt: Restore possibility to use both ACPI and FDT from bootloader
arch/x86/kernel/devicetree.c | 3 ++-
drivers/of/fdt.c | 10 +---------
2 files changed, 3 insertions(+), 10 deletions(-)
--
2.47.1.613.gc27f4b7a9f-goog
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] x86/of: Don't use DTB for SMP setup if ACPI is enabled
2025-01-05 17:16 [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
@ 2025-01-05 17:16 ` Dmytro Maluka
2025-01-05 17:16 ` [PATCH 2/2] of/fdt: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
2025-01-05 17:31 ` [PATCH 0/2] of, x86: " Dmytro Maluka
2 siblings, 0 replies; 4+ messages in thread
From: Dmytro Maluka @ 2025-01-05 17:16 UTC (permalink / raw)
To: Thomas Gleixner, Rob Herring
Cc: Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Saravana Kannan, Saurabh Sengar, Usama Arif, Stephen Boyd,
Frank Rowand, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
Pierre-Clément Tosi, Shikha Panwar, Will Deacon, Keir Fraser,
Michal Mazurek, Bartłomiej Grzesik, Tomasz Nowicki,
Grzegorz Jaszczyk, Dmytro Maluka
There are cases when it is useful to use both ACPI and DTB provided by
the bootloader, however in such cases we should make sure to prevent
conflicts between the two. Namely, don't try to use DTB for SMP setup
if ACPI is enabled.
Precisely, this prevents at least:
- incorrectly calling register_lapic_address(APIC_DEFAULT_PHYS_BASE)
after the LAPIC was already successfully enumerated via ACPI, causing
noisy kernel warnings and probably potential real issues as well
- failed IOAPIC setup in the case when IOAPIC is enumerated via mptable
instead of ACPI (e.g. with acpi=noirq), due to
mpparse_parse_smp_config() overridden by x86_dtb_parse_smp_config()
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
arch/x86/kernel/devicetree.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 59d23cdf4ed0..dd8748c45529 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -2,6 +2,7 @@
/*
* Architecture specific OF callbacks.
*/
+#include <linux/acpi.h>
#include <linux/export.h>
#include <linux/io.h>
#include <linux/interrupt.h>
@@ -313,6 +314,6 @@ void __init x86_flattree_get_config(void)
if (initial_dtb)
early_memunmap(dt, map_len);
#endif
- if (of_have_populated_dt())
+ if (acpi_disabled && of_have_populated_dt())
x86_init.mpparse.parse_smp_cfg = x86_dtb_parse_smp_config;
}
--
2.47.1.613.gc27f4b7a9f-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] of/fdt: Restore possibility to use both ACPI and FDT from bootloader
2025-01-05 17:16 [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
2025-01-05 17:16 ` [PATCH 1/2] x86/of: Don't use DTB for SMP setup if ACPI is enabled Dmytro Maluka
@ 2025-01-05 17:16 ` Dmytro Maluka
2025-01-05 17:31 ` [PATCH 0/2] of, x86: " Dmytro Maluka
2 siblings, 0 replies; 4+ messages in thread
From: Dmytro Maluka @ 2025-01-05 17:16 UTC (permalink / raw)
To: Thomas Gleixner, Rob Herring
Cc: Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Saravana Kannan, Saurabh Sengar, Usama Arif, Stephen Boyd,
Frank Rowand, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
Pierre-Clément Tosi, Shikha Panwar, Will Deacon, Keir Fraser,
Michal Mazurek, Bartłomiej Grzesik, Tomasz Nowicki,
Grzegorz Jaszczyk, Dmytro Maluka
There are cases when the bootloader provides information to the kernel
in both ACPI and DTB, not interchangeably. One such use case is virtual
machines in Android. When running on x86, the Android Virtualization
Framework (AVF) boots VMs with ACPI like it is usually done on x86 (i.e.
the virtual LAPIC, IOAPIC, HPET, PCI MMCONFIG etc are described in ACPI)
but also passes various AVF-specific boot parameters in DTB. This allows
reusing the same implementations of various AVF components on both
arm64 and x86.
Commit 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
removed the possibility to do that, since among other things
it introduced forcing emptying the bootloader-provided DTB if ACPI is
enabled (probably assuming that if ACPI is available, a DTB can only be
useful for applying overlays to it afterwards, for testing purposes).
So restore this possibility. Instead of completely preventing using ACPI
and DT together, rely on arch-specific setup code to prevent using both
to set up the same things (see various acpi_disabled checks under arch/).
Fixes: 7b937cc243e5 ("of: Create of_root if no dtb provided by firmware")
Signed-off-by: Dmytro Maluka <dmaluka@chromium.org>
---
drivers/of/fdt.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0121100372b4..3b29a5c50e2e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -8,7 +8,6 @@
#define pr_fmt(fmt) "OF: fdt: " fmt
-#include <linux/acpi.h>
#include <linux/crash_dump.h>
#include <linux/crc32.h>
#include <linux/kernel.h>
@@ -1215,14 +1214,7 @@ void __init unflatten_device_tree(void)
/* Save the statically-placed regions in the reserved_mem array */
fdt_scan_reserved_mem_reg_nodes();
- /* Don't use the bootloader provided DTB if ACPI is enabled */
- if (!acpi_disabled)
- fdt = NULL;
-
- /*
- * Populate an empty root node when ACPI is enabled or bootloader
- * doesn't provide one.
- */
+ /* Populate an empty root node when bootloader doesn't provide one */
if (!fdt) {
fdt = (void *) __dtb_empty_root_begin;
/* fdt_totalsize() will be used for copy size */
--
2.47.1.613.gc27f4b7a9f-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader
2025-01-05 17:16 [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
2025-01-05 17:16 ` [PATCH 1/2] x86/of: Don't use DTB for SMP setup if ACPI is enabled Dmytro Maluka
2025-01-05 17:16 ` [PATCH 2/2] of/fdt: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
@ 2025-01-05 17:31 ` Dmytro Maluka
2 siblings, 0 replies; 4+ messages in thread
From: Dmytro Maluka @ 2025-01-05 17:31 UTC (permalink / raw)
To: Thomas Gleixner, Rob Herring
Cc: Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Saravana Kannan, Saurabh Sengar, Usama Arif, Stephen Boyd,
Frank Rowand, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT),
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE,
Pierre-Clément Tosi, Shikha Panwar, Will Deacon, Keir Fraser,
Michal Mazurek, Bartłomiej Grzesik, Tomasz Nowicki,
Grzegorz Jaszczyk
Apologies, forgot to add v2 to the subjects. Just resent as [1] so
please disregard this one.
v1 is in [2].
[1] https://lore.kernel.org/all/20250105172741.3476758-1-dmaluka@chromium.org/
[2] https://lore.kernel.org/all/20241223181813.224446-1-dmaluka@chromium.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-05 17:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-05 17:16 [PATCH 0/2] of, x86: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
2025-01-05 17:16 ` [PATCH 1/2] x86/of: Don't use DTB for SMP setup if ACPI is enabled Dmytro Maluka
2025-01-05 17:16 ` [PATCH 2/2] of/fdt: Restore possibility to use both ACPI and FDT from bootloader Dmytro Maluka
2025-01-05 17:31 ` [PATCH 0/2] of, x86: " Dmytro Maluka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox