Skip to content

Commit

Permalink
arm64: alternatives: use tpidr_el2 on VHE hosts
Browse files Browse the repository at this point in the history
When upstream 6d99b68933fb was back-ported to upstream v4.9.x stable as
eea5902, 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,
0ec3713 ("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 <[email protected]>
Reviewed-by: Christoffer Dall <[email protected]>
Reviewed-by: Catalin Marinas <[email protected]>
Signed-off-by: Catalin Marinas <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Fixes: eea5902 ("arm64: alternatives: use tpidr_el2 on VHE hosts")
Fixes: 0ec3713 ("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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Change-Id: Ieddfef9a2875478d537f96e5fab516034a06ad94
  • Loading branch information
nvswarren authored and gregkh committed Jan 10, 2020
1 parent 9759f95 commit c337cad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions arch/arm64/mm/proc.S
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ ENTRY(cpu_do_suspend)
mrs x8, mdscr_el1
mrs x9, oslsr_el1
mrs x10, sctlr_el1
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
mrs x11, tpidr_el1
alternative_else
mrs x11, tpidr_el2
alternative_endif
mrs x12, sp_el0
stp x2, x3, [x0]
stp x4, xzr, [x0, #16]
Expand Down Expand Up @@ -116,7 +120,11 @@ ENTRY(cpu_do_resume)
msr mdscr_el1, x10

msr sctlr_el1, x12
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
msr tpidr_el1, x13
alternative_else
msr tpidr_el2, x13
alternative_endif
msr sp_el0, x14
/*
* Restore oslsr_el1 by writing oslar_el1
Expand Down

0 comments on commit c337cad

Please sign in to comment.