Skip to contentSkip to conversation

treewide: break dependencies on x86's RM header

PATCH Applied Sean Christopherson 5 participants 30 messages Nov 26, 2019 – Jan 19, 2020

Subsystems (13)
x86 Sound ACPI ASoC +9 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 cover treewide: break dependencies on x86's RM header

x86's asm/realmode.h, which defines low level structures, variables and helpers used to bring up APs during SMP boot, ends up getting included in practically every nook and cranny of the kernel because the address used by ACPI for resuming from S3 also happens to be stored in the real mode header, and ACPI bleeds the dependency into its widely included headers.

As a result, modifying realmode.h for even the most trivial change to the boot code triggers a full kernel rebuild, which is frustrating to say the least as it some of the most difficult code to get exactly right *and* is also some of the most functionally isolated code in the kernel.

To break the kernel's widespread dependency on realmode.h, add a wrapper in the aforementioned ACPI S3 code to access the real mode header instead of derefencing the header directly in asm/acpi.h and thereby exposing it to the world via linux/acpi.h.

v2:
- Rebased on tip/x86/cleanups, commit b74374fef924 ("x86/setup: Enhance the comments").
- Use acpi_get_wakeup_address() as new function name. [Boris and Pavel]
- Capture acpi_get_wakeup_address() in a local address. [Pavel]
- Collect acks. I didn't add Rafael's acks on patches 11 and 12 due to the above changes.
- Explicitly call out the removal of <asm/realmode.h> from <asm/acpi.h>

    in patch 12. [Ingo]

- Remove superfluous Fixes: tags. [Ard]

Patch Synopsis:
- Patches 01-09 fix a variety of build errors that arise when patch 12 drops realmode.h from asm/acpi.h. Most of the errors are quite absurb as they have no relation whatsoever to x86's RM boot code, but occur because realmode.h happens to include asm/io.h.

- Patch 10 removes a spurious include of realmode.h from an ACPI header.

- Patches 11 and 12 implement the wrapper and move it out of acpi.h.

Sean Christopherson (12):
x86/efi: Explicitly include realmode.h to handle RM trampoline quirk x86/boot: Explicitly include realmode.h to handle RM reservations x86/ftrace: Explicitly include vmalloc.h for
set_vm_flush_reset_perms()
x86/kprobes: Explicitly include vmalloc.h for
set_vm_flush_reset_perms()
perf/x86/intel: Explicitly include asm/io.h to use virt_to_phys() efi/capsule-loader: Explicitly include linux/io.h for page_to_phys()
virt: vbox: Explicitly include linux/io.h to pick up various defs
vmw_balloon: Explicitly include linux/io.h for virt_to_phys()
ASoC: Intel: Skylake: Explicitly include linux/io.h for virt_to_phys() x86/ACPI/sleep: Remove an unnecessary include of asm/realmode.h ACPI/sleep: Convert acpi_wakeup_address into a function x86/ACPI/sleep: Move acpi_get_wakeup_address() into sleep.c, remove
<asm/realmode.h> from <asm/acpi.h>

 arch/ia64/include/asm/acpi.h             |  5 ++++-
 arch/ia64/kernel/acpi.c                  |  2 --
 arch/x86/events/intel/ds.c               |  1 +
 arch/x86/include/asm/acpi.h              |  3 +--
 arch/x86/kernel/acpi/sleep.c             | 11 +++++++++++
 arch/x86/kernel/acpi/sleep.h             |  2 +-
 arch/x86/kernel/ftrace.c                 |  1 +
 arch/x86/kernel/kprobes/core.c           |  1 +
 arch/x86/kernel/setup.c                  |  1 +
 arch/x86/platform/efi/quirks.c           |  1 +
 drivers/acpi/sleep.c                     |  3 +++
 drivers/firmware/efi/capsule-loader.c    |  1 +
 drivers/misc/vmw_balloon.c               |  1 +
 drivers/virt/vboxguest/vboxguest_core.c  |  1 +
 drivers/virt/vboxguest/vboxguest_utils.c |  1 +
 sound/soc/intel/skylake/skl-sst-cldma.c  |  1 +
 16 files changed, 30 insertions(+), 6 deletions(-)
Signature · 1 line
2.24.0
#1 lore raw

PATCH v2 1/12 x86/efi: Explicitly include realmode.h to handle RM trampoline quirk

Explicitly include asm/realmode.h, which is needed to handle a real mode trampoline quirk in efi_free_boot_services(), instead of picking it up by way of linux/acpi.h. acpi.h will soon stop including realmode.h so that changing realmode.h doesn't require a full kernel rebuild.

---
 arch/x86/platform/efi/quirks.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/platform/efi/quirks.c +1 -0
index 3b9fd679cea9..f9ef5c5346ca 100644
@@ -16,6 +16,7 @@
 #include <asm/efi.h>
 #include <asm/uv/uv.h>
 #include <asm/cpu_device_id.h>
