[PATCH 0/2] x86/mm/pat: HIGHMEM pages in set_pages_array_*()
From: Christian
Date: Tue Nov 17 2026 - 04:49:42 EST
On i386 without PAE nearly all memory is HIGHMEM, and a DRM driver that
keeps its shmem buffers there (drm_gem_shmem_get_pages_locked() ->
set_pages_array_wc()) hits two problems in the page-array CPA paths:
1. The CPA walk takes __cpa_addr()'s 0 for a HIGHMEM page as a virtual
address and oopses in __cpa_process_fault()'s warning path, with the
CPA lock held, so every later CPA user hangs.
2. _set_pages_array() and set_pages_array_wb() skip HIGHMEM pages when
they reserve and free the memory type, so a write-combined user mapping
of such a page is left write-back by PAT. A device that does not snoop
the CPU's caches then reads stale data.
Patch 1 skips HIGHMEM pages in the CPA walk, as there is nothing there for
it to change. Patch 2 reserves and frees their memory type like any other
page's.
Found and tested on an HP ElitePad 900 G1 (Atom Z2760, Clover Trail, i386
without PAE, 2 GB) running an out-of-tree PowerVR SGX545 DRM driver with
its buffers in HIGHMEM. Before: an oops in set_pages_array_wc() on the
first buffer and an unreachable machine (patch 1), then continuous GPU page
faults and firmware resets until the GPU wedged (patch 2). With both: no
GPU faults or kernel warnings through the driver's uAPI tests (50/50), 100
rendered frames checked against a reference, glmark2 and video playback.
Written and tested on 7.3.4; this series is rebased on v7.4-rc3, where it
builds for i386.
Christian (2):
x86/mm/pat: skip HIGHMEM pages in a page array
x86/mm/pat: track the memory type of HIGHMEM pages in a page array
arch/x86/mm/pat/set_memory.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
--
2.47.3