mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-09-04 20:19:47 +08:00 
			
		
		
		
	arm64/mm: move runtime pgds to rodata
Now that deliberate writes to swapper_pg_dir are made via the fixmap, we can defend against errant writes by moving it into the rodata section. Since tramp_pg_dir and reserved_ttbr0 must be at a fixed offset from swapper_pg_dir, and are not modified at runtime, these are also moved into the rodata section. Likewise, idmap_pg_dir is not modified at runtime, and is moved into rodata. Signed-off-by: Jun Yao <yaojun8558363@gmail.com> Reviewed-by: James Morse <james.morse@arm.com> [Mark: simplify linker script, commit message] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
		
							parent
							
								
									2330b7ca78
								
							
						
					
					
						commit
						8eb7e28d4c
					
				| @ -287,18 +287,20 @@ __create_page_tables: | ||||
| 	mov	x28, lr | ||||
| 
 | ||||
| 	/* | ||||
| 	 * Invalidate the idmap and swapper page tables to avoid potential | ||||
| 	 * dirty cache lines being evicted. | ||||
| 	 * Invalidate the init page tables to avoid potential dirty cache lines | ||||
| 	 * being evicted. Other page tables are allocated in rodata as part of | ||||
| 	 * the kernel image, and thus are clean to the PoC per the boot | ||||
| 	 * protocol. | ||||
| 	 */ | ||||
| 	adrp	x0, idmap_pg_dir | ||||
| 	adrp	x0, init_pg_dir | ||||
| 	adrp	x1, init_pg_end | ||||
| 	sub	x1, x1, x0 | ||||
| 	bl	__inval_dcache_area | ||||
| 
 | ||||
| 	/* | ||||
| 	 * Clear the idmap and swapper page tables. | ||||
| 	 * Clear the init page tables. | ||||
| 	 */ | ||||
| 	adrp	x0, idmap_pg_dir | ||||
| 	adrp	x0, init_pg_dir | ||||
| 	adrp	x1, init_pg_end | ||||
| 	sub	x1, x1, x0 | ||||
| 1:	stp	xzr, xzr, [x0], #16 | ||||
|  | ||||
| @ -138,6 +138,23 @@ SECTIONS | ||||
| 	EXCEPTION_TABLE(8)		/* __init_begin will be marked RO NX */ | ||||
| 	NOTES | ||||
| 
 | ||||
| 	. = ALIGN(PAGE_SIZE);
 | ||||
| 	idmap_pg_dir = .;
 | ||||
| 	. += IDMAP_DIR_SIZE;
 | ||||
| 
 | ||||
| #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 | ||||
| 	tramp_pg_dir = .;
 | ||||
| 	. += PAGE_SIZE;
 | ||||
| #endif | ||||
| 
 | ||||
| #ifdef CONFIG_ARM64_SW_TTBR0_PAN | ||||
| 	reserved_ttbr0 = .;
 | ||||
| 	. += RESERVED_TTBR0_SIZE;
 | ||||
| #endif | ||||
| 	swapper_pg_dir = .;
 | ||||
| 	. += PAGE_SIZE;
 | ||||
| 	swapper_pg_end = .;
 | ||||
| 
 | ||||
| 	. = ALIGN(SEGMENT_ALIGN);
 | ||||
| 	__init_begin = .;
 | ||||
| 	__inittext_begin = .;
 | ||||
| @ -216,22 +233,6 @@ SECTIONS | ||||
| 	BSS_SECTION(0, 0, 0) | ||||
| 
 | ||||
| 	. = ALIGN(PAGE_SIZE);
 | ||||
| 	idmap_pg_dir = .;
 | ||||
| 	. += IDMAP_DIR_SIZE;
 | ||||
| 
 | ||||
| #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 | ||||
| 	tramp_pg_dir = .;
 | ||||
| 	. += PAGE_SIZE;
 | ||||
| #endif | ||||
| 
 | ||||
| #ifdef CONFIG_ARM64_SW_TTBR0_PAN | ||||
| 	reserved_ttbr0 = .;
 | ||||
| 	. += RESERVED_TTBR0_SIZE;
 | ||||
| #endif | ||||
| 	swapper_pg_dir = .;
 | ||||
| 	. += PAGE_SIZE;
 | ||||
| 	swapper_pg_end = .;
 | ||||
| 
 | ||||
| 	init_pg_dir = .;
 | ||||
| 	. += INIT_DIR_SIZE;
 | ||||
| 	init_pg_end = .;
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jun Yao
						Jun Yao