Skip to content

Commit a4fdb2a

Browse files
committed
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 updates from Will Deacon: - Support for new architectural features introduced in ARMv8.1: * Privileged Access Never (PAN) to catch user pointer dereferences in the kernel * Large System Extension (LSE) for building scalable atomics and locks (depends on locking/arch-atomic from tip, which is included here) * Hardware Dirty Bit Management (DBM) for updating clean PTEs automatically - Move our PSCI implementation out into drivers/firmware/, where it can be shared with arch/arm/. RMK has also pulled this component branch and has additional patches moving arch/arm/ over. MAINTAINERS is updated accordingly. - Better BUG implementation based on the BRK instruction for trapping - Leaf TLB invalidation for unmapping user pages - Support for PROBE_ONLY PCI configurations - Various cleanups and non-critical fixes, including: * Always flush FP/SIMD state over exec() * Restrict memblock additions based on range of linear mapping * Ensure *(LIST_POISON) generates a fatal fault * Context-tracking syscall return no longer corrupts return value when not forced on. * Alternatives patching synchronisation/stability improvements * Signed sub-word cmpxchg compare fix (tickled by HAVE_CMPXCHG_LOCAL) * Force SMP=y * Hide direct DCC access from userspace * Fix EFI stub memory allocation when DRAM starts at 0x0 * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (92 commits) arm64: flush FP/SIMD state correctly after execve() arm64: makefile: fix perf_callchain.o kconfig dependency arm64: set MAX_MEMBLOCK_ADDR according to linear region size of/fdt: make memblock maximum physical address arch configurable arm64: Fix source code file path in comments arm64: entry: always restore x0 from the stack on syscall return arm64: mdscr_el1: avoid exposing DCC to userspace arm64: kconfig: Move LIST_POISON to a safe value arm64: Add __exception_irq_entry definition for function graph arm64: mm: ensure patched kernel text is fetched from PoU arm64: alternatives: ensure secondary CPUs execute ISB after patching arm64: make ll/sc __cmpxchg_case_##name asm consistent arm64: dma-mapping: Simplify pgprot handling arm64: restore cpu suspend/resume functionality ARM64: PCI: do not enable resources on PROBE_ONLY systems arm64: cmpxchg: truncate sub-word signed types before comparison arm64: alternative: put secondary CPUs into polling loop during patch arm64/Documentation: clarify wording regarding memory below the Image arm64: lse: fix lse cmpxchg code indentation arm64: remove redundant object file list ...
2 parents 807249d + 674c242 commit a4fdb2a

86 files changed

Lines changed: 2321 additions & 1145 deletions

Some content is hidden

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

‎Documentation/arm64/booting.txt‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The decompressed kernel image contains a 64-byte header as follows:
8181
u64 res3 = 0; /* reserved */
8282
u64 res4 = 0; /* reserved */
8383
u32 magic = 0x644d5241; /* Magic number, little endian, "ARM\x64" */
84-
u32 res5; /* reserved (used for PE COFF offset) */
84+
u32 res5; /* reserved (used for PE COFF offset) */
8585

8686

8787
Header notes:
@@ -103,7 +103,7 @@ Header notes:
103103

104104
- The flags field (introduced in v3.17) is a little-endian 64-bit field
105105
composed as follows:
106-
Bit 0: Kernel endianness. 1 if BE, 0 if LE.
106+
Bit 0: Kernel endianness. 1 if BE, 0 if LE.
107107
Bits 1-63: Reserved.
108108

109109
- When image_size is zero, a bootloader should attempt to keep as much
@@ -115,11 +115,14 @@ The Image must be placed text_offset bytes from a 2MB aligned base
115115
address near the start of usable system RAM and called there. Memory
116116
below that base address is currently unusable by Linux, and therefore it
117117
is strongly recommended that this location is the start of system RAM.
118+
The region between the 2 MB aligned base address and the start of the
119+
image has no special significance to the kernel, and may be used for
120+
other purposes.
118121
At least image_size bytes from the start of the image must be free for
119122
use by the kernel.
120123

