Commit d8b0bd57 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull powerpc updates from Michael Ellerman:

 - Extend KCSAN support to 32-bit and BookE. Add some KCSAN annotations

 - Make ELFv2 ABI the default for 64-bit big-endian kernel builds, and
   use the -mprofile-kernel option (kernel specific ftrace ABI) for big
   endian ELFv2 kernels

 - Add initial Dynamic Execution Control Register (DEXCR) support, and
   allow the ROP protection instructions to be used on Power 10

 - Various other small features and fixes

Thanks to Aditya Gupta, Aneesh Kumar K.V, Benjamin Gray, Brian King,
Christophe Leroy, Colin Ian King, Dmitry Torokhov, Gaurav Batra, Jean
Delvare, Joel Stanley, Marco Elver, Masahiro Yamada, Nageswara R Sastry,
Nathan Chancellor, Naveen N Rao, Nayna Jain, Nicholas Piggin, Paul
Gortmaker, Randy Dunlap, Rob Herring, Rohan McLure, Russell Currey,
Sachin Sant, Timothy Pearson, Tom Rix, and Uwe Kleine-König.

* tag 'powerpc-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (76 commits)
  powerpc: remove checks for binutils older than 2.25
  powerpc: Fail build if using recordmcount with binutils v2.37
  powerpc/iommu: TCEs are incorrectly manipulated with DLPAR add/remove of memory
  powerpc/iommu: Only build sPAPR access functions on pSeries
  powerpc: powernv: Annotate data races in opal events
  powerpc: Mark writes registering ipi to host cpu through kvm and polling
  powerpc: Annotate accesses to ipi message flags
  powerpc: powernv: Fix KCSAN datarace warnings on idle_state contention
  powerpc: Mark [h]ssr_valid accesses in check_return_regs_valid
  powerpc: qspinlock: Enforce qnode writes prior to publishing to queue
  powerpc: qspinlock: Mark accesses to qnode lock checks
  powerpc/powernv/pci: Remove last IODA1 defines
  powerpc/powernv/pci: Remove MVE code
  powerpc/powernv/pci: Remove ioda1 support
  powerpc: 52xx: Make immr_id DT match tables static
  powerpc: mpc512x: Remove open coded "ranges" parsing
  powerpc: fsl_soc: Use of_range_to_resource() for "ranges" parsing
  powerpc: fsl: Use of_property_read_reg() to parse "reg"
  powerpc: fsl_rio: Use of_range_to_resource() for "ranges" parsing
  macintosh: Use of_property_read_reg() to parse "reg"
  ...
parents b69f0aeb 54a11654
Loading
Loading
Loading
Loading
+58 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0-or-later

==========================================
DEXCR (Dynamic Execution Control Register)
==========================================

Overview
========

The DEXCR is a privileged special purpose register (SPR) introduced in
PowerPC ISA 3.1B (Power10) that allows per-cpu control over several dynamic
execution behaviours. These behaviours include speculation (e.g., indirect
branch target prediction) and enabling return-oriented programming (ROP)
protection instructions.

The execution control is exposed in hardware as up to 32 bits ('aspects') in
the DEXCR. Each aspect controls a certain behaviour, and can be set or cleared
to enable/disable the aspect. There are several variants of the DEXCR for
different purposes:

DEXCR
    A privileged SPR that can control aspects for userspace and kernel space
HDEXCR
    A hypervisor-privileged SPR that can control aspects for the hypervisor and
    enforce aspects for the kernel and userspace.
UDEXCR
    An optional ultravisor-privileged SPR that can control aspects for the ultravisor.

Userspace can examine the current DEXCR state using a dedicated SPR that
provides a non-privileged read-only view of the userspace DEXCR aspects.
There is also an SPR that provides a read-only view of the hypervisor enforced
aspects, which ORed with the userspace DEXCR view gives the effective DEXCR
state for a process.


Configuration
=============

The DEXCR is currently unconfigurable. All threads are run with the
NPHIE aspect enabled.