+#include <asm/realmode.h>
 #include <asm/reboot.h>
 
 #define EFI_MIN_RESERVE 5120
Signature · 1 line
2.24.0
#2 lore raw

[tip: core/headers] x86/efi: Explicitly include realmode.h to handle RM trampoline quirk

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     e71b6f0b68de3296839a311355c5f590ac3446e5
Gitweb:        https://git.kernel.org/tip/e71b6f0b68de3296839a311355c5f590ac3446e5
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:06 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:47 +01:00

x86/efi: Explicitly include realmode.h to handle RM trampoline quirk

Explicitly include asm/realmode.h, which is needed to handle a real mode trampoline quirk in efi_free_boot_services(), instead of picking it up by way of linux/acpi.h. acpi.h will soon stop including realmode.h so that changing realmode.h doesn't require a full kernel rebuild.

---
 arch/x86/platform/efi/quirks.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/platform/efi/quirks.c +1 -0
index 7675cf7..4de2446 100644
@@ -16,6 +16,7 @@
 #include <asm/efi.h>
 #include <asm/uv/uv.h>
 #include <asm/cpu_device_id.h>
+#include <asm/realmode.h>
 #include <asm/reboot.h>
 
 #define EFI_MIN_RESERVE 5120
#3 lore raw

PATCH v2 2/12 x86/boot: Explicitly include realmode.h to handle RM reservations

In reply to Sean Christopherson

Explicitly include asm/realmode.h, which provides reserve_real_mode(), instead of picking it up by an indirect include of asm/acpi.h. acpi.h will soon stop including realmode.h so that changing realmode.h doesn't require a full kernel rebuild.

---
 arch/x86/kernel/setup.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/setup.c +1 -0
index a87138186724..38dfb61cacb8 100644
@@ -35,6 +35,7 @@
 #include <asm/kaslr.h>
 #include <asm/mce.h>
 #include <asm/mtrr.h>
+#include <asm/realmode.h>
 #include <asm/olpc_ofw.h>
 #include <asm/pci-direct.h>
 #include <asm/prom.h>
Signature · 1 line
2.24.0
#4 lore raw

[tip: core/headers] x86/boot: Explicitly include realmode.h to handle RM reservations

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     ca947b72e1dec3a000190733f7e0be38fe73eaae
Gitweb:        https://git.kernel.org/tip/ca947b72e1dec3a000190733f7e0be38fe73eaae
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:07 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:47 +01:00

x86/boot: Explicitly include realmode.h to handle RM reservations

Explicitly include asm/realmode.h, which provides reserve_real_mode(), instead of picking it up by an indirect include of asm/acpi.h. acpi.h will soon stop including realmode.h so that changing realmode.h doesn't require a full kernel rebuild.

---
 arch/x86/kernel/setup.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/setup.c +1 -0
index b5ac993..a584983 100644
@@ -35,6 +35,7 @@
 #include <asm/kaslr.h>
 #include <asm/mce.h>
 #include <asm/mtrr.h>
+#include <asm/realmode.h>
 #include <asm/olpc_ofw.h>
 #include <asm/pci-direct.h>
 #include <asm/prom.h>
#5 lore raw

PATCH v2 3/12 x86/ftrace: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

In reply to Sean Christopherson

The inclusion of linux/vmalloc.h, which is required for its definition of set_vm_flush_reset_perms(), is somehow dependent on asm/realmode.h being included by asm/acpi.h. Explicitly include linux/vmalloc.h so that a future patch can drop the realmode.h include from asm/acpi.h without breaking the build.

---
 arch/x86/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace.c +1 -0
index 024c3053dbba..2009047bb015 100644
@@ -23,6 +23,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/memory.h>
+#include <linux/vmalloc.h>
 
 #include <trace/syscall.h>
 
Signature · 1 line
2.24.0
#6 lore raw

[tip: core/headers] x86/ftrace: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     ac0b14dc16561c530796bfe9646ac2e0369a0bd6
Gitweb:        https://git.kernel.org/tip/ac0b14dc16561c530796bfe9646ac2e0369a0bd6
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:08 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:47 +01:00

x86/ftrace: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

The inclusion of linux/vmalloc.h, which is required for its definition of set_vm_flush_reset_perms(), is somehow dependent on asm/realmode.h being included by asm/acpi.h. Explicitly include linux/vmalloc.h so that a future patch can drop the realmode.h include from asm/acpi.h without breaking the build.

---
 arch/x86/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace.c +1 -0
index 060a361..18560d0 100644
@@ -23,6 +23,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/memory.h>
+#include <linux/vmalloc.h>
 
 #include <trace/syscall.h>
 
#7 lore raw

PATCH v2 4/12 x86/kprobes: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

In reply to Sean Christopherson

The inclusion of linux/vmalloc.h, which is required for its definition of set_vm_flush_reset_perms(), is somehow dependent on asm/realmode.h being included by asm/acpi.h. Explicitly include linux/vmalloc.h so that a future patch can drop the realmode.h include from asm/acpi.h without breaking the build.

