From: Thomas Gleixner <tglx@linutronix.de>
To: Borislav Petkov <bp@alien8.de>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
Ingo Molnar <mingo@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
David Woodhouse <dwmw@amazon.co.uk>,
Dionna Amalie Glaze <dionnaglaze@google.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Kees Cook <keescook@chromium.org>,
Kevin Loughlin <kevinloughlin@google.com>,
Len Brown <len.brown@intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
linux-efi@vger.kernel.org, x86@kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: 4067196a5227 ("mm/page_alloc: fix deadlock on cpu_hotplug_lock in __accept_page()") (was: Re: [tip: x86/boot] x86/boot: Provide __pti_set_user_pgtbl() to startup code)
Date: Tue, 06 May 2025 12:14:15 +0200 [thread overview]
Message-ID: <87ecx2nj0o.ffs@tglx> (raw)
In-Reply-To: <20250506092445.GBaBnVXXyvnazly6iF@fat_crate.local>
On Tue, May 06 2025 at 11:24, Borislav Petkov wrote:
> [ 1.329836] ---[ end Kernel panic - not syncing: kernel: panic_on_warn set ... ]---
>
> Fun stuff.
The only workable fix for this is:
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -894,7 +894,7 @@ config INTEL_TDX_GUEST
select ARCH_HAS_CC_PLATFORM
select X86_MEM_ENCRYPT
select X86_MCE
- select UNACCEPTED_MEMORY
+ select UNACCEPTED_MEMORY if BROKEN
help
Support running as a guest under Intel TDX. Without this support,
the guest kernel can not boot or run under TDX.
@@ -1515,7 +1515,7 @@ config AMD_MEM_ENCRYPT
select INSTRUCTION_DECODER
select ARCH_HAS_CC_PLATFORM
select X86_MEM_ENCRYPT
- select UNACCEPTED_MEMORY
+ select UNACCEPTED_MEMORY if BROKEN
select CRYPTO_LIB_AESGCM
help
Say yes to enable support for the encryption of system memory.
Why?
The whole logic of this static branch _is_ completely broken. It wants to
track whether any zone has unaccepted memory, but all of that lacks any
form of global serialization.
__accept_page()
last = list_empty(&zone->unaccepted_pages);
spin_unlock_irqrestore(&zone->lock, *flags);
if (last)
static_branch_dec();
__free_unaccepted()
spin_lock_irqsave(&zone->lock, flags);
first = list_empty(&zone->unaccepted_pages);
spin_unlock_irqrestore(&zone->lock, flags);
if (first)
static_branch_inc();
So anything which operates on the same zone after the lock was dropped
can race against the actual dec/inc operations. It's not even consistent
on the same zone, so how is that supposed to be consistent even across
different zones?
The work deferement:
__accept_page()
last = list_empty(&zone->unaccepted_pages);
spin_unlock_irqrestore(&zone->lock, *flags);
if (last) {
if (...)
schedule_work(...);
else
static_branch_dec();
made this actually worse as the work is fully async and therefore
decrements can be lost:
__accept_page()
schedule_work()
....
__accept_page()
schedule_work()
-> As the work is already scheduled, but not yet processed,
it is not queued again, which means the second decrement
is lost.
But that is just the tip of the iceberg as everything underneath which
"manages" and depends on that static branch is completely broken
already.
Seriously?
Thanks,
tglx
next prev parent reply other threads:[~2025-05-06 10:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 9:24 4067196a5227 ("mm/page_alloc: fix deadlock on cpu_hotplug_lock in __accept_page()") (was: Re: [tip: x86/boot] x86/boot: Provide __pti_set_user_pgtbl() to startup code) Borislav Petkov
2025-05-06 10:14 ` Thomas Gleixner [this message]
2025-05-06 10:23 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ecx2nj0o.ffs@tglx \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dionnaglaze@google.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kevinloughlin@google.com \
--cc=kirill@shutemov.name \
--cc=len.brown@intel.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=thomas.lendacky@amd.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.