coredump and ptrace
===================

The userspace values of the DEXCR and HDEXCR (in this order) are exposed under
``NT_PPC_DEXCR``. These are each 64 bits and readonly, and are intended to
assist with core dumps. The DEXCR may be made writable in future. The top 32
bits of both registers (corresponding to the non-userspace bits) are masked off.

If the kernel config ``CONFIG_CHECKPOINT_RESTORE`` is enabled, then
``NT_PPC_HASHKEYR`` is available and exposes the HASHKEYR value of the process
for reading and writing. This is a tradeoff between increased security and
checkpoint/restore support: a process should normally have no need to know its
secret key, but restoring a process requires setting its original key. The key
therefore appears in core dumps, and an attacker may be able to retrieve it from
a coredump and effectively bypass ROP protection on any threads that share this
key (potentially all threads from the same parent that have not run ``exec()``).
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ powerpc
    cxl
    cxlflash
    dawr-power9
    dexcr
    dscr
    eeh-pci-error-recovery
    elf_hwcaps
+9 −2
Original line number Diff line number Diff line
@@ -11448,7 +11448,13 @@ F: arch/mips/include/uapi/asm/kvm*
F:	arch/mips/kvm/
KERNEL VIRTUAL MACHINE FOR POWERPC (KVM/powerpc)
M:	Michael Ellerman <mpe@ellerman.id.au>
R:	Nicholas Piggin <npiggin@gmail.com>
L:	linuxppc-dev@lists.ozlabs.org
L:	kvm@vger.kernel.org
S:	Maintained (Book3S 64-bit HV)
S:	Odd fixes (Book3S 64-bit PR)
S:	Orphan (Book3E and 32-bit)
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git topic/ppc-kvm
F:	arch/powerpc/include/asm/kvm*
F:	arch/powerpc/include/uapi/asm/kvm*
@@ -11981,11 +11987,12 @@ F: lib/linear_ranges.c
F:	lib/test_linear_ranges.c
LINUX FOR POWER MACINTOSH
M:	Benjamin Herrenschmidt <benh@kernel.crashing.org>
L:	linuxppc-dev@lists.ozlabs.org
S:	Odd Fixes
S:	Orphan
F:	arch/powerpc/platforms/powermac/
F:	drivers/macintosh/
X:	drivers/macintosh/adb-iop.c
X:	drivers/macintosh/via-macii.c
LINUX FOR POWERPC (32-BIT AND 64-BIT)
M:	Michael Ellerman <mpe@ellerman.id.au>
+9 −8
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ config PPC
	select HAVE_ARCH_KASAN			if PPC_RADIX_MMU
	select HAVE_ARCH_KASAN			if PPC_BOOK3E_64
	select HAVE_ARCH_KASAN_VMALLOC		if HAVE_ARCH_KASAN
	select HAVE_ARCH_KCSAN            	if PPC_BOOK3S_64
	select HAVE_ARCH_KCSAN
	select HAVE_ARCH_KFENCE			if ARCH_SUPPORTS_DEBUG_PAGEALLOC
	select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
	select HAVE_ARCH_WITHIN_STACK_FRAMES
@@ -235,7 +235,7 @@ config PPC
	select HAVE_FUNCTION_DESCRIPTORS	if PPC64_ELF_ABI_V1
	select HAVE_FUNCTION_ERROR_INJECTION
	select HAVE_FUNCTION_GRAPH_TRACER
	select HAVE_FUNCTION_TRACER
	select HAVE_FUNCTION_TRACER		if PPC64 || (PPC32 && CC_IS_GCC)
	select HAVE_GCC_PLUGINS			if GCC_VERSION >= 50200   # plugin support on gcc <= 5.1 is buggy on PPC
	select HAVE_GENERIC_VDSO
	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP
@@ -547,8 +547,9 @@ config LD_HEAD_STUB_CATCH
	  If unsure, say "N".

