linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] kvm: arm64: Fix up hyp relocations
@ 2020-11-19 16:25 David Brazdil
  2020-11-19 16:25 ` [RFC PATCH 1/6] kvm: arm64: Set up .hyp.rodata ELF section David Brazdil
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: David Brazdil @ 2020-11-19 16:25 UTC (permalink / raw)
  To: kvmarm
  Cc: linux-arm-kernel, linux-kernel, Marc Zyngier, James Morse,
	Julien Thierry, Suzuki K Poulose, Catalin Marinas, Will Deacon,
	Mark Rutland, Andrew Scull, Ard Biesheuvel, kernel-team,
	David Brazdil

Hi,

KVM nVHE hyp code runs under different VA mapping than the kernel, which
meant that .hyp.text code had to use PC-relative addressing because
relocations would produce a kernel VA. Programmers had to be extremely
careful with C semantics to not break this fragile setup. See
hyp_symbol_addr comments for details.

Now that we're moving to all nVHE hyp code/data being in separate ELF
sections from the rest of the kernel, it is becoming possible to revisit
relocations during early boot, filter those used by nVHE hyp and
converting those (already relocated) kern VAs to hyp VAs.

Sending this as an RFC, mainly to get feedback but also because it's
only lightly tested. It still feels hacky but much more robust than the
existing approach. The one place where I see somebody breaking this is
the list of ELF sections owned by ELF. That list is currently evolving
but should stabilize over time.

The patches are based on kvmarm/queue (with Marc's "Host EL2 entry
improvements") and my "Opt-in always-on nVHE hypervisor" v2 series.

-David

David Brazdil (6):
  kvm: arm64: Set up .hyp.rodata ELF section
  kvm: arm64: Fix up RELA relocations in hyp code/data
  kvm: arm64: Fix up RELR relocation in hyp code/data
  kvm: arm64: Remove patching of fn pointers in hyp
  kvm: arm64: Fix constant-pool users in hyp
  kvm: arm64: Remove hyp_symbol_addr

 arch/arm64/include/asm/kvm_asm.h         |  20 ----
 arch/arm64/include/asm/kvm_mmu.h         |  48 ++++-----
 arch/arm64/include/asm/sections.h        |   2 +-
 arch/arm64/kernel/image-vars.h           |   1 -
 arch/arm64/kernel/smp.c                  |   4 +-
 arch/arm64/kernel/vmlinux.lds.S          |   7 +-
 arch/arm64/kvm/arm.c                     |   7 +-
 arch/arm64/kvm/hyp/include/hyp/switch.h  |   4 +-
 arch/arm64/kvm/hyp/nvhe/host.S           |  29 +++---
 arch/arm64/kvm/hyp/nvhe/hyp-main.c       |  11 +-
 arch/arm64/kvm/hyp/nvhe/hyp-smp.c        |   4 +-
 arch/arm64/kvm/hyp/nvhe/hyp.lds.S        |   1 +
 arch/arm64/kvm/hyp/nvhe/psci-relay.c     |   4 +-
 arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c |   2 +-
 arch/arm64/kvm/va_layout.c               | 123 +++++++++++++++++++++--
 15 files changed, 175 insertions(+), 92 deletions(-)

-- 
2.29.2.299.gdc1121823c-goog


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

end of thread, other threads:[~2020-12-09 13:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 16:25 [RFC PATCH 0/6] kvm: arm64: Fix up hyp relocations David Brazdil
2020-11-19 16:25 ` [RFC PATCH 1/6] kvm: arm64: Set up .hyp.rodata ELF section David Brazdil
2020-11-24 13:35   ` Ard Biesheuvel
2020-11-19 16:25 ` [RFC PATCH 2/6] kvm: arm64: Fix up RELA relocations in hyp code/data David Brazdil
2020-11-24 13:09   ` Marc Zyngier
2020-11-24 13:45   ` Ard Biesheuvel
2020-11-19 16:25 ` [RFC PATCH 3/6] kvm: arm64: Fix up RELR relocation " David Brazdil
2020-11-24 13:24   ` Marc Zyngier
2020-11-24 14:02   ` Ard Biesheuvel
2020-11-19 16:25 ` [RFC PATCH 4/6] kvm: arm64: Remove patching of fn pointers in hyp David Brazdil
2020-11-24 14:03   ` Ard Biesheuvel
2020-11-19 16:25 ` [RFC PATCH 5/6] kvm: arm64: Fix constant-pool users " David Brazdil
2020-11-24 14:08   ` Ard Biesheuvel
2020-12-09 13:01     ` David Brazdil
2020-11-19 16:25 ` [RFC PATCH 6/6] kvm: arm64: Remove hyp_symbol_addr David Brazdil
2020-11-24 14:08   ` Ard Biesheuvel

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).