---
 arch/x86/kernel/kprobes/core.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/kprobes/core.c +1 -0
index 43fc13c831af..e7d4c89c9aba 100644
@@ -40,6 +40,7 @@
 #include <linux/frame.h>
 #include <linux/kasan.h>
 #include <linux/moduleloader.h>
+#include <linux/vmalloc.h>
 
 #include <asm/text-patching.h>
 #include <asm/cacheflush.h>
Signature · 1 line
2.24.0
#8 lore raw

[tip: core/headers] x86/kprobes: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     6315ec9286e5146760a22d5ba8ccc6f5606e1401
Gitweb:        https://git.kernel.org/tip/6315ec9286e5146760a22d5ba8ccc6f5606e1401
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:09 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

x86/kprobes: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

The inclusion of linux/vmalloc.h, which is required for its definition of set_vm_flush_reset_perms(), is somehow dependent on asm/realmode.h being included by asm/acpi.h. Explicitly include linux/vmalloc.h so that a future patch can drop the realmode.h include from asm/acpi.h without breaking the build.

---
 arch/x86/kernel/kprobes/core.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/kprobes/core.c +1 -0
index 4f13af7..a0c223a 100644
@@ -40,6 +40,7 @@
 #include <linux/frame.h>
 #include <linux/kasan.h>
 #include <linux/moduleloader.h>
+#include <linux/vmalloc.h>
 
 #include <asm/text-patching.h>
 #include <asm/cacheflush.h>
#9 lore raw

PATCH v2 5/12 perf/x86/intel: Explicitly include asm/io.h to use virt_to_phys()

In reply to Sean Christopherson

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in asm/realmode.h via asm/acpi.h. Explicitly include asm/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 arch/x86/events/intel/ds.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/events/intel/ds.c +1 -0
index ce83950036c5..4b94ae4ae369 100644
@@ -7,6 +7,7 @@
 #include <asm/perf_event.h>
 #include <asm/tlbflush.h>
 #include <asm/insn.h>
+#include <asm/io.h>
 
 #include "../perf_event.h"
 
Signature · 1 line
2.24.0
#10 lore raw

[tip: core/headers] perf/x86/intel: Explicitly include asm/io.h to use virt_to_phys()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     59e9f58749cb85df314fd189a6bf58ae34170cf0
Gitweb:        https://git.kernel.org/tip/59e9f58749cb85df314fd189a6bf58ae34170cf0
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:10 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

perf/x86/intel: Explicitly include asm/io.h to use virt_to_phys()

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in asm/realmode.h via asm/acpi.h. Explicitly include asm/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 arch/x86/events/intel/ds.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/events/intel/ds.c +1 -0
index ce83950..4b94ae4 100644
@@ -7,6 +7,7 @@
 #include <asm/perf_event.h>
 #include <asm/tlbflush.h>
 #include <asm/insn.h>
+#include <asm/io.h>
 
 #include "../perf_event.h"
 
#11 lore raw

PATCH v2 6/12 efi/capsule-loader: Explicitly include linux/io.h for page_to_phys()

In reply to Sean Christopherson

Through a labyrinthian sequence of includes, usage of page_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/firmware/efi/capsule-loader.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/efi/capsule-loader.c +1 -0
index b1395133389e..d3067cbd5114 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/miscdevice.h>
 #include <linux/highmem.h>
+#include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/efi.h>
Signature · 1 line
2.24.0
#12 lore raw

[tip: core/headers] efi/capsule-loader: Explicitly include linux/io.h for page_to_phys()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     c6625a314cb81149718390c6be01a9294a016966
Gitweb:        https://git.kernel.org/tip/c6625a314cb81149718390c6be01a9294a016966
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:11 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

efi/capsule-loader: Explicitly include linux/io.h for page_to_phys()

Through a labyrinthian sequence of includes, usage of page_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/firmware/efi/capsule-loader.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/efi/capsule-loader.c +1 -0
index b139513..d3067cb 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/miscdevice.h>
 #include <linux/highmem.h>
+#include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/efi.h>
#13 lore raw

PATCH v2 7/12 virt: vbox: Explicitly include linux/io.h to pick up various defs

In reply to Sean Christopherson

Through a labyrinthian sequence of includes, usage of page_to_phys(), virt_to_phys() and out*() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/virt/vboxguest/vboxguest_core.c  | 1 +
 drivers/virt/vboxguest/vboxguest_utils.c | 1 +
 2 files changed, 2 insertions(+)
drivers/virt/vboxguest/vboxguest_core.c +1 -0
index 2307b0329aec..d823d558c0c4 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/sizes.h>
drivers/virt/vboxguest/vboxguest_utils.c +1 -0
index 75fd140b02ff..80e0f1254476 100644
@@ -7,6 +7,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/module.h>
Signature · 1 line
2.24.0
#14 lore raw

