Skip to content

Commit f4000cd

Browse files
committed
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 updates from Catalin Marinas: - struct thread_info moved off-stack (also touching include/linux/thread_info.h and include/linux/restart_block.h) - cpus_have_cap() reworked to avoid __builtin_constant_p() for static key use (also touching drivers/irqchip/irq-gic-v3.c) - uprobes support (currently only for native 64-bit tasks) - Emulation of kernel Privileged Access Never (PAN) using TTBR0_EL1 switching to a reserved page table - CPU capacity information passing via DT or sysfs (used by the scheduler) - support for systems without FP/SIMD (IOW, kernel avoids touching these registers; there is no soft-float ABI, nor kernel emulation for AArch64 FP/SIMD) - handling of hardware watchpoint with unaligned addresses, varied lengths and offsets from base - use of the page table contiguous hint for kernel mappings - hugetlb fixes for sizes involving the contiguous hint - remove unnecessary I-cache invalidation in flush_cache_range() - CNTHCTL_EL2 access fix for CPUs with VHE support (ARMv8.1) - boot-time checks for writable+executable kernel mappings - simplify asm/opcodes.h and avoid including the 32-bit ARM counterpart and make the arm64 kernel headers self-consistent (Xen headers patch merged separately) - Workaround for broken .inst support in certain binutils versions * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (60 commits) arm64: Disable PAN on uaccess_enable() arm64: Work around broken .inst when defective gas is detected arm64: Add detection code for broken .inst support in binutils arm64: Remove reference to asm/opcodes.h arm64: Get rid of asm/opcodes.h arm64: smp: Prevent raw_smp_processor_id() recursion arm64: head.S: Fix CNTHCTL_EL2 access on VHE system arm64: Remove I-cache invalidation from flush_cache_range() arm64: Enable HIBERNATION in defconfig arm64: Enable CONFIG_ARM64_SW_TTBR0_PAN arm64: xen: Enable user access before a privcmd hvc call arm64: Handle faults caused by inadvertent user access with PAN enabled arm64: Disable TTBR0_EL1 during normal kernel execution arm64: Introduce uaccess_{disable,enable} functionality based on TTBR0_EL1 arm64: Factor out TTBR0_EL1 post-update workaround into a specific asm macro arm64: Factor out PAN enabling/disabling into separate uaccess_* macros arm64: Update the synchronous external abort fault description selftests: arm64: add test for unaligned/inexact watchpoint handling arm64: Allow hw watchpoint of length 3,5,6 and 7 arm64: hw_breakpoint: Handle inexact watchpoint addresses ...
2 parents 2ec4584 + 7503712 commit f4000cd

Some content is hidden

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

90 files changed

