mirror-linux/arch/arm64
Linus Torvalds 5bebe8de19 mm/huge_memory: Fix initialization of huge zero folio
The recent fix to properly initialize the tags of the huge zero folio
had an unfortunate not-so-subtle side effect: it caused the actual
*contents* of the huge zero folio to not be initialized at all when the
hardware didn't support the memory tagging.

The reason was the unfortunate semantics of tag_clear_highpage(): on
hardware that didn't do the tagging, it would silently just not do
anything at all.  And since this is done only on arm64 with MTE support,
that basically meant most hardware.

It wasn't necessarily immediately obvious since the huge zero page isn't
necessarily very heavily used - or because it might already be zero
because all-zeroes is the most common pattern.  But it ends up causing
random odd user space failures when you do hit it.

The unfortunate semantics have been around for a while, but became a
real bug only when we started actively using __GFP_ZEROTAGS in the
generic get_huge_zero_folio() function - before that, it had only ever
been used in code that checked that the hardware supported it.

Fix this by simply changing the semantics of tag_clear_highpage() to
return whether it actually successfully did something or not.  While at
it, also make it initialize multiple pages in one go, since that's
actually what the only caller wants it to do and it simplifies the whole
logic.

Fixes: adfb6609c6 ("mm/huge_memory: initialise the tags of the huge zero folio")
Link: https://lore.kernel.org/all/20251117082023.90176-1-00107082@163.com/
Reviewed-by: David Hildenbrand (Red Hat) <david@kernel.org>
Reported-and-tested-by: David Wang <00107082@163.com>
Reported-and-tested-by: Carlos Llamas <cmllamas@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2025-11-18 08:21:27 -08:00
..
boot arm64: dts: broadcom: bcm2712: Define VGIC interrupt 2025-10-13 10:31:04 -07:00
configs soc: defconfig updates for 6.18 2025-10-01 17:25:57 -07:00
crypto
hyperv
include mm/huge_memory: Fix initialization of huge zero folio 2025-11-18 08:21:27 -08:00
kernel arm64 fixes for -rc6 2025-11-11 10:31:17 -08:00
kvm KVM: arm64: vgic-v3: Release reserved slot outside of lpi_xa's lock 2025-11-08 11:19:32 +00:00
lib
mm mm/huge_memory: Fix initialization of huge zero folio 2025-11-18 08:21:27 -08:00
net bpf/arm64: Fix BPF_ST into arena memory 2025-10-31 11:20:53 -07:00
tools guest_memfd: 2025-10-04 08:52:16 -07:00
xen
Kbuild
Kconfig Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
Kconfig.debug
Kconfig.platforms soc: driver updates for 6.18 2025-10-01 17:32:51 -07:00
Makefile