Skip to content

Commit 441692a

Browse files
committed
Merge branch 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM updates from Russell King: - add support for ELF fdpic binaries on both MMU and noMMU platforms - linker script cleanups - support for compressed .data section for XIP images - discard memblock arrays when possible - various cleanups - atomic DMA pool updates - better diagnostics of missing/corrupt device tree - export information to allow userspace kexec tool to place images more inteligently, so that the device tree isn't overwritten by the booting kernel - make early_printk more efficient on semihosted systems - noMMU cleanups - SA1111 PCMCIA update in preparation for further cleanups * 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm: (38 commits) ARM: 8719/1: NOMMU: work around maybe-uninitialized warning ARM: 8717/2: debug printch/printascii: translate '\n' to "\r\n" not "\n\r" ARM: 8713/1: NOMMU: Support MPU in XIP configuration ARM: 8712/1: NOMMU: Use more MPU regions to cover memory ARM: 8711/1: V7M: Add support for MPU to M-class ARM: 8710/1: Kconfig: Kill CONFIG_VECTORS_BASE ARM: 8709/1: NOMMU: Disallow MPU for XIP ARM: 8708/1: NOMMU: Rework MPU to be mostly done in C ARM: 8707/1: NOMMU: Update MPU accessors to use cp15 helpers ARM: 8706/1: NOMMU: Move out MPU setup in separate module ARM: 8702/1: head-common.S: Clear lr before jumping to start_kernel() ARM: 8705/1: early_printk: use printascii() rather than printch() ARM: 8703/1: debug.S: move hexbuf to a writable section ARM: add additional table to compressed kernel ARM: decompressor: fix BSS size calculation pcmcia: sa1111: remove special sa1111 mmio accessors pcmcia: sa1111: use sa1111_get_irq() to obtain IRQ resources ARM: better diagnostics with missing/corrupt dtb ARM: 8699/1: dma-mapping: Remove init_dma_coherent_pool_size() ARM: 8698/1: dma-mapping: Mark atomic_pool as __ro_after_init ..
2 parents 5b0e2cb + 0219614 commit 441692a

46 files changed

Lines changed: 1226 additions & 540 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/arm/Kconfig‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ config ARM
33
bool
44
default y
55
select ARCH_CLOCKSOURCE_DATA
6+
select ARCH_DISCARD_MEMBLOCK if !HAVE_ARCH_PFN_VALID
67
select ARCH_HAS_DEBUG_VIRTUAL
78
select ARCH_HAS_DEVMEM_IS_ALLOWED
89
select ARCH_HAS_ELF_RANDOMIZE
@@ -240,15 +241,6 @@ config NEED_RET_TO_USER
240241
config ARCH_MTD_XIP
241242
bool
242243

243-
config VECTORS_BASE
244-
hex
245-
default 0xffff0000 if MMU || CPU_HIGH_VECTOR
246-
default DRAM_BASE if REMAP_VECTORS_TO_RAM
247-
default 0x00000000
248-
help
249-
The base address of exception vectors. This must be two pages
250-
in size.
251-
252244
config ARM_PATCH_PHYS_VIRT
253245
bool "Patch physical to virtual translations at runtime" if EMBEDDED
254246
default y
@@ -2006,6 +1998,17 @@ config XIP_PHYS_ADDR
20061998
be linked for and stored to. This address is dependent on your
20071999
own flash usage.
20082000

2001+
config XIP_DEFLATED_DATA
2002+
bool "Store kernel .data section compressed in ROM"
2003+
depends on XIP_KERNEL
2004+
select ZLIB_INFLATE
2005+
help
2006+
Before the kernel is actually executed, its .data section has to be
2007+
copied to RAM from ROM. This option allows for storing that data
2008+
in compressed form and decompressed to RAM rather than merely being
2009+
copied, saving some precious ROM space. A possible drawback is a
2010+
slightly longer boot delay.
2011+
20092012
config KEXEC
20102013
bool "Kexec system call (EXPERIMENTAL)"
20112014
depends on (!SMP || PM_SLEEP_SMP)

‎arch/arm/Kconfig-nommu‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ config REMAP_VECTORS_TO_RAM
5353

5454
config ARM_MPU
5555
bool 'Use the ARM v7 PMSA Compliant MPU'
56-
depends on CPU_V7
57-
default y
56+
depends on CPU_V7 || CPU_V7M
57+
default y if CPU_V7
5858
help
5959
Some ARM systems without an MMU have instead a Memory Protection
6060
Unit (MPU) that defines the type and permissions for regions of

‎arch/arm/boot/Makefile‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,19 @@ targets := Image zImage xipImage bootpImage uImage
3131

