mbox series

[0/3] arm64: KVM: Allow direct function calls on VHE

Message ID 20190109135435.178664-1-marc.zyngier@arm.com (mailing list archive)
Headers show
Series arm64: KVM: Allow direct function calls on VHE | expand

Message

Marc Zyngier Jan. 9, 2019, 1:54 p.m. UTC
It recently appeared that the nasty hack we use to call a HYP function
on a non-VHE system has an interesting side effect on VHE: We wrap any
such call into a hypercall, losing any form of type checking between
the caller and the callee.

This isn't a big deal if you can guarantee to write code that is
always 100% correct, but it appears that I'm not you.

In order to restore some sanity, let's use the following property: On
a VHE system, it is always possible to call any function directly as
they live in the same address space. We can thus always emit a direct
call, and use a static key to flip from one to the other. As a bonus,
this also sanitizes !VHE systems as we always generate code for noth
revisions of the architecture.

Marc Zyngier (3):
  arm/arm64: KVM: Introduce kvm_call_hyp_ret()
  arm64: KVM: Allow for direct call of HYP functions when using VHE
  arm64: KVM: Drop VHE-specific HYP call stub

 arch/arm/include/asm/kvm_host.h   |  3 +++
 arch/arm64/include/asm/kvm_host.h | 31 ++++++++++++++++++++++++++++++-
 arch/arm64/kvm/debug.c            |  2 +-
 arch/arm64/kvm/hyp.S              |  3 ---
 arch/arm64/kvm/hyp/hyp-entry.S    | 12 ------------
 virt/kvm/arm/arm.c                |  2 +-
 virt/kvm/arm/vgic/vgic-v3.c       |  4 ++--
 7 files changed, 37 insertions(+), 20 deletions(-)

Comments

Andrew Murray Jan. 9, 2019, 2:11 p.m. UTC | #1
On Wed, Jan 09, 2019 at 01:54:32PM +0000, Marc Zyngier wrote:
> It recently appeared that the nasty hack we use to call a HYP function
> on a non-VHE system has an interesting side effect on VHE: We wrap any
> such call into a hypercall, losing any form of type checking between
> the caller and the callee.
> 
> This isn't a big deal if you can guarantee to write code that is
> always 100% correct, but it appears that I'm not you.
> 
> In order to restore some sanity, let's use the following property: On
> a VHE system, it is always possible to call any function directly as
> they live in the same address space. We can thus always emit a direct
> call, and use a static key to flip from one to the other. As a bonus,
> this also sanitizes !VHE systems as we always generate code for noth

s/noth/both/g

Andrew Murray

> revisions of the architecture.
> 
> Marc Zyngier (3):
>   arm/arm64: KVM: Introduce kvm_call_hyp_ret()
>   arm64: KVM: Allow for direct call of HYP functions when using VHE
>   arm64: KVM: Drop VHE-specific HYP call stub
> 
>  arch/arm/include/asm/kvm_host.h   |  3 +++
>  arch/arm64/include/asm/kvm_host.h | 31 ++++++++++++++++++++++++++++++-
>  arch/arm64/kvm/debug.c            |  2 +-
>  arch/arm64/kvm/hyp.S              |  3 ---
>  arch/arm64/kvm/hyp/hyp-entry.S    | 12 ------------
>  virt/kvm/arm/arm.c                |  2 +-
>  virt/kvm/arm/vgic/vgic-v3.c       |  4 ++--
>  7 files changed, 37 insertions(+), 20 deletions(-)
> 
> -- 
> 2.20.1
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm