diff mbox series

[RFC,06/62] mm/khugepaged: Handle encrypted pages

Message ID 20190508144422.13171-7-kirill.shutemov@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Intel MKTME enabling | expand

Commit Message

Kirill A. Shutemov May 8, 2019, 2:43 p.m. UTC
For !NUMA khugepaged allocates page in advance, before we found a VMA
for collapse. We don't yet know which KeyID to use for the allocation.

The page is allocated with KeyID-0. Once we know that the VMA is
suitable for collapsing, we prepare the page for KeyID we need, based on

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
 mm/khugepaged.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series


diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 449044378782..96326a7e9d61 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1055,6 +1055,16 @@  static void collapse_huge_page(struct mm_struct *mm,
+	/*
+	 * At this point new_page is allocated as non-encrypted.
+	 * If VMA's KeyID is non-zero, we need to prepare it to be encrypted
+	 * before coping data.
+	 */
+	if (vma_keyid(vma)) {
+		prep_encrypted_page(new_page, HPAGE_PMD_ORDER,
+				vma_keyid(vma), false);
+	}
 	__collapse_huge_page_copy(pte, new_page, vma, address, pte_ptl);