[PATCH 07/45] arch/s390: Enable __s390_enable_skey_pmd to handle hugetlb vmas
From: Oscar Salvador
Date: Thu Jul 04 2024 - 00:33:14 EST
__s390_enable_skey_pmd does nothing for THP, but will handle pmd-leafs
hugetlb vmas from now onwards, so teach it how to handle those.
Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>
---
arch/s390/mm/gmap.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index 474a25ca5c48..e1d098dc7f07 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -2723,6 +2723,20 @@ static int __s390_enable_skey_pte(pte_t *pte, unsigned long addr,
static int __s390_enable_skey_pmd(pmd_t *pmd, unsigned long addr,
unsigned long next, struct mm_walk *walk)
{
+ if (pmd_leaf(*pmd) && is_vm_hugetlb_page(vma))
+ unsigned long start, end;
+ struct page *page = pmd_page(*pmd);
+
+ if (pmd_val(*pmd) & _SEGMENT_ENTRY_INVALID ||
+ !(pmd_val(*pmd) & _SEGMENT_ENTRY_WRITE))
+ return 0;
+
+ start = pmd_val(*pmd) & HPAGE_MASK;
+ end = start + HPAGE_SIZE;
+ __storage_key_init_range(start, end);
+ set_bit(PG_arch_1, &page->flags);
+ }
+
cond_resched();
return 0;
}
--
2.26.2