diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index bf428a1..bcfbbb5 100755 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -477,6 +477,31 @@ config SECCOMP and the task is only allowed to execute a few safe syscalls defined by each seccomp mode. +config ARM64_MODULE_CMODEL_LARGE + bool + +config ARM64_ERRATUM_843419 + bool "Cortex-A53: 843419: A load or store might access an incorrect address" + depends on MODULES + default y + select ARM64_MODULE_CMODEL_LARGE + select ARM64_MODULE_CMODEL_LARGE if MODULES + help + This option builds kernel modules using the large memory model in + order to avoid the use of the ADRP instruction, which can cause + a subsequent memory access to use an incorrect address on Cortex-A53 + parts up to r0p4. + + Note that the kernel itself must be linked with a version of ld + which fixes potentially affected ADRP instructions through the + use of veneers. + This option links the kernel with '--fix-cortex-a53-843419' and + builds modules using the large memory model in order to avoid the use + of the ADRP instruction, which can cause a subsequent memory access + to use an incorrect address on Cortex-A53 parts up to r0p4. + + If unsure, say Y. + endmenu menu "Boot options" diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index e2782e1..4196f47 100755 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -34,6 +34,19 @@ AS += -EL LD += -EL endif +ifeq ($(CONFIG_ARM64_MODULE_CMODEL_LARGE), y) +KBUILD_CFLAGS_MODULE += -mcmodel=large +endif + +ifeq ($(CONFIG_ARM64_ERRATUM_843419),y) +ld-843419-workaround := $(call ld-option, --fix-cortex-a53-843419) +ifeq ($(ld-843419-workaround),) +$(warning ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum) +else +LDFLAGS_vmlinux += --fix-cortex-a53-843419 +endif +endif + comma = , CHECKFLAGS += -D__aarch64__