Skip to content

x86/xen: clear the user pgd pointer when freeing it - #78

Merged
kaniini merged 1 commit into
edera/mainlinefrom
kavi/cor-190-xen-pv-user-pgd-ptlock
Nov 4, 2026
Merged

kaniini merged 1 commit into
edera/mainlinefrom
kavi/cor-190-xen-pv-user-pgd-ptlock

Conversation

@kdaula

@kdaula kdaula commented Nov 3, 2026 •

Copy link
Copy Markdown

On a Xen PV kernel with lock debugging, every mm teardown warns "virt_to_cache: Object is not a Slab page!" from ptlock_free() in pgd_free(), in dom0 and in every PV domU at boot.

xen_pgd_alloc() keeps the user pgd in page->private of the kernel pgd page, and that field shares its slot with ptdesc->ptl. xen_pgd_free() frees the user pgd but leaves the pointer, so when split ptlocks are allocated separately (lock debugging, PREEMPT_RT) pagetable_dtor() frees it again as a ptlock. Without SLUB consistency checks that corrupts the slab. Shipped kernels never allocate split ptlocks separately, so they are unaffected. Upstream master has the same code.

This clears page->private after freeing the user pgd.

Tested by booting a lock-debugging dom0 and PV domU under Xen with this applied: the warning no longer appears.

COR-190

xen_pgd_alloc() keeps the user pgd of a 64-bit PV mm in page->private of
the kernel pgd page, and xen_pgd_free() frees it without clearing the
pointer. page->private shares its slot with ptdesc->ptl, so when split
ptlocks are allocated separately (lock debugging, PREEMPT_RT),
pagetable_dtor() hands the freed user pgd to kmem_cache_free() as a
ptlock. With SLUB consistency checks this warns "virt_to_cache: Object is
not a Slab page!" on every mm teardown; without them it corrupts the slab.

Clear page->private once the user pgd is freed.

Signed-off-by: Kavi <kavi@edera.dev>
@kdaula
kdaula marked this pull request as ready for review November 3, 2026 23:58
@kaniini
kaniini merged commit 1dc86dd into edera/mainline Nov 4, 2026
3 checks passed
@kdaula
kdaula deleted the kavi/cor-190-xen-pv-user-pgd-ptlock branch November 4, 2026 00:27
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Backport to edera/6.18-lts: proposed in #82

Checks and builds passed.

Run log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants