mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Magnus Lindholm <linmag7@gmail.com>
To: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org,
	hch@infradead.org, macro@orcam.me.uk,
	glaubitz@physik.fu-berlin.de, mattst88@gmail.com,
	richard.henderson@linaro.org, ink@unseen.parts
Cc: Magnus Lindholm <linmag7@gmail.com>
Subject: [PATCH 0/1] alpha: fix user-space corruption during memory compaction
Date: Fri,  2 Jan 2026 18:30:42 +0100	[thread overview]
Message-ID: <20260102173603.18247-1-linmag7@gmail.com> (raw)

This patch fixes long-standing user-space crashes on Alpha systems
when memory compaction is enabled.

Observed symptoms include:
  - sporadic SIGSEGV in unrelated user programs
  - glibc allocator failures (e.g. "unaligned tcache chunk detected")
  - gcc "internal compiler error"
  - heap corruption detected by malloc consistency checks

The failures occur only when page migration / compaction is active
and disappear when compaction is disabled. They affect both UP and
SMP kernels and are not specific to a particular Alpha CPU model.

Root cause
==========

Alpha relies on Address Space Numbers (ASNs) for user-space instruction
cache coherency. Existing TLB shootdown paths during page migration
primarily depend on MM context rollover, with lazy invalidation of
translations on CPUs not actively running the MM.

This approach is insufficient during page migration. Migration creates
a window where stale data or instruction translations can survive long
enough for a CPU to perform loads or stores using the wrong physical
page. This leads to silent user-space memory corruption that later
manifests as crashes.

Testing shows that the corruption is triggered during the unmap phase
of migration. Installing the fix in ptep_clear_flush() is sufficient.
No additional handling is required when installing the new mapping.

Instruction barriers were evaluated during debugging but were found
not to be required. Immediate TLB invalidation combined with ASN
rollover is sufficient to prevent stale instruction and data access.

Solution
========

This patch introduces a migration-specific TLB flush helper that
combines:
  - MM context invalidation (ASN rollover),
  - immediate per-CPU TLB invalidation,
  - synchronous cross-CPU shootdown.

The helper is used only by the page migration / compaction unmap
path, leaving normal TLB semantics unchanged for other VM operations.

Summary
=======

This patch fixes real user-visible corruption bugs during page
migration on Alpha by making TLB shootdowns migration-safe, without
impacting non-migration code paths.

Thanks for taking a look.

Magnus Lindholm (1):
  alpha: fix user-space corruption during memory compaction

 arch/alpha/include/asm/pgtable.h  |  33 ++++++++-
 arch/alpha/include/asm/tlbflush.h |   4 +-
 arch/alpha/mm/Makefile            |   2 +-
 arch/alpha/mm/tlbflush.c          | 112 ++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 arch/alpha/mm/tlbflush.c

-- 
2.51.0


             reply	other threads:[~2026-01-02 17:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-02 17:30 Magnus Lindholm [this message]
2026-01-02 17:30 ` [PATCH 1/1] " Magnus Lindholm
2026-01-03 13:41   ` Ivan Kokshaysky
2026-01-10 23:50   ` matoro
2026-01-02 17:57 ` [PATCH 0/1] " John Paul Adrian Glaubitz
2026-01-20  7:44   ` Michael Cree
2026-01-20 22:44     ` Magnus Lindholm

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=20260102173603.18247-1-linmag7@gmail.com \
    --to=linmag7@gmail.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=hch@infradead.org \
    --cc=ink@unseen.parts \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®