nios2: Don't use _end for calculating min_low_pfn
If there is a initramfs linked into the kernel which will be freed later on there is free memory somewhere between _etext and _end, thus using _end for min_low_pfn is not correct. This may lead to issues in dma_capable when checking 'min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))' as the address addr might be below min_low_pfn. Picked find_limits from architecture arm for applying min_low_pfn and max_low_pfn. Maybe using _etext for min_low_pfn would be fine too. Signed-off-by: Andreas Oetken <andreas.oetken@siemens.com> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
This commit is contained in:
parent
9abcfcb203
commit
7f7bc20bc4
1 changed files with 12 additions and 9 deletions
|
@ -32,8 +32,6 @@ EXPORT_SYMBOL(memory_start);
|
||||||
unsigned long memory_end;
|
unsigned long memory_end;
|
||||||
EXPORT_SYMBOL(memory_end);
|
EXPORT_SYMBOL(memory_end);
|
||||||
|
|
||||||
unsigned long memory_size;
|
|
||||||
|
|
||||||
static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
0};
|
0};
|
||||||
|
@ -141,16 +139,22 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
|
||||||
parse_early_param();
|
parse_early_param();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __init find_limits(unsigned long *min, unsigned long *max_low,
|
||||||
|
unsigned long *max_high)
|
||||||
|
{
|
||||||
|
*max_low = PFN_DOWN(memblock_get_current_limit());
|
||||||
|
*min = PFN_UP(memblock_start_of_DRAM());
|
||||||
|
*max_high = PFN_DOWN(memblock_end_of_DRAM());
|
||||||
|
}
|
||||||
|
|
||||||
void __init setup_arch(char **cmdline_p)
|
void __init setup_arch(char **cmdline_p)
|
||||||
{
|
{
|
||||||
int dram_start;
|
int dram_start;
|
||||||
|
|
||||||
console_verbose();
|
console_verbose();
|
||||||
|
|
||||||
dram_start = memblock_start_of_DRAM();
|
memory_start = memblock_start_of_DRAM();
|
||||||
memory_size = memblock_phys_mem_size();
|
memory_end = memblock_end_of_DRAM();
|
||||||
memory_start = PAGE_ALIGN((unsigned long)__pa(_end));
|
|
||||||
memory_end = (unsigned long) CONFIG_NIOS2_MEM_BASE + memory_size;
|
|
||||||
|
|
||||||
init_mm.start_code = (unsigned long) _stext;
|
init_mm.start_code = (unsigned long) _stext;
|
||||||
init_mm.end_code = (unsigned long) _etext;
|
init_mm.end_code = (unsigned long) _etext;
|
||||||
|
@ -161,11 +165,10 @@ void __init setup_arch(char **cmdline_p)
|
||||||
/* Keep a copy of command line */
|
/* Keep a copy of command line */
|
||||||
*cmdline_p = boot_command_line;
|
*cmdline_p = boot_command_line;
|
||||||
|
|
||||||
min_low_pfn = PFN_UP(memory_start);
|
find_limits(&min_low_pfn, &max_low_pfn, &max_pfn);
|
||||||
max_low_pfn = PFN_DOWN(memory_end);
|
|
||||||
max_mapnr = max_low_pfn;
|
max_mapnr = max_low_pfn;
|
||||||
|
|
||||||
memblock_reserve(dram_start, memory_start - dram_start);
|
memblock_reserve(__pa_symbol(_stext), _end - _stext);
|
||||||
#ifdef CONFIG_BLK_DEV_INITRD
|
#ifdef CONFIG_BLK_DEV_INITRD
|
||||||
if (initrd_start) {
|
if (initrd_start) {
|
||||||
memblock_reserve(virt_to_phys((void *)initrd_start),
|
memblock_reserve(virt_to_phys((void *)initrd_start),
|
||||||
|
|
Loading…
Add table
Reference in a new issue