121-
Any memory described to the kernel (even that below the 2MB aligned base
122-
address) which is not marked as reserved from the kernel e.g. with a
124+
Any memory described to the kernel (even that below the start of the
125+
image) which is not marked as reserved from the kernel (e.g., with a
123126
memreserve region in the device tree) will be considered as available to
124127
the kernel.
125128

‎arch/arm64/Kconfig‎

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ config ARM64
2929
select EDAC_SUPPORT
3030
select GENERIC_ALLOCATOR
3131
select GENERIC_CLOCKEVENTS
32-
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
32+
select GENERIC_CLOCKEVENTS_BROADCAST
3333
select GENERIC_CPU_AUTOPROBE
3434
select GENERIC_EARLY_IOREMAP
3535
select GENERIC_IRQ_PROBE
@@ -54,6 +54,7 @@ config ARM64
5454
select HAVE_C_RECORDMCOUNT
5555
select HAVE_CC_STACKPROTECTOR
5656
select HAVE_CMPXCHG_DOUBLE
57+
select HAVE_CMPXCHG_LOCAL
5758
select HAVE_DEBUG_BUGVERBOSE
5859
select HAVE_DEBUG_KMEMLEAK
5960
select HAVE_DMA_API_DEBUG
@@ -105,6 +106,10 @@ config NO_IOPORT_MAP
105106
config STACKTRACE_SUPPORT
106107
def_bool y
107108

109+
config ILLEGAL_POINTER_VALUE
110+
hex
111+
default 0xdead000000000000
112+
108113
config LOCKDEP_SUPPORT
109114
def_bool y
110115

@@ -114,6 +119,14 @@ config TRACE_IRQFLAGS_SUPPORT
114119
config RWSEM_XCHGADD_ALGORITHM
115120
def_bool y
116121

122+
config GENERIC_BUG
123+
def_bool y
124+
depends on BUG
125+
126+
config GENERIC_BUG_RELATIVE_POINTERS
127+
def_bool y
128+
depends on GENERIC_BUG
129+
117130
config GENERIC_HWEIGHT
118131
def_bool y
119132

@@ -138,6 +151,9 @@ config NEED_DMA_MAP_STATE
138151
config NEED_SG_DMA_LENGTH
139152
def_bool y
140153

154+
config SMP
155+
def_bool y
156+
141157
config SWIOTLB
142158
def_bool y
143159

@@ -372,30 +388,15 @@ config CPU_BIG_ENDIAN
372388
help
373389
Say Y if you plan on running a kernel in big-endian mode.
374390

375-
config SMP
376-
bool "Symmetric Multi-Processing"
377-
help
378-
This enables support for systems with more than one CPU. If
379-
you say N here, the kernel will run on single and
380-
multiprocessor machines, but will use only one CPU of a
381-
multiprocessor machine. If you say Y here, the kernel will run
382-
on many, but not all, single processor machines. On a single
383-
processor machine, the kernel will run faster if you say N
384-
here.
385-
386-
If you don't know what to do here, say N.
387-
388391
config SCHED_MC
389392
bool "Multi-core scheduler support"
390-
depends on SMP
391393
help
392394
Multi-core scheduler support improves the CPU scheduler's decision
393395
making when dealing with multi-core CPU chips at a cost of slightly
394396
increased overhead in some places. If unsure say N here.
395397

396398
config SCHED_SMT
397399
bool "SMT scheduler support"
398-
depends on SMP
399400
help
400401
Improves the CPU scheduler's decision making when dealing with
401402
MultiThreading at a cost of slightly increased overhead in some
@@ -404,23 +405,17 @@ config SCHED_SMT
404405
config NR_CPUS
405406
int "Maximum number of CPUs (2-4096)"
406407
range 2 4096
407-
depends on SMP
408408
# These have to remain sorted largest to smallest
409409
default "64"
410410

411411
config HOTPLUG_CPU
412412
bool "Support for hot-pluggable CPUs"
413-
depends on SMP
414413
help
415414
Say Y here to experiment with turning CPUs off and on. CPUs
416415
can be controlled through /sys/devices/system/cpu.
417416

418417
source kernel/Kconfig.preempt
419418

