Skip to content

Commit 9ba733e

Browse files
author
Alex Shi
committed
Merge branch 'v4.4/topic/mm-kaslr' into linux-linaro-lsk-v4.4
2 parents 138f2c3 + 5dd612e commit 9ba733e

120 files changed

Lines changed: 3499 additions & 937 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: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,28 @@ Header notes:
109109
1 - 4K
110110
2 - 16K
111111
3 - 64K
112-
Bits 3-63: Reserved.
112+
Bit 3: Kernel physical placement
113+
0 - 2MB aligned base should be as close as possible
114+
to the base of DRAM, since memory below it is not
115+
accessible via the linear mapping
116+
1 - 2MB aligned base may be anywhere in physical
117+
memory
118+
Bits 4-63: Reserved.
113119

114120
- When image_size is zero, a bootloader should attempt to keep as much
115121
memory as possible free for use by the kernel immediately after the
116122
end of the kernel image. The amount of space required will vary
117123
depending on selected features, and is effectively unbound.
118124

119125
The Image must be placed text_offset bytes from a 2MB aligned base
120-
address near the start of usable system RAM and called there. Memory
121-
below that base address is currently unusable by Linux, and therefore it
122-
is strongly recommended that this location is the start of system RAM.
123-
The region between the 2 MB aligned base address and the start of the
124-
image has no special significance to the kernel, and may be used for
125-
other purposes.
126+
address anywhere in usable system RAM and called there. The region
127+
between the 2 MB aligned base address and the start of the image has no
128+
special significance to the kernel, and may be used for other purposes.
126129
At least image_size bytes from the start of the image must be free for
127130
use by the kernel.
131+
NOTE: versions prior to v4.6 cannot make use of memory below the
132+
physical offset of the Image so it is recommended that the Image be
133+
placed as close as possible to the start of system RAM.
128134

129135
Any memory described to the kernel (even that below the start of the
130136
image) which is not marked as reserved from the kernel (e.g., with a
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Silicon Errata and Software Workarounds
2+
=======================================
3+
4+
Author: Will Deacon <will.deacon@arm.com>
5+
Date : 27 November 2015
6+
7+
It is an unfortunate fact of life that hardware is often produced with
8+
so-called "errata", which can cause it to deviate from the architecture
9+
under specific circumstances. For hardware produced by ARM, these
10+
errata are broadly classified into the following categories:
11+
12+
Category A: A critical error without a viable workaround.
13+
Category B: A significant or critical error with an acceptable
14+
workaround.
15+
Category C: A minor error that is not expected to occur under normal
16+
operation.
17+
18+
For more information, consult one of the "Software Developers Errata
19+
Notice" documents available on infocenter.arm.com (registration
20+
required).
21+
22+
As far as Linux is concerned, Category B errata may require some special
23+
treatment in the operating system. For example, avoiding a particular
24+
sequence of code, or configuring the processor in a particular way. A
25+
less common situation may require similar actions in order to declassify
26+
a Category A erratum into a Category C erratum. These are collectively
27+
known as "software workarounds" and are only required in the minority of
28+
cases (e.g. those cases that both require a non-secure workaround *and*
29+
can be triggered by Linux).
30+
31+
For software workarounds that may adversely impact systems unaffected by
32+
the erratum in question, a Kconfig entry is added under "Kernel
33+
Features" -> "ARM errata workarounds via the alternatives framework".
34+
These are enabled by default and patched in at runtime when an affected
35+
CPU is detected. For less-intrusive workarounds, a Kconfig option is not
36+
available and the code is structured (preferably with a comment) in such
37+
a way that the erratum will not be hit.
38+
39+
This approach can make it slightly onerous to determine exactly which
40+
errata are worked around in an arbitrary kernel source tree, so this
41+
file acts as a registry of software workarounds in the Linux Kernel and
42+
will be updated when new workarounds are committed and backported to
43+
stable kernels.
44+
45+
| Implementor | Component | Erratum ID | Kconfig |
46+
+----------------+-----------------+-----------------+-------------------------+
47+
| ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 |
48+
| ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
49+
| ARM | Cortex-A53 | #824069 | ARM64_ERRATUM_824069 |
50+
| ARM | Cortex-A53 | #819472 | ARM64_ERRATUM_819472 |
51+
| ARM | Cortex-A53 | #845719 | ARM64_ERRATUM_845719 |
52+
| ARM | Cortex-A53 | #843419 | ARM64_ERRATUM_843419 |
53+
| ARM | Cortex-A57 | #832075 | ARM64_ERRATUM_832075 |
54+
| ARM | Cortex-A57 | #852523 | N/A |
55+
| ARM | Cortex-A57 | #834220 | ARM64_ERRATUM_834220 |
56+
| | | | |
57+
| Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 |
58+
| Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 |

Documentation/features/time/irq-time-acct/arch-support.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| alpha: | .. |
1010
| arc: | TODO |
1111
| arm: | ok |
12-
| arm64: | .. |
12+
| arm64: | ok |
1313
| avr32: | TODO |
1414
| blackfin: | TODO |
1515
| c6x: | TODO |

