From: Marc Zyngier <marc.zyngier@arm.com> To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] arm64: KVM: Allow for direct call of HYP functions when using VHE Date: Wed, 9 Jan 2019 13:54:34 +0000 [thread overview] Message-ID: <20190109135435.178664-3-marc.zyngier@arm.com> (raw) In-Reply-To: <20190109135435.178664-1-marc.zyngier@arm.com> When running VHE, there is no need to jump via some stub to perform a "HYP" function call, as there is a single address space. Let's thus change kvm_call_hyp() and co to perform a direct call in this case. Although this results in a bit of code expansion, it allows the compiler to check for type compatibility, something that we are missing so far. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/include/asm/kvm_host.h | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e54cb7c88a4e..df32edbadd69 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -370,8 +370,36 @@ void kvm_arm_halt_guest(struct kvm *kvm); void kvm_arm_resume_guest(struct kvm *kvm); u64 __kvm_call_hyp(void *hypfn, ...); -#define kvm_call_hyp(f, ...) __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__) -#define kvm_call_hyp_ret(f, ...) kvm_call_hyp(f, ##__VA_ARGS__) + +/* + * The couple of isb() below are there to guarantee the same behaviour + * on VHE as on !VHE, where the eret to EL1 acts as a context + * synchronization event. + */ +#define kvm_call_hyp(f, ...) \ + do { \ + if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN)) { \ + f(__VA_ARGS__); \ + isb(); \ + } else { \ + __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__); \ + } \ + } while(0) + +#define kvm_call_hyp_ret(f, ...) \ + ({ \ + u64 ret; \ + \ + if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN)) { \ + ret = f(__VA_ARGS__); \ + isb(); \ + } else { \ + ret = __kvm_call_hyp(kvm_ksym_ref(f), \ + ##__VA_ARGS__); \ + } \ + \ + ret; \ + }) void force_vm_exit(const cpumask_t *mask); void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com> To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: Christoffer Dall <christoffer.dall@arm.com> Subject: [PATCH 2/3] arm64: KVM: Allow for direct call of HYP functions when using VHE Date: Wed, 9 Jan 2019 13:54:34 +0000 [thread overview] Message-ID: <20190109135435.178664-3-marc.zyngier@arm.com> (raw) In-Reply-To: <20190109135435.178664-1-marc.zyngier@arm.com> When running VHE, there is no need to jump via some stub to perform a "HYP" function call, as there is a single address space. Let's thus change kvm_call_hyp() and co to perform a direct call in this case. Although this results in a bit of code expansion, it allows the compiler to check for type compatibility, something that we are missing so far. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/include/asm/kvm_host.h | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e54cb7c88a4e..df32edbadd69 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -370,8 +370,36 @@ void kvm_arm_halt_guest(struct kvm *kvm); void kvm_arm_resume_guest(struct kvm *kvm); u64 __kvm_call_hyp(void *hypfn, ...); -#define kvm_call_hyp(f, ...) __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__) -#define kvm_call_hyp_ret(f, ...) kvm_call_hyp(f, ##__VA_ARGS__) + +/* + * The couple of isb() below are there to guarantee the same behaviour + * on VHE as on !VHE, where the eret to EL1 acts as a context + * synchronization event. + */ +#define kvm_call_hyp(f, ...) \ + do { \ + if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN)) { \ + f(__VA_ARGS__); \ + isb(); \ + } else { \ + __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__); \ + } \ + } while(0) + +#define kvm_call_hyp_ret(f, ...) \ + ({ \ + u64 ret; \ + \ + if (cpus_have_const_cap(ARM64_HAS_VIRT_HOST_EXTN)) { \ + ret = f(__VA_ARGS__); \ + isb(); \ + } else { \ + ret = __kvm_call_hyp(kvm_ksym_ref(f), \ + ##__VA_ARGS__); \ + } \ + \ + ret; \ + }) void force_vm_exit(const cpumask_t *mask); void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-09 13:54 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-09 13:54 [PATCH 0/3] arm64: KVM: Allow direct function calls on VHE Marc Zyngier 2019-01-09 13:54 ` Marc Zyngier 2019-01-09 13:54 ` [PATCH 1/3] arm/arm64: KVM: Introduce kvm_call_hyp_ret() Marc Zyngier 2019-01-09 13:54 ` Marc Zyngier 2019-01-09 13:54 ` Marc Zyngier [this message] 2019-01-09 13:54 ` [PATCH 2/3] arm64: KVM: Allow for direct call of HYP functions when using VHE Marc Zyngier 2019-01-09 14:24 ` Andrew Murray 2019-01-09 14:24 ` Andrew Murray 2019-01-09 14:45 ` Marc Zyngier 2019-01-09 14:45 ` Marc Zyngier 2019-01-09 14:51 ` Julien Thierry 2019-01-09 14:51 ` Julien Thierry 2019-01-09 14:52 ` Julien Thierry 2019-01-09 14:52 ` Julien Thierry 2019-01-09 16:01 ` Marc Zyngier 2019-01-09 16:01 ` Marc Zyngier 2019-01-09 16:04 ` Andrew Murray 2019-01-09 16:04 ` Andrew Murray 2019-01-09 13:54 ` [PATCH 3/3] arm64: KVM: Drop VHE-specific HYP call stub Marc Zyngier 2019-01-09 13:54 ` Marc Zyngier 2019-01-09 14:11 ` [PATCH 0/3] arm64: KVM: Allow direct function calls on VHE Andrew Murray 2019-01-09 14:11 ` Andrew Murray
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190109135435.178664-3-marc.zyngier@arm.com \ --to=marc.zyngier@arm.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.