1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright(c) 2017 Intel Corporation. All rights reserved. 4 * 5 * This code is based in part on work published here: 6 * 7 * https://github.com/IAIK/KAISER 8 * 9 * The original work was written by and signed off by for the Linux 10 * kernel by: 11 * 12 * Signed-off-by: Richard Fellner <richard.fellner@student.tugraz.at> 13 * Signed-off-by: Moritz Lipp <moritz.lipp@iaik.tugraz.at> 14 * Signed-off-by: Daniel Gruss <daniel.gruss@iaik.tugraz.at> 15 * Signed-off-by: Michael Schwarz <michael.schwarz@iaik.tugraz.at> 16 * 17 * Major changes to the original code by: Dave Hansen <dave.hansen@intel.com> 18 * Mostly rewritten by Thomas Gleixner <tglx@kernel.org> and 19 * Andy Lutomirsky <luto@amacapital.net> 20 */ 21 #include <linux/kernel.h> 22 #include <linux/errno.h> 23 #include <linux/string.h> 24 #include <linux/types.h> 25 #include <linux/bug.h> 26 #include <linux/init.h> 27 #include <linux/spinlock.h> 28 #include <linux/mm.h> 29 #include <linux/uaccess.h> 30 #include <linux/cpu.h> 31 32 #include <asm/cpufeature.h> 33 #include <asm/hypervisor.h> 34 #include <asm/cpuid/api.h> 35 #include <asm/vsyscall.h> 36 #include <asm/cmdline.h> 37 #include <asm/pti.h> 38 #include <asm/tlbflush.h> 39 #include <asm/desc.h> 40 #include <asm/sections.h> 41 #include <asm/set_memory.h> 42 #include <asm/bugs.h> 43 44 #undef pr_fmt 45 #define pr_fmt(fmt) "Kernel/User page tables isolation: " fmt 46 47 /* Backporting helper */ 48 #ifndef __GFP_NOTRACK 49 #define __GFP_NOTRACK 0 50 #endif 51 52 /* 53 * Define the page-table levels we clone for user-space on 32 54 * and 64 bit. 55 */ 56 #ifdef CONFIG_X86_64 57 #define PTI_LEVEL_KERNEL_IMAGE PTI_CLONE_PMD 58 #else 59 #define PTI_LEVEL_KERNEL_IMAGE PTI_CLONE_PTE 60 #endif 61 62 static void __init pti_print_if_insecure(const char *reason) 63 { 64 if (boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN)) 65 pr_info("%s\n", reason); 66 } 67 68 static void __init pti_print_if_secure(const char *reason) 69 { 70 if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN)) 71 pr_info("%s\n", reason); 72 } 73 74 /* Assume mode is auto unless overridden via cmdline below. */ 75 static enum pti_mode { 76 PTI_AUTO = 0, 77 PTI_FORCE_OFF, 78 PTI_FORCE_ON 79 } pti_mode; 80 81 void __init pti_check_boottime_disable(void) 82 { 83 if (hypervisor_is_type(X86_HYPER_XEN_PV)) { 84 pti_mode = PTI_FORCE_OFF; 85 pti_print_if_insecure("disabled on XEN PV."); 86 return; 87 } 88 89 if (pti_mode == PTI_AUTO && 90 !cpu_attack_vector_mitigated(CPU_MITIGATE_USER_KERNEL)) 91 pti_mode = PTI_FORCE_OFF; 92 if (pti_mode == PTI_FORCE_OFF) { 93 pti_print_if_insecure("disabled on command line."); 94 return; 95 } 96 97 if (pti_mode == PTI_FORCE_ON) 98 pti_print_if_secure("force enabled on command line."); 99 100 if (pti_mode == PTI_AUTO && !boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN)) 101 return; 102 103 setup_force_cpu_cap(X86_FEATURE_PTI); 104 105 if (cpu_feature_enabled(X86_FEATURE_INVLPGB)) { 106 pr_debug("PTI enabled, disabling INVLPGB\n"); 107 setup_clear_cpu_cap(X86_FEATURE_INVLPGB); 108 } 109 110 if (cpu_feature_enabled(X86_FEATURE_FRED)) { 111 pr_debug("PTI enabled, disabling FRED\n"); 112 setup_clear_cpu_cap(X86_FEATURE_FRED); 113 } 114 } 115 116 static int __init pti_parse_cmdline(char *arg) 117 { 118 if (!strcmp(arg, "off")) 119 pti_mode = PTI_FORCE_OFF; 120 else if (!strcmp(arg, "on")) 121 pti_mode = PTI_FORCE_ON; 122 else if (!strcmp(arg, "auto")) 123 pti_mode = PTI_AUTO; 124 else 125 return -EINVAL; 126 return 0; 127 } 128 early_param("pti", pti_parse_cmdline); 129 130 static int __init pti_parse_cmdline_nopti(char *arg) 131 { 132 pti_mode = PTI_FORCE_OFF; 133 return 0; 134 } 135 early_param("nopti", pti_parse_cmdline_nopti); 136 137 pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd) 138 { 139 /* 140 * Changes to the high (kernel) portion of the kernelmode page 141 * tables are not automatically propagated to the usermode tables. 142 * 143 * Users should keep in mind that, unlike the kernelmode tables, 144 * there is no vmalloc_fault equivalent for the usermode tables. 145 * Top-level entries added to init_mm's usermode pgd after boot 146 * will not be automatically propagated to other mms. 147 */ 148 if (!pgdp_maps_userspace(pgdp) || (pgd.pgd & _PAGE_NOPTISHADOW)) 149 return pgd; 150 151 /* 152 * The user page tables get the full PGD, accessible from 153 * userspace: 154 */ 155 kernel_to_user_pgdp(pgdp)->pgd = pgd.pgd; 156 157 /* 158 * If this is normal user memory, make it NX in the kernel 159 * pagetables so that, if we somehow screw up and return to 160 * usermode with the kernel CR3 loaded, we'll get a page fault 161 * instead of allowing user code to execute with the wrong CR3. 162 * 163 * As exceptions, we don't set NX if: 164 * - _PAGE_USER is not set. This could be an executable 165 * EFI runtime mapping or something similar, and the kernel 166 * may execute from it 167 * - we don't have NX support 168 * - we're clearing the PGD (i.e. the new pgd is not present). 169 */ 170 if ((pgd.pgd & (_PAGE_USER|_PAGE_PRESENT)) == (_PAGE_USER|_PAGE_PRESENT) && 171 (__supported_pte_mask & _PAGE_NX)) 172 pgd.pgd |= _PAGE_NX; 173 174 /* return the copy of the PGD we want the kernel to use: */ 175 return pgd; 176 } 177 178 /* 179 * Walk the user copy of the page tables (optionally) trying to allocate 180 * page table pages on the way down. 181 * 182 * Returns a pointer to a P4D on success, or NULL on failure. 183 */ 184 static p4d_t *pti_user_pagetable_walk_p4d(unsigned long address) 185 { 186 pgd_t *pgd = kernel_to_user_pgdp(pgd_offset_k(address)); 187 gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO); 188 189 if (address < PAGE_OFFSET) { 190 WARN_ONCE(1, "attempt to walk user address\n"); 191 return NULL; 192 } 193 194 if (pgd_none(*pgd)) { 195 unsigned long new_p4d_page = __get_free_page(gfp); 196 if (WARN_ON_ONCE(!new_p4d_page)) 197 return NULL; 198 199 set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page))); 200 } 201 BUILD_BUG_ON(pgd_leaf(*pgd)); 202 203 return p4d_offset(pgd, address); 204 } 205 206 /* 207 * Walk the user copy of the page tables (optionally) trying to allocate 208 * page table pages on the way down. 209 * 210 * Returns a pointer to a PMD on success, or NULL on failure. 211 */ 212 static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address) 213 { 214 gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO); 215 p4d_t *p4d; 216 pud_t *pud; 217 218 p4d = pti_user_pagetable_walk_p4d(address); 219 if (!p4d) 220 return NULL; 221 222 BUILD_BUG_ON(p4d_leaf(*p4d)); 223 if (p4d_none(*p4d)) { 224 unsigned long new_pud_page = __get_free_page(gfp); 225 if (WARN_ON_ONCE(!new_pud_page)) 226 return NULL; 227 228 set_p4d(p4d, __p4d(_KERNPG_TABLE | __pa(new_pud_page))); 229 } 230 231 pud = pud_offset(p4d, address); 232 /* The user page tables do not use large mappings: */ 233 if (pud_leaf(*pud)) { 234 WARN_ON(1); 235 return NULL; 236 } 237 if (pud_none(*pud)) { 238 unsigned long new_pmd_page = __get_free_page(gfp); 239 if (WARN_ON_ONCE(!new_pmd_page)) 240 return NULL; 241 242 set_pud(pud, __pud(_KERNPG_TABLE | __pa(new_pmd_page))); 243 } 244 245 return pmd_offset(pud, address); 246 } 247 248 /* 249 * Walk the shadow copy of the page tables (optionally) trying to allocate 250 * page table pages on the way down. Does not support large pages. 251 * 252 * Note: this is only used when mapping *new* kernel data into the 253 * user/shadow page tables. It is never used for userspace data. 254 * 255 * Returns a pointer to a PTE on success, or NULL on failure. 256 */ 257 static pte_t *pti_user_pagetable_walk_pte(unsigned long address, bool late_text) 258 { 259 gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO); 260 pmd_t *pmd; 261 pte_t *pte; 262 263 pmd = pti_user_pagetable_walk_pmd(address); 264 if (!pmd) 265 return NULL; 266 267 /* Large PMD mapping found */ 268 if (pmd_leaf(*pmd)) { 269 /* Clear the PMD if we hit a large mapping from the first round */ 270 if (late_text) { 271 set_pmd(pmd, __pmd(0)); 272 } else { 273 WARN_ON_ONCE(1); 274 return NULL; 275 } 276 } 277 278 if (pmd_none(*pmd)) { 279 unsigned long new_pte_page = __get_free_page(gfp); 280 if (!new_pte_page) 281 return NULL; 282 283 set_pmd(pmd, __pmd(_KERNPG_TABLE | __pa(new_pte_page))); 284 } 285 286 pte = pte_offset_kernel(pmd, address); 287 if (pte_flags(*pte) & _PAGE_USER) { 288 WARN_ONCE(1, "attempt to walk to user pte\n"); 289 return NULL; 290 } 291 return pte; 292 } 293 294 #ifdef CONFIG_X86_VSYSCALL_EMULATION 295 static void __init pti_setup_vsyscall(void) 296 { 297 pte_t *pte, *target_pte; 298 unsigned int level; 299 300 pte = lookup_address(VSYSCALL_ADDR, &level); 301 if (!pte || WARN_ON(level != PG_LEVEL_4K) || pte_none(*pte)) 302 return; 303 304 target_pte = pti_user_pagetable_walk_pte(VSYSCALL_ADDR, false); 305 if (WARN_ON(!target_pte)) 306 return; 307 308 *target_pte = *pte; 309 set_vsyscall_pgtable_user_bits(kernel_to_user_pgdp(swapper_pg_dir)); 310 } 311 #else 312 static void __init pti_setup_vsyscall(void) { } 313 #endif 314 315 enum pti_clone_level { 316 PTI_CLONE_PMD, 317 PTI_CLONE_PTE, 318 }; 319 320 static void 321 pti_clone_pgtable(unsigned long start, unsigned long end, 322 enum pti_clone_level level, bool late_text) 323 { 324 unsigned long addr; 325 326 /* 327 * Clone the populated PMDs which cover start to end. These PMD areas 328 * can have holes. 329 */ 330 for (addr = start; addr < end;) { 331 pte_t *pte, *target_pte; 332 pmd_t *pmd, *target_pmd; 333 pgd_t *pgd; 334 p4d_t *p4d; 335 pud_t *pud; 336 337 /* Overflow check */ 338 if (addr < start) 339 break; 340 341 pgd = pgd_offset_k(addr); 342 if (WARN_ON(pgd_none(*pgd))) 343 return; 344 p4d = p4d_offset(pgd, addr); 345 if (WARN_ON(p4d_none(*p4d))) 346 return; 347 348 pud = pud_offset(p4d, addr); 349 if (pud_none(*pud)) { 350 WARN_ON_ONCE(addr & ~PUD_MASK); 351 addr = round_up(addr + 1, PUD_SIZE); 352 continue; 353 } 354 355 pmd = pmd_offset(pud, addr); 356 if (pmd_none(*pmd)) { 357 WARN_ON_ONCE(addr & ~PMD_MASK); 358 addr = round_up(addr + 1, PMD_SIZE); 359 continue; 360 } 361 362 if (pmd_leaf(*pmd) || level == PTI_CLONE_PMD) { 363 target_pmd = pti_user_pagetable_walk_pmd(addr); 364 if (WARN_ON(!target_pmd)) 365 return; 366 367 /* 368 * Only clone present PMDs. This ensures only setting 369 * _PAGE_GLOBAL on present PMDs. This should only be 370 * called on well-known addresses anyway, so a non- 371 * present PMD would be a surprise. 372 */ 373 if (WARN_ON(!(pmd_flags(*pmd) & _PAGE_PRESENT))) 374 return; 375 376 /* 377 * Setting 'target_pmd' below creates a mapping in both 378 * the user and kernel page tables. It is effectively 379 * global, so set it as global in both copies. Note: 380 * the X86_FEATURE_PGE check is not _required_ because 381 * the CPU ignores _PAGE_GLOBAL when PGE is not 382 * supported. The check keeps consistency with 383 * code that only set this bit when supported. 384 */ 385 if (boot_cpu_has(X86_FEATURE_PGE)) 386 *pmd = pmd_set_flags(*pmd, _PAGE_GLOBAL); 387 388 /* 389 * Copy the PMD. That is, the kernelmode and usermode 390 * tables will share the last-level page tables of this 391 * address range 392 */ 393 *target_pmd = *pmd; 394 395 addr = round_up(addr + 1, PMD_SIZE); 396 397 } else if (level == PTI_CLONE_PTE) { 398 399 /* Walk the page-table down to the pte level */ 400 pte = pte_offset_kernel(pmd, addr); 401 if (pte_none(*pte)) { 402 addr = round_up(addr + 1, PAGE_SIZE); 403 continue; 404 } 405 406 /* Only clone present PTEs */ 407 if (WARN_ON(!(pte_flags(*pte) & _PAGE_PRESENT))) 408 return; 409 410 /* Allocate PTE in the user page-table */ 411 target_pte = pti_user_pagetable_walk_pte(addr, late_text); 412 if (WARN_ON(!target_pte)) 413 return; 414 415 /* Set GLOBAL bit in both PTEs */ 416 if (boot_cpu_has(X86_FEATURE_PGE)) 417 *pte = pte_set_flags(*pte, _PAGE_GLOBAL); 418 419 /* Clone the PTE */ 420 *target_pte = *pte; 421 422 addr = round_up(addr + 1, PAGE_SIZE); 423 424 } else { 425 BUG(); 426 } 427 } 428 } 429 430 #ifdef CONFIG_X86_64 431 /* 432 * Clone a single p4d (i.e. a top-level entry on 4-level systems and a 433 * next-level entry on 5-level systems. 434 */ 435 static void __init pti_clone_p4d(unsigned long addr) 436 { 437 p4d_t *kernel_p4d, *user_p4d; 438 pgd_t *kernel_pgd; 439 440 user_p4d = pti_user_pagetable_walk_p4d(addr); 441 if (!user_p4d) 442 return; 443 444 kernel_pgd = pgd_offset_k(addr); 445 kernel_p4d = p4d_offset(kernel_pgd, addr); 446 *user_p4d = *kernel_p4d; 447 } 448 449 /* 450 * Clone the CPU_ENTRY_AREA and associated data into the user space visible 451 * page table. 452 */ 453 static void __init pti_clone_user_shared(void) 454 { 455 unsigned int cpu; 456 457 pti_clone_p4d(CPU_ENTRY_AREA_BASE); 458 459 for_each_possible_cpu(cpu) { 460 /* 461 * The SYSCALL64 entry code needs one word of scratch space 462 * in which to spill a register. It lives in the sp2 slot 463 * of the CPU's TSS. 464 * 465 * This is done for all possible CPUs during boot to ensure 466 * that it's propagated to all mms. 467 */ 468 469 unsigned long va = (unsigned long)&per_cpu(cpu_tss_rw, cpu); 470 phys_addr_t pa = per_cpu_ptr_to_phys((void *)va); 471 pte_t *target_pte; 472 473 target_pte = pti_user_pagetable_walk_pte(va, false); 474 if (WARN_ON(!target_pte)) 475 return; 476 477 *target_pte = pfn_pte(pa >> PAGE_SHIFT, PAGE_KERNEL); 478 } 479 } 480 481 #else /* CONFIG_X86_64 */ 482 483 /* 484 * On 32 bit PAE systems with 1GB of Kernel address space there is only 485 * one pgd/p4d for the whole kernel. Cloning that would map the whole 486 * address space into the user page-tables, making PTI useless. So clone 487 * the page-table on the PMD level to prevent that. 488 */ 489 static void __init pti_clone_user_shared(void) 490 { 491 unsigned long start, end; 492 493 start = CPU_ENTRY_AREA_BASE; 494 end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES); 495 496 pti_clone_pgtable(start, end, PTI_CLONE_PMD, false); 497 } 498 #endif /* CONFIG_X86_64 */ 499 500 /* 501 * Clone the ESPFIX P4D into the user space visible page table 502 */ 503 static void __init pti_setup_espfix64(void) 504 { 505 #ifdef CONFIG_X86_ESPFIX64 506 pti_clone_p4d(ESPFIX_BASE_ADDR); 507 #endif 508 } 509 510 /* 511 * Clone the populated PMDs of the entry text and force it RO. 512 */ 513 static void pti_clone_entry_text(bool late) 514 { 515 pti_clone_pgtable((unsigned long) __entry_text_start, 516 (unsigned long) __entry_text_end, 517 PTI_LEVEL_KERNEL_IMAGE, late); 518 } 519 520 /* 521 * Global pages and PCIDs are both ways to make kernel TLB entries 522 * live longer, reduce TLB misses and improve kernel performance. 523 * But, leaving all kernel text Global makes it potentially accessible 524 * to Meltdown-style attacks which make it trivial to find gadgets or 525 * defeat KASLR. 526 * 527 * Only use global pages when it is really worth it. 528 */ 529 static inline bool pti_kernel_image_global_ok(void) 530 { 531 /* 532 * Systems with PCIDs get little benefit from global 533 * kernel text and are not worth the downsides. 534 */ 535 if (cpu_feature_enabled(X86_FEATURE_PCID)) 536 return false; 537 538 /* 539 * Only do global kernel image for pti=auto. Do the most 540 * secure thing (not global) if pti=on specified. 541 */ 542 if (pti_mode != PTI_AUTO) 543 return false; 544 545 /* 546 * K8 may not tolerate the cleared _PAGE_RW on the userspace 547 * global kernel image pages. Do the safe thing (disable 548 * global kernel image). This is unlikely to ever be 549 * noticed because PTI is disabled by default on AMD CPUs. 550 */ 551 if (boot_cpu_has(X86_FEATURE_K8)) 552 return false; 553 554 /* 555 * RANDSTRUCT derives its hardening benefits from the 556 * attacker's lack of knowledge about the layout of kernel 557 * data structures. Keep the kernel image non-global in 558 * cases where RANDSTRUCT is in use to help keep the layout a 559 * secret. 560 */ 561 if (IS_ENABLED(CONFIG_RANDSTRUCT)) 562 return false; 563 564 return true; 565 } 566 567 /* 568 * For some configurations, map all of kernel text into the user page 569 * tables. This reduces TLB misses, especially on non-PCID systems. 570 */ 571 static void pti_clone_kernel_text(void) 572 { 573 /* 574 * rodata is part of the kernel image and is normally 575 * readable on the filesystem or on the web. But, do not 576 * clone the areas past rodata, they might contain secrets. 577 */ 578 unsigned long start = PFN_ALIGN(_text); 579 unsigned long end_clone = (unsigned long)__end_rodata_aligned; 580 unsigned long end_global = PFN_ALIGN((unsigned long)_etext); 581 582 if (!pti_kernel_image_global_ok()) 583 return; 584 585 pr_debug("mapping partial kernel image into user address space\n"); 586 587 /* 588 * Note that this will undo _some_ of the work that 589 * pti_set_kernel_image_nonglobal() did to clear the 590 * global bit. 591 */ 592 pti_clone_pgtable(start, end_clone, PTI_LEVEL_KERNEL_IMAGE, false); 593 594 /* 595 * pti_clone_pgtable() will set the global bit in any PMDs 596 * that it clones, but we also need to get any PTEs in 597 * the last level for areas that are not huge-page-aligned. 598 */ 599 600 /* Set the global bit for normal non-__init kernel text: */ 601 set_memory_global(start, (end_global - start) >> PAGE_SHIFT); 602 } 603 604 static void pti_set_kernel_image_nonglobal(void) 605 { 606 /* 607 * The identity map is created with PMDs, regardless of the 608 * actual length of the kernel. We need to clear 609 * _PAGE_GLOBAL up to a PMD boundary, not just to the end 610 * of the image. 611 */ 612 unsigned long start = PFN_ALIGN(_text); 613 unsigned long end = ALIGN((unsigned long)_end, PMD_SIZE); 614 615 /* 616 * This clears _PAGE_GLOBAL from the entire kernel image. 617 * pti_clone_kernel_text() map put _PAGE_GLOBAL back for 618 * areas that are mapped to userspace. 619 */ 620 set_memory_nonglobal(start, (end - start) >> PAGE_SHIFT); 621 } 622 623 /* 624 * Initialize kernel page table isolation 625 */ 626 void __init pti_init(void) 627 { 628 if (!boot_cpu_has(X86_FEATURE_PTI)) 629 return; 630 631 pr_info("enabled\n"); 632 633 #ifdef CONFIG_X86_32 634 /* 635 * We check for X86_FEATURE_PCID here. But the init-code will 636 * clear the feature flag on 32 bit because the feature is not 637 * supported on 32 bit anyway. To print the warning we need to 638 * check with cpuid directly again. 639 */ 640 if (cpuid_ecx(0x1) & BIT(17)) { 641 /* Use printk to work around pr_fmt() */ 642 printk(KERN_WARNING "\n"); 643 printk(KERN_WARNING "************************************************************\n"); 644 printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n"); 645 printk(KERN_WARNING "** **\n"); 646 printk(KERN_WARNING "** You are using 32-bit PTI on a 64-bit PCID-capable CPU. **\n"); 647 printk(KERN_WARNING "** Your performance will increase dramatically if you **\n"); 648 printk(KERN_WARNING "** switch to a 64-bit kernel! **\n"); 649 printk(KERN_WARNING "** **\n"); 650 printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n"); 651 printk(KERN_WARNING "************************************************************\n"); 652 } 653 #endif 654 655 pti_clone_user_shared(); 656 657 /* Undo all global bits from the init pagetables in head_64.S: */ 658 pti_set_kernel_image_nonglobal(); 659 660 /* Replace some of the global bits just for shared entry text: */ 661 /* 662 * This is very early in boot. Device and Late initcalls can do 663 * modprobe before free_initmem() and mark_readonly(). This 664 * pti_clone_entry_text() allows those user-mode-helpers to function, 665 * but notably the text is still RW. 666 */ 667 pti_clone_entry_text(false); 668 pti_setup_espfix64(); 669 pti_setup_vsyscall(); 670 } 671 672 /* 673 * Finalize the kernel mappings in the userspace page-table. Some of the 674 * mappings for the kernel image might have changed since pti_init() 675 * cloned them. This is because parts of the kernel image have been 676 * mapped RO and/or NX. These changes need to be cloned again to the 677 * userspace page-table. 678 */ 679 void pti_finalize(void) 680 { 681 if (!boot_cpu_has(X86_FEATURE_PTI)) 682 return; 683 /* 684 * This is after free_initmem() (all initcalls are done) and we've done 685 * mark_readonly(). Text is now NX which might've split some PMDs 686 * relative to the early clone. 687 */ 688 pti_clone_entry_text(true); 689 pti_clone_kernel_text(); 690 691 debug_checkwx_user(); 692 } 693