Documentation/features/vm/huge-vmap/arch-support.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| alpha: | TODO |
1010
| arc: | TODO |
1111
| arm: | TODO |
12-
| arm64: | TODO |
12+
| arm64: | ok |
1313
| avr32: | TODO |
1414
| blackfin: | TODO |
1515
| c6x: | TODO |

arch/arm/include/asm/kvm_asm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
#define rr_lo_hi(a1, a2) a1, a2
8080
#endif
8181

82+
#define kvm_ksym_ref(kva) (kva)
83+
8284
#ifndef __ASSEMBLY__
8385
struct kvm;
8486
struct kvm_vcpu;

arch/arm/kvm/arm.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ static void cpu_init_hyp_mode(void *dummy)
969969
pgd_ptr = kvm_mmu_get_httbr();
970970
stack_page = __this_cpu_read(kvm_arm_hyp_stack_page);
971971
hyp_stack_ptr = stack_page + PAGE_SIZE;
972-
vector_ptr = (unsigned long)__kvm_hyp_vector;
972+
vector_ptr = (unsigned long)kvm_ksym_ref(__kvm_hyp_vector);
973973

974974
__cpu_init_hyp_mode(boot_pgd_ptr, pgd_ptr, hyp_stack_ptr, vector_ptr);
975975