3232
ifeq ($(CONFIG_XIP_KERNEL),y)
3333

34+
cmd_deflate_xip_data = $(CONFIG_SHELL) -c \
35+
'$(srctree)/$(src)/deflate_xip_data.sh $< $@ || { rm -f $@; false; }'
36+
37+
ifeq ($(CONFIG_XIP_DEFLATED_DATA),y)
38+
quiet_cmd_mkxip = XIPZ $@
39+
cmd_mkxip = $(cmd_objcopy) && $(cmd_deflate_xip_data)
40+
else
41+
quiet_cmd_mkxip = $(quiet_cmd_objcopy)
42+
cmd_mkxip = $(cmd_objcopy)
43+
endif
44+
3445
$(obj)/xipImage: vmlinux FORCE
35-
$(call if_changed,objcopy)
46+
$(call if_changed,mkxip)
3647
@$(kecho) ' Physical Address of xipImage: $(CONFIG_XIP_PHYS_ADDR)'
3748

3849
$(obj)/Image $(obj)/zImage: FORCE

‎arch/arm/boot/compressed/Makefile‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
117117
asflags-y := -DZIMAGE
118118

119119
# Supply kernel BSS size to the decompressor via a linker symbol.
120-
KBSS_SZ = $(shell $(CROSS_COMPILE)size $(obj)/../../../../vmlinux | \
121-
awk 'END{print $$3}')
120+
KBSS_SZ = $(shell $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
121+
perl -e 'while (<>) { \
122+
$$bss_start=hex($$1) if /^([[:xdigit:]]+) B __bss_start$$/; \
123+
$$bss_end=hex($$1) if /^([[:xdigit:]]+) B __bss_stop$$/; \
124+
}; printf "%d\n", $$bss_end - $$bss_start;')
122125
LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
123126
# Supply ZRELADDR to the decompressor via a linker symbol.
124127
ifneq ($(CONFIG_AUTO_ZRELADDR),y)

‎arch/arm/boot/compressed/head.S‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ start:
143143
.word _magic_start @ absolute load/run zImage address
144144
.word _magic_end @ zImage end address
145145
.word 0x04030201 @ endianness flag
146+
.word 0x45454545 @ another magic number to indicate
147+
.word _magic_table @ additional data table
146148

147149
__EFI_HEADER
148150
1:

‎arch/arm/boot/compressed/vmlinux.lds.S‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,22 @@ SECTIONS
4444
*(.glue_7t)
4545
*(.glue_7)
4646
}
47+
.table : ALIGN(4) {
48+
_table_start = .;
49+
LONG(ZIMAGE_MAGIC(2))
50+
LONG(ZIMAGE_MAGIC(0x5a534c4b))
51+
LONG(ZIMAGE_MAGIC(__piggy_size_addr - _start))
52+
LONG(ZIMAGE_MAGIC(_kernel_bss_size))
53+
LONG(0)
54+
_table_end = .;
55+
}
4756
.rodata : {
4857
*(.rodata)
4958
*(.rodata.*)
5059
}
5160
.piggydata : {
5261
*(.piggydata)
62+
__piggy_size_addr = . - 4;
5363
}
5464

5565
. = ALIGN(4);
@@ -97,6 +107,7 @@ SECTIONS
97107
_magic_sig = ZIMAGE_MAGIC(0x016f2818);
98108
_magic_start = ZIMAGE_MAGIC(_start);
99109
_magic_end = ZIMAGE_MAGIC(_edata);
110+
_magic_table = ZIMAGE_MAGIC(_table_start - _start);
100111

101112
. = BSS_START;
102113
__bss_start = .;

