Skip to content

Commit 114e3ba

Browse files
committed
Merge branch 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM fixes from Russell King: "Only three fixes this time: - Emil found an overflow problem with the memory layout sanity check. - Ard Biesheuvel noticed that late-allocated page tables (for EFI) weren't being properly constructed. - Guenter Roeck reported a problem found on qemu caused by the recent addr_limit changes" * 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm: ARM: fix address limit restoration for undefined instructions ARM: 8591/1: mm: use fully constructed struct pages for EFI pgd allocations ARM: 8590/1: sanity_check_meminfo(): avoid overflow on vmalloc_limit
2 parents 395c434 + 87eed3c commit 114e3ba

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

arch/arm/kernel/entry-armv.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ __und_svc_fault:
295295
bl __und_fault
296296

297297
__und_svc_finish:
298+
get_thread_info tsk
298299
ldr r5, [sp, #S_PSR] @ Get SVC cpsr
299300
svc_exit r5 @ return from exception
300301
UNWIND(.fnend )

arch/arm/mm/mmu.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ static void *__init late_alloc(unsigned long sz)
728728
{
729729
void *ptr = (void *)__get_free_pages(PGALLOC_GFP, get_order(sz));
730730

731-
BUG_ON(!ptr);
731+
if (!ptr || !pgtable_page_ctor(virt_to_page(ptr)))
732+
BUG();
732733
return ptr;
733734
}
734735

@@ -1155,10 +1156,19 @@ void __init sanity_check_meminfo(void)
11551156
{
11561157
phys_addr_t memblock_limit = 0;
11571158
int highmem = 0;
1158-
phys_addr_t vmalloc_limit = __pa(vmalloc_min - 1) + 1;
1159+
u64 vmalloc_limit;
11591160
struct memblock_region *reg;
11601161
bool should_use_highmem = false;
11611162

1163+
/*
1164+
* Let's use our own (unoptimized) equivalent of __pa() that is
1165+
* not affected by wrap-arounds when sizeof(phys_addr_t) == 4.
1166+
* The result is used as the upper bound on physical memory address
1167+
* and may itself be outside the valid range for which phys_addr_t
1168+
* and therefore __pa() is defined.
1169+
*/
1170+
vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET;
1171+
11621172
for_each_memblock(memory, reg) {
11631173
phys_addr_t block_start = reg->base;
11641174
phys_addr_t block_end = reg->base + reg->size;
@@ -1183,10 +1193,11 @@ void __init sanity_check_meminfo(void)
11831193
if (reg->size > size_limit) {
11841194
phys_addr_t overlap_size = reg->size - size_limit;
11851195

1186-
pr_notice("Truncating RAM at %pa-%pa to -%pa",
1187-
&block_start, &block_end, &vmalloc_limit);
1188-
memblock_remove(vmalloc_limit, overlap_size);
1196+
pr_notice("Truncating RAM at %pa-%pa",
1197+
&block_start, &block_end);
11891198
block_end = vmalloc_limit;
1199+
pr_cont(" to -%pa", &block_end);
1200+
memblock_remove(vmalloc_limit, overlap_size);
11901201
should_use_highmem = true;
11911202
}
11921203
}

0 commit comments

Comments
 (0)