From nobody Mon Feb 9 17:56:23 2026 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1409F329378 for ; Tue, 3 Feb 2026 17:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770141544; cv=none; b=KN5JtUhMvrZ036gz7gq+a/W4vhoI7Lara37HF/aBcIHE86JbIHcx98Ck/v4aHMfn/C3xWJXRe8jmMtY6+8WQsHbpX9CljT2DPV184mzf13XKxH8KJrPJSjlwQXkxyJ/fknAuNwM0XLWZg4vYHOw/CEF6eJK3RXLAekmGASB3uDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770141544; c=relaxed/simple; bh=nC9VDmqMVXaxesQvTdS96JiSN9qfL4favK0Q2cyDagw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OZwjSYtch/BWhR3WH6pdRMl6c1Qh/AuPJDRosqIj2jlACgci3mjVGyTBfre2kqnS5frT+awO/j+zoCFHl1EITVwwnr6/7YlhtOIdwqYb+IqpTbxEuZYyilDe3Wi2i4MxT8zdfPrsSL04Z/VByuJayDjU48fB/9AqqRveYabriHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fcvYCIZo; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fcvYCIZo" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-794e0e933ccso22524817b3.1 for ; Tue, 03 Feb 2026 09:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770141542; x=1770746342; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D6q457KiJcc3DXhj7d5HgrU4vz29quL+9gex1dTE6dI=; b=fcvYCIZo+FHLz0qMe3jUQZ6AmvZCBS/2ukTgP716aYNYPdxxfUh/AdGh0aPBLeUVUO 04suTGMXxA2nY90+SmA0Hz583uFaR/OMLeznTVXdyvw9FHMMSRjxGjlwe2mhhhnBM4zC CuOIjUsOFu2itvYqNpOd6TZqmCamkJHEYZqXO9svoX4hFoV7J0gC3q/zsAIm3A7/qbca 9inkhkZwm2MF3MNpTSyzuXY0+INRcei4c7mTm9dBW6wLxmlPwNzIqcX1MI4VqDbWCCJy dFJ2PQHKDe/QeVHLjGSndO5ZWxrZtmxDjFYGFA5kowWwNlfrgRB0TO3YugEhAp0SXFQm yrCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770141542; x=1770746342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=D6q457KiJcc3DXhj7d5HgrU4vz29quL+9gex1dTE6dI=; b=ZbeJkhOEtdRySbEoSqElXGhYCwMOS/S+4O2dh38LAvTxYG0fyLeJixQ4uskbhq8TyL lTsSFXW0YTqxyojtgiGj56Gshk+9BNnWXZ0uc4xYQlA8oJ2SUQnmIIitqo0tX31+/bxI 4lBtWM2pxHkfkENRAP8keH0R1KlIthUiOxQS+6PJafZvQ33D5Tp5KukbuMwlHN8ZDS5M XsGDbRco6V9tGCUb5pBxoJhElO9zr/a0Vp7VTIwfYWV0lyEcdat514pdqMADIsmTdnyD qMr8bmhKA6wozAt94sK8EVzQ7eQjrK2Yp9A7jd2cXzJzGwZ/zED+2YrhgPY0Y7Y3Zi8W F6nA== X-Gm-Message-State: AOJu0YwfueQQsWJvTYuNeQFdmvUOunZk4PWVa4FGEvcb48pSujxU03DU 8PFE4Ny6FxZS7xof2so4xYiDDyz2sdQm9ieHhHOYEZznObkHdeV5g4xITe8m X-Gm-Gg: AZuq6aIaIM0vefqEY17DojbkMaVDQg1wsmcct6NY9Fzux/g/ljOge7oCNW7Q4rMuPLV 1dPt61kQFyXXK3pQMXFjs/wCokCCIqvtCxEQEc3x9FvaP+CZ+CTZlVTs0bBq5l/m8DN+lFmiK5a UGFniuyLFqZmy+Leh1GZiE8UQsddTlcM5vNdaI+ZK3FSsKMIaMJK7JmE6qRzY/w781Zf1JwnM9E HYr1kET39CQqzN7E/3Vx77rsKztxnPJp+StFSD+kmPvzvvrXqRTMWiNj3R83eltjKbu1vYFmY+P l7Ti875B3bfiUkBtih2zojjxUnaGae6V2d08quhM7zzkWzntP6shNb24UB8hF54B2KQS+TZsXtJ 7pAoaUe71Z1iX5fjW6uPtAHJivtM8+vOIME2zrFCuP8uK6e6cHW8BSXG7CxsMQ75q94OT X-Received: by 2002:a05:690c:f87:b0:78f:8503:7773 with SMTP id 00721157ae682-794fe62b630mr4399747b3.3.1770141541888; Tue, 03 Feb 2026 09:59:01 -0800 (PST) Received: from citadel.lan ([2600:6c4a:4d3f:6d5c::1dba]) by smtp.gmail.com with ESMTPSA id 00721157ae682-794fefc8849sm1204647b3.38.2026.02.03.09.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 09:59:01 -0800 (PST) From: Brian Gerst To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Ingo Molnar , "H . Peter Anvin" , Thomas Gleixner , Borislav Petkov , Ard Biesheuvel , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Brian Gerst Subject: [PATCH v2 3/4] x86/acpi/suspend: Clean up stack usage Date: Tue, 3 Feb 2026 12:58:20 -0500 Message-ID: <20260203175821.511847-4-brgerst@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203175821.511847-1-brgerst@gmail.com> References: <20260203175821.511847-1-brgerst@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Save the stack pointer to current->thread.sp right before calling x86_acpi_enter_sleep_state(). This allows removal of the temporary stack. Also remove the extra stack adjustments that are not needed. Signed-off-by: Brian Gerst --- arch/x86/kernel/acpi/sleep.c | 20 -------------------- arch/x86/kernel/acpi/wakeup_64.S | 18 +++++++----------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 91fa262f0e30..72b5028feaf2 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -25,10 +25,6 @@ =20 unsigned long acpi_realmode_flags; =20 -#if defined(CONFIG_SMP) && defined(CONFIG_64BIT) -static char temp_stack[4096]; -#endif - /** * acpi_get_wakeup_address - provide physical address for S3 wakeup * @@ -113,22 +109,6 @@ int x86_acpi_suspend_lowlevel(void) saved_magic =3D 0x12345678; #else /* CONFIG_64BIT */ #ifdef CONFIG_SMP - /* - * As each CPU starts up, it will find its own stack pointer - * from its current_task->thread.sp. Typically that will be - * the idle thread for a newly-started AP, or even the boot - * CPU which will find it set to &init_task in the static - * per-cpu data. - * - * Make the resuming CPU use the temporary stack at startup - * by setting current->thread.sp to point to that. The true - * %rsp will be restored with the rest of the CPU context, - * by do_suspend_lowlevel(). And unwinders don't care about - * the abuse of ->thread.sp because it's a dead variable - * while the thread is running on the CPU anyway; the true - * value is in the actual %rsp register. - */ - current->thread.sp =3D (unsigned long)temp_stack + sizeof(temp_stack); /* * Ensure the CPU knows which one it is when it comes back, if * it isn't in parallel mode and expected to work that out for diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup= _64.S index 099401ef2ea4..b4bb1ca228b6 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -18,6 +18,10 @@ */ SYM_FUNC_START(wakeup_long64) ANNOTATE_NOENDBR + + /* pop return address to common_startup_64() */ + addq $8, %rsp + movq saved_magic(%rip), %rax movq $0x123456789abcdef0, %rdx cmpq %rdx, %rax @@ -28,8 +32,6 @@ SYM_FUNC_START(wakeup_long64) 1: jmp 1b 2: - movq saved_rsp(%rip), %rsp - movq saved_rbx(%rip), %rbx movq saved_rdi(%rip), %rdi movq saved_rsi(%rip), %rsi @@ -41,12 +43,10 @@ STACK_FRAME_NON_STANDARD wakeup_long64 =20 SYM_FUNC_START(do_suspend_lowlevel) FRAME_BEGIN - subq $8, %rsp xorl %eax, %eax call save_processor_state =20 movq $saved_context, %rax - movq %rsp, pt_regs_sp(%rax) movq %rbp, pt_regs_bp(%rax) movq %rsi, pt_regs_si(%rax) movq %rdi, pt_regs_di(%rax) @@ -64,13 +64,14 @@ SYM_FUNC_START(do_suspend_lowlevel) pushfq popq pt_regs_flags(%rax) =20 - movq %rsp, saved_rsp(%rip) + movq PER_CPU_VAR(current_task), %rax + movq %rsp, TASK_threadsp(%rax) + movq %rbp, saved_rbp(%rip) movq %rbx, saved_rbx(%rip) movq %rdi, saved_rdi(%rip) movq %rsi, saved_rsi(%rip) =20 - addq $8, %rsp movl $3, %edi xorl %eax, %eax call x86_acpi_enter_sleep_state @@ -89,7 +90,6 @@ SYM_FUNC_START(do_suspend_lowlevel) movq %rbx, %cr0 pushq pt_regs_flags(%rax) popfq - movq pt_regs_sp(%rax), %rsp movq pt_regs_bp(%rax), %rbp movq pt_regs_si(%rax), %rsi movq pt_regs_di(%rax), %rdi @@ -115,11 +115,9 @@ SYM_FUNC_START(do_suspend_lowlevel) #endif =20 xorl %eax, %eax - addq $8, %rsp FRAME_END jmp restore_processor_state SYM_FUNC_END(do_suspend_lowlevel) -STACK_FRAME_NON_STANDARD do_suspend_lowlevel =20 .data saved_rbp: .quad 0 @@ -127,6 +125,4 @@ saved_rsi: .quad 0 saved_rdi: .quad 0 saved_rbx: .quad 0 =20 -saved_rsp: .quad 0 - SYM_DATA(saved_magic, .quad 0) --=20 2.52.0