420-
config UP_LATE_INIT
421-
def_bool y
422-
depends on !SMP
423-
424419
config HZ
425420
int
426421
default 100
@@ -562,6 +557,53 @@ config SETEND_EMULATION
562557
If unsure, say Y
563558
endif
564559

560+
menu "ARMv8.1 architectural features"
561+
562+
config ARM64_HW_AFDBM
563+
bool "Support for hardware updates of the Access and Dirty page flags"
564+
default y
565+
help
566+
The ARMv8.1 architecture extensions introduce support for
567+
hardware updates of the access and dirty information in page
568+
table entries. When enabled in TCR_EL1 (HA and HD bits) on
569+
capable processors, accesses to pages with PTE_AF cleared will
570+
set this bit instead of raising an access flag fault.
571+
Similarly, writes to read-only pages with the DBM bit set will
572+
clear the read-only bit (AP[2]) instead of raising a
573+
permission fault.
574+
575+
Kernels built with this configuration option enabled continue
576+
to work on pre-ARMv8.1 hardware and the performance impact is
577+
minimal. If unsure, say Y.
578+
579+
config ARM64_PAN
580+
bool "Enable support for Privileged Access Never (PAN)"
581+
default y
582+
help
583+
Privileged Access Never (PAN; part of the ARMv8.1 Extensions)
584+
prevents the kernel or hypervisor from accessing user-space (EL0)
585+
memory directly.
586+
587+
Choosing this option will cause any unprotected (not using
588+
copy_to_user et al) memory access to fail with a permission fault.
589+
590+
The feature is detected at runtime, and will remain as a 'nop'
591+
instruction if the cpu does not implement the feature.
592+
593+
config ARM64_LSE_ATOMICS
594+
bool "Atomic instructions"
595+
help
596+
As part of the Large System Extensions, ARMv8.1 introduces new
597+
atomic instructions that are designed specifically to scale in
598+
very large systems.
599+
600+
Say Y here to make use of these instructions for the in-kernel
601+
atomic routines. This incurs a small overhead on CPUs that do
602+
not support these instructions and requires the kernel to be
603+
built with binutils >= 2.25.
604+
605+
endmenu
606+
565607
endmenu
566608

567609
menu "Boot options"

‎arch/arm64/Makefile‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ GZFLAGS :=-9
1717

1818
KBUILD_DEFCONFIG := defconfig
1919

20-
KBUILD_CFLAGS += -mgeneral-regs-only
20+
# Check for binutils support for specific extensions
21+
lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
22+
23+
ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
24+
ifeq ($(lseinstr),)
25+
$(warning LSE atomics not supported by binutils)
26+
endif
27+
endif
28+
29+
KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
30+
KBUILD_AFLAGS += $(lseinstr)
31+
2132
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
2233
KBUILD_CPPFLAGS += -mbig-endian
2334
AS += -EB
@@ -58,7 +69,10 @@ all: $(KBUILD_IMAGE) $(KBUILD_DTBS)
5869

5970
boot := arch/arm64/boot
6071

61-
Image Image.gz: vmlinux
72+
Image: vmlinux
73+
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
74+
75+
Image.%: vmlinux
6276
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
6377

6478
zinstall install: vmlinux

‎arch/arm64/boot/Makefile‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ targets := Image Image.gz
1919
$(obj)/Image: vmlinux FORCE
2020
$(call if_changed,objcopy)
2121

22+
$(obj)/Image.bz2: $(obj)/Image FORCE
23+
$(call if_changed,bzip2)
24+
2225
$(obj)/Image.gz: $(obj)/Image FORCE
2326
$(call if_changed,gzip)
2427

28+
$(obj)/Image.lz4: $(obj)/Image FORCE
29+
$(call if_changed,lz4)
30+
31+
$(obj)/Image.lzma: $(obj)/Image FORCE
32+
$(call if_changed,lzma)
33+
34+
$(obj)/Image.lzo: $(obj)/Image FORCE
35+
$(call if_changed,lzo)
36+
2537
install: $(obj)/Image
2638
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
2739
$(obj)/Image System.map "$(INSTALL_PATH)"

‎arch/arm64/include/asm/alternative.h‎

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#ifndef __ASSEMBLY__
55

