From cf1b09908a231f3bb5e8ca15b76f05c4df91e292 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 1 Sep 2017 03:39:46 +0100 Subject: ARM: 8693/1: discard memblock arrays when possible On ARM the generic pfn_valid() version is used with some configurations such as SA1100 based devices. In that case the memblock arrays are no longer used after boot and can be discarded. Signed-off-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7888c9803eb0..979aac3e2fbf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2,6 +2,7 @@ config ARM bool default y select ARCH_CLOCKSOURCE_DATA + select ARCH_DISCARD_MEMBLOCK if !HAVE_ARCH_PFN_VALID select ARCH_HAS_DEBUG_VIRTUAL select ARCH_HAS_DEVMEM_IS_ALLOWED select ARCH_HAS_ELF_RANDOMIZE -- cgit v1.2.3 From 94058906acfbe3474e26d665924260e44a30e1bc Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 4 Sep 2017 09:17:09 +0100 Subject: ARM: 8694/1: Remove leftover of fixmap_page_table fixmap_page_table was removed by commit 836a24183273 (ARM: expand fixmap region to 3MB), but some traces are still there - get rid of them. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/include/asm/highmem.h | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h index 0a0e2d1784c0..61736fdccc79 100644 --- a/arch/arm/include/asm/highmem.h +++ b/arch/arm/include/asm/highmem.h @@ -18,7 +18,6 @@ } while (0) extern pte_t *pkmap_page_table; -extern pte_t *fixmap_page_table; extern void *kmap_high(struct page *page); extern void kunmap_high(struct page *page); -- cgit v1.2.3 From 6022f80da0d9d42e02e78f3fb42930ee86f3e7af Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 4 Sep 2017 09:17:32 +0100 Subject: ARM: 8695/1: entry: Remove dead code in sys_mmap2 We support page size of 4K only, remove dead code. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/kernel/entry-common.S | 9 --------- 1 file changed, 9 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index ca3614dc6938..cc70bc5650a5 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -394,17 +394,8 @@ ENDPROC(sys_fstatfs64_wrapper) * offset, we return EINVAL. */ sys_mmap2: -#if PAGE_SHIFT > 12 - tst r5, #PGOFF_MASK - moveq r5, r5, lsr #PAGE_SHIFT - 12 - streq r5, [sp, #4] - beq sys_mmap_pgoff - mov r0, #-EINVAL - ret lr -#else str r5, [sp, #4] b sys_mmap_pgoff -#endif ENDPROC(sys_mmap2) #ifdef CONFIG_OABI_COMPAT -- cgit v1.2.3 From 0d9ac1625ac1041742c72c3b680198f0304539b2 Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 4 Sep 2017 09:17:48 +0100 Subject: ARM: 8696/1: mm: Remove dead code in mem_init() The code in question checks memory constrains to set default policy for overcommit; however we support page size of 4K only thus condition is always evaluated to false. Remove that dead code. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/mm/init.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index ad80548325fe..81d4482b6861 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -580,16 +580,6 @@ void __init mem_init(void) BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET); BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET); #endif - - if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { - extern int sysctl_overcommit_memory; - /* - * On a machine this small we won't get - * anywhere without overcommit, so turn - * it on by default. - */ - sysctl_overcommit_memory = OVERCOMMIT_ALWAYS; - } } #ifdef CONFIG_STRICT_KERNEL_RWX -- cgit v1.2.3 From acb624488df3073be4e6f3c0a86b155c40d63ab2 Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 25 Sep 2017 10:25:53 +0100 Subject: ARM: 8697/1: dma-mapping: Do not pass data to gen_pool_set_algo() gen_pool_first_fit_order_align() does not make use of additional data, so pass plain NULL there. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/mm/dma-mapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index fcf1473d6fed..785606e3783e 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -443,7 +443,7 @@ static int __init atomic_pool_init(void) gen_pool_set_algo(atomic_pool, gen_pool_first_fit_order_align, - (void *)PAGE_SHIFT); + NULL); pr_info("DMA: preallocated %zu KiB pool for atomic coherent allocations\n", atomic_pool_size / 1024); return 0; -- cgit v1.2.3 From b337e1c40d3ea2d6f09228c4ff203f006abc9095 Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 25 Sep 2017 10:29:07 +0100 Subject: ARM: 8698/1: dma-mapping: Mark atomic_pool as __ro_after_init atomic_pool is setup once while init stage and never changed after that, so it is good candidate for __ro_after_init. Since we are here mark atomic_pool_size with __init_data. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/mm/dma-mapping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 785606e3783e..24519f4508b9 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -382,9 +382,9 @@ static void __dma_free_remap(void *cpu_addr, size_t size) } #define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K -static struct gen_pool *atomic_pool; +static struct gen_pool *atomic_pool __ro_after_init; -static size_t atomic_pool_size = DEFAULT_DMA_COHERENT_POOL_SIZE; +static size_t atomic_pool_size __initdata = DEFAULT_DMA_COHERENT_POOL_SIZE; static int __init early_coherent_pool(char *p) { -- cgit v1.2.3 From 0f7c4c15a30ffc5f5fd563ad1159cb899e121407 Mon Sep 17 00:00:00 2001 From: Vladimir Murzin Date: Mon, 25 Sep 2017 10:31:15 +0100 Subject: ARM: 8699/1: dma-mapping: Remove init_dma_coherent_pool_size() There are no users of init_dma_coherent_pool_size() left due to 387870f ("mm: dmapool: use provided gfp flags for all dma_alloc_coherent() calls"), so remove it. Signed-off-by: Vladimir Murzin Signed-off-by: Russell King --- arch/arm/include/asm/dma-mapping.h | 7 ------- arch/arm/mm/dma-mapping.c | 15 --------------- 2 files changed, 22 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 4e0285a66ef8..462803f3a6a0 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -189,13 +189,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, dma_addr_t dma_addr, size_t size, unsigned long attrs); -/* - * This can be called during early boot to increase the size of the atomic - * coherent DMA pool above the default value of 256KiB. It must be called - * before postcore_initcall. - */ -extern void __init init_dma_coherent_pool_size(unsigned long size); - /* * For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic" * and utilize bounce buffers as needed to work around limited DMA windows. diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 24519f4508b9..ada8eb206a90 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -393,21 +393,6 @@ static int __init early_coherent_pool(char *p) } early_param("coherent_pool", early_coherent_pool); -void __init init_dma_coherent_pool_size(unsigned long size) -{ - /* - * Catch any attempt to set the pool size too late. - */ - BUG_ON(atomic_pool); - - /* - * Set architecture specific coherent pool size only if - * it has not been changed by kernel command line parameter. - */ - if (atomic_pool_size == DEFAULT_DMA_COHERENT_POOL_SIZE) - atomic_pool_size = size; -} - /* * Initialise the coherent pool for atomic allocations. */ -- cgit v1.2.3 From 99cf8f903148347e3d2ac86ffe98bb04bebc6983 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 21 Sep 2017 12:06:20 +0100 Subject: ARM: better diagnostics with missing/corrupt dtb With a kernel containing both DT and atag support, the diagnostics output when the dtb is missing or corrupt assume that we're trying to boot using atags and the machine ID, and only print the machine ID. This is not useful for diagnosing a missing or corrupt dtb. Move the message into arch/arm/kernel/setup.c, and print the address of the dtb/atag list, and the first 16 bytes of memory of the dtb or atag list. This allows us to see whether the dtb was corrupted in some way, causing the fallback to the machine ID / atag list. Tested-by: Keerthy Signed-off-by: Russell King --- arch/arm/kernel/atags_parse.c | 7 ++----- arch/arm/kernel/setup.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c index 98fbfd235ac8..c10a3e8ee998 100644 --- a/arch/arm/kernel/atags_parse.c +++ b/arch/arm/kernel/atags_parse.c @@ -196,11 +196,8 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr) break; } - if (!mdesc) { - early_print("\nError: unrecognized/unsupported machine ID" - " (r1 = 0x%08x).\n\n", machine_nr); - dump_machine_table(); /* does not return */ - } + if (!mdesc) + return NULL; if (__atags_pointer) tags = phys_to_virt(__atags_pointer); diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8e9a3e40d949..fc40a2b40595 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1069,6 +1069,16 @@ void __init setup_arch(char **cmdline_p) mdesc = setup_machine_fdt(__atags_pointer); if (!mdesc) mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type); + if (!mdesc) { + early_print("\nError: invalid dtb and unrecognized/unsupported machine ID\n"); + early_print(" r1=0x%08x, r2=0x%08x\n", __machine_arch_type, + __atags_pointer); + if (__atags_pointer) + early_print(" r2[]=%*ph\n", 16, + phys_to_virt(__atags_pointer)); + dump_machine_table(); + } + machine_desc = mdesc; machine_name = mdesc->name; dump_stack_set_arch_desc("%s", mdesc->name); -- cgit v1.2.3 From 429f7a062e3b5cf6fcf01eb00600cee5fe4d751f Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 21 Sep 2017 17:15:23 +0100 Subject: ARM: decompressor: fix BSS size calculation Assuming size(1) gives the size of the BSS is a mistake - it reports the size of the .bss section in the ELF image, which may not be the same as the region we mark with the __bss_start..__bss_stop symbols. We use the size of the BSS in the decompressor to know whether the kernel will overwrite the appended dtb, by adding the BSS size to the size of the Image (stored at the end of the compressed data) and adding the desired address of the decompressed image. If the BSS size is smaller than it really is, the decompressor can incorrectly assume that the BSS clearance will not overwrite the DTB. Here is an illustration: $ arm-linux-size vmlinux text data bss dec hex filename 8136972 3098076 10240348 21475396 147b044 vmlinux $ arm-linux-nm vmlinux | grep __bss_ c0ac0e34 B __bss_start c1484f9c B __bss_stop $ stat -c %s arch/arm/boot/Image 11243060 In the above case, we are 12 bytes short. This is caused by the BSS section being aligned by one of its input sections: Idx Name Size VMA LMA File off Algn 23 __bug_table 00005d3c c0abb0f8 c0abb0f8 00acb0f8 2**2 CONTENTS, ALLOC, LOAD, DATA 24 .bss 009c415c c0ac0e40 c0ac0e40 00ad0e34 2**6 ALLOC Note that there's an additional 12 bytes difference between the file offset and LMA compared with the bug table - this occurs because one of the input sections for the .bss section requires a 64 byte alignment. Fix this by using 'nm' and perl to obtain the address of the __bss_start and __bss_stop symbols, using their difference for the size of the BSS. Tested-by: Tony Lindgren Tested-by: Keerthy Signed-off-by: Russell King --- arch/arm/boot/compressed/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index d50430c40045..9519ce3d2e1c 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -116,8 +116,11 @@ ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj) asflags-y := -DZIMAGE # Supply kernel BSS size to the decompressor via a linker symbol. -KBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \ - awk 'END{print $$3}') +KBSS_SZ = $(shell $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \ + perl -e 'while (<>) { \ + $$bss_start=hex($$1) if /^([[:xdigit:]]+) B __bss_start$$/; \ + $$bss_end=hex($$1) if /^([[:xdigit:]]+) B __bss_stop$$/; \ + }; printf "%d\n", $$bss_end - $$bss_start;') LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ) # Supply ZRELADDR to the decompressor via a linker symbol. ifneq ($(CONFIG_AUTO_ZRELADDR),y) -- cgit v1.2.3 From c772568788b5f0cbaac7c8d4111d7173bfc90673 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 21 Sep 2017 18:10:19 +0100 Subject: ARM: add additional table to compressed kernel Add an additional extendable table to the compressed kernel so that we can provide further information to boot loaders regarding the properties of the image contained within. This is necessary for correct behaviour of kexec. Tested-by: Tony Lindgren Tested-by: Keerthy Signed-off-by: Russell King --- arch/arm/boot/compressed/head.S | 2 ++ arch/arm/boot/compressed/vmlinux.lds.S | 11 +++++++++++ 2 files changed, 13 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 8a756870c238..45c8823c3750 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -143,6 +143,8 @@ start: .word _magic_start @ absolute load/run zImage address .word _magic_end @ zImage end address .word 0x04030201 @ endianness flag + .word 0x45454545 @ another magic number to indicate + .word _magic_table @ additional data table __EFI_HEADER 1: diff --git a/arch/arm/boot/compressed/vmlinux.lds.S b/arch/arm/boot/compressed/vmlinux.lds.S index 7a4c59154361..b38dcef90756 100644 --- a/arch/arm/boot/compressed/vmlinux.lds.S +++ b/arch/arm/boot/compressed/vmlinux.lds.S @@ -44,12 +44,22 @@ SECTIONS *(.glue_7t) *(.glue_7) } + .table : ALIGN(4) { + _table_start = .; + LONG(ZIMAGE_MAGIC(2)) + LONG(ZIMAGE_MAGIC(0x5a534c4b)) + LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start)) + LONG(ZIMAGE_MAGIC(_kernel_bss_size)) + LONG(0) + _table_end = .; + } .rodata : { *(.rodata) *(.rodata.*) } .piggydata : { *(.piggydata) + __piggy_size_addr = . - 4; } . = ALIGN(4); @@ -88,6 +98,7 @@ SECTIONS _magic_sig = ZIMAGE_MAGIC(0x016f2818); _magic_start = ZIMAGE_MAGIC(_start); _magic_end = ZIMAGE_MAGIC(_edata); + _magic_table = ZIMAGE_MAGIC(_table_start - _start); . = BSS_START; __bss_start = .; -- cgit v1.2.3 From e11d1314d83ec7f562fa01df29878d0b1138cf00 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 6 Oct 2017 19:36:58 +0100 Subject: ARM: 8703/1: debug.S: move hexbuf to a writable section This was located in .text which is meant to be read-only. And in the XIP case this shortcut simply doesn't work and may trigger a Flash controller mode switch and crash the kernel. Move it to the .bss area. Signed-off-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/kernel/debug.S | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S index ea9646cc2a0e..423f4432586d 100644 --- a/arch/arm/kernel/debug.S +++ b/arch/arm/kernel/debug.S @@ -55,7 +55,9 @@ ENDPROC(printhex4) ENTRY(printhex2) mov r1, #2 -printhex: adr r2, hexbuf +printhex: adr r2, hexbuf_rel + ldr r3, [r2] + add r2, r2, r3 add r3, r2, r1 mov r1, #0 strb r1, [r3] @@ -71,7 +73,11 @@ printhex: adr r2, hexbuf b printascii ENDPROC(printhex2) -hexbuf: .space 16 + .pushsection .bss +hexbuf_addr: .space 16 + .popsection + .align +hexbuf_rel: .long hexbuf_addr - . .ltorg @@ -120,7 +126,9 @@ ENTRY(printascii) ENDPROC(printascii) ENTRY(printch) - adr r1, hexbuf + adr r1, hexbuf_rel + ldr r2, [r1] + add r1, r1, r2 strb r0, [r1] mov r0, #0x03 @ SYS_WRITEC ARM( svc #0x123456 ) -- cgit v1.2.3 From de880632fc02a889c0c3d2247fa08dc9e1afa228 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Fri, 6 Oct 2017 19:49:19 +0100 Subject: ARM: 8705/1: early_printk: use printascii() rather than printch() With printch() the console messages are sent out one character at a time which is agonizingly slow especially with semihosting as the whole trap intercept, remote byte access, and system resume danse is performed for every single character across a relatively slow remote debug connection. Let's use printascii() to send a whole string at once. This is also going to be more efficient, albeit to a quite lesser extent, with serial ports as well. Signed-off-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/kernel/early_printk.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/early_printk.c b/arch/arm/kernel/early_printk.c index 43076536965c..9257736ec9fa 100644 --- a/arch/arm/kernel/early_printk.c +++ b/arch/arm/kernel/early_printk.c @@ -11,16 +11,20 @@ #include #include #include +#include -extern void printch(int); +extern void printascii(const char *); static void early_write(const char *s, unsigned n) { - while (n-- > 0) { - if (*s == '\n') - printch('\r'); - printch(*s); - s++; + char buf[128]; + while (n) { + unsigned l = min(n, sizeof(buf)-1); + memcpy(buf, s, l); + buf[l] = 0; + s += l; + n -= l; + printascii(buf); } } -- cgit v1.2.3 From 2a14b80cb03bee9a4973e5a91e0ed48df25b57ce Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 2 Nov 2017 21:58:41 +0100 Subject: ARM: 8717/2: debug printch/printascii: translate '\n' to "\r\n" not "\n\r" Some terminals apparently have issues with "\n\r" and mess up the display. Let's use the traditional "\r\n" ordering. Signed-off-by: Nicolas Pitre Reported-by: Chris Brandt Tested-by: Chris Brandt Signed-off-by: Russell King --- arch/arm/kernel/debug.S | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S index 423f4432586d..611ded664d61 100644 --- a/arch/arm/kernel/debug.S +++ b/arch/arm/kernel/debug.S @@ -85,25 +85,28 @@ hexbuf_rel: .long hexbuf_addr - . ENTRY(printascii) addruart_current r3, r1, r2 - b 2f -1: waituart r2, r3 - senduart r1, r3 - busyuart r2, r3 - teq r1, #'\n' - moveq r1, #'\r' - beq 1b -2: teq r0, #0 +1: teq r0, #0 ldrneb r1, [r0], #1 teqne r1, #0 - bne 1b - ret lr + reteq lr +2: teq r1, #'\n' + bne 3f + mov r1, #'\r' + waituart r2, r3 + senduart r1, r3 + busyuart r2, r3 + mov r1, #'\n' +3: waituart r2, r3 + senduart r1, r3 + busyuart r2, r3 + b 1b ENDPROC(printascii) ENTRY(printch) addruart_current r3, r1, r2 mov r1, r0 mov r0, #0 - b 1b + b 2b ENDPROC(printch) #ifdef CONFIG_MMU -- cgit v1.2.3