Message ID | 20230113140610.7132-1-jgross@suse.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp292609wrt; Fri, 13 Jan 2023 06:15:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8nISOjh3C8kGflM7cj+YS6uqdSh8gFKgB4vJJLfz9TYkyvAub9cOP+TaM6R/2zvabjEPV X-Received: by 2002:a17:907:a488:b0:84d:2171:d79 with SMTP id vp8-20020a170907a48800b0084d21710d79mr25960197ejc.54.1673619319504; Fri, 13 Jan 2023 06:15:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673619319; cv=none; d=google.com; s=arc-20160816; b=z8l9hGs2ZNuxb6wL+mTsH+T3mXcpu1Tcg7ygoRy2rfuQYr0OmfZH+sGXW3L8PKhCji EBZNQBTUpnI8LK8zTM2MjI5kpzMNdvVlrbin7U7sgsOrGnuuXW+9LCXKBtokDU2r0RMJ DdB4WlKjvYOuXj+pJYk6Cb7wn9Buc6qmOj/1cHFLtgpzDRUxVJ20sCCYfoqNkNNYWSYh 2+H8CrDfPK57O7KVbSxPciRNqov/SbPghQat9tKug8q8icRQIXTk3kXR+Za7hscg/SVP ek2sNZiqJQHkw9WbU2nZcwAx/wpVsdSygSpxzArUyUXrRzlEFU+dlVkK+daBM2GnNvPx Ky3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qerTG7yVEdATebY6zaKCk2qNuAQ7K4by6XyL0WSCPFo=; b=cTN05yHsFbM36HbCqH3VVmfH/pCnuNmHnPvbWVMgLSUq/6kqbkUsgkf7cQ7kz0nwbl 2S6RJlTq8/P4+G/zY1EBdnhRcbvTJvQYHh8USqH6YUXeTi9pGPsmcC5qGjR0G8CV1mGk ZyboL1+EL4X8/MS9ADT2YcK9qTILEZi+Zi8sJK/v6CsmvXLeQBZRNnp9eL/FwpMtYcKC GIdQZSkhAuBzFABgL0zqtV0YITE91wDHJX1GLxX0P0YdRHsHdOPMF/3QOq9+t4belJaX Eczzfn5S5Rv4jWa+RnJhFG/eqnxxrZ0mp4+gmuovTJlfj0KkaAU3jD+KWviO2/ECfyYI pSFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mlMz7tpa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p20-20020a1709060dd400b0078e19e971b2si15795517eji.915.2023.01.13.06.14.54; Fri, 13 Jan 2023 06:15:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mlMz7tpa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241927AbjAMOKe (ORCPT <rfc822;callmefire3@gmail.com> + 99 others); Fri, 13 Jan 2023 09:10:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233098AbjAMOKI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Jan 2023 09:10:08 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5575C1F6; Fri, 13 Jan 2023 06:06:13 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B856E256B8; Fri, 13 Jan 2023 14:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673618771; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qerTG7yVEdATebY6zaKCk2qNuAQ7K4by6XyL0WSCPFo=; b=mlMz7tpaDKH5ON0g3Sl4mmBovvApom2MngsecURVvLNhBb2UjbPkYxhetfIhGhxNoH0ZBB Z8F0qUptHNhmYOLMOX7rYBaAOAWfUUHinRaV/sD4EEA2d5dDZF+YutajoQc1DwcLPCLOU8 TEZAJnoIvy9o4hrjiLIPqIQCjVeXCZk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4F2591358A; Fri, 13 Jan 2023 14:06:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bXH8EVNlwWPnDQAAMHmgww (envelope-from <jgross@suse.com>); Fri, 13 Jan 2023 14:06:11 +0000 From: Juergen Gross <jgross@suse.com> To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org Cc: Juergen Gross <jgross@suse.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, "Rafael J. Wysocki" <rafael@kernel.org>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, Stefano Stabellini <sstabellini@kernel.org>, Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>, xen-devel@lists.xenproject.org, =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= <marmarek@invisiblethingslab.com> Subject: [PATCH] x86/acpi: fix suspend with Xen Date: Fri, 13 Jan 2023 15:06:10 +0100 Message-Id: <20230113140610.7132-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754917051568129315?= X-GMAIL-MSGID: =?utf-8?q?1754917051568129315?= |
Series |
x86/acpi: fix suspend with Xen
|
|
Commit Message
Juergen Gross
Jan. 13, 2023, 2:06 p.m. UTC
Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which
Xen PV dom0 can use to return a dummy non-zero wakeup address (this
address won't ever be used, as the real suspend handling is done by the
hypervisor).
Fixes: f1e525009493 ("x86/boot: Skip realmode init code when running as Xen PV guest")
Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
arch/x86/include/asm/acpi.h | 2 +-
arch/x86/kernel/acpi/sleep.c | 3 ++-
include/xen/acpi.h | 9 +++++++++
3 files changed, 12 insertions(+), 2 deletions(-)
Comments
On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: > > Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which > Xen PV dom0 can use to return a dummy non-zero wakeup address (this > address won't ever be used, as the real suspend handling is done by the > hypervisor). How exactly does this help? > Fixes: f1e525009493 ("x86/boot: Skip realmode init code when running as Xen PV guest") > Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> > Signed-off-by: Juergen Gross <jgross@suse.com> > --- > arch/x86/include/asm/acpi.h | 2 +- > arch/x86/kernel/acpi/sleep.c | 3 ++- > include/xen/acpi.h | 9 +++++++++ > 3 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h > index 65064d9f7fa6..137259ff8f03 100644 > --- a/arch/x86/include/asm/acpi.h > +++ b/arch/x86/include/asm/acpi.h > @@ -61,7 +61,7 @@ static inline void acpi_disable_pci(void) > extern int (*acpi_suspend_lowlevel)(void); > > /* Physical address to resume after wakeup */ > -unsigned long acpi_get_wakeup_address(void); > +extern unsigned long (*acpi_get_wakeup_address)(void); > > /* > * Check if the CPU can handle C2 and deeper > diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c > index 3b7f4cdbf2e0..1a3cd5e24cd0 100644 > --- a/arch/x86/kernel/acpi/sleep.c > +++ b/arch/x86/kernel/acpi/sleep.c > @@ -33,10 +33,11 @@ static char temp_stack[4096]; > * 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) > +static unsigned long x86_acpi_get_wakeup_address(void) > { > return ((unsigned long)(real_mode_header->wakeup_start)); > } > +unsigned long (*acpi_get_wakeup_address)(void) = x86_acpi_get_wakeup_address; > > /** > * x86_acpi_enter_sleep_state - enter sleep state > diff --git a/include/xen/acpi.h b/include/xen/acpi.h > index b1e11863144d..7e1e5dbfb77c 100644 > --- a/include/xen/acpi.h > +++ b/include/xen/acpi.h > @@ -56,6 +56,12 @@ static inline int xen_acpi_suspend_lowlevel(void) > return 0; > } > > +static inline unsigned long xen_acpi_get_wakeup_address(void) > +{ > + /* Just return a dummy non-zero value, it will never be used. */ > + return 1; > +} > + > static inline void xen_acpi_sleep_register(void) > { > if (xen_initial_domain()) { > @@ -65,6 +71,9 @@ static inline void xen_acpi_sleep_register(void) > &xen_acpi_notify_hypervisor_extended_sleep); > > acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel; > +#ifdef CONFIG_ACPI_SLEEP > + acpi_get_wakeup_address = xen_acpi_get_wakeup_address; > +#endif > } > } > #else > -- > 2.35.3 >
On Fri, Jan 13, 2023 at 08:40:15PM +0100, Rafael J. Wysocki wrote: > On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: > > > > Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which > > Xen PV dom0 can use to return a dummy non-zero wakeup address (this > > address won't ever be used, as the real suspend handling is done by the > > hypervisor). > > How exactly does this help? By not accessing calling acpi_get_wakeup_address() (with the patch renamed to x86_acpi_get_wakeup_address()) during PV dom0 suspend, which otherwise would access not initialized real_mode_header. I confirm this patch fixes the issue. > > Fixes: f1e525009493 ("x86/boot: Skip realmode init code when running as Xen PV guest") > > Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> > > Signed-off-by: Juergen Gross <jgross@suse.com> > > --- > > arch/x86/include/asm/acpi.h | 2 +- > > arch/x86/kernel/acpi/sleep.c | 3 ++- > > include/xen/acpi.h | 9 +++++++++ > > 3 files changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h > > index 65064d9f7fa6..137259ff8f03 100644 > > --- a/arch/x86/include/asm/acpi.h > > +++ b/arch/x86/include/asm/acpi.h > > @@ -61,7 +61,7 @@ static inline void acpi_disable_pci(void) > > extern int (*acpi_suspend_lowlevel)(void); > > > > /* Physical address to resume after wakeup */ > > -unsigned long acpi_get_wakeup_address(void); > > +extern unsigned long (*acpi_get_wakeup_address)(void); > > > > /* > > * Check if the CPU can handle C2 and deeper > > diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c > > index 3b7f4cdbf2e0..1a3cd5e24cd0 100644 > > --- a/arch/x86/kernel/acpi/sleep.c > > +++ b/arch/x86/kernel/acpi/sleep.c > > @@ -33,10 +33,11 @@ static char temp_stack[4096]; > > * 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) > > +static unsigned long x86_acpi_get_wakeup_address(void) > > { > > return ((unsigned long)(real_mode_header->wakeup_start)); > > } > > +unsigned long (*acpi_get_wakeup_address)(void) = x86_acpi_get_wakeup_address; > > > > /** > > * x86_acpi_enter_sleep_state - enter sleep state > > diff --git a/include/xen/acpi.h b/include/xen/acpi.h > > index b1e11863144d..7e1e5dbfb77c 100644 > > --- a/include/xen/acpi.h > > +++ b/include/xen/acpi.h > > @@ -56,6 +56,12 @@ static inline int xen_acpi_suspend_lowlevel(void) > > return 0; > > } > > > > +static inline unsigned long xen_acpi_get_wakeup_address(void) > > +{ > > + /* Just return a dummy non-zero value, it will never be used. */ > > + return 1; > > +} > > + > > static inline void xen_acpi_sleep_register(void) > > { > > if (xen_initial_domain()) { > > @@ -65,6 +71,9 @@ static inline void xen_acpi_sleep_register(void) > > &xen_acpi_notify_hypervisor_extended_sleep); > > > > acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel; > > +#ifdef CONFIG_ACPI_SLEEP > > + acpi_get_wakeup_address = xen_acpi_get_wakeup_address; > > +#endif > > } > > } > > #else > > -- > > 2.35.3 > >
On 13.01.23 20:40, Rafael J. Wysocki wrote: > On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: >> >> Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which >> Xen PV dom0 can use to return a dummy non-zero wakeup address (this >> address won't ever be used, as the real suspend handling is done by the >> hypervisor). > > How exactly does this help? I believed the first sentence of the commit message would make this clear enough. I can expand the commit message to go more into detail if you think this is really needed. Juergen
On Mon, Jan 16, 2023 at 7:45 AM Juergen Gross <jgross@suse.com> wrote: > > On 13.01.23 20:40, Rafael J. Wysocki wrote: > > On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: > >> > >> Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which > >> Xen PV dom0 can use to return a dummy non-zero wakeup address (this > >> address won't ever be used, as the real suspend handling is done by the > >> hypervisor). > > > > How exactly does this help? > > I believed the first sentence of the commit message would make this > clear enough. That was clear, but the fix part wasn't really. > I can expand the commit message to go more into detail if you think > this is really needed. IMO calling acpi_set_waking_vector() with a known-invalid wakeup vector address in dom0 is plain confusing. I'm not sure what to do about it yet, but IMV something needs to be done.
On 17.01.23 15:09, Rafael J. Wysocki wrote: > On Mon, Jan 16, 2023 at 7:45 AM Juergen Gross <jgross@suse.com> wrote: >> >> On 13.01.23 20:40, Rafael J. Wysocki wrote: >>> On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: >>>> >>>> Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which >>>> Xen PV dom0 can use to return a dummy non-zero wakeup address (this >>>> address won't ever be used, as the real suspend handling is done by the >>>> hypervisor). >>> >>> How exactly does this help? >> >> I believed the first sentence of the commit message would make this >> clear enough. > > That was clear, but the fix part wasn't really. > >> I can expand the commit message to go more into detail if you think >> this is really needed. > > IMO calling acpi_set_waking_vector() with a known-invalid wakeup > vector address in dom0 is plain confusing. > > I'm not sure what to do about it yet, but IMV something needs to be done. Another possibility would be to modify acpi_sleep_prepare(), e.g. like the attached patch (compile tested only). Juergen
On Tue, Jan 17, 2023 at 4:32 PM Juergen Gross <jgross@suse.com> wrote: > > On 17.01.23 15:09, Rafael J. Wysocki wrote: > > On Mon, Jan 16, 2023 at 7:45 AM Juergen Gross <jgross@suse.com> wrote: > >> > >> On 13.01.23 20:40, Rafael J. Wysocki wrote: > >>> On Fri, Jan 13, 2023 at 3:06 PM Juergen Gross <jgross@suse.com> wrote: > >>>> > >>>> Commit f1e525009493 ("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 indirection for acpi_get_wakeup_address() which > >>>> Xen PV dom0 can use to return a dummy non-zero wakeup address (this > >>>> address won't ever be used, as the real suspend handling is done by the > >>>> hypervisor). > >>> > >>> How exactly does this help? > >> > >> I believed the first sentence of the commit message would make this > >> clear enough. > > > > That was clear, but the fix part wasn't really. > > > >> I can expand the commit message to go more into detail if you think > >> this is really needed. > > > > IMO calling acpi_set_waking_vector() with a known-invalid wakeup > > vector address in dom0 is plain confusing. > > > > I'm not sure what to do about it yet, but IMV something needs to be done. > > Another possibility would be to modify acpi_sleep_prepare(), e.g. like the > attached patch (compile tested only). I prefer this to the previous version. It is much more straightforward IMV.
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 65064d9f7fa6..137259ff8f03 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h @@ -61,7 +61,7 @@ static inline void acpi_disable_pci(void) extern int (*acpi_suspend_lowlevel)(void); /* Physical address to resume after wakeup */ -unsigned long acpi_get_wakeup_address(void); +extern unsigned long (*acpi_get_wakeup_address)(void); /* * Check if the CPU can handle C2 and deeper diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 3b7f4cdbf2e0..1a3cd5e24cd0 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -33,10 +33,11 @@ static char temp_stack[4096]; * 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) +static unsigned long x86_acpi_get_wakeup_address(void) { return ((unsigned long)(real_mode_header->wakeup_start)); } +unsigned long (*acpi_get_wakeup_address)(void) = x86_acpi_get_wakeup_address; /** * x86_acpi_enter_sleep_state - enter sleep state diff --git a/include/xen/acpi.h b/include/xen/acpi.h index b1e11863144d..7e1e5dbfb77c 100644 --- a/include/xen/acpi.h +++ b/include/xen/acpi.h @@ -56,6 +56,12 @@ static inline int xen_acpi_suspend_lowlevel(void) return 0; } +static inline unsigned long xen_acpi_get_wakeup_address(void) +{ + /* Just return a dummy non-zero value, it will never be used. */ + return 1; +} + static inline void xen_acpi_sleep_register(void) { if (xen_initial_domain()) { @@ -65,6 +71,9 @@ static inline void xen_acpi_sleep_register(void) &xen_acpi_notify_hypervisor_extended_sleep); acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel; +#ifdef CONFIG_ACPI_SLEEP + acpi_get_wakeup_address = xen_acpi_get_wakeup_address; +#endif } } #else