@@ -439,18 +439,13 @@ static noinline int vmalloc_fault(unsigned long address)
439
439
if (pgd_none (* pgd_ref ))
440
440
return -1 ;
441
441
442
- if (pgd_none (* pgd )) {
443
- set_pgd (pgd , * pgd_ref );
444
- arch_flush_lazy_mmu_mode ();
445
- } else if (CONFIG_PGTABLE_LEVELS > 4 ) {
446
- /*
447
- * With folded p4d, pgd_none() is always false, so the pgd may
448
- * point to an empty page table entry and pgd_page_vaddr()
449
- * will return garbage.
450
- *
451
- * We will do the correct sanity check on the p4d level.
452
- */
453
- BUG_ON (pgd_page_vaddr (* pgd ) != pgd_page_vaddr (* pgd_ref ));
442
+ if (CONFIG_PGTABLE_LEVELS > 4 ) {
443
+ if (pgd_none (* pgd )) {
444
+ set_pgd (pgd , * pgd_ref );
445
+ arch_flush_lazy_mmu_mode ();
446
+ } else {
447
+ BUG_ON (pgd_page_vaddr (* pgd ) != pgd_page_vaddr (* pgd_ref ));
448
+ }
454
449
}
455
450
456
451
/* With 4-level paging, copying happens on the p4d level. */
@@ -459,7 +454,7 @@ static noinline int vmalloc_fault(unsigned long address)
459
454
if (p4d_none (* p4d_ref ))
460
455
return -1 ;
461
456
462
- if (p4d_none (* p4d )) {
457
+ if (p4d_none (* p4d ) && CONFIG_PGTABLE_LEVELS == 4 ) {
463
458
set_p4d (p4d , * p4d_ref );
464
459
arch_flush_lazy_mmu_mode ();
465
460
} else {
@@ -470,6 +465,7 @@ static noinline int vmalloc_fault(unsigned long address)
470
465
* Below here mismatches are bugs because these lower tables
471
466
* are shared:
472
467
*/
468
+ BUILD_BUG_ON (CONFIG_PGTABLE_LEVELS < 4 );
473
469
474
470
pud = pud_offset (p4d , address );
475
471
pud_ref = pud_offset (p4d_ref , address );
0 commit comments