Skip to contentSkip to conversation

treewide: break dependencies on x86's RM header

PATCH Applied Sean Christopherson 9 participants 41 messages Nov 19, 2019 – Nov 26, 2019

Subsystems (13)
x86 Sound ACPI ASoC +9 more subsystems

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Build tested on x86 with allyesconfig and allmodconfig, so hopefully there aren't more build issues lurking, but at this point it wouldn't surprise me in the least if this somehow manages to break the build.

Based on tip/master, commit ceceaf1f12ba ("Merge branch 'WIP.x86/cleanups'").

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_wakeup_address() definition into sleep.c

 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                     |  4 ++--
 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, 29 insertions(+), 8 deletions(-)
Signature · 1 line
2.24.0
#1 lore raw

PATCH 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.

Fixes 5bc653b731821 ("x86/efi: Allocate a trampoline if needed in efi_free_boot_services()")
---
 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:     950e3ce5372c474066ccfc66f424be6bc2828c99
Gitweb:        https://git.kernel.org/tip/950e3ce5372c474066ccfc66f424be6bc2828c99
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:10 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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 3b9fd67..f9ef5c5 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 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.

Fixes c1877650f3c9 ("x86/setup: Clean up the header portion of setup.c")
---
 arch/x86/kernel/setup.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/setup.c +1 -0
index 559764a4af5f..b6d7301b1037 100644
@@ -33,6 +33,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:     db802ef3c91fad3b40a240f63d8e2fda23a1a9b1
Gitweb:        https://git.kernel.org/tip/db802ef3c91fad3b40a240f63d8e2fda23a1a9b1
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:11 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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 a871381..38dfb61 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 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.

Fixes 7fdfe1e40b225 ("x86/ftrace: Use vmalloc special flag")
---
 arch/x86/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace.c +1 -0
index 2a179fb35cd1..681eae0fb64d 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
maintainer Acked-by on v1 3/12
#6 lore raw

Re: [PATCH 03/12] x86/ftrace: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

Quoted 8 lines · On Mon, 18 Nov 2019 16:21:12 -0800 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.

Fixes 7fdfe1e40b225 ("x86/ftrace: Use vmalloc special flag")

-- Steve

Quoted 16 lines
---
 arch/x86/kernel/ftrace.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/ftrace.c +1 -0
index 2a179fb35cd1..681eae0fb64d 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

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

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:     68f461af8bb9f1d4e69469aa91a741f12f679f19
Gitweb:        https://git.kernel.org/tip/68f461af8bb9f1d4e69469aa91a741f12f679f19
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:12 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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 024c305..2009047 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>
 
#8 lore raw

PATCH 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.

Fixes 241a1f2238064 ("x86/kprobes: Use vmalloc special flag")
---
 arch/x86/kernel/kprobes/core.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/kprobes/core.c +1 -0
index 4f13af7cbcdb..a0c223ab7264 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
maintainer Acked-by on v1 4/12
#9 lore raw

Re: [PATCH 04/12] x86/kprobes: Explicitly include vmalloc.h for set_vm_flush_reset_perms()

Quoted 8 lines · On Mon, 18 Nov 2019 16:21:13 -0800 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.

Fixes 241a1f2238064 ("x86/kprobes: Use vmalloc special flag")

-- Steve

Quoted 16 lines
---
 arch/x86/kernel/kprobes/core.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/kprobes/core.c +1 -0
index 4f13af7cbcdb..a0c223ab7264 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>
#10 lore raw

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

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:     d5d411f81e552a67f2aa7cc39bba0c1d7d3db09a
Gitweb:        https://git.kernel.org/tip/d5d411f81e552a67f2aa7cc39bba0c1d7d3db09a
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:13 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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 43fc13c..e7d4c89 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>
#11 lore raw

PATCH 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
#12 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:     7bd4cb7e93c288dbec40cd3065e4fceb21343b11
Gitweb:        https://git.kernel.org/tip/7bd4cb7e93c288dbec40cd3065e4fceb21343b11
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:14 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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"
 
#13 lore raw

PATCH 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
#14 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:     53db61e1d344adda56a2a9dc8ae4fc099df0f95a
Gitweb:        https://git.kernel.org/tip/53db61e1d344adda56a2a9dc8ae4fc099df0f95a
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:15 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:26 +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>
#15 lore raw

PATCH 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 43c391626a00..50920b6fc319 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
#16 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:     3f61b293e48068606fac988f6d72a710c0dce668
Gitweb:        https://git.kernel.org/tip/3f61b293e48068606fac988f6d72a710c0dce668
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:16 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +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 75fd140..80e0f12 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>
#17 lore raw

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