[tip: core/headers] virt: vbox: Explicitly include linux/io.h to pick up various defs

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     41bfc11cde43222de6066a380f51b26897fba075
Gitweb:        https://git.kernel.org/tip/41bfc11cde43222de6066a380f51b26897fba075
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:12 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

virt: vbox: Explicitly include linux/io.h to pick up various defs

Through a labyrinthian sequence of includes, usage of page_to_phys(), virt_to_phys() and out*() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/virt/vboxguest/vboxguest_core.c  | 1 +
 drivers/virt/vboxguest/vboxguest_utils.c | 1 +
 2 files changed, 2 insertions(+)
drivers/virt/vboxguest/vboxguest_core.c +1 -0
index 2307b03..d823d55 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/sizes.h>
drivers/virt/vboxguest/vboxguest_utils.c +1 -0
index 43c3916..50920b6 100644
@@ -7,6 +7,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/module.h>
#15 lore raw

PATCH v2 8/12 vmw_balloon: Explicitly include linux/io.h for virt_to_phys()

In reply to Sean Christopherson

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/misc/vmw_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/misc/vmw_balloon.c +1 -0
index 5e6be1527571..b837e7eba5f7 100644
@@ -17,6 +17,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/types.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
Signature · 1 line
2.24.0
#16 lore raw

[tip: core/headers] vmw_balloon: Explicitly include linux/io.h for virt_to_phys()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     97976e01d3586e488b6c4c84881806d5d2960e6c
Gitweb:        https://git.kernel.org/tip/97976e01d3586e488b6c4c84881806d5d2960e6c
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:13 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

vmw_balloon: Explicitly include linux/io.h for virt_to_phys()

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 drivers/misc/vmw_balloon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/misc/vmw_balloon.c +1 -0
index 5e6be15..b837e7e 100644
@@ -17,6 +17,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/types.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/vmalloc.h>
#17 lore raw

PATCH v2 9/12 ASoC: Intel: Skylake: Explicitly include linux/io.h for virt_to_phys()

In reply to Sean Christopherson

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 sound/soc/intel/skylake/skl-sst-cldma.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/intel/skylake/skl-sst-cldma.c +1 -0
index 5a2c35f58fda..36f697c61074 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include "../common/sst-dsp.h"
Signature · 1 line
2.24.0
#18 lore raw

[tip: core/headers] ASoC: Intel: Skylake: Explicitly include linux/io.h for virt_to_phys()

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     321354ba6883b5151fd283dc14fb29280e1fbd2e
Gitweb:        https://git.kernel.org/tip/321354ba6883b5151fd283dc14fb29280e1fbd2e
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:14 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

ASoC: Intel: Skylake: Explicitly include linux/io.h for virt_to_phys()

Through a labyrinthian sequence of includes, usage of virt_to_phys() is dependent on the include of asm/io.h in x86's asm/realmode.h, which is included in x86's asm/acpi.h and thus by linux/acpi.h. Explicitly include linux/io.h to break the dependency on realmode.h so that a future patch can remove the realmode.h include from acpi.h without breaking the build.

---
 sound/soc/intel/skylake/skl-sst-cldma.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/intel/skylake/skl-sst-cldma.c +1 -0
index 5a2c35f..36f697c 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include "../common/sst-dsp.h"
#19 lore raw

PATCH v2 10/12 x86/ACPI/sleep: Remove an unnecessary include of asm/realmode.h

In reply to Sean Christopherson

None of the declarations in x86's acpi/sleep.h are in any way dependent on the real mode boot code. Remove sleep.h's include of asm/realmode.h to limit the dependencies on realmode.h to code that actually interacts with the boot code.

---
 arch/x86/kernel/acpi/sleep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/sleep.h +1 -1
index fbb60ca4255c..d06c2079b6c1 100644
@@ -3,7 +3,7 @@
  *	Variables and functions used by the code in sleep.c
  */
 
-#include <asm/realmode.h>
+#include <linux/linkage.h>
 
 extern unsigned long saved_video_mode;
 extern long saved_magic;
Signature · 1 line
2.24.0
#20 lore raw

[tip: core/headers] x86/ACPI/sleep: Remove an unnecessary include of asm/realmode.h

The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     cb28909525acdd1a89c5b2de761eaf2f788c0057
Gitweb:        https://git.kernel.org/tip/cb28909525acdd1a89c5b2de761eaf2f788c0057
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:15 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

x86/ACPI/sleep: Remove an unnecessary include of asm/realmode.h

None of the declarations in x86's acpi/sleep.h are in any way dependent on the real mode boot code. Remove sleep.h's include of asm/realmode.h to limit the dependencies on realmode.h to code that actually interacts with the boot code.

---
 arch/x86/kernel/acpi/sleep.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/sleep.h +1 -1
index fbb60ca..d06c207 100644
@@ -3,7 +3,7 @@
  *	Variables and functions used by the code in sleep.c
  */
 
-#include <asm/realmode.h>
+#include <linux/linkage.h>
 
 extern unsigned long saved_video_mode;
 extern long saved_magic;
