diff options
Diffstat (limited to 'arch/x86/mm/init.c')
| -rw-r--r-- | arch/x86/mm/init.c | 92 | 
1 files changed, 35 insertions, 57 deletions
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 679893ea5e68..eb503f53c319 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -7,6 +7,7 @@  #include <linux/swapops.h>  #include <linux/kmemleak.h>  #include <linux/sched/task.h> +#include <linux/execmem.h>  #include <asm/set_memory.h>  #include <asm/cpu_device_id.h> @@ -261,21 +262,17 @@ static void __init probe_page_size_mask(void)  	}  } -#define INTEL_MATCH(_model) { .vendor  = X86_VENDOR_INTEL,	\ -			      .family  = 6,			\ -			      .model = _model,			\ -			    }  /*   * INVLPG may not properly flush Global entries   * on these CPUs when PCIDs are enabled.   */  static const struct x86_cpu_id invlpg_miss_ids[] = { -	INTEL_MATCH(INTEL_FAM6_ALDERLAKE   ), -	INTEL_MATCH(INTEL_FAM6_ALDERLAKE_L ), -	INTEL_MATCH(INTEL_FAM6_ATOM_GRACEMONT ), -	INTEL_MATCH(INTEL_FAM6_RAPTORLAKE  ), -	INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_P), -	INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_S), +	X86_MATCH_VFM(INTEL_ALDERLAKE,	    0), +	X86_MATCH_VFM(INTEL_ALDERLAKE_L,    0), +	X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, 0), +	X86_MATCH_VFM(INTEL_RAPTORLAKE,	    0), +	X86_MATCH_VFM(INTEL_RAPTORLAKE_P,   0), +	X86_MATCH_VFM(INTEL_RAPTORLAKE_S,   0),  	{}  }; @@ -990,53 +987,6 @@ void __init free_initrd_mem(unsigned long start, unsigned long end)  }  #endif -/* - * Calculate the precise size of the DMA zone (first 16 MB of RAM), - * and pass it to the MM layer - to help it set zone watermarks more - * accurately. - * - * Done on 64-bit systems only for the time being, although 32-bit systems - * might benefit from this as well. - */ -void __init memblock_find_dma_reserve(void) -{ -#ifdef CONFIG_X86_64 -	u64 nr_pages = 0, nr_free_pages = 0; -	unsigned long start_pfn, end_pfn; -	phys_addr_t start_addr, end_addr; -	int i; -	u64 u; - -	/* -	 * Iterate over all memory ranges (free and reserved ones alike), -	 * to calculate the total number of pages in the first 16 MB of RAM: -	 */ -	nr_pages = 0; -	for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) { -		start_pfn = min(start_pfn, MAX_DMA_PFN); -		end_pfn   = min(end_pfn,   MAX_DMA_PFN); - -		nr_pages += end_pfn - start_pfn; -	} - -	/* -	 * Iterate over free memory ranges to calculate the number of free -	 * pages in the DMA zone, while not counting potential partial -	 * pages at the beginning or the end of the range: -	 */ -	nr_free_pages = 0; -	for_each_free_mem_range(u, NUMA_NO_NODE, MEMBLOCK_NONE, &start_addr, &end_addr, NULL) { -		start_pfn = min_t(unsigned long, PFN_UP(start_addr), MAX_DMA_PFN); -		end_pfn   = min_t(unsigned long, PFN_DOWN(end_addr), MAX_DMA_PFN); - -		if (start_pfn < end_pfn) -			nr_free_pages += end_pfn - start_pfn; -	} - -	set_dma_reserve(nr_pages - nr_free_pages); -#endif -} -  void __init zone_sizes_init(void)  {  	unsigned long max_zone_pfns[MAX_NR_ZONES]; @@ -1099,3 +1049,31 @@ unsigned long arch_max_swapfile_size(void)  	return pages;  }  #endif + +#ifdef CONFIG_EXECMEM +static struct execmem_info execmem_info __ro_after_init; + +struct execmem_info __init *execmem_arch_setup(void) +{ +	unsigned long start, offset = 0; + +	if (kaslr_enabled()) +		offset = get_random_u32_inclusive(1, 1024) * PAGE_SIZE; + +	start = MODULES_VADDR + offset; + +	execmem_info = (struct execmem_info){ +		.ranges = { +			[EXECMEM_DEFAULT] = { +				.flags	= EXECMEM_KASAN_SHADOW, +				.start	= start, +				.end	= MODULES_END, +				.pgprot	= PAGE_KERNEL, +				.alignment = MODULE_ALIGN, +			}, +		}, +	}; + +	return &execmem_info; +} +#endif /* CONFIG_EXECMEM */  |