Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'riscv-for-linus-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux into master

Pull RISC-V fixes from Palmer Dabbelt:
"A few more fixes this week:

- A fix to avoid using SBI calls during kasan initialization, as the
SBI calls themselves have not been probed yet.

- Three fixes related to systems with multiple memory regions"

* tag 'riscv-for-linus-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
riscv: Parse all memory blocks to remove unusable memory
RISC-V: Do not rely on initrd_start/end computed during early dt parsing
RISC-V: Set maximum number of mapped pages correctly
riscv: kasan: use local_tlb_flush_all() to avoid uninitialized __sbi_rfence

+49 -25
+47 -23
arch/riscv/mm/init.c
··· 95 95 #ifdef CONFIG_BLK_DEV_INITRD 96 96 static void __init setup_initrd(void) 97 97 { 98 + phys_addr_t start; 98 99 unsigned long size; 99 100 100 - if (initrd_start >= initrd_end) { 101 - pr_info("initrd not found or empty"); 102 - goto disable; 103 - } 104 - if (__pa_symbol(initrd_end) > PFN_PHYS(max_low_pfn)) { 105 - pr_err("initrd extends beyond end of memory"); 101 + /* Ignore the virtul address computed during device tree parsing */ 102 + initrd_start = initrd_end = 0; 103 + 104 + if (!phys_initrd_size) 105 + return; 106 + /* 107 + * Round the memory region to page boundaries as per free_initrd_mem() 108 + * This allows us to detect whether the pages overlapping the initrd 109 + * are in use, but more importantly, reserves the entire set of pages 110 + * as we don't want these pages allocated for other purposes. 111 + */ 112 + start = round_down(phys_initrd_start, PAGE_SIZE); 113 + size = phys_initrd_size + (phys_initrd_start - start); 114 + size = round_up(size, PAGE_SIZE); 115 + 116 + if (!memblock_is_region_memory(start, size)) { 117 + pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region", 118 + (u64)start, size); 106 119 goto disable; 107 120 } 108 121 109 - size = initrd_end - initrd_start; 110 - memblock_reserve(__pa_symbol(initrd_start), size); 122 + if (memblock_is_region_reserved(start, size)) { 123 + pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region\n", 124 + (u64)start, size); 125 + goto disable; 126 + } 127 + 128 + memblock_reserve(start, size); 129 + /* Now convert initrd to virtual addresses */ 130 + initrd_start = (unsigned long)__va(phys_initrd_start); 131 + initrd_end = initrd_start + phys_initrd_size; 111 132 initrd_below_start_ok = 1; 112 133 113 134 pr_info("Initial ramdisk at: 0x%p (%lu bytes)\n", ··· 147 126 { 148 127 struct memblock_region *reg; 149 128 phys_addr_t mem_size = 0; 129 + phys_addr_t total_mem = 0; 130 + phys_addr_t mem_start, end = 0; 150 131 phys_addr_t vmlinux_end = __pa_symbol(&_end); 151 132 phys_addr_t vmlinux_start = __pa_symbol(&_start); 152 133 153 134 /* Find the memory region containing the kernel */ 154 135 for_each_memblock(memory, reg) { 155 - phys_addr_t end = reg->base + reg->size; 156 - 157 - if (reg->base <= vmlinux_start && vmlinux_end <= end) { 158 - mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); 159 - 160 - /* 161 - * Remove memblock from the end of usable area to the 162 - * end of region 163 - */ 164 - if (reg->base + mem_size < end) 165 - memblock_remove(reg->base + mem_size, 166 - end - reg->base - mem_size); 167 - } 136 + end = reg->base + reg->size; 137 + if (!total_mem) 138 + mem_start = reg->base; 139 + if (reg->base <= vmlinux_start && vmlinux_end <= end) 140 + BUG_ON(reg->size == 0); 141 + total_mem = total_mem + reg->size; 168 142 } 169 - BUG_ON(mem_size == 0); 143 + 144 + /* 145 + * Remove memblock from the end of usable area to the 146 + * end of region 147 + */ 148 + mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET); 149 + if (mem_start + mem_size < end) 150 + memblock_remove(mem_start + mem_size, 151 + end - mem_start - mem_size); 170 152 171 153 /* Reserve from the start of the kernel to the end of the kernel */ 172 154 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); 173 155 174 - set_max_mapnr(PFN_DOWN(mem_size)); 175 156 max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 176 157 max_low_pfn = max_pfn; 158 + set_max_mapnr(max_low_pfn); 177 159 178 160 #ifdef CONFIG_BLK_DEV_INITRD 179 161 setup_initrd();
+2 -2
arch/riscv/mm/kasan_init.c
··· 44 44 (__pa(((uintptr_t) kasan_early_shadow_pmd))), 45 45 __pgprot(_PAGE_TABLE))); 46 46 47 - flush_tlb_all(); 47 + local_flush_tlb_all(); 48 48 } 49 49 50 50 static void __init populate(void *start, void *end) ··· 79 79 pfn_pgd(PFN_DOWN(__pa(&pmd[offset])), 80 80 __pgprot(_PAGE_TABLE))); 81 81 82 - flush_tlb_all(); 82 + local_flush_tlb_all(); 83 83 memset(start, 0, end - start); 84 84 } 85 85