#21 lore raw

PATCH v2 11/12 ACPI/sleep: Convert acpi_wakeup_address into a function

In reply to Sean Christopherson

Convert acpi_wakeup_address from a raw variable into a function so that x86 can wrap its dereference of the real mode boot header in a function instead of broadcasting it to the world via a #define. This sets the stage for a future patch to move x86's definition of the new function, acpi_get_wakeup_address(), out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

---
 arch/ia64/include/asm/acpi.h | 5 ++++-
 arch/ia64/kernel/acpi.c      | 2 --
 arch/x86/include/asm/acpi.h  | 5 ++++-
 drivers/acpi/sleep.c         | 3 +++
 4 files changed, 11 insertions(+), 4 deletions(-)
arch/ia64/include/asm/acpi.h +4 -1
index f886d4dc9d55..b66ba907019c 100644
@@ -38,7 +38,10 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
 /* Low-level suspend routine. */
 extern int acpi_suspend_lowlevel(void);
 
-extern unsigned long acpi_wakeup_address;
+static inline unsigned long acpi_get_wakeup_address(void)
+{
+	return 0;
+}
 
 /*
  * Record the cpei override flag and current logical cpu. This is
arch/ia64/kernel/acpi.c +0 -2
index 70d1587ddcd4..a5636524af76 100644
@@ -42,8 +42,6 @@ int acpi_lapic;
 unsigned int acpi_cpei_override;
 unsigned int acpi_cpei_phys_cpuid;
 
-unsigned long acpi_wakeup_address = 0;
-
 #define ACPI_MAX_PLATFORM_INTERRUPTS	256
 
 /* Array to record platform interrupt vectors for generic interrupt routing. */
arch/x86/include/asm/acpi.h +4 -1
index bc9693c9107e..23ffafd927a1 100644
@@ -62,7 +62,10 @@ static inline void acpi_disable_pci(void)
 extern int (*acpi_suspend_lowlevel)(void);
 
 /* Physical address to resume after wakeup */
-#define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start))
+static inline unsigned long acpi_get_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
 
 /*
  * Check if the CPU can handle C2 and deeper
drivers/acpi/sleep.c +3 -0
index 9fa77d72ef27..2e87ccf17ff6 100644
@@ -61,8 +61,11 @@ static struct notifier_block tts_notifier = {
 static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
+	unsigned long acpi_wakeup_address;
+
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
+		acpi_wakeup_address = acpi_get_wakeup_address();
 		if (!acpi_wakeup_address)
 			return -EFAULT;
 		acpi_set_waking_vector(acpi_wakeup_address);
Signature · 1 line
2.24.0
Acked-by on v2 11/12
#22 lore raw

Re: [PATCH v2 11/12] ACPI/sleep: Convert acpi_wakeup_address into a function

Quoted 10 lines · Sean Christopherson

Convert acpi_wakeup_address from a raw variable into a function so that x86 can wrap its dereference of the real mode boot header in a function instead of broadcasting it to the world via a #define. This sets the stage for a future patch to move x86's definition of the new function, acpi_get_wakeup_address(), out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

Thanks!

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#23 lore raw

[tip: core/headers] ACPI/sleep: Convert acpi_wakeup_address into a function

In reply to Sean Christopherson
The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     8c53b318b222eff55d2900b554094a099b1a30f6
Gitweb:        https://git.kernel.org/tip/8c53b318b222eff55d2900b554094a099b1a30f6
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:16 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

ACPI/sleep: Convert acpi_wakeup_address into a function

Convert acpi_wakeup_address from a raw variable into a function so that x86 can wrap its dereference of the real mode boot header in a function instead of broadcasting it to the world via a #define. This sets the stage for a future patch to move x86's definition of the new function, acpi_get_wakeup_address(), out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

---
 arch/ia64/include/asm/acpi.h | 5 ++++-
 arch/ia64/kernel/acpi.c      | 2 --
 arch/x86/include/asm/acpi.h  | 5 ++++-
 drivers/acpi/sleep.c         | 3 +++
 4 files changed, 11 insertions(+), 4 deletions(-)
arch/ia64/include/asm/acpi.h +4 -1
index f886d4d..b66ba90 100644
@@ -38,7 +38,10 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
 /* Low-level suspend routine. */
 extern int acpi_suspend_lowlevel(void);
 
-extern unsigned long acpi_wakeup_address;
+static inline unsigned long acpi_get_wakeup_address(void)
+{
+	return 0;
+}
 
 /*
  * Record the cpei override flag and current logical cpu. This is
arch/ia64/kernel/acpi.c +0 -2
index 70d1587..a563652 100644
@@ -42,8 +42,6 @@ int acpi_lapic;
 unsigned int acpi_cpei_override;
 unsigned int acpi_cpei_phys_cpuid;
 
-unsigned long acpi_wakeup_address = 0;
-
 #define ACPI_MAX_PLATFORM_INTERRUPTS	256
 
 /* Array to record platform interrupt vectors for generic interrupt routing. */
