Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f61e9925 authored by Laura Abbott's avatar Laura Abbott
Browse files

arm: mm: Account for lowmem in the static vm



Linux page directory size differs from the ARM section size used
for lowmem mappings (2MB vs. 1MB). The ioremap code takes this
into account when static mappings are set up and pads PMD sections
accordingly. Lowmem needs to be tracked in the static mappings as
well to account for the size difference as well. If the lowmem
is not tracked, we may attempt to use part of an address range that
should be reserved which can trigger BUGs() or unexpected faults.

Change-Id: I60b1ce50a7cafbd189066d7331ee8b4c4ce3027b
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
parent 86155e46
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -91,8 +91,7 @@ void __init add_static_vm_early(struct static_vm *svm)
	void *vaddr;

	vm = &svm->vm;
	if (vm_area_check_early(vm))
		return;
	if (!vm_area_check_early(vm))
		vm_area_add_early(vm);
	vaddr = vm->addr;

+6 −4
Original line number Diff line number Diff line
@@ -1487,7 +1487,7 @@ EXPORT_SYMBOL(mem_text_write_kernel_word);
static void __init map_lowmem(void)
{
	struct memblock_region *reg;
	struct vm_struct *vm;
	struct static_vm *svm;
	phys_addr_t start;
	phys_addr_t end;
	unsigned long vaddr;
@@ -1555,9 +1555,10 @@ static void __init map_lowmem(void)
		create_mapping(&map);
	}

	vm = early_alloc_aligned(sizeof(*vm) * nr, __alignof__(*vm));
	svm = early_alloc_aligned(sizeof(*svm) * nr, __alignof__(*svm));

	for_each_memblock(memory, reg) {
		struct vm_struct *vm;

		start = reg->base;
		end = start + reg->size;
@@ -1567,6 +1568,7 @@ static void __init map_lowmem(void)
		if (start >= end)
			break;

		vm = &svm->vm;
		pfn = __phys_to_pfn(start);
		vaddr = __phys_to_virt(start);
		length = end - start;
@@ -1575,10 +1577,10 @@ static void __init map_lowmem(void)
		vm->addr = (void *)(vaddr & PAGE_MASK);
		vm->size = PAGE_ALIGN(length + (vaddr & ~PAGE_MASK));
		vm->phys_addr = __pfn_to_phys(pfn);
		vm->flags = VM_LOWMEM | VM_ARM_STATIC_MAPPING;
		vm->flags = VM_LOWMEM;
		vm->flags |= VM_ARM_MTYPE(type);
		vm->caller = map_lowmem;
		vm_area_add_early(vm++);
		add_static_vm_early(svm++);
	}
}