Skip to content

Commit

Permalink
FROMLIST: BACKPORT: [PATCH 6/6] arm64: Wire up and expose the new com…
Browse files Browse the repository at this point in the history
…pat vDSO

(cherry pick from url https://patchwork.kernel.org/patch/10060447/)

Expose the new compat vDSO via the COMPAT_VDSO config option.

The option is not enabled in defconfig because we really need a 32-bit
compiler this time, and we rely on the user to provide it themselves
by setting CROSS_COMPILE_ARM32. Therefore enabling the option by
default would make little sense, since the user must explicitly set a
non-standard environment variable anyway.

CONFIG_COMPAT_VDSO is not directly used in the code, because we want
to ignore it (build as if it were not set) if the user didn't set
CROSS_COMPILE_ARM32. If the variable has been set to a valid prefix,
CONFIG_VDSO32 will be set; this is the option that the code and
Makefiles test.

For more flexibility, like CROSS_COMPILE, CROSS_COMPILE_ARM32 can also
be set via CONFIG_CROSS_COMPILE_ARM32 (the environment variable
overrides the config option, as expected).

Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>

Also needs to set CONFIG_ARM_ARCH_TIMER_VCT_ACCESS when CONFIG_VDSO32
is selected.  Backport removed any references to clang compiler.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Bug: 63737556
Bug: 20045882
Orig-Change-Id: Ie8a7d6c2b5ba3edca591a9a953ce99ec792da882
Change-Id: I35f7906772c33576bd82d1c6406bb3bfe35a2f77
Signed-off-by: khusika <khusikadhamar@gmail.com>
  • Loading branch information
kevin-brodsky-arm authored and khusika committed Oct 13, 2018
1 parent b6c3ce0 commit dc082c8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
25 changes: 25 additions & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,31 @@ config SYSVIPC_COMPAT
def_bool y
depends on COMPAT && SYSVIPC

config COMPAT_VDSO
bool "32-bit vDSO"
depends on COMPAT
select ARM_ARCH_TIMER_VCT_ACCESS
default n
help
Warning: a 32-bit toolchain is necessary to build the vDSO. You
must explicitly define which toolchain should be used by setting
CROSS_COMPILE_ARM32 to the prefix of the 32-bit toolchain (same format
as CROSS_COMPILE). If CROSS_COMPILE_ARM32 is empty, a warning will be
printed and the kernel will be built as if COMPAT_VDSO had not been
set. If CROSS_COMPILE_ARM32 is set to an invalid prefix, compilation
will be aborted.

Provide a vDSO to 32-bit processes. It includes the symbols provided
by the vDSO from the 32-bit kernel, so that a 32-bit libc can use
the compat vDSO without modification. It also provides sigreturn
trampolines, replacing the sigreturn page.

config CROSS_COMPILE_ARM32
string "32-bit toolchain prefix"
help
Same as setting CROSS_COMPILE_ARM32 in the environment, but saved for
future builds. The environment variable overrides this config option.

endmenu

menu "Power management options"
Expand Down
28 changes: 28 additions & 0 deletions arch/arm64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,35 @@ GZFLAGS :=-9

KBUILD_DEFCONFIG := defconfig

ifeq ($(CONFIG_COMPAT_VDSO), y)
CROSS_COMPILE_ARM32 ?= $(CONFIG_CROSS_COMPILE_ARM32:"%"=%)

# Check that the user has provided a valid prefix for the 32-bit toolchain.
# To prevent selecting the system CC by default, the prefix is not
# allowed to be empty, unlike CROSS_COMPILE. In the unlikely event that the
# system CC is actually the 32-bit ARM compiler to be used, the
# variable can be set to the dirname (e.g. CROSS_COMPILE_ARM32=/usr/bin/).
# Note: this Makefile is read both before and after regenerating the config
# (if needed). Any warning appearing before the config has been regenerated
# should be ignored. If the error is triggered and you set
# CONFIG_CROSS_COMPILE_ARM32, set CROSS_COMPILE_ARM32 to an appropriate value
# when invoking make and fix CONFIG_CROSS_COMPILE_ARM32.
ifeq ($(CROSS_COMPILE_ARM32),)
$(warning CROSS_COMPILE_ARM32 not defined or empty, the compat vDSO will not be built)
else ifeq ($(shell which $(CROSS_COMPILE_ARM32)gcc 2> /dev/null),)
$(error $(CROSS_COMPILE_ARM32)gcc not found, check CROSS_COMPILE_ARM32)
else
export CROSS_COMPILE_ARM32
export CONFIG_VDSO32 := y
vdso32 := -DCONFIG_VDSO32=1
endif
endif

KBUILD_CFLAGS += $(vdso32)
KBUILD_CFLAGS += -mgeneral-regs-only
KBUILD_CFLAGS += -fno-pic
KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
KBUILD_AFLAGS += $(vdso32)

ifeq ($(cc-name),clang)
KBUILD_CFLAGS += -DCONFIG_ARCH_SUPPORTS_INT128
Expand Down Expand Up @@ -128,6 +154,8 @@ archclean:
prepare: vdso_prepare
vdso_prepare: prepare0
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
$(if $(CONFIG_VDSO32),$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 \
include/generated/vdso32-offsets.h)

define archhelp
echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
Expand Down
3 changes: 3 additions & 0 deletions arch/arm64/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ arm64-obj-y := debug-monitors.o entry.o irq.o fpsimd.o \
arm64-obj-$(CONFIG_COMPAT) += sys32.o signal32.o \
sys_compat.o \
../../arm/kernel/opcodes.o
ifneq ($(CONFIG_VDSO32),y)
arm64-obj-$(CONFIG_COMPAT) += sigreturn32.o
endif
arm64-obj-$(CONFIG_KUSER_HELPERS) += kuser32.o
arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o
arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o
Expand All @@ -49,6 +51,7 @@ arm64-obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o
endif

obj-y += $(arm64-obj-y) vdso/
obj-$(CONFIG_VDSO32) += vdso32/
obj-m += $(arm64-obj-m)
head-y := head.o
extra-y := $(head-y) vmlinux.lds

0 comments on commit dc082c8

Please sign in to comment.