arch/x86/include/asm/acpi.h +4 -1
index bc9693c..23ffafd 100644
@@ -62,7 +62,10 @@ static inline void acpi_disable_pci(void)
 extern int (*acpi_suspend_lowlevel)(void);
 
 /* Physical address to resume after wakeup */
-#define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start))
+static inline unsigned long acpi_get_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
 
 /*
  * Check if the CPU can handle C2 and deeper
drivers/acpi/sleep.c +3 -0
index 6747a27..4398806 100644
@@ -61,8 +61,11 @@ static struct notifier_block tts_notifier = {
 static int acpi_sleep_prepare(u32 acpi_state)
 {
 #ifdef CONFIG_ACPI_SLEEP
+	unsigned long acpi_wakeup_address;
+
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state == ACPI_STATE_S3) {
+		acpi_wakeup_address = acpi_get_wakeup_address();
 		if (!acpi_wakeup_address)
 			return -EFAULT;
 		acpi_set_waking_vector(acpi_wakeup_address);
#24 lore raw

PATCH v2 12/12 x86/ACPI/sleep: Move acpi_get_wakeup_address() into sleep.c, remove <asm/realmode.h> from <asm/acpi.h>

In reply to Sean Christopherson

Move the definition of acpi_get_wakeup_address() into sleep.c to break linux/acpi.h's dependency (by way of asm/acpi.h) on asm/realmode.h. Everyone and their mother includes linux/acpi.h, i.e. modifying realmode.h results in a full kernel rebuild, which makes the already inscrutable real mode boot code even more difficult to understand and is positively rage inducing when trying to make changes to x86's boot flow.

No functional change intended.

---
 arch/x86/include/asm/acpi.h  |  6 +-----
 arch/x86/kernel/acpi/sleep.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 5 deletions(-)
arch/x86/include/asm/acpi.h +1 -5
index 23ffafd927a1..ca0976456a6b 100644
@@ -13,7 +13,6 @@
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/mpspec.h>
-#include <asm/realmode.h>
 #include <asm/x86_init.h>
 
 #ifdef CONFIG_ACPI_APEI
@@ -62,10 +61,7 @@ static inline void acpi_disable_pci(void)
 extern int (*acpi_suspend_lowlevel)(void);
 
 /* Physical address to resume after wakeup */
