On Mon, Sep 07, 2020 at 03:20:07PM +0100, Marc Zyngier wrote: > On Thu, 03 Sep 2020 14:53:05 +0100, > Andrew Scull <ascull@xxxxxxxxxx> wrote: > > > > Rather than passing arbitrary function pointers to run at hyp, define > > and equivalent set of SMCCC functions. > > > > Since the SMCCC functions are strongly tied to the original function > > prototypes, it is not expected for the host to ever call an invalid ID > > but a warning is raised if this does ever occur. > > > > As __kvm_vcpu_run is used for every switch between the host and a guest, > > it is explicitly singled out to be identified before the other function > > IDs to improve the performance of the hot path. > > > > Signed-off-by: Andrew Scull <ascull@xxxxxxxxxx> > > Signed-off-by: David Brazdil <dbrazdil@xxxxxxxxxx> > > --- > > arch/arm64/include/asm/kvm_asm.h | 24 ++++++ > > arch/arm64/include/asm/kvm_host.h | 25 ++++--- > > arch/arm64/kvm/arm.c | 2 +- > > arch/arm64/kvm/hyp.S | 24 ++---- > > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 113 +++++++++++++++++++++++++---- > > 5 files changed, 145 insertions(+), 43 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h > > index 4bbde3d3989c..4a73f1349151 100644 > > --- a/arch/arm64/include/asm/kvm_asm.h > > +++ b/arch/arm64/include/asm/kvm_asm.h > > @@ -38,6 +38,30 @@ > > > > #define __SMCCC_WORKAROUND_1_SMC_SZ 36 > > > > +#define KVM_HOST_SMCCC_ID(id) \ > > + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ > > + ARM_SMCCC_SMC_64, \ > > + ARM_SMCCC_OWNER_STANDARD_HYP, \ > > + (id)) > > + > > +#define KVM_HOST_SMCCC_FUNC(name) KVM_HOST_SMCCC_ID(__KVM_HOST_SMCCC_FUNC_##name) > > + > > +#define __KVM_HOST_SMCCC_FUNC___kvm_hyp_init 0 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_flush_vm_context 1 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_vmid_ipa 2 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_vmid 3 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_local_vmid 4 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_timer_set_cntvoff 5 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_vcpu_run 6 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_enable_ssbs 7 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_get_ich_vtr_el2 8 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_read_vmcr 9 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_write_vmcr 10 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_init_lrs 11 > > +#define __KVM_HOST_SMCCC_FUNC___kvm_get_mdcr_el2 12 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_save_aprs 13 > > +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_restore_aprs 14 > > Wait. This looks broken. How do you distinguish between these and the > stubs? The __KVM_HOST_SMCCC_FUNC_* definitions are just the function ID part of the SMCCC x0 argument. KVM_HOST_SMCCC_ID builds it into a 64-bit fastcall owner by the hypervisor. The stubs fall into the legacy region so these don't conflict. _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm