Skip to content

Commit 588ab3f

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: "Here are the main arm64 updates for 4.6. There are some relatively intrusive changes to support KASLR, the reworking of the kernel virtual memory layout and initial page table creation. Summary: - Initial page table creation reworked to avoid breaking large block mappings (huge pages) into smaller ones. The ARM architecture requires break-before-make in such cases to avoid TLB conflicts but that's not always possible on live page tables - Kernel virtual memory layout: the kernel image is no longer linked to the bottom of the linear mapping (PAGE_OFFSET) but at the bottom of the vmalloc space, allowing the kernel to be loaded (nearly) anywhere in physical RAM - Kernel ASLR: position independent kernel Image and modules being randomly mapped in the vmalloc space with the randomness is provided by UEFI (efi_get_random_bytes() patches merged via the arm64 tree, acked by Matt Fleming) - Implement relative exception tables for arm64, required by KASLR (initial code for ARCH_HAS_RELATIVE_EXTABLE added to lib/extable.c but actual x86 conversion to deferred to 4.7 because of the merge dependencies) - Support for the User Access Override feature of ARMv8.2: this allows uaccess functions (get_user etc.) to be implemented using LDTR/STTR instructions. Such instructions, when run by the kernel, perform unprivileged accesses adding an extra level of protection. The set_fs() macro is used to "upgrade" such instruction to privileged accesses via the UAO bit - Half-precision floating point support (part of ARMv8.2) - Optimisations for CPUs with or without a hardware prefetcher (using run-time code patching) - copy_page performance improvement to deal with 128 bytes at a time - Sanity checks on the CPU capabilities (via CPUID) to prevent incompatible secondary CPUs from being brought up (e.g. weird big.LITTLE configurations) - valid_user_regs() reworked for better sanity check of the sigcontext information (restored pstate information) - ACPI parking protocol implementation - CONFIG_DEBUG_RODATA enabled by default - VDSO code marked as read-only - DEBUG_PAGEALLOC support - ARCH_HAS_UBSAN_SANITIZE_ALL enabled - Erratum workaround Cavium ThunderX SoC - set_pte_at() fix for PROT_NONE mappings - Code clean-ups" * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (99 commits) arm64: kasan: Fix zero shadow mapping overriding kernel image shadow arm64: kasan: Use actual memory node when populating the kernel image shadow arm64: Update PTE_RDONLY in set_pte_at() for PROT_NONE permission arm64: Fix misspellings in comments. arm64: efi: add missing frame pointer assignment arm64: make mrs_s prefixing implicit in read_cpuid arm64: enable CONFIG_DEBUG_RODATA by default arm64: Rework valid_user_regs arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly arm64: KVM: Move kvm_call_hyp back to its original localtion arm64: mm: treat memstart_addr as a signed quantity arm64: mm: list kernel sections in order arm64: lse: deal with clobbered IP registers after branch via PLT arm64: mm: dump: Use VA_START directly instead of private LOWEST_ADDR arm64: kconfig: add submenu for 8.2 architectural features arm64: kernel: acpi: fix ioremap in ACPI parking protocol cpu_postboot arm64: Add support for Half precision floating point arm64: Remove fixmap include fragility arm64: Add workaround for Cavium erratum 27456 arm64: mm: Mark .rodata as RO ...
2 parents 3d15cfd + 2776e0e commit 588ab3f

Some content is hidden

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

106 files changed

+3128
-900
lines changed

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

Documentation/arm64/silicon-errata.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ stable kernels.
5656
| | | | |
5757
| Cavium | ThunderX ITS | #22375, #24313 | CAVIUM_ERRATUM_22375 |
5858
| Cavium | ThunderX GICv3 | #23154 | CAVIUM_ERRATUM_23154 |
59+
| Cavium | ThunderX Core | #27456 | CAVIUM_ERRATUM_27456 |

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
@@ -48,6 +48,8 @@
4848
#define rr_lo_hi(a1, a2) a1, a2
4949
#endif
5050

51+
#define kvm_ksym_ref(kva) (kva)
52+
5153
#ifndef __ASSEMBLY__
5254
struct kvm;
5355
struct kvm_vcpu;

arch/arm/kvm/arm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static void cpu_init_hyp_mode(void *dummy)
10511051
pgd_ptr = kvm_mmu_get_httbr();
10521052
stack_page = __this_cpu_read(kvm_arm_hyp_stack_page);
10531053
hyp_stack_ptr = stack_page + PAGE_SIZE;
1054-
vector_ptr = (unsigned long)__kvm_hyp_vector;
1054+
vector_ptr = (unsigned long)kvm_ksym_ref(__kvm_hyp_vector);
10551055

