linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] arm64: alternatives runtime patching
@ 2014-11-14 15:54 Andre Przywara
  2014-11-14 15:54 ` [PATCH 1/6] arm64: add cpu_capabilities bitmap Andre Przywara
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Andre Przywara @ 2014-11-14 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

This series introduces alternatives runtime patching to arm64.
This allows to patch assembly instruction at runtime to either
fix hardware bugs or optimize for certain hardware features. Look
at patch 5/6 for an example on how to use this.

The code is heavily based on the x86 implementation.
Currently this is focussed on fixing CPU errata, but in the future
runtime optimizations for new CPU features are planned.

Patch 1/6 introduces a new cpu_hwcaps bitmap, which holds kernel
internal CPU feature flags. Since elf_hwcaps is also a userspace ABI,
I refrained from tinkering with this (tried this, gets messy).

Based on bits in this bitmap, in patch 2/6 we provide a macro to
replace (inline) assembly instructions at runtime with alternative
instructions. As on x86, those bits go into separate ELF sections.
The patching is done using stop_machine() to avoid mayhem in SMP.

Patch 3/6 introduces means to set cpu_hwcaps bits based on detecting
a certain CPU revision. Currently this is based on the architectural
bits in the MIDR register, but the code is flexible enough to easily
introduce more advanced criteria.
To support a heterogenous CPU setup (e.g. big.LITTLE), we scan all
CPUs in the system.

Patch 4 and 5 use the new framework to introduce workarounds for two
ARM-Cortex errata. Patch 4 introduces some more framework for the
detection, while patch 5 should be used as a blueprint for how to add
workarounds for CPU errata in the future.

Patch 6/6 finally introduces Kconfig entries for the bugs.
Those are meant to
a) document the errata and workarounds and
b) to allow system vendors to remove certain workarounds for custom
build kernels.
Though this shouldn't be strictly necessary, experience shows that
people will do b) anyway and I deem it better to provide official
means rather than provoking random hacks.

The code can be found also in the alternatives/v1 branch of:
http://www.linux-arm.org/git?p=linux-ap.git
git://linux-arm.org/linux-ap.git


Please review and comment!

Cheers,
Andre.

Andre Przywara (6):
  arm64: add cpu_capabilities bitmap
  arm64: add alternative runtime patching
  arm64: detect silicon revisions and set cap bits accordingly
  arm64: add Cortex-A53 cache errata workaround
  arm64: add Cortex-A57 erratum 832075 workaround
  arm64: protect alternatives workarounds with Kconfig options

 arch/arm64/Kconfig                       |  107 +++++++++++++++++++++++++++++
 arch/arm64/include/asm/alternative-asm.h |   29 ++++++++
 arch/arm64/include/asm/alternative.h     |   43 ++++++++++++
 arch/arm64/include/asm/cpufeature.h      |   29 ++++++++
 arch/arm64/include/asm/cputype.h         |    5 ++
 arch/arm64/include/asm/io.h              |   23 +++++--
 arch/arm64/kernel/Makefile               |    2 +-
 arch/arm64/kernel/alternative.c          |   64 +++++++++++++++++
 arch/arm64/kernel/cpu_errata.c           |  110 ++++++++++++++++++++++++++++++
 arch/arm64/kernel/cpuinfo.c              |    3 +
 arch/arm64/kernel/setup.c                |    3 +
 arch/arm64/kernel/smp.c                  |    2 +
 arch/arm64/kernel/vmlinux.lds.S          |   11 +++
 arch/arm64/mm/cache.S                    |    4 +-
 arch/arm64/mm/init.c                     |    2 +
 15 files changed, 431 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm64/include/asm/alternative-asm.h
 create mode 100644 arch/arm64/include/asm/alternative.h
 create mode 100644 arch/arm64/kernel/alternative.c
 create mode 100644 arch/arm64/kernel/cpu_errata.c

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-11-28 13:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14 15:54 [PATCH 0/6] arm64: alternatives runtime patching Andre Przywara
2014-11-14 15:54 ` [PATCH 1/6] arm64: add cpu_capabilities bitmap Andre Przywara
2014-11-14 15:54 ` [PATCH 2/6] arm64: add alternative runtime patching Andre Przywara
2014-11-14 15:54 ` [PATCH 3/6] arm64: detect silicon revisions and set cap bits accordingly Andre Przywara
2014-11-14 15:54 ` [PATCH 4/6] arm64: add Cortex-A53 cache errata workaround Andre Przywara
2014-11-14 15:54 ` [PATCH 5/6] arm64: add Cortex-A57 erratum 832075 workaround Andre Przywara
2014-11-14 15:54 ` [PATCH 6/6] arm64: protect alternatives workarounds with Kconfig options Andre Przywara
2014-11-14 16:20 ` [PATCH 0/6] arm64: alternatives runtime patching Arnd Bergmann
2014-11-14 16:31   ` Catalin Marinas
2014-11-25 15:29 ` Will Deacon
2014-11-28 13:40   ` [PATCH] arm64: add module support for alternatives fixups Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).