-static inline unsigned long acpi_get_wakeup_address(void)
-{
-	return ((unsigned long)(real_mode_header->wakeup_start));
-}
+unsigned long acpi_get_wakeup_address(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
arch/x86/kernel/acpi/sleep.c +11 -0
index ca13851f0570..26b7256f590f 100644
@@ -26,6 +26,17 @@ unsigned long acpi_realmode_flags;
 static char temp_stack[4096];
 #endif
 
+/**
+ * acpi_get_wakeup_address - provide physical address for S3 wakeup
+ *
+ * Returns the physical address where the kernel should be resumed after the
+ * system awakes from S3, e.g. for programming into the firmware waking vector.
+ */
+unsigned long acpi_get_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
+
 /**
  * x86_acpi_enter_sleep_state - enter sleep state
  * @state: Sleep state to enter.
Signature · 1 line
2.24.0
#25 lore raw

Re: [PATCH v2 12/12] x86/ACPI/sleep: Move acpi_get_wakeup_address() into sleep.c, remove <asm/realmode.h> from <asm/acpi.h>

I love your patch! Yet something to improve:

Hi Sean,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20191126]
[cannot apply to tip/x86/core tip/auto-latest efi/next v5.4 v5.4-rc8 v5.4-rc7 v5.4] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Sean-Christopherson/treewide-break-dependencies-on-x86-s-RM-header/20191127-065047
base:    131b7b67e6c2926531dd92915647335bec2e64fb
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.4.0-14) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

arch/x86/platform/intel-quark/imr_selftest.c: In function 'imr_self_test':

>> arch/x86/platform/intel-quark/imr_selftest.c:59:22: error: implicit declaration of function 'virt_to_phys'; did you mean 'virt_to_page'? [-Werror=implicit-function-declaration]
     phys_addr_t base  = virt_to_phys(&_text);
                         ^~~~~~~~~~~~
                         virt_to_page

cc1: some warnings being treated as errors

vim +59 arch/x86/platform/intel-quark/imr_selftest.c

28a375df16c2b6 Bryan O'Donoghue 2015-01-30   49  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   50  /**
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   51   * imr_self_test
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   52   *
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   53   * Verify IMR self_test with some simple tests to verify overlap,
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   54   * zero sized allocations and 1 KiB sized areas.
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   55   *
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   56   */
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   57  static void __init imr_self_test(void)
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   58  {
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  @59  	phys_addr_t base  = virt_to_phys(&_text);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   60  	size_t size = virt_to_phys(&__end_rodata) - base;
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   61  	const char *fmt_over = "overlapped IMR @ (0x%08lx - 0x%08lx)\n";
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   62  	int ret;
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   63  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   64  	/* Test zero zero. */
c637fa5294cefe Bryan O'Donoghue 2016-02-23   65  	ret = imr_add_range(0, 0, 0, 0);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   66  	imr_self_test_result(ret < 0, "zero sized IMR\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   67  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   68  	/* Test exact overlap. */
c637fa5294cefe Bryan O'Donoghue 2016-02-23   69  	ret = imr_add_range(base, size, IMR_CPU, IMR_CPU);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   70  	imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size));
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   71  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   72  	/* Test overlap with base inside of existing. */
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   73  	base += size - IMR_ALIGN;
c637fa5294cefe Bryan O'Donoghue 2016-02-23   74  	ret = imr_add_range(base, size, IMR_CPU, IMR_CPU);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   75  	imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size));
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   76  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   77  	/* Test overlap with end inside of existing. */
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   78  	base -= size + IMR_ALIGN * 2;
c637fa5294cefe Bryan O'Donoghue 2016-02-23   79  	ret = imr_add_range(base, size, IMR_CPU, IMR_CPU);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   80  	imr_self_test_result(ret < 0, fmt_over, __va(base), __va(base + size));
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   81  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   82  	/* Test that a 1 KiB IMR @ zero with read/write all will bomb out. */
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   83  	ret = imr_add_range(0, IMR_ALIGN, IMR_READ_ACCESS_ALL,
c637fa5294cefe Bryan O'Donoghue 2016-02-23   84  			    IMR_WRITE_ACCESS_ALL);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   85  	imr_self_test_result(ret < 0, "1KiB IMR @ 0x00000000 - access-all\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   86  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   87  	/* Test that a 1 KiB IMR @ zero with CPU only will work. */
c637fa5294cefe Bryan O'Donoghue 2016-02-23   88  	ret = imr_add_range(0, IMR_ALIGN, IMR_CPU, IMR_CPU);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   89  	imr_self_test_result(ret >= 0, "1KiB IMR @ 0x00000000 - cpu-access\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   90  	if (ret >= 0) {
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   91  		ret = imr_remove_range(0, IMR_ALIGN);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   92  		imr_self_test_result(ret == 0, "teardown - cpu-access\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   93  	}
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   94  
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   95  	/* Test 2 KiB works. */
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   96  	size = IMR_ALIGN * 2;
c637fa5294cefe Bryan O'Donoghue 2016-02-23   97  	ret = imr_add_range(0, size, IMR_READ_ACCESS_ALL, IMR_WRITE_ACCESS_ALL);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   98  	imr_self_test_result(ret >= 0, "2KiB IMR @ 0x00000000\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30   99  	if (ret >= 0) {
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  100  		ret = imr_remove_range(0, size);
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  101  		imr_self_test_result(ret == 0, "teardown 2KiB\n");
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  102  	}
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  103  }
28a375df16c2b6 Bryan O'Donoghue 2015-01-30  104  

:::::: The code at line 59 was first introduced by commit
:::::: 28a375df16c2b6d01227541f3956568995aa5fda x86/intel/quark: Add Isolated Memory Regions for Quark X1000

:::::: TO: Bryan O'Donoghue <[email protected]> :::::: CC: Ingo Molnar <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation

#26 lore raw

[tip: core/headers] x86/ACPI/sleep: Move acpi_get_wakeup_address() into sleep.c, remove <asm/realmode.h> from <asm/acpi.h>

In reply to Sean Christopherson
The following commit has been merged into the core/headers branch of tip:

The following commit has been merged into the core/headers branch of tip:

Commit-ID:     960786422fe90a86e81131f5dbd902cb5ebf8760
Gitweb:        https://git.kernel.org/tip/960786422fe90a86e81131f5dbd902cb5ebf8760
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Tue, 26 Nov 2019 08:54:17 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 10 Dec 2019 10:15:48 +01:00

x86/ACPI/sleep: Move acpi_get_wakeup_address() into sleep.c, remove <asm/realmode.h> from <asm/acpi.h>

Move the definition of acpi_get_wakeup_address() into sleep.c to break linux/acpi.h's dependency (by way of asm/acpi.h) on asm/realmode.h. Everyone and their mother includes linux/acpi.h, i.e. modifying realmode.h results in a full kernel rebuild, which makes the already inscrutable real mode boot code even more difficult to understand and is positively rage inducing when trying to make changes to x86's boot flow.

No functional change intended.

---
 arch/x86/include/asm/acpi.h  |  6 +-----
 arch/x86/kernel/acpi/sleep.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 5 deletions(-)
arch/x86/include/asm/acpi.h +1 -5
index 23ffafd..ca09764 100644
@@ -13,7 +13,6 @@
 #include <asm/processor.h>
 #include <asm/mmu.h>
 #include <asm/mpspec.h>
-#include <asm/realmode.h>
 #include <asm/x86_init.h>
 
 #ifdef CONFIG_ACPI_APEI
@@ -62,10 +61,7 @@ static inline void acpi_disable_pci(void)
 extern int (*acpi_suspend_lowlevel)(void);
 
 /* Physical address to resume after wakeup */
-static inline unsigned long acpi_get_wakeup_address(void)
-{
-	return ((unsigned long)(real_mode_header->wakeup_start));
-}
+unsigned long acpi_get_wakeup_address(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
arch/x86/kernel/acpi/sleep.c +11 -0
index ca13851..26b7256 100644
@@ -27,6 +27,17 @@ static char temp_stack[4096];
 #endif
 
 /**
+ * acpi_get_wakeup_address - provide physical address for S3 wakeup
+ *
+ * Returns the physical address where the kernel should be resumed after the
+ * system awakes from S3, e.g. for programming into the firmware waking vector.
+ */
+unsigned long acpi_get_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
+
+/**
  * x86_acpi_enter_sleep_state - enter sleep state
  * @state: Sleep state to enter.
  *
#27 lore raw
In reply to Sean Christopherson
Quoted 24 lines · Sean Christopherson

x86's asm/realmode.h, which defines low level structures, variables and helpers used to bring up APs during SMP boot, ends up getting included in practically every nook and cranny of the kernel because the address used by ACPI for resuming from S3 also happens to be stored in the real mode header, and ACPI bleeds the dependency into its widely included headers.

As a result, modifying realmode.h for even the most trivial change to the boot code triggers a full kernel rebuild, which is frustrating to say the least as it some of the most difficult code to get exactly right *and* is also some of the most functionally isolated code in the kernel.

To break the kernel's widespread dependency on realmode.h, add a wrapper in the aforementioned ACPI S3 code to access the real mode header instead of derefencing the header directly in asm/acpi.h and thereby exposing it to the world via linux/acpi.h.

v2:
- Rebased on tip/x86/cleanups, commit b74374fef924 ("x86/setup: Enhance the comments").
- Use acpi_get_wakeup_address() as new function name. [Boris and Pavel]
- Capture acpi_get_wakeup_address() in a local address. [Pavel]
- Collect acks. I didn't add Rafael's acks on patches 11 and 12 due to the above changes.
- Explicitly call out the removal of <asm/realmode.h> from <asm/acpi.h>

Quoted 2 lines
    in patch 12. [Ingo]

- Remove superfluous Fixes: tags. [Ard]

You didn't include every patch from v1 though, such us my fix to Quark:

[PATCH] x86/platform/intel/quark: Explicitly include linux/io.h for virt_to_phys()

I've applied that one too and your updated patches, and it's now all pushed out into tip:WIP.core/headers.

Thanks,

Ingo

#28 lore raw
Quoted 30 lines · Ingo Molnar
Quoted 24 lines · Sean Christopherson

x86's asm/realmode.h, which defines low level structures, variables and helpers used to bring up APs during SMP boot, ends up getting included in practically every nook and cranny of the kernel because the address used by ACPI for resuming from S3 also happens to be stored in the real mode header, and ACPI bleeds the dependency into its widely included headers.

As a result, modifying realmode.h for even the most trivial change to the boot code triggers a full kernel rebuild, which is frustrating to say the least as it some of the most difficult code to get exactly right *and* is also some of the most functionally isolated code in the kernel.

To break the kernel's widespread dependency on realmode.h, add a wrapper in the aforementioned ACPI S3 code to access the real mode header instead of derefencing the header directly in asm/acpi.h and thereby exposing it to the world via linux/acpi.h.

v2:
- Rebased on tip/x86/cleanups, commit b74374fef924 ("x86/setup: Enhance the comments").
- Use acpi_get_wakeup_address() as new function name. [Boris and Pavel]
- Capture acpi_get_wakeup_address() in a local address. [Pavel]
- Collect acks. I didn't add Rafael's acks on patches 11 and 12 due to the above changes.
- Explicitly call out the removal of <asm/realmode.h> from <asm/acpi.h>

Quoted 2 lines
    in patch 12. [Ingo]

- Remove superfluous Fixes: tags. [Ard]

Quoted 6 lines

You didn't include every patch from v1 though, such us my fix to Quark:

[PATCH] x86/platform/intel/quark: Explicitly include linux/io.h for virt_to_phys()

I've applied that one too and your updated patches, and it's now all pushed out into tip:WIP.core/headers.

Sorry, it wasn't clear to me whether or not to include that one. Next time I'll ask.

#29 lore raw
Quoted 10 lines · Sean Christopherson
Quoted 7 lines

You didn't include every patch from v1 though, such us my fix to Quark:

[PATCH] x86/platform/intel/quark: Explicitly include linux/io.h for virt_to_phys()

I've applied that one too and your updated patches, and it's now all pushed out into tip:WIP.core/headers.

Sorry, it wasn't clear to me whether or not to include that one. Next time I'll ask.

No problem - in general it's best to include all, because in general it's much easier for maintainers to leave out something than to remember to add it back in. ;-)

Thanks,

Ingo