In reply to Sean Christopherson

iThrough 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
#18 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:     0ea1d7c60b8c88283e2656c7cfe688dc68646d44
Gitweb:        https://git.kernel.org/tip/0ea1d7c60b8c88283e2656c7cfe688dc68646d44
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:17 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +01:00

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

iThrough 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>
#19 lore raw

PATCH 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
maintainer Acked-by on v1 9/12
#20 lore raw

Re: [PATCH 09/12] ASoC: Intel: Skylake: Explicitly include linux/io.h for virt_to_phys()

Quoted 6 lines · 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.

#21 lore raw

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

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:     6d1002c4229fa3cfdb5b73a2c8a45a4b6090ba0a
Gitweb:        https://git.kernel.org/tip/6d1002c4229fa3cfdb5b73a2c8a45a4b6090ba0a
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:18 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +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"
#22 lore raw

PATCH 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.

Fixes c9b77ccb52a5c ("x86, realmode: Move ACPI wakeup to unified realmode 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
Acked-by on v1 10/12
#23 lore raw

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

Quoted 7 lines · CET 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.

Fixes c9b77ccb52a5c ("x86, realmode: Move ACPI wakeup to unified realmode code")
Quoted 18 lines
---
 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;
#24 lore raw

[tip: core/headers] x86/ACPI/sleep: Remove an unnecessary include of asm/realmode.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:     25466d56fbadb785a1342aae4b2147ea1781d55a
Gitweb:        https://git.kernel.org/tip/25466d56fbadb785a1342aae4b2147ea1781d55a
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:19 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +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;
#25 lore raw

PATCH 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 the definition of acpi_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         | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)
arch/ia64/include/asm/acpi.h +4 -1
index f886d4dc9d55..36d7003eee71 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_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..57788ec6fa82 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_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
 
 /*
  * Check if the CPU can handle C2 and deeper
drivers/acpi/sleep.c +2 -2
index 2af937a8b1c5..9e66c4109556 100644
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 
 	}
 	ACPI_FLUSH_CPU_CACHE();
Signature · 1 line
2.24.0
Acked-by on v1 11/12
#26 lore raw

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

Quoted 9 lines · CET 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 the definition of acpi_wakeup_address() out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

Quoted 69 lines
---
 arch/ia64/include/asm/acpi.h | 5 ++++-
 arch/ia64/kernel/acpi.c      | 2 --
 arch/x86/include/asm/acpi.h  | 5 ++++-
 drivers/acpi/sleep.c         | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)
arch/ia64/include/asm/acpi.h +4 -1
index f886d4dc9d55..36d7003eee71 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_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..57788ec6fa82 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_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
 
 /*
  * Check if the CPU can handle C2 and deeper
drivers/acpi/sleep.c +2 -2
index 2af937a8b1c5..9e66c4109556 100644
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 
 	}
 	ACPI_FLUSH_CPU_CACHE();
#27 lore raw

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

Quoted 13 lines · CET Sean Christopherson
Quoted 9 lines

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 the definition of acpi_wakeup_address() out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

Quoted 12 lines

drivers/acpi/sleep.c static int acpi_sleep_prepare(u32 acpi_state) · line 69

Quoted 12 lines
drivers/acpi/sleep.c +2 -2
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 

You might want to store result in a variable... especially since you are turning inline function into real one in a next patch.

And maybe function should be called get_acip_wakeup_address or something? This way it is easy to mistake actual wakeup address from function that gets it...

Best regards,
Pavel

Quoted 2 lines
#28 lore raw

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

Quoted 29 lines · Pavel Machek
Quoted 13 lines · CET Sean Christopherson
Quoted 9 lines

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 the definition of acpi_wakeup_address() out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

Quoted 12 lines

drivers/acpi/sleep.c static int acpi_sleep_prepare(u32 acpi_state) · line 69

Quoted 12 lines
drivers/acpi/sleep.c +2 -2
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 

You might want to store result in a variable... especially since you are turning inline function into real one in a next patch.

Quoted 3 lines

And maybe function should be called get_acip_wakeup_address or something? This way it is easy to mistake actual wakeup address from function that gets it...

Agreed on both counts.

Ingo,

Would you prefer a v2 of the entire series (with Acks and removal of Fixes), or a v2 that includes only the last two patches?

#29 lore raw

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

Quoted 34 lines · Sean Christopherson
Quoted 29 lines · Pavel Machek
Quoted 13 lines · CET Sean Christopherson
Quoted 9 lines

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 the definition of acpi_wakeup_address() out of asm/acpi.h and thus break acpi.h's dependency on asm/realmode.h.

No functional change intended.

Quoted 12 lines

drivers/acpi/sleep.c static int acpi_sleep_prepare(u32 acpi_state) · line 69

Quoted 12 lines
drivers/acpi/sleep.c +2 -2
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state = ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 

You might want to store result in a variable... especially since you are turning inline function into real one in a next patch.

Quoted 3 lines

And maybe function should be called get_acip_wakeup_address or something? This way it is easy to mistake actual wakeup address from function that gets it...

Quoted 7 lines

Agreed on both counts.

Ingo,

Would you prefer a v2 of the entire series (with Acks and removal of Fixes), or a v2 that includes only the last two patches?

Yep, that would be handy. I have them committed to tip:core/headers, but haven't sent it to Linus yet, and can redo that all with these improvements.

Thanks,

Ingo

#30 lore raw

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

Quoted 6 lines · Ingo Molnar
Quoted 2 lines

Would you prefer a v2 of the entire series (with Acks and removal of Fixes), or a v2 that includes only the last two patches?

Yep, that would be handy. I have them committed to tip:core/headers, but haven't sent it to Linus yet, and can redo that all with these improvements.

Now these bits are back in tip:WIP.core/headers, waiting for the v2 submission.

Thanks,

Ingo

#31 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:     a9760aba02b346e74fffe8e35e4f1e9067de5281
Gitweb:        https://git.kernel.org/tip/a9760aba02b346e74fffe8e35e4f1e9067de5281
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:20 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +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 the definition of acpi_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         | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)
arch/ia64/include/asm/acpi.h +4 -1
index f886d4d..36d7003 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_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..57788ec 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_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
 
 /*
  * Check if the CPU can handle C2 and deeper
drivers/acpi/sleep.c +2 -2
index 9fa77d7..f5cca9f 100644
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state == ACPI_STATE_S3) {
-		if (!acpi_wakeup_address)
+		if (!acpi_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address);
+		acpi_set_waking_vector(acpi_wakeup_address());
 
 	}
 	ACPI_FLUSH_CPU_CACHE();
#32 lore raw

PATCH 12/12 x86/ACPI/sleep: Move acpi_wakeup_address() definition into sleep.c

In reply to Sean Christopherson

Move the definition of acpi_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.

---
 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 57788ec6fa82..0cae3f773d44 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_wakeup_address(void)
-{
-	return ((unsigned long)(real_mode_header->wakeup_start));
-}
+unsigned long acpi_wakeup_address(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
arch/x86/kernel/acpi/sleep.c +11 -0
index ca13851f0570..44d3fb1a1de3 100644
@@ -26,6 +26,17 @@ unsigned long acpi_realmode_flags;
 static char temp_stack[4096];
 #endif
 
+/**
+ * acpi_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_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
Acked-by on v1 12/12
#33 lore raw

Re: [PATCH 12/12] x86/ACPI/sleep: Move acpi_wakeup_address() definition into sleep.c

Quoted 8 lines · CET Sean Christopherson

Move the definition of acpi_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.

Quoted 52 lines
---
 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 57788ec6fa82..0cae3f773d44 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_wakeup_address(void)
-{
-	return ((unsigned long)(real_mode_header->wakeup_start));
-}
+unsigned long acpi_wakeup_address(void);
 
 /*
  * Check if the CPU can handle C2 and deeper
arch/x86/kernel/acpi/sleep.c +11 -0
index ca13851f0570..44d3fb1a1de3 100644
@@ -26,6 +26,17 @@ unsigned long acpi_realmode_flags;
 static char temp_stack[4096];
 #endif
 
+/**
+ * acpi_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_wakeup_address(void)
+{
+	return ((unsigned long)(real_mode_header->wakeup_start));
+}
+
 /**
  * x86_acpi_enter_sleep_state - enter sleep state
  * @state: Sleep state to enter.
#34 lore raw

[tip: core/headers] x86/ACPI/sleep: Move acpi_wakeup_address() definition 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:     7c8dfff8783bdc19696b563e01c588e81205ef15
Gitweb:        https://git.kernel.org/tip/7c8dfff8783bdc19696b563e01c588e81205ef15
Author:        Sean Christopherson <[email protected]>
AuthorDate:    Mon, 18 Nov 2019 16:21:21 -08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 19 Nov 2019 17:50:27 +01:00

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

Move the definition of acpi_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.

[ mingo: Renamed acpi_wakeup_address() to acpi_get_wakeup_address(), as suggested by Borislav Petkov. ]

---
 arch/ia64/include/asm/acpi.h |  2 +-
 arch/x86/include/asm/acpi.h  |  6 +-----
 arch/x86/kernel/acpi/sleep.c | 11 +++++++++++
 drivers/acpi/sleep.c         |  4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)
arch/ia64/include/asm/acpi.h +1 -1
index 36d7003..b66ba90 100644
@@ -38,7 +38,7 @@ int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
 /* Low-level suspend routine. */
 extern int acpi_suspend_lowlevel(void);
 