10561056
__cpu_init_hyp_mode(boot_pgd_ptr, pgd_ptr, hyp_stack_ptr, vector_ptr);
10571057
__cpu_init_stage2();
@@ -1220,13 +1220,15 @@ static int init_hyp_mode(void)
12201220
/*
12211221
* Map the Hyp-code called directly from the host
12221222
*/
1223-
err = create_hyp_mappings(__hyp_text_start, __hyp_text_end);
1223+
err = create_hyp_mappings(kvm_ksym_ref(__hyp_text_start),
1224+
kvm_ksym_ref(__hyp_text_end));
12241225
if (err) {
12251226
kvm_err("Cannot map world-switch code\n");
12261227
goto out_err;
12271228
}
12281229

1229-
err = create_hyp_mappings(__start_rodata, __end_rodata);
1230+
err = create_hyp_mappings(kvm_ksym_ref(__start_rodata),
1231+
kvm_ksym_ref(__end_rodata));
12301232
if (err) {
12311233
kvm_err("Cannot map rodata section\n");
12321234
goto out_err;

arch/arm64/Kconfig

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config ARM64
1414
select ARCH_WANT_OPTIONAL_GPIOLIB
1515
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
1616
select ARCH_WANT_FRAME_POINTERS
17+
select ARCH_HAS_UBSAN_SANITIZE_ALL
1718
select ARM_AMBA
1819
select ARM_ARCH_TIMER
1920
select ARM_GIC
@@ -49,6 +50,7 @@ config ARM64
4950
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
5051
select HAVE_ARCH_AUDITSYSCALL
5152
select HAVE_ARCH_BITREVERSE
53+
select HAVE_ARCH_HUGE_VMAP
5254
select HAVE_ARCH_JUMP_LABEL
5355
select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
5456
select HAVE_ARCH_KGDB
@@ -391,6 +393,7 @@ config ARM64_ERRATUM_843419
391393
bool "Cortex-A53: 843419: A load or store might access an incorrect address"
392394
depends on MODULES
393395
default y
396+
select ARM64_MODULE_CMODEL_LARGE
394397
help
395398
This option builds kernel modules using the large memory model in
396399
order to avoid the use of the ADRP instruction, which can cause
@@ -430,6 +433,17 @@ config CAVIUM_ERRATUM_23154
430433

431434
If unsure, say Y.
432435

436+
config CAVIUM_ERRATUM_27456
437+
bool "Cavium erratum 27456: Broadcast TLBI instructions may cause icache corruption"
438+
default y
439+
help
440+
On ThunderX T88 pass 1.x through 2.1 parts, broadcast TLBI
441+
instructions may cause the icache to become corrupted if it
442+
contains data for a non-current ASID. The fix is to
443+
invalidate the icache when changing the mm context.
444+
445+
If unsure, say Y.
446+
433447
endmenu
434448

435449

@@ -535,6 +549,9 @@ config HOTPLUG_CPU
535549
source kernel/Kconfig.preempt
536550
source kernel/Kconfig.hz
537551

552+
config ARCH_SUPPORTS_DEBUG_PAGEALLOC
553+
def_bool y
554+
538555
config ARCH_HAS_HOLES_MEMORYMODEL
539556
def_bool y if SPARSEMEM
540557

@@ -763,10 +780,97 @@ config ARM64_VHE
763780

764781
endmenu
765782

783+
menu "ARMv8.2 architectural features"
784+
785+
config ARM64_UAO
786+
bool "Enable support for User Access Override (UAO)"
787+
default y
788+
help
789+
User Access Override (UAO; part of the ARMv8.2 Extensions)
790+
causes the 'unprivileged' variant of the load/store instructions to
791+
be overriden to be privileged.
792+
793+
This option changes get_user() and friends to use the 'unprivileged'
794+
variant of the load/store instructions. This ensures that user-space
795+
really did have access to the supplied memory. When addr_limit is
796+
set to kernel memory the UAO bit will be set, allowing privileged
797+
access to kernel memory.
798+
799+
Choosing this option will cause copy_to_user() et al to use user-space
800+
memory permissions.
801+
802+
The feature is detected at runtime, the kernel will use the
803+
regular load/store instructions if the cpu does not implement the
804+
feature.
805+
806+
endmenu
807+
808+
config ARM64_MODULE_CMODEL_LARGE
809+
bool
810+
811+
config ARM64_MODULE_PLTS
812+
bool
813+
select ARM64_MODULE_CMODEL_LARGE
814+
select HAVE_MOD_ARCH_SPECIFIC
815+
816+
config RELOCATABLE
817+
bool
818+
help
819+
This builds the kernel as a Position Independent Executable (PIE),
820+
which retains all relocation metadata required to relocate the
821+
kernel binary at runtime to a different virtual address than the
822+
address it was linked at.
823+
Since AArch64 uses the RELA relocation format, this requires a
824+
relocation pass at runtime even if the kernel is loaded at the
825+
same address it was linked at.
826+
827+
config RANDOMIZE_BASE
828+
bool "Randomize the address of the kernel image"
829+
select ARM64_MODULE_PLTS
830+
select RELOCATABLE
831+
help
832+
Randomizes the virtual address at which the kernel image is
833+
loaded, as a security feature that deters exploit attempts
834+
relying on knowledge of the location of kernel internals.
835+
836+
It is the bootloader's job to provide entropy, by passing a
837+
random u64 value in /chosen/kaslr-seed at kernel entry.
838+
839+
When booting via the UEFI stub, it will invoke the firmware's
840+
EFI_RNG_PROTOCOL implementation (if available) to supply entropy
841+
to the kernel proper. In addition, it will randomise the physical
842+
location of the kernel Image as well.
843+
844+
If unsure, say N.
845+
846+
config RANDOMIZE_MODULE_REGION_FULL
847+
bool "Randomize the module region independently from the core kernel"
848+
depends on RANDOMIZE_BASE
849+
default y
850+
help
851+
Randomizes the location of the module region without considering the
852+
location of the core kernel. This way, it is impossible for modules
853+
to leak information about the location of core kernel data structures
854+
but it does imply that function calls between modules and the core
855+
kernel will need to be resolved via veneers in the module PLT.
856+
857+
When this option is not set, the module region will be randomized over
858+
a limited range that contains the [_stext, _etext] interval of the
859+
core kernel, so branch relocations are always in range.
860+
766861
endmenu
767862

768863
menu "Boot options"
769864

865+
config ARM64_ACPI_PARKING_PROTOCOL
866+
bool "Enable support for the ARM64 ACPI parking protocol"
867+
depends on ACPI
868+
help
869+
Enable support for the ARM64 ACPI parking protocol. If disabled
870+
the kernel will not allow booting through the ARM64 ACPI parking
871+
protocol even if the corresponding data is present in the ACPI
872+
MADT table.
873+
770874
config CMDLINE
771875
string "Default kernel command string"
772876
default ""

arch/arm64/Kconfig.debug

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ config DEBUG_SET_MODULE_RONX
5050

5151
config DEBUG_RODATA
5252
bool "Make kernel text and rodata read-only"
53+
default y
5354
help
5455
If this is set, kernel text and rodata will be made read-only. This
5556
is to help catch accidental or malicious attempts to change the
56-
kernel's executable code. Additionally splits rodata from kernel
57-
text so it can be made explicitly non-executable.
57+
kernel's executable code.
5858

59-
If in doubt, say Y
59+
If in doubt, say Y
6060

6161
config DEBUG_ALIGN_RODATA
6262
depends on DEBUG_RODATA && ARM64_4K_PAGES

arch/arm64/Makefile

Lines changed: 9 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
@@ -43,10 +47,14 @@ endif
4347

4448
CHECKFLAGS += -D__aarch64__
4549

46-
ifeq ($(CONFIG_ARM64_ERRATUM_843419), y)
50+
ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y)
4751
KBUILD_CFLAGS_MODULE += -mcmodel=large
4852
endif
4953

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

arch/arm64/boot/dts/nvidia/tegra132.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
/*
314314
* There are two serial driver i.e. 8250 based simple serial
315315
* driver and APB DMA based serial driver for higher baudrate
316-
* and performace. To enable the 8250 based driver, the compatible
316+
* and performance. To enable the 8250 based driver, the compatible
317317
* is "nvidia,tegra124-uart", "nvidia,tegra20-uart" and to enable
318318
* the APB DMA based serial driver, the comptible is
319319
* "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart".

arch/arm64/boot/dts/nvidia/tegra210.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
/*
346346
* There are two serial driver i.e. 8250 based simple serial
347347
* driver and APB DMA based serial driver for higher baudrate
348-
* and performace. To enable the 8250 based driver, the compatible
348+
* and performance. To enable the 8250 based driver, the compatible
349349
* is "nvidia,tegra124-uart", "nvidia,tegra20-uart" and to enable
350350
* the APB DMA based serial driver, the comptible is
351351
* "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart".

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)