@@ -1061,7 +1061,8 @@ static int init_hyp_mode(void)
10611061
/*
10621062
* Map the Hyp-code called directly from the host
10631063
*/
1064-
err = create_hyp_mappings(__kvm_hyp_code_start, __kvm_hyp_code_end);
1064+
err = create_hyp_mappings(kvm_ksym_ref(__kvm_hyp_code_start),
1065+
kvm_ksym_ref(__kvm_hyp_code_end));
10651066
if (err) {
10661067
kvm_err("Cannot map world-switch code\n");
10671068
goto out_free_mappings;

arch/arm64/Kconfig

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config ARM64
1313
select ARCH_WANT_OPTIONAL_GPIOLIB
1414
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
1515
select ARCH_WANT_FRAME_POINTERS
16+
select ARCH_HAS_UBSAN_SANITIZE_ALL
1617
select ARM_AMBA
1718
select ARM_ARCH_TIMER
1819
select ARM_GIC
@@ -48,6 +49,7 @@ config ARM64
4849
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
4950
select HAVE_ARCH_AUDITSYSCALL
5051
select HAVE_ARCH_BITREVERSE
52+
select HAVE_ARCH_HUGE_VMAP
5153
select HAVE_ARCH_JUMP_LABEL
5254
select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
5355
select HAVE_ARCH_KGDB
@@ -70,6 +72,7 @@ config ARM64
7072
select HAVE_FUNCTION_GRAPH_TRACER
7173
select HAVE_GENERIC_DMA_COHERENT
7274
select HAVE_HW_BREAKPOINT if PERF_EVENTS
75+
select HAVE_IRQ_TIME_ACCOUNTING
7376
select HAVE_MEMBLOCK
7477
select HAVE_PATA_PLATFORM
7578
select HAVE_PERF_EVENTS
@@ -362,6 +365,7 @@ config ARM64_ERRATUM_843419
362365
bool "Cortex-A53: 843419: A load or store might access an incorrect address"
363366
depends on MODULES
364367
default y
368+
select ARM64_MODULE_CMODEL_LARGE
365369
help
366370
This option builds kernel modules using the large memory model in
367371
order to avoid the use of the ADRP instruction, which can cause
@@ -506,6 +510,9 @@ config HOTPLUG_CPU
506510
source kernel/Kconfig.preempt
507511
source kernel/Kconfig.hz
508512

513+
config ARCH_SUPPORTS_DEBUG_PAGEALLOC
514+
def_bool y
515+
509516
config ARCH_HAS_HOLES_MEMORYMODEL
510517
def_bool y if SPARSEMEM
511518

@@ -529,9 +536,6 @@ config HW_PERF_EVENTS
529536
config SYS_SUPPORTS_HUGETLBFS
530537
def_bool y
531538

532-
config ARCH_WANT_GENERAL_HUGETLB
533-
def_bool y
534-
535539
config ARCH_WANT_HUGE_PMD_SHARE
536540
def_bool y if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
537541

@@ -704,10 +708,93 @@ config ARM64_LSE_ATOMICS
704708

705709
endmenu
706710

711+
config ARM64_UAO
712+
bool "Enable support for User Access Override (UAO)"
713+
default y
714+
help
715+
User Access Override (UAO; part of the ARMv8.2 Extensions)
716+
causes the 'unprivileged' variant of the load/store instructions to
717+
be overriden to be privileged.
718+
719+
This option changes get_user() and friends to use the 'unprivileged'
720+
variant of the load/store instructions. This ensures that user-space
721+
really did have access to the supplied memory. When addr_limit is
722+
set to kernel memory the UAO bit will be set, allowing privileged
723+
access to kernel memory.
724+
725+
Choosing this option will cause copy_to_user() et al to use user-space
726+
memory permissions.
727+
728+
The feature is detected at runtime, the kernel will use the
729+
regular load/store instructions if the cpu does not implement the
730+
feature.
731+
732+
config ARM64_MODULE_CMODEL_LARGE
733+
bool
734+
735+
config ARM64_MODULE_PLTS
736+
bool
737+
select ARM64_MODULE_CMODEL_LARGE
738+
select HAVE_MOD_ARCH_SPECIFIC
739+
740+
config RELOCATABLE
741+
bool
742+
help
743+
This builds the kernel as a Position Independent Executable (PIE),
744+
which retains all relocation metadata required to relocate the
745+
kernel binary at runtime to a different virtual address than the
746+
address it was linked at.
747+
Since AArch64 uses the RELA relocation format, this requires a
748+
relocation pass at runtime even if the kernel is loaded at the
749+
same address it was linked at.
750+
751+
config RANDOMIZE_BASE
752+
bool "Randomize the address of the kernel image"
753+
select ARM64_MODULE_PLTS
754+
select RELOCATABLE
755+
help
756+
Randomizes the virtual address at which the kernel image is
757+
loaded, as a security feature that deters exploit attempts
758+
relying on knowledge of the location of kernel internals.
759+
760+
It is the bootloader's job to provide entropy, by passing a
761+
random u64 value in /chosen/kaslr-seed at kernel entry.
762+
763+
When booting via the UEFI stub, it will invoke the firmware's
764+
EFI_RNG_PROTOCOL implementation (if available) to supply entropy
765+
to the kernel proper. In addition, it will randomise the physical
766+
location of the kernel Image as well.
767+
768+
If unsure, say N.
769+
770+
config RANDOMIZE_MODULE_REGION_FULL
771+
bool "Randomize the module region independently from the core kernel"
772+
depends on RANDOMIZE_BASE
773+
default y
774+
help
775+
Randomizes the location of the module region without considering the
776+
location of the core kernel. This way, it is impossible for modules
777+
to leak information about the location of core kernel data structures
778+
but it does imply that function calls between modules and the core
779+
kernel will need to be resolved via veneers in the module PLT.
780+
781+
When this option is not set, the module region will be randomized over
782+
a limited range that contains the [_stext, _etext] interval of the
783+
core kernel, so branch relocations are always in range.
784+
707785
endmenu
708786

709787
menu "Boot options"
710788

789+
config ARM64_ACPI_PARKING_PROTOCOL
790+
bool "Enable support for the ARM64 ACPI parking protocol"
791+
depends on ACPI
792+
help
793+
Enable support for the ARM64 ACPI parking protocol. If disabled
794+
the kernel will not allow booting through the ARM64 ACPI parking
795+
protocol even if the corresponding data is present in the ACPI
796+
MADT table.
797+
711798
config CMDLINE
712799
string "Default kernel command string"
713800
default ""

arch/arm64/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
1515
OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
1616
GZFLAGS :=-9
1717

18+
ifneq ($(CONFIG_RELOCATABLE),)
19+
LDFLAGS_vmlinux += -pie
20+
endif
21+
1822
KBUILD_DEFCONFIG := defconfig
1923

2024
# Check for binutils support for specific extensions
@@ -28,6 +32,7 @@ endif
2832

2933
KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
3034
KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
35+
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
3136
KBUILD_AFLAGS += $(lseinstr)
3237

3338
ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
@@ -42,10 +47,14 @@ endif
4247

4348
CHECKFLAGS += -D__aarch64__
4449

45-
ifeq ($(CONFIG_ARM64_ERRATUM_843419), y)
50+
ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
4651
KBUILD_CFLAGS_MODULE += -mcmodel=large
4752
endif
4853

54+
ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
55+
KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds
56+
endif
57+
4958
# Default value
5059
head-y := arch/arm64/kernel/head.o
5160

arch/arm64/include/asm/acpi.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,26 @@ void __init acpi_init_cpus(void);
8787
static inline void acpi_init_cpus(void) { }
8888
#endif /* CONFIG_ACPI */
8989

90+
#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
91+
bool acpi_parking_protocol_valid(int cpu);
92+
void __init
93+
acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
94+
#else
95+
static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
96+
static inline void
97+
acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
98+
{}
99+
#endif
100+
90101
static inline const char *acpi_get_enable_method(int cpu)
91102
{
92-
return acpi_psci_present() ? "psci" : NULL;
103+
if (acpi_psci_present())
104+
return "psci";
105+
106+
if (acpi_parking_protocol_valid(cpu))
107+
return "parking-protocol";
108+
109+
return NULL;
93110
}
94111

95112
#ifdef CONFIG_ACPI_APEI

0 commit comments

Comments
 (0)