+2284
-525
lines changed
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
==========================================
2+
ARM CPUs capacity bindings
3+
==========================================
4+
5+
==========================================
6+
1 - Introduction
7+
==========================================
8+
9+
ARM systems may be configured to have cpus with different power/performance
10+
characteristics within the same chip. In this case, additional information has
11+
to be made available to the kernel for it to be aware of such differences and
12+
take decisions accordingly.
13+
14+
==========================================
15+
2 - CPU capacity definition
16+
==========================================
17+
18+
CPU capacity is a number that provides the scheduler information about CPUs
19+
heterogeneity. Such heterogeneity can come from micro-architectural differences
20+
(e.g., ARM big.LITTLE systems) or maximum frequency at which CPUs can run
21+
(e.g., SMP systems with multiple frequency domains). Heterogeneity in this
22+
context is about differing performance characteristics; this binding tries to
23+
capture a first-order approximation of the relative performance of CPUs.
24+
25+
CPU capacities are obtained by running a suitable benchmark. This binding makes
26+
no guarantees on the validity or suitability of any particular benchmark, the
27+
final capacity should, however, be:
28+
29+
* A "single-threaded" or CPU affine benchmark
30+
* Divided by the running frequency of the CPU executing the benchmark
31+
* Not subject to dynamic frequency scaling of the CPU
32+
33+
For the time being we however advise usage of the Dhrystone benchmark. What
34+
above thus becomes:
35+
36+
CPU capacities are obtained by running the Dhrystone benchmark on each CPU at
37+
max frequency (with caches enabled). The obtained DMIPS score is then divided
38+
by the frequency (in MHz) at which the benchmark has been run, so that
39+
DMIPS/MHz are obtained. Such values are then normalized w.r.t. the highest
40+
score obtained in the system.
41+
42+
==========================================
43+
3 - capacity-dmips-mhz
44+
==========================================
45+
46+
capacity-dmips-mhz is an optional cpu node [1] property: u32 value
47+
representing CPU capacity expressed in normalized DMIPS/MHz. At boot time, the
48+
maximum frequency available to the cpu is then used to calculate the capacity
49+
value internally used by the kernel.
50+
51+
capacity-dmips-mhz property is all-or-nothing: if it is specified for a cpu
52+
node, it has to be specified for every other cpu nodes, or the system will
53+
fall back to the default capacity value for every CPU. If cpufreq is not
54+
available, final capacities are calculated by directly using capacity-dmips-
55+
mhz values (normalized w.r.t. the highest value found while parsing the DT).
56+
57+
===========================================
58+
4 - Examples
59+
===========================================
60+
61+
Example 1 (ARM 64-bit, 6-cpu system, two clusters):
62+
capacities-dmips-mhz are scaled w.r.t. 1024 (cpu@0 and cpu@1)
63+
supposing cluster0@max-freq=1100 and custer1@max-freq=850,
64+
final capacities are 1024 for cluster0 and 446 for cluster1
65+
66+
cpus {
67+
#address-cells = <2>;
68+
#size-cells = <0>;
69+
70+
cpu-map {
71+
cluster0 {
72+
core0 {
73+
cpu = <&A57_0>;
74+
};
75+
core1 {
76+
cpu = <&A57_1>;
77+
};
78+
};
79+
80+
cluster1 {
81+
core0 {
82+
cpu = <&A53_0>;
83+
};
84+
core1 {
85+
cpu = <&A53_1>;
86+
};
87+
core2 {
88+
cpu = <&A53_2>;
89+
};
90+
core3 {
91+
cpu = <&A53_3>;
92+
};
93+
};
94+
};
95+
96+
idle-states {
97+
entry-method = "arm,psci";
98+
99+
CPU_SLEEP_0: cpu-sleep-0 {
100+
compatible = "arm,idle-state";
101+
arm,psci-suspend-param = <0x0010000>;
102+
local-timer-stop;
103+
entry-latency-us = <100>;
104+
exit-latency-us = <250>;
105+
min-residency-us = <150>;
106+
};
107+
108+
CLUSTER_SLEEP_0: cluster-sleep-0 {
109+
compatible = "arm,idle-state";
110+
arm,psci-suspend-param = <0x1010000>;
111+
local-timer-stop;
112+
entry-latency-us = <800>;
113+
exit-latency-us = <700>;
114+
min-residency-us = <2500>;
115+
};
116+
};
117+
118+
A57_0: cpu@0 {
119+
compatible = "arm,cortex-a57","arm,armv8";
120+
reg = <0x0 0x0>;
121+
device_type = "cpu";
122+
enable-method = "psci";
123+
next-level-cache = <&A57_L2>;
124+
clocks = <&scpi_dvfs 0>;
125+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
126+
capacity-dmips-mhz = <1024>;
127+
};
128+
129+
A57_1: cpu@1 {
130+
compatible = "arm,cortex-a57","arm,armv8";
131+
reg = <0x0 0x1>;
132+
device_type = "cpu";
133+
enable-method = "psci";
134+
next-level-cache = <&A57_L2>;
135+
clocks = <&scpi_dvfs 0>;
136+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
137+
capacity-dmips-mhz = <1024>;
138+
};
139+
140+
A53_0: cpu@100 {
141+
compatible = "arm,cortex-a53","arm,armv8";
142+
reg = <0x0 0x100>;
143+
device_type = "cpu";
144+
enable-method = "psci";
145+
next-level-cache = <&A53_L2>;
146+
clocks = <&scpi_dvfs 1>;
147+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
148+
capacity-dmips-mhz = <578>;
149+
};
150+
151+
A53_1: cpu@101 {
152+
compatible = "arm,cortex-a53","arm,armv8";
153+
reg = <0x0 0x101>;
154+
device_type = "cpu";
155+
enable-method = "psci";
156+
next-level-cache = <&A53_L2>;
157+
clocks = <&scpi_dvfs 1>;
158+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
159+
capacity-dmips-mhz = <578>;
160+
};
161+
162+
A53_2: cpu@102 {
163+
compatible = "arm,cortex-a53","arm,armv8";
164+
reg = <0x0 0x102>;
165+
device_type = "cpu";
166+
enable-method = "psci";
167+
next-level-cache = <&A53_L2>;
168+
clocks = <&scpi_dvfs 1>;
169+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
170+
capacity-dmips-mhz = <578>;
171+
};
172+
173+
A53_3: cpu@103 {
174+
compatible = "arm,cortex-a53","arm,armv8";
175+
reg = <0x0 0x103>;
176+
device_type = "cpu";
177+
enable-method = "psci";
178+
next-level-cache = <&A53_L2>;
179+
clocks = <&scpi_dvfs 1>;
180+
cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>;
181+
capacity-dmips-mhz = <578>;
182+
};
183+
184+
A57_L2: l2-cache0 {
185+
compatible = "cache";
186+
};
187+
188+
A53_L2: l2-cache1 {
189+
compatible = "cache";
190+
};
191+
};
192+
193+
Example 2 (ARM 32-bit, 4-cpu system, two clusters,
194+
cpus 0,1@1GHz, cpus 2,3@500MHz):
195+
capacities-dmips-mhz are scaled w.r.t. 2 (cpu@0 and cpu@1), this means that first
196+
cpu@0 and cpu@1 are twice fast than cpu@2 and cpu@3 (at the same frequency)
197+
198+
cpus {
199+
#address-cells = <1>;
200+
#size-cells = <0>;
201+
202+
cpu0: cpu@0 {
203+
device_type = "cpu";
204+
compatible = "arm,cortex-a15";
205+
reg = <0>;
206+
capacity-dmips-mhz = <2>;
207+
};
208+
209+
cpu1: cpu@1 {
210+
device_type = "cpu";
211+
compatible = "arm,cortex-a15";
212+
reg = <1>;
213+
capacity-dmips-mhz = <2>;
214+
};
215+
216+
cpu2: cpu@2 {
217+
device_type = "cpu";
218+
compatible = "arm,cortex-a15";
219+
reg = <0x100>;
220+
capacity-dmips-mhz = <1>;
221+
};
222+
223+
cpu3: cpu@3 {
224+
device_type = "cpu";
225+
compatible = "arm,cortex-a15";
226+
reg = <0x101>;
227+
capacity-dmips-mhz = <1>;
228+
};
229+
};
230+
231+
===========================================
232+
5 - References
233+
===========================================
234+
235+
[1] ARM Linux Kernel documentation - CPUs bindings
236+
Documentation/devicetree/bindings/arm/cpus.txt