-static inline unsigned long acpi_wakeup_address(void)
+static inline unsigned long acpi_get_wakeup_address(void)
 {
 	return 0;
 }
arch/x86/include/asm/acpi.h +1 -5
index 57788ec..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_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.
  *
drivers/acpi/sleep.c +2 -2
index f5cca9f..6d3b2ea 100644
@@ -63,9 +63,9 @@ static int acpi_sleep_prepare(u32 acpi_state)
 #ifdef CONFIG_ACPI_SLEEP
 	/* do we have a wakeup address for S2 and S3? */
 	if (acpi_state == ACPI_STATE_S3) {
-		if (!acpi_wakeup_address())
+		if (!acpi_get_wakeup_address())
 			return -EFAULT;
-		acpi_set_waking_vector(acpi_wakeup_address());
+		acpi_set_waking_vector(acpi_get_wakeup_address());
 
 	}
 	ACPI_FLUSH_CPU_CACHE();
#35 lore raw
In reply to Sean Christopherson
Quoted 20 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.

Build tested on x86 with allyesconfig and allmodconfig, so hopefully there aren't more build issues lurking, but at this point it wouldn't surprise me in the least if this somehow manages to break the build.

Quoted 7 lines

Based on tip/master, commit ceceaf1f12ba ("Merge branch 'WIP.x86/cleanups'").

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.

