Skip to content

Commit b7f7e8e

Browse files
committed
s390/mm: Add PTE_MARKER support for hugetlbfs mappings
JIRA: https://issues.redhat.com/browse/RHEL-74362 Tested: by me Conflicts: due b20c821 patchset not being backported commit 487ef5d Author: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Date: Thu Nov 21 18:45:23 2024 +0100 s390/mm: Add PTE_MARKER support for hugetlbfs mappings Commit 8a13897 ("mm: userfaultfd: support UFFDIO_POISON for hugetlbfs") added support for PTE_MARKER_POISONED for hugetlbfs, but PTE_MARKER also needs support for swap entries. For s390, swap entries were only supported on PTE level, not on the PMD/PUD levels that are used for large hugetlbfs mappings. Therefore, when writing a PTE_MARKER_POISONED entry, the resulting entry on PMD/PUD level would be an invalid / empty entry. Further access would then generate a pagefault loop, instead of the expected SIGBUS. It is a loop inside the kernel, but interruptible and uffd fault handling also calls schedule() in between, so at least it won't completely block the system. Previous commits prepared support for swap entries on PMD/PUD levels. PTE_MARKER support for hugetlbfs can now be enabled by simply adding an extra is_pte_marker() check to huge_pte_none_mostly(). Fault handling code also needs to be adjusted to expect the VM_FAULT_HWPOISON_LARGE fault flag, which was not possible on s390 before. Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
1 parent bf0362c commit b7f7e8e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/s390/include/asm/hugetlb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static inline int huge_pte_none(pte_t pte)
9191

9292
static inline int huge_pte_none_mostly(pte_t pte)
9393
{
94-
return huge_pte_none(pte);
94+
return huge_pte_none(pte) || is_pte_marker(pte);
9595
}
9696

9797
static inline int huge_pte_write(pte_t pte)

arch/s390/mm/fault.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ static void do_fault_error(struct pt_regs *regs, vm_fault_t fault)
307307
do_no_context(regs);
308308
else
309309
do_sigsegv(regs, SEGV_MAPERR);
310-
} else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON)) {
310+
} else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON |
311+
VM_FAULT_HWPOISON_LARGE)) {
311312
/* Kernel mode? Handle exceptions or die */
312313
if (!user_mode(regs))
313314
do_no_context(regs);

0 commit comments

Comments
 (0)