Skip to content

Commit fe0ba8c

Browse files
jgross1hansendc
authored andcommitted
acpi: Fix suspend with Xen PV
Commit f1e5250 ("x86/boot: Skip realmode init code when running as Xen PV guest") missed one code path accessing real_mode_header, leading to dereferencing NULL when suspending the system under Xen: [ 348.284004] PM: suspend entry (deep) [ 348.289532] Filesystems sync: 0.005 seconds [ 348.291545] Freezing user space processes ... (elapsed 0.000 seconds) done. [ 348.292457] OOM killer disabled. [ 348.292462] Freezing remaining freezable tasks ... (elapsed 0.104 seconds) done. [ 348.396612] printk: Suspending console(s) (use no_console_suspend to debug) [ 348.749228] PM: suspend devices took 0.352 seconds [ 348.769713] ACPI: EC: interrupt blocked [ 348.816077] BUG: kernel NULL pointer dereference, address: 000000000000001c [ 348.816080] #PF: supervisor read access in kernel mode [ 348.816081] #PF: error_code(0x0000) - not-present page [ 348.816083] PGD 0 P4D 0 [ 348.816086] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 348.816089] CPU: 0 PID: 6764 Comm: systemd-sleep Not tainted 6.1.3-1.fc32.qubes.x86_64 #1 [ 348.816092] Hardware name: Star Labs StarBook/StarBook, BIOS 8.01 07/03/2022 [ 348.816093] RIP: e030:acpi_get_wakeup_address+0xc/0x20 Fix that by adding an optional acpi callback allowing to skip setting the wakeup address, as in the Xen PV case this will be handled by the hypervisor anyway. Fixes: f1e5250 ("x86/boot: Skip realmode init code when running as Xen PV guest") Reported-by: Marek Marczykowski-Górecki <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/all/20230117155724.22940-1-jgross%40suse.com
1 parent 8c29f01 commit fe0ba8c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

arch/x86/include/asm/acpi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/mmu.h>
1515
#include <asm/mpspec.h>
1616
#include <asm/x86_init.h>
17+
#include <asm/cpufeature.h>
1718

1819
#ifdef CONFIG_ACPI_APEI
1920
# include <asm/pgtable_types.h>
@@ -63,6 +64,13 @@ extern int (*acpi_suspend_lowlevel)(void);
6364
/* Physical address to resume after wakeup */
6465
unsigned long acpi_get_wakeup_address(void);
6566

67+
static inline bool acpi_skip_set_wakeup_address(void)
68+
{
69+
return cpu_feature_enabled(X86_FEATURE_XENPV);
70+
}
71+
72+
#define acpi_skip_set_wakeup_address acpi_skip_set_wakeup_address
73+
6674
/*
6775
* Check if the CPU can handle C2 and deeper
6876
*/

drivers/acpi/sleep.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ static struct notifier_block tts_notifier = {
6060
.priority = 0,
6161
};
6262

63+
#ifndef acpi_skip_set_wakeup_address
64+
#define acpi_skip_set_wakeup_address() false
65+
#endif
66+
6367
static int acpi_sleep_prepare(u32 acpi_state)
6468
{
6569
#ifdef CONFIG_ACPI_SLEEP
6670
unsigned long acpi_wakeup_address;
6771

6872
/* do we have a wakeup address for S2 and S3? */
69-
if (acpi_state == ACPI_STATE_S3) {
73+
if (acpi_state == ACPI_STATE_S3 && !acpi_skip_set_wakeup_address()) {
7074
acpi_wakeup_address = acpi_get_wakeup_address();
7175
if (!acpi_wakeup_address)
7276
return -EFAULT;

0 commit comments

Comments
 (0)