arm64: alternatives: use tpidr_el2 on VHE hosts 69/249769/1
authorStephen Warren <swarren@nvidia.com>
Wed, 8 Jan 2020 18:54:14 +0000 (11:54 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 16 Dec 2020 11:21:00 +0000 (20:21 +0900)
commite5c7867abd0be01727e24b0f27b7ac315a29dd61
treed69f2809a2d4246edfae48626e456d8d247a1f2b
parent76d69e09a40cf4b7866a6582092fad7cd6bec3c3
arm64: alternatives: use tpidr_el2 on VHE hosts

When upstream 6d99b68933fb was back-ported to upstream v4.9.x stable as
eea59020a7f2, the edits to arch/arm64/mm/proc.S were dropped because
proc.S didn't save/restore tpidr_el1 at all. Separately, in android-4.9,
0ec37136b90e ("UPSTREAM: arm64: move sp_el0 and tpidr_el1 into
cpu_suspend_ctx") modified proc.S to save/restore tpidir_el1. These two
paths were later merged together in android-4.9. The missing edits to
proc.S should have been added in during the merge, but were not. This
change restores those edits. The original upstream change description
of 6d99b68933fb follows; this is where the missing code appeared
originally.

Commit 6d99b68933fbcf51f84fcbba49246ce1209ec193 upstream.

Now that KVM uses tpidr_el2 in the same way as Linux's cpu_offset in
tpidr_el1, merge the two. This saves KVM from save/restoring tpidr_el1
on VHE hosts, and allows future code to blindly access per-cpu variables
without triggering world-switch.

Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Fixes: eea59020a7f2 ("arm64: alternatives: use tpidr_el2 on VHE hosts")
Fixes: 0ec37136b90e ("UPSTREAM: arm64: move sp_el0 and tpidr_el1 into cpu_suspend_ctx")
Fixes: 4a5211fa1474 ("Merge 4.9.114 into android-4.9-p")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
[sw0312.kim: cherry-pick android-4.9-q commit c337caddb549 to fix booting issue
- also fully applying linux-4.9.y commit eea59020a7f2 ("arm64: alternatives: use tpidr_el2 on VHE hosts") skipped from khadas' revert]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Iad39e6f1fb662b95967e8ebd07a36844bf46cd2d
arch/arm64/include/asm/alternative.h
arch/arm64/include/asm/percpu.h
arch/arm64/kernel/alternative.c
arch/arm64/kernel/cpufeature.c
arch/arm64/mm/proc.S