config MPROFILE_KERNEL
	depends on PPC64 && CPU_LITTLE_ENDIAN && FUNCTION_TRACER
	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
	depends on PPC64_ELF_ABI_V2 && FUNCTION_TRACER
	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -mlittle-endian) if CPU_LITTLE_ENDIAN
	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -mbig-endian) if CPU_BIG_ENDIAN

config HOTPLUG_CPU
	bool "Support for enabling/disabling CPUs"
@@ -624,10 +625,12 @@ config ARCH_HAS_KEXEC_PURGATORY
	def_bool KEXEC_FILE

config PPC64_BIG_ENDIAN_ELF_ABI_V2
	bool "Build big-endian kernel using ELF ABI V2 (EXPERIMENTAL)"
	# Option is available to BFD, but LLD does not support ELFv1 so this is
	# always true there.
	prompt "Build big-endian kernel using ELF ABI V2" if LD_IS_BFD && EXPERT
	def_bool y
	depends on PPC64 && CPU_BIG_ENDIAN
	depends on CC_HAS_ELFV2
	depends on LD_VERSION >= 22400 || LLD_VERSION >= 150000
	help
	  This builds the kernel image using the "Power Architecture 64-Bit ELF
	  V2 ABI Specification", which has a reduced stack overhead and faster
@@ -638,8 +641,6 @@ config PPC64_BIG_ENDIAN_ELF_ABI_V2
	  it is less well tested by kernel and toolchain. However some distros
	  build userspace this way, and it can produce a functioning kernel.

	  This requires GCC and binutils 2.24 or newer.

config RELOCATABLE
	bool "Build a relocatable kernel"
	depends on PPC64 || (FLATMEM && (44x || PPC_85xx))
+8 −15
Original line number Diff line number Diff line
@@ -42,18 +42,13 @@ machine-$(CONFIG_PPC64) += 64
machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
UTS_MACHINE := $(subst $(space),,$(machine-y))

# XXX This needs to be before we override LD below
ifdef CONFIG_PPC32
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
else
ifeq ($(call ld-ifversion, -ge, 22500, y),y)
ifeq ($(CONFIG_PPC64)$(CONFIG_LD_IS_BFD),yy)
# Have the linker provide sfpr if possible.
# There is a corresponding test in arch/powerpc/lib/Makefile
KBUILD_LDFLAGS_MODULE += --save-restore-funcs
else
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
endif
endif

ifdef CONFIG_CPU_LITTLE_ENDIAN
KBUILD_CFLAGS	+= -mlittle-endian
@@ -166,7 +161,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
KBUILD_CPPFLAGS	+= -I $(srctree)/arch/$(ARCH) $(asinstr)
KBUILD_AFLAGS	+= $(AFLAGS-y)
KBUILD_CFLAGS	+= $(call cc-option,-msoft-float)
KBUILD_CFLAGS	+= -pipe $(CFLAGS-y)
KBUILD_CFLAGS	+= $(CFLAGS-y)
CPP		= $(CC) -E $(KBUILD_CFLAGS)

CHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
@@ -398,14 +393,12 @@ endif
endif

PHONY += checkbin
# Check toolchain versions:
# - gcc-4.6 is the minimum kernel-wide version so nothing required.
checkbin:
	@if test "x${CONFIG_LD_IS_LLD}" != "xy" -a \
		"x$(call ld-ifversion, -le, 22400, y)" = "xy" ; then \
		echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
		echo 'in some circumstances.' ; \
		echo    '*** binutils 2.23 do not define the TOC symbol ' ; \
		echo -n '*** Please use a different binutils version.' ; \
	@if test "x${CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT}" = "xy" -a \
		"x${CONFIG_LD_IS_BFD}" = "xy" -a \
		"${CONFIG_LD_VERSION}" = "23700" ; then \
		echo -n '*** binutils 2.37 drops unused section symbols, which recordmcount ' ; \
		echo 'is unable to handle.' ; \
		echo '*** Please use a different binutils version.' ; \
		false ; \
	fi
Loading