‎arch/arm/boot/deflate_xip_data.sh‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/sh
2+
3+
# XIP kernel .data segment compressor
4+
#
5+
# Created by: Nicolas Pitre, August 2017
6+
# Copyright: (C) 2017 Linaro Limited
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License version 2 as
10+
# published by the Free Software Foundation.
11+
12+
# This script locates the start of the .data section in xipImage and
13+
# substitutes it with a compressed version. The needed offsets are obtained
14+
# from symbol addresses in vmlinux. It is expected that .data extends to
15+
# the end of xipImage.
16+
17+
set -e
18+
19+
VMLINUX="$1"
20+
XIPIMAGE="$2"
21+
22+
DD="dd status=none"
23+
24+
# Use "make V=1" to debug this script.
25+
case "$KBUILD_VERBOSE" in
26+
*1*)
27+
set -x
28+
;;
29+
esac
30+
31+
sym_val() {
32+
# extract hex value for symbol in $1
33+
local val=$($NM "$VMLINUX" | sed -n "/ $1$/{s/ .*$//p;q}")
34+
[ "$val" ] || { echo "can't find $1 in $VMLINUX" 1>&2; exit 1; }
35+
# convert from hex to decimal
36+
echo $((0x$val))
37+
}
38+
39+
__data_loc=$(sym_val __data_loc)
40+
_edata_loc=$(sym_val _edata_loc)
41+
base_offset=$(sym_val _xiprom)
42+
43+
# convert to file based offsets
44+
data_start=$(($__data_loc - $base_offset))
45+
data_end=$(($_edata_loc - $base_offset))
46+
47+
# Make sure data occupies the last part of the file.
48+
file_end=$(stat -c "%s" "$XIPIMAGE")
49+
if [ "$file_end" != "$data_end" ]; then
50+
printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \
51+
$(($file_end + $base_offset)) $_edata_loc 2>&1
52+
exit 1;
53+
fi
54+
55+
# be ready to clean up
56+
trap 'rm -f "$XIPIMAGE.tmp"' 0 1 2 3
57+
58+
# substitute the data section by a compressed version
59+
$DD if="$XIPIMAGE" count=$data_start iflag=count_bytes of="$XIPIMAGE.tmp"
60+
$DD if="$XIPIMAGE" skip=$data_start iflag=skip_bytes |
61+
gzip -9 >> "$XIPIMAGE.tmp"
62+
63+
# replace kernel binary
64+
mv -f "$XIPIMAGE.tmp" "$XIPIMAGE"

‎arch/arm/include/asm/cputype.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
174174
return read_cpuid(CPUID_CACHETYPE);
175175
}
176176

177+
static inline unsigned int __attribute_const__ read_cpuid_mputype(void)
178+
{
179+
return read_cpuid(CPUID_MPUIR);
180+
}
181+
177182
#elif defined(CONFIG_CPU_V7M)
178183

179184
static inline unsigned int __attribute_const__ read_cpuid_id(void)
@@ -186,6 +191,11 @@ static inline unsigned int __attribute_const__ read_cpuid_cachetype(void)
186191
return readl(BASEADDR_V7M_SCB + V7M_SCB_CTR);
187192
}
188193

194+
static inline unsigned int __attribute_const__ read_cpuid_mputype(void)
195+
{
196+
return readl(BASEADDR_V7M_SCB + MPU_TYPE);
197+
}
198+
189199
#else /* ifdef CONFIG_CPU_CP15 / elif defined(CONFIG_CPU_V7M) */
190200

191201
static inline unsigned int __attribute_const__ read_cpuid_id(void)

‎arch/arm/include/asm/dma-mapping.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,6 @@ extern int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma,
190190
void *cpu_addr, dma_addr_t dma_addr, size_t size,
191191
unsigned long attrs);
192192

193-
/*
194-
* This can be called during early boot to increase the size of the atomic
195-
* coherent DMA pool above the default value of 256KiB. It must be called
196-
* before postcore_initcall.
197-
*/
198-
extern void __init init_dma_coherent_pool_size(unsigned long size);
199-
200193
/*
201194
* For SA-1111, IXP425, and ADI systems the dma-mapping functions are "magic"
202195
* and utilize bounce buffers as needed to work around limited DMA windows.

‎arch/arm/include/asm/elf.h‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@ struct elf32_hdr;
101101
extern int elf_check_arch(const struct elf32_hdr *);
102102
#define elf_check_arch elf_check_arch
103103

104+
#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC platform */
105+
#define elf_check_fdpic(x) ((x)->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC)
106+
#define elf_check_const_displacement(x) ((x)->e_flags & EF_ARM_PIC)
107+
#define ELF_FDPIC_CORE_EFLAGS 0
108+
104109
#define vmcore_elf64_check_arch(x) (0)
105110

106-
extern int arm_elf_read_implies_exec(const struct elf32_hdr *, int);
107-
#define elf_read_implies_exec(ex,stk) arm_elf_read_implies_exec(&(ex), stk)
111+
extern int arm_elf_read_implies_exec(int);
112+
#define elf_read_implies_exec(ex,stk) arm_elf_read_implies_exec(stk)
108113

109114
struct task_struct;
110115
int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
@@ -121,6 +126,13 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
121126
have no such handler. */
122127
#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
123128

129+
#define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \
130+
do { \
131+
(_r)->ARM_r7 = _exec_map_addr; \
132+
(_r)->ARM_r8 = _interp_map_addr; \
133+
(_r)->ARM_r9 = dynamic_addr; \
134+
} while(0)
135+
124136
extern void elf_set_personality(const struct elf32_hdr *);
125137
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))
126138

0 commit comments

Comments
 (0)