Documentation/devicetree/bindings/arm/cpus.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ nodes to be present and contain the properties described below.
241241
# List of phandles to idle state nodes supported
242242
by this cpu [3].
243243

244+
- capacity-dmips-mhz
245+
Usage: Optional
246+
Value type: <u32>
247+
Definition:
248+
# u32 value representing CPU capacity [3] in
249+
DMIPS/MHz, relative to highest capacity-dmips-mhz
250+
in the system.
251+
244252
- rockchip,pmu
245253
Usage: optional for systems that have an "enable-method"
246254
property value of "rockchip,rk3066-smp"
@@ -464,3 +472,5 @@ cpus {
464472
[2] arm/msm/qcom,kpss-acc.txt
465473
[3] ARM Linux kernel documentation - idle states bindings
466474
Documentation/devicetree/bindings/arm/idle-states.txt
475+
[3] ARM Linux kernel documentation - cpu capacity bindings
476+
Documentation/devicetree/bindings/arm/cpu-capacity.txt

arch/arm64/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ config ARM64
110110
select POWER_SUPPLY
111111
select SPARSE_IRQ
112112
select SYSCTL_EXCEPTION_TRACE
113+
select THREAD_INFO_IN_TASK
113114
help
114115
ARM 64-bit (AArch64) Linux support.
115116

@@ -239,6 +240,9 @@ config PGTABLE_LEVELS
239240
default 3 if ARM64_16K_PAGES && ARM64_VA_BITS_47
240241
default 4 if !ARM64_64K_PAGES && ARM64_VA_BITS_48
241242

243+
config ARCH_SUPPORTS_UPROBES
244+
def_bool y
245+
242246
source "init/Kconfig"
243247

244248
source "kernel/Kconfig.freezer"
@@ -791,6 +795,14 @@ config SETEND_EMULATION
791795
If unsure, say Y
792796
endif
793797

798+
config ARM64_SW_TTBR0_PAN
799+
bool "Emulate Privileged Access Never using TTBR0_EL1 switching"
800+
help
801+
Enabling this option prevents the kernel from accessing
802+
user-space memory directly by pointing TTBR0_EL1 to a reserved
803+
zeroed area and reserved ASID. The user access routines
804+
restore the valid TTBR0_EL1 temporarily.
805+
794806
menu "ARMv8.1 architectural features"
795807

796808
config ARM64_HW_AFDBM

arch/arm64/Kconfig.debug

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ menu "Kernel hacking"
22

33
source "lib/Kconfig.debug"
44

5-
config ARM64_PTDUMP
5+
config ARM64_PTDUMP_CORE
6+
def_bool n
7+
8+
config ARM64_PTDUMP_DEBUGFS
69
bool "Export kernel pagetable layout to userspace via debugfs"
710
depends on DEBUG_KERNEL
11+
select ARM64_PTDUMP_CORE
812
select DEBUG_FS
913
help
1014
Say Y here if you want to show the kernel pagetable layout in a
@@ -38,6 +42,35 @@ config ARM64_RANDOMIZE_TEXT_OFFSET
3842
of TEXT_OFFSET and platforms must not require a specific
3943
value.
4044

45+
config DEBUG_WX
46+
bool "Warn on W+X mappings at boot"
47+
select ARM64_PTDUMP_CORE
48+
---help---
49+
Generate a warning if any W+X mappings are found at boot.
50+
51+
This is useful for discovering cases where the kernel is leaving
52+
W+X mappings after applying NX, as such mappings are a security risk.
53+
This check also includes UXN, which should be set on all kernel
54+
mappings.
55+
56+
Look for a message in dmesg output like this:
57+
58+
arm64/mm: Checked W+X mappings: passed, no W+X pages found.
59+
60+
or like this, if the check failed:
61+
62+
arm64/mm: Checked W+X mappings: FAILED, <N> W+X pages found.
63+
64+
Note that even if the check fails, your kernel is possibly
65+
still fine, as W+X mappings are not a security hole in
66+
themselves, what they do is that they make the exploitation
67+
of other unfixed kernel bugs easier.
68+
69+
There is no runtime or memory usage effect of this option
70+
once the kernel has booted up - it's a one time check.
71+
72+
If in doubt, say "Y".
73+
4174
config DEBUG_SET_MODULE_RONX
4275
bool "Set loadable kernel module data as NX and text as RO"
4376
depends on MODULES

arch/arm64/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ $(warning LSE atomics not supported by binutils)
3737
endif
3838
endif
3939

40-
KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
40+
brokengasinst := $(call as-instr,1:\n.inst 0\n.rept . - 1b\n\nnop\n.endr\n,,-DCONFIG_BROKEN_GAS_INST=1)
41+
42+
ifneq ($(brokengasinst),)
43+
$(warning Detected assembler with broken .inst; disassembly will be unreliable)
44+
endif
45+
46+
KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst)
4147
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
4248
KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
43-
KBUILD_AFLAGS += $(lseinstr)
49+
KBUILD_AFLAGS += $(lseinstr) $(brokengasinst)
4450

4551
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
4652
KBUILD_CPPFLAGS += -mbig-endian

arch/arm64/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CONFIG_KEXEC=y
8282
# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
8383
CONFIG_COMPAT=y
8484
CONFIG_CPU_IDLE=y
85+
CONFIG_HIBERNATION=y
8586
CONFIG_ARM_CPUIDLE=y
8687
CONFIG_CPU_FREQ=y
8788
CONFIG_CPUFREQ_DT=y

arch/arm64/include/asm/Kbuild

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
generic-y += bugs.h
22
generic-y += clkdev.h
33
generic-y += cputime.h
4-
generic-y += current.h
54
generic-y += delay.h
65
generic-y += div64.h
76
generic-y += dma.h

0 commit comments

Comments
 (0)