Yeah, these kind of parasitic header dependencies are the main driving force behind kernel header spaghetti hell: it's super easy to add a new header, but very hard to remove them...

Hence they practically only accumulate.

As a result header removal patches get priority, from me at least. :-)

Quoted 3 lines

- 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.

So if the ACPI maintainers are fine with -tip carrying patches #11 and #12 then I'd be glad to route these patches upstream.

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

I edited the title of patch 12 slightly, to:

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

to make sure the big header dependency change is obvious at first sight.

Thanks,

Ingo

#36 lore raw

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

Quoted 3 lines · Ingo Molnar

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

One more fix was needed, for the intel-quark driver that is only built on 32-bit configs:

=========>
From: Ingo Molnar <[email protected]>
Date: Tue, 19 Nov 2019 12:51:56 +0100
Subject: [PATCH] x86/platform/intel/quark: Explicitly include linux/io.h for virt_to_phys()

Similarly to the previous patches by 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."

Cc Sean Christopherson <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/platform/intel-quark/imr.c          | 2 ++
 arch/x86/platform/intel-quark/imr_selftest.c | 2 ++
 2 files changed, 4 insertions(+)
arch/x86/platform/intel-quark/imr.c +2 -0
index 6dd25dc5f027..e9d97d52475e 100644
@@ -29,6 +29,8 @@
 #include <asm/cpu_device_id.h>
 #include <asm/imr.h>
 #include <asm/iosf_mbi.h>
+#include <asm/io.h>
+
 #include <linux/debugfs.h>
 #include <linux/init.h>
 #include <linux/mm.h>
arch/x86/platform/intel-quark/imr_selftest.c +2 -0
index 42f879b75f9b..4307830e1b6f 100644
@@ -14,6 +14,8 @@
 #include <asm-generic/sections.h>
 #include <asm/cpu_device_id.h>
 #include <asm/imr.h>
+#include <asm/io.h>
+
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/types.h>
Reviewed-by on v1 1/1
#37 lore raw

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

Quoted 16 lines · Ingo Molnar
Quoted 3 lines · Ingo Molnar

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

One more fix was needed, for the intel-quark driver that is only built on 32-bit configs:

=========>
From: Ingo Molnar <[email protected]>
Date: Tue, 19 Nov 2019 12:51:56 +0100
Subject: [PATCH] x86/platform/intel/quark: Explicitly include linux/io.h for virt_to_phys()

Quoted 9 lines

Similarly to the previous patches by 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."

LGTM,

Quoted 17 lines
Cc Sean Christopherson <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/platform/intel-quark/imr.c          | 2 ++
 arch/x86/platform/intel-quark/imr_selftest.c | 2 ++
 2 files changed, 4 insertions(+)
arch/x86/platform/intel-quark/imr.c +0 -0
index 6dd25dc5f027..e9d97d52475e 100644

