Commit 502269ab authored by Alexander Gordeev's avatar Alexander Gordeev Committed by Andrew Morton
Browse files

s390/mm: add missing ctor/dtor on page table upgrade

Commit 78966b550289 ("s390: pgtable: add statistics for PUD and P4D level
page table") misses the call to pagetable_p4d_ctor() against a newly
allocated P4D table in crst_table_upgrade();

Commit 68c601de75d8 ("mm: introduce ctor/dtor at PGD level") misses the
call to pagetable_pgd_ctor() against a newly allocated PGD and the call to
pagetable_dtor() against a newly allocated P4D that is about to be freed
on crst_table_upgrade() PGD upgrade fail path.

The missed constructors and destructor break (at least) the page table
accounting when a process memory space is upgraded.

Link: https://lkml.kernel.org/r/20250123160349.200154-1-agordeev@linux.ibm.com


Fixes: 78966b550289 ("s390: pgtable: add statistics for PUD and P4D level page table")
Fixes: 68c601de75d8 ("mm: introduce ctor/dtor at PGD level")
Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Reported-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Closes: https://lore.kernel.org/all/20250122074954.8685-A-hca@linux.ibm.com/


Suggested-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
Acked-by: default avatarQi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: default avatarKevin Brodsky <kevin.brodsky@arm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 0e81f6e4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -88,12 +88,14 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
		if (unlikely(!p4d))
			goto err_p4d;
		crst_table_init(p4d, _REGION2_ENTRY_EMPTY);
		pagetable_p4d_ctor(virt_to_ptdesc(p4d));
	}
	if (end > _REGION1_SIZE) {
		pgd = crst_table_alloc(mm);
		if (unlikely(!pgd))
			goto err_pgd;
		crst_table_init(pgd, _REGION1_ENTRY_EMPTY);
		pagetable_pgd_ctor(virt_to_ptdesc(pgd));
	}

	spin_lock_bh(&mm->page_table_lock);
@@ -130,6 +132,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
	return 0;

err_pgd:
	pagetable_dtor(virt_to_ptdesc(p4d));
	crst_table_free(mm, p4d);
err_p4d:
	return -ENOMEM;