6+
#include <linux/init.h>
7+
#include <linux/kconfig.h>
68
#include <linux/types.h>
79
#include <linux/stddef.h>
810
#include <linux/stringify.h>
@@ -15,7 +17,7 @@ struct alt_instr {
1517
u8 alt_len; /* size of new instruction(s), <= orig_len */
1618
};
1719

18-
void apply_alternatives_all(void);
20+
void __init apply_alternatives_all(void);
1921
void apply_alternatives(void *start, size_t length);
2022
void free_alternatives_memory(void);
2123

@@ -40,7 +42,8 @@ void free_alternatives_memory(void);
4042
* be fixed in a binutils release posterior to 2.25.51.0.2 (anything
4143
* containing commit 4e4d08cf7399b606 or c1baaddf8861).
4244
*/
43-
#define ALTERNATIVE(oldinstr, newinstr, feature) \
45+
#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled) \
46+
".if "__stringify(cfg_enabled)" == 1\n" \
4447
"661:\n\t" \
4548
oldinstr "\n" \
4649
"662:\n" \
@@ -53,7 +56,11 @@ void free_alternatives_memory(void);
5356
"664:\n\t" \
5457
".popsection\n\t" \
5558
".org . - (664b-663b) + (662b-661b)\n\t" \
56-
".org . - (662b-661b) + (664b-663b)\n"
59+
".org . - (662b-661b) + (664b-663b)\n" \
60+
".endif\n"
61+
62+
#define _ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg, ...) \
63+
__ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg))
5764

5865
#else
5966

@@ -65,7 +72,8 @@ void free_alternatives_memory(void);
6572
.byte \alt_len
6673
.endm
6774

68-
.macro alternative_insn insn1 insn2 cap
75+
.macro alternative_insn insn1, insn2, cap, enable = 1
76+
.if \enable
6977
661: \insn1
7078
662: .pushsection .altinstructions, "a"
7179
altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f
@@ -75,8 +83,70 @@ void free_alternatives_memory(void);
7583
664: .popsection
7684
.org . - (664b-663b) + (662b-661b)
7785
.org . - (662b-661b) + (664b-663b)
86+
.endif
87+
.endm
88+
89+
/*
90+
* Begin an alternative code sequence.
91+
*
92+
* The code that follows this macro will be assembled and linked as
93+
* normal. There are no restrictions on this code.
94+
*/
95+
.macro alternative_if_not cap, enable = 1
96+
.if \enable
97+
.pushsection .altinstructions, "a"
98+
altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f
99+
.popsection
100+
661:
101+
.endif
102+
.endm
103+
104+
/*
105+
* Provide the alternative code sequence.
106+
*
107+
* The code that follows this macro is assembled into a special
108+
* section to be used for dynamic patching. Code that follows this
109+
* macro must:
110+
*
111+
* 1. Be exactly the same length (in bytes) as the default code
112+
* sequence.
113+
*
114+
* 2. Not contain a branch target that is used outside of the
115+
* alternative sequence it is defined in (branches into an
116+
* alternative sequence are not fixed up).
117+
*/
118+
.macro alternative_else, enable = 1
119+
.if \enable
120+
662: .pushsection .altinstr_replacement, "ax"
121+
663:
122+
.endif
78123
.endm
79124

125+
/*
126+
* Complete an alternative code sequence.
127+
*/
128+
.macro alternative_endif, enable = 1
129+
.if \enable
130+
664: .popsection
131+
.org . - (664b-663b) + (662b-661b)
132+
.org . - (662b-661b) + (664b-663b)
133+
.endif
134+
.endm
135+
136+
#define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...) \
137+
alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
138+
139+
80140
#endif /* __ASSEMBLY__ */
81141

142+
/*
143+
* Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature));
144+
*
145+
* Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature, CONFIG_FOO));
146+
* N.B. If CONFIG_FOO is specified, but not selected, the whole block
147+
* will be omitted, including oldinstr.
148+
*/
149+
#define ALTERNATIVE(oldinstr, newinstr, ...) \
150+
_ALTERNATIVE_CFG(oldinstr, newinstr, __VA_ARGS__, 1)
151+
82152
#endif /* __ASM_ALTERNATIVE_H */

0 commit comments

Comments
 (0)