From patchwork Thu Jan 19 22:22:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 46046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp582977wrn; Thu, 19 Jan 2023 14:50:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXtDTVx8psHP8nkox5Uj1L9vMSFE39LUFYLoKpVrToebzUKwNRGlsXOzZbmdXdt4oceKpgPu X-Received: by 2002:a05:6a00:1c8f:b0:58b:c63e:6bc6 with SMTP id y15-20020a056a001c8f00b0058bc63e6bc6mr11812468pfw.29.1674168617062; Thu, 19 Jan 2023 14:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674168617; cv=none; d=google.com; s=arc-20160816; b=G7eZzEkcnzrYQlp+Isi7h8drglx8abF8KBGnbfWok0dIljN542qD79qhBiUlGwRyDC 3ICba1M6YcsNLALRJ9H6qoZz//GbEYcdsomxYqllTu4MxHe/I2UwEG/BWB4Fq1c3qn/N XyBncnWZ000CJfZdcXdQZ1Y/StoGq/JtqlcyowkgaNeSRAZyjpNU8U5iERlc2OoKRV6G kYXwMaH23IKxZDHrcAA76Q64pyFJ/HN1IBCL7dVsbaH9vi4qgHi+bBF0OgmAoq7gr0+H pbpOCtMqo3IK3upaKGgsNIXT33v8US7LcM4ivu4GQYefTsLz/JnMebOY/3t1JJAYchaB aRJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=Dl7CD/D7G+lEEnQAkMUvyaCXOdQrmVHbu2hv3zw7wS4=; b=o29uT02AxFJs9aZoNmy1x9SprmZzA+kNHcr8HHt8fMYL0Q2CpzZ7m4UgjrA9Ps8YPo /T+IPbTS/fKaSs4XWHYWMezIsOD2G9Xp5nMngQfNHFo9LFLReyJ9XijwNMzW9xa6d97E dhMP+RBiRQHXcNfpyibS3Ax20JkrFDWSTc/aReiTcB76BPI6u7+ZqAEwbL66Dlj/HNub TXoj9Xrrf4RFOX2+r5n/rDPiYhlOncBCEDQXozVSa28MscV2JyJONOo2Y2SzkiwuO0Ql ZQ8Y4vv6eZlqF8SdxNCzDKl40ylV+TtPLKpBlE3zJlDgYRli4lQ6IC6cBopq/G72iYDH n79A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YYaNfLX3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020a625211000000b005769b34452fsi36456891pfb.203.2023.01.19.14.50.01; Thu, 19 Jan 2023 14:50:17 -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=@linutronix.de header.s=2020 header.b=YYaNfLX3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjASWlY (ORCPT + 99 others); Thu, 19 Jan 2023 17:41:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231312AbjASWkq (ORCPT ); Thu, 19 Jan 2023 17:40:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF92645BE8; Thu, 19 Jan 2023 14:22:41 -0800 (PST) Date: Thu, 19 Jan 2023 22:22:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1674166960; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=Dl7CD/D7G+lEEnQAkMUvyaCXOdQrmVHbu2hv3zw7wS4=; b=YYaNfLX37nPmqRGXTrjCpTAOYLZPNqRJJmdTb1zEc+kWrUmpOaFHlvPiItv7IsLhWKum+P OgxqAtitccCGygSTSR+VDPPWTS9q714/WvRE//+jPl7HrLiQTA6tNzU9ZUHcWHRX4eIXOY /cY2J/qH/30Mji2QNBqnUHdzZ4xNsocpgddCHpsjZL8ys1bAB/qDeHf7KlhPgp29/cqbTN 8u46YcVkxG7hwLA3p1bMVJjxb3fqDj67Qn+Sqx3b+3P1537bFSlXFpOqkEiyB3lKJ5aPTH ZuvxhSiZnGARFiJsvbrNk0uwcUpR2s4Oj3lcfO9vqLqP/zNArwYORh3O4xk8eg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1674166960; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=Dl7CD/D7G+lEEnQAkMUvyaCXOdQrmVHbu2hv3zw7wS4=; b=pxNV52oubP0oYTEICwRZIfeuv8AG/eouBTkHsFGWNTPue8NVmjMF0Zde0bLSKfGikKWAVj gpFg8HQqVzY9A1BQ== From: "tip-bot2 for Juergen Gross" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] acpi: Fix suspend with Xen PV Cc: marmarek@invisiblethingslab.com, Juergen Gross , Dave Hansen , "Rafael J. Wysocki" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167416695968.4906.1267929896543710738.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755493031935843066?= X-GMAIL-MSGID: =?utf-8?q?1755493031935843066?= The following commit has been merged into the x86/urgent branch of tip: Commit-ID: fe0ba8c23f9a35b0307eb662f16dd3a75fcdae41 Gitweb: https://git.kernel.org/tip/fe0ba8c23f9a35b0307eb662f16dd3a75fcdae41 Author: Juergen Gross AuthorDate: Tue, 17 Jan 2023 16:57:23 +01:00 Committer: Dave Hansen CommitterDate: Thu, 19 Jan 2023 13:52:05 -08:00 acpi: Fix suspend with Xen PV 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 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: f1e525009493 ("x86/boot: Skip realmode init code when running as Xen PV guest") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Juergen Gross Signed-off-by: Dave Hansen Acked-by: Rafael J. Wysocki Link: https://lore.kernel.org/all/20230117155724.22940-1-jgross%40suse.com --- arch/x86/include/asm/acpi.h | 8 ++++++++ drivers/acpi/sleep.c | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 65064d9..8eb74cf 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef CONFIG_ACPI_APEI # include @@ -63,6 +64,13 @@ extern int (*acpi_suspend_lowlevel)(void); /* Physical address to resume after wakeup */ unsigned long acpi_get_wakeup_address(void); +static inline bool acpi_skip_set_wakeup_address(void) +{ + return cpu_feature_enabled(X86_FEATURE_XENPV); +} + +#define acpi_skip_set_wakeup_address acpi_skip_set_wakeup_address + /* * Check if the CPU can handle C2 and deeper */ diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 0b557c0..4ca6672 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -60,13 +60,17 @@ static struct notifier_block tts_notifier = { .priority = 0, }; +#ifndef acpi_skip_set_wakeup_address +#define acpi_skip_set_wakeup_address() false +#endif + static int acpi_sleep_prepare(u32 acpi_state) { #ifdef CONFIG_ACPI_SLEEP unsigned long acpi_wakeup_address; /* do we have a wakeup address for S2 and S3? */ - if (acpi_state == ACPI_STATE_S3) { + if (acpi_state == ACPI_STATE_S3 && !acpi_skip_set_wakeup_address()) { acpi_wakeup_address = acpi_get_wakeup_address(); if (!acpi_wakeup_address) return -EFAULT;