Lines Matching refs:ppd

98 static void __head sme_clear_pgd(struct sme_populate_pgd_data *ppd)  in sme_clear_pgd()  argument
103 pgd_start = ppd->vaddr & PGDIR_MASK; in sme_clear_pgd()
104 pgd_end = ppd->vaddr_end & PGDIR_MASK; in sme_clear_pgd()
108 pgd_p = ppd->pgd + pgd_index(ppd->vaddr); in sme_clear_pgd()
113 static pud_t __head *sme_prepare_pgd(struct sme_populate_pgd_data *ppd) in sme_prepare_pgd() argument
120 pgd = ppd->pgd + pgd_index(ppd->vaddr); in sme_prepare_pgd()
122 p4d = ppd->pgtable_area; in sme_prepare_pgd()
124 ppd->pgtable_area += sizeof(*p4d) * PTRS_PER_P4D; in sme_prepare_pgd()
128 p4d = p4d_offset(pgd, ppd->vaddr); in sme_prepare_pgd()
130 pud = ppd->pgtable_area; in sme_prepare_pgd()
132 ppd->pgtable_area += sizeof(*pud) * PTRS_PER_PUD; in sme_prepare_pgd()
136 pud = pud_offset(p4d, ppd->vaddr); in sme_prepare_pgd()
138 pmd = ppd->pgtable_area; in sme_prepare_pgd()
140 ppd->pgtable_area += sizeof(*pmd) * PTRS_PER_PMD; in sme_prepare_pgd()
150 static void __head sme_populate_pgd_large(struct sme_populate_pgd_data *ppd) in sme_populate_pgd_large() argument
155 pud = sme_prepare_pgd(ppd); in sme_populate_pgd_large()
159 pmd = pmd_offset(pud, ppd->vaddr); in sme_populate_pgd_large()
163 set_pmd(pmd, __pmd(ppd->paddr | ppd->pmd_flags)); in sme_populate_pgd_large()
166 static void __head sme_populate_pgd(struct sme_populate_pgd_data *ppd) in sme_populate_pgd() argument
172 pud = sme_prepare_pgd(ppd); in sme_populate_pgd()
176 pmd = pmd_offset(pud, ppd->vaddr); in sme_populate_pgd()
178 pte = ppd->pgtable_area; in sme_populate_pgd()
180 ppd->pgtable_area += sizeof(*pte) * PTRS_PER_PTE; in sme_populate_pgd()
187 pte = pte_offset_kernel(pmd, ppd->vaddr); in sme_populate_pgd()
189 set_pte(pte, __pte(ppd->paddr | ppd->pte_flags)); in sme_populate_pgd()
192 static void __head __sme_map_range_pmd(struct sme_populate_pgd_data *ppd) in __sme_map_range_pmd() argument
194 while (ppd->vaddr < ppd->vaddr_end) { in __sme_map_range_pmd()
195 sme_populate_pgd_large(ppd); in __sme_map_range_pmd()
197 ppd->vaddr += PMD_SIZE; in __sme_map_range_pmd()
198 ppd->paddr += PMD_SIZE; in __sme_map_range_pmd()
202 static void __head __sme_map_range_pte(struct sme_populate_pgd_data *ppd) in __sme_map_range_pte() argument
204 while (ppd->vaddr < ppd->vaddr_end) { in __sme_map_range_pte()
205 sme_populate_pgd(ppd); in __sme_map_range_pte()
207 ppd->vaddr += PAGE_SIZE; in __sme_map_range_pte()
208 ppd->paddr += PAGE_SIZE; in __sme_map_range_pte()
212 static void __head __sme_map_range(struct sme_populate_pgd_data *ppd, in __sme_map_range() argument
217 ppd->pmd_flags = pmd_flags; in __sme_map_range()
218 ppd->pte_flags = pte_flags; in __sme_map_range()
221 vaddr_end = ppd->vaddr_end; in __sme_map_range()
224 ppd->vaddr_end = ALIGN(ppd->vaddr, PMD_SIZE); in __sme_map_range()
225 __sme_map_range_pte(ppd); in __sme_map_range()
228 ppd->vaddr_end = vaddr_end & PMD_MASK; in __sme_map_range()
229 __sme_map_range_pmd(ppd); in __sme_map_range()
232 ppd->vaddr_end = vaddr_end; in __sme_map_range()
233 __sme_map_range_pte(ppd); in __sme_map_range()
236 static void __head sme_map_range_encrypted(struct sme_populate_pgd_data *ppd) in sme_map_range_encrypted() argument
238 __sme_map_range(ppd, PMD_FLAGS_ENC, PTE_FLAGS_ENC); in sme_map_range_encrypted()
241 static void __head sme_map_range_decrypted(struct sme_populate_pgd_data *ppd) in sme_map_range_decrypted() argument
243 __sme_map_range(ppd, PMD_FLAGS_DEC, PTE_FLAGS_DEC); in sme_map_range_decrypted()
246 static void __head sme_map_range_decrypted_wp(struct sme_populate_pgd_data *ppd) in sme_map_range_decrypted_wp() argument
248 __sme_map_range(ppd, PMD_FLAGS_DEC_WP, PTE_FLAGS_DEC_WP); in sme_map_range_decrypted_wp()
294 struct sme_populate_pgd_data ppd; in sme_encrypt_kernel() local
383 ppd.pgtable_area = (void *)execute_end; in sme_encrypt_kernel()
389 ppd.pgd = (pgd_t *)native_read_cr3_pa(); in sme_encrypt_kernel()
390 ppd.paddr = workarea_start; in sme_encrypt_kernel()
391 ppd.vaddr = workarea_start; in sme_encrypt_kernel()
392 ppd.vaddr_end = workarea_end; in sme_encrypt_kernel()
393 sme_map_range_decrypted(&ppd); in sme_encrypt_kernel()
404 ppd.pgd = ppd.pgtable_area; in sme_encrypt_kernel()
405 memset(ppd.pgd, 0, sizeof(pgd_t) * PTRS_PER_PGD); in sme_encrypt_kernel()
406 ppd.pgtable_area += sizeof(pgd_t) * PTRS_PER_PGD; in sme_encrypt_kernel()
424 ppd.paddr = kernel_start; in sme_encrypt_kernel()
425 ppd.vaddr = kernel_start; in sme_encrypt_kernel()
426 ppd.vaddr_end = kernel_end; in sme_encrypt_kernel()
427 sme_map_range_encrypted(&ppd); in sme_encrypt_kernel()
430 ppd.paddr = kernel_start; in sme_encrypt_kernel()
431 ppd.vaddr = kernel_start + decrypted_base; in sme_encrypt_kernel()
432 ppd.vaddr_end = kernel_end + decrypted_base; in sme_encrypt_kernel()
433 sme_map_range_decrypted_wp(&ppd); in sme_encrypt_kernel()
437 ppd.paddr = initrd_start; in sme_encrypt_kernel()
438 ppd.vaddr = initrd_start; in sme_encrypt_kernel()
439 ppd.vaddr_end = initrd_end; in sme_encrypt_kernel()
440 sme_map_range_encrypted(&ppd); in sme_encrypt_kernel()
444 ppd.paddr = initrd_start; in sme_encrypt_kernel()
445 ppd.vaddr = initrd_start + decrypted_base; in sme_encrypt_kernel()
446 ppd.vaddr_end = initrd_end + decrypted_base; in sme_encrypt_kernel()
447 sme_map_range_decrypted_wp(&ppd); in sme_encrypt_kernel()
451 ppd.paddr = workarea_start; in sme_encrypt_kernel()
452 ppd.vaddr = workarea_start; in sme_encrypt_kernel()
453 ppd.vaddr_end = workarea_end; in sme_encrypt_kernel()
454 sme_map_range_decrypted(&ppd); in sme_encrypt_kernel()
456 ppd.paddr = workarea_start; in sme_encrypt_kernel()
457 ppd.vaddr = workarea_start + decrypted_base; in sme_encrypt_kernel()
458 ppd.vaddr_end = workarea_end + decrypted_base; in sme_encrypt_kernel()
459 sme_map_range_decrypted(&ppd); in sme_encrypt_kernel()
463 kernel_len, workarea_start, (unsigned long)ppd.pgd); in sme_encrypt_kernel()
468 (unsigned long)ppd.pgd); in sme_encrypt_kernel()
475 ppd.vaddr = kernel_start + decrypted_base; in sme_encrypt_kernel()
476 ppd.vaddr_end = kernel_end + decrypted_base; in sme_encrypt_kernel()
477 sme_clear_pgd(&ppd); in sme_encrypt_kernel()
480 ppd.vaddr = initrd_start + decrypted_base; in sme_encrypt_kernel()
481 ppd.vaddr_end = initrd_end + decrypted_base; in sme_encrypt_kernel()
482 sme_clear_pgd(&ppd); in sme_encrypt_kernel()
485 ppd.vaddr = workarea_start + decrypted_base; in sme_encrypt_kernel()
486 ppd.vaddr_end = workarea_end + decrypted_base; in sme_encrypt_kernel()
487 sme_clear_pgd(&ppd); in sme_encrypt_kernel()