arch/x86/platform/intel-quark/imr.c line 32

Quoted 4 lines
arch/x86/platform/intel-quark/imr.c +1 -0
@@ -29,6 +29,8 @@
 #include <asm/cpu_device_id.h>
 #include <asm/imr.h>
 #include <asm/iosf_mbi.h>
+#include <asm/io.h>

A nit: perhaps put it after imr.h.

Quoted 18 lines
arch/x86/platform/intel-quark/imr.c +1 -0
+
 #include <linux/debugfs.h>
 #include <linux/init.h>
 #include <linux/mm.h>
arch/x86/platform/intel-quark/imr_selftest.c +2 -0
index 42f879b75f9b..4307830e1b6f 100644
@@ -14,6 +14,8 @@
 #include <asm-generic/sections.h>
 #include <asm/cpu_device_id.h>
 #include <asm/imr.h>
+#include <asm/io.h>
+
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/types.h>
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#38 lore raw
In reply to Ingo Molnar
Quoted 51 lines · Ingo Molnar
Quoted 20 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.

Build tested on x86 with allyesconfig and allmodconfig, so hopefully there aren't more build issues lurking, but at this point it wouldn't surprise me in the least if this somehow manages to break the build.

Quoted 7 lines

Based on tip/master, commit ceceaf1f12ba ("Merge branch 'WIP.x86/cleanups'").

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.

Yeah, these kind of parasitic header dependencies are the main driving force behind kernel header spaghetti hell: it's super easy to add a new header, but very hard to remove them...

Hence they practically only accumulate.

As a result header removal patches get priority, from me at least. :-)

Quoted 3 lines

- 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.

So if the ACPI maintainers are fine with -tip carrying patches #11 and #12 then I'd be glad to route these patches upstream.

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

Quoted 6 lines

I edited the title of patch 12 slightly, to:

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

to make sure the big header dependency change is obvious at first sight.

I'm fine with the patches but can we drop the fixes headers please? This doesn't actually fix anything, and touching early boot stuff for no good reason should be avoided imo.

#39 lore raw
Quoted 54 lines · Ard Biesheuvel
Quoted 53 lines · Ingo Molnar
Quoted 20 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.

Build tested on x86 with allyesconfig and allmodconfig, so hopefully there aren't more build issues lurking, but at this point it wouldn't surprise me in the least if this somehow manages to break the build.

Quoted 7 lines

Based on tip/master, commit ceceaf1f12ba ("Merge branch 'WIP.x86/cleanups'").

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.

Yeah, these kind of parasitic header dependencies are the main driving force behind kernel header spaghetti hell: it's super easy to add a new header, but very hard to remove them...

Hence they practically only accumulate.

As a result header removal patches get priority, from me at least. :-)

Quoted 3 lines

- 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.

So if the ACPI maintainers are fine with -tip carrying patches #11 and #12 then I'd be glad to route these patches upstream.

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

I edited the title of patch 12 slightly, to:

Quoted 8 lines
Quoted 4 lines

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

to make sure the big header dependency change is obvious at first sight.

I'm fine with the patches but can we drop the fixes headers please? This doesn't actually fix anything, and touching early boot stuff for no good reason should be avoided imo.

Agreed and done.

Thanks,

Ingo

#40 lore raw
Quoted 60 lines · Ingo Molnar
Quoted 56 lines · Ard Biesheuvel
Quoted 55 lines · Ingo Molnar
Quoted 20 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.

Build tested on x86 with allyesconfig and allmodconfig, so hopefully there aren't more build issues lurking, but at this point it wouldn't surprise me in the least if this somehow manages to break the build.

Quoted 7 lines

Based on tip/master, commit ceceaf1f12ba ("Merge branch 'WIP.x86/cleanups'").

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.

Yeah, these kind of parasitic header dependencies are the main driving force behind kernel header spaghetti hell: it's super easy to add a new header, but very hard to remove them...

Hence they practically only accumulate.

As a result header removal patches get priority, from me at least. :-)

Quoted 3 lines

- 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.

So if the ACPI maintainers are fine with -tip carrying patches #11 and #12 then I'd be glad to route these patches upstream.

I've applied them to tip:WIP.core/headers as a work-in-progress tree, and I'm testing them on randconfigs to make sure there's no broken dependencies. I'll wait for the ACPI acks.

I edited the title of patch 12 slightly, to:

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

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

to make sure the big header dependency change is obvious at first sight.

I'm fine with the patches but can we drop the fixes headers please? This doesn't actually fix anything, and touching early boot stuff for no good reason should be avoided imo.

Agreed and done.

Thanks Ingo