linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] KVM/arm updates for 5.4-rc2
@ 2019-10-01  9:20 Marc Zyngier
  2019-10-01  9:20 ` [PATCH 1/4] arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220 Marc Zyngier
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Marc Zyngier @ 2019-10-01  9:20 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

Paolo, Radim,

Here's the first set of KVM/arm fixes for 5.4. The first three patches
remove a construct which helped us bringing up VHE back in the days,
but which is now more of a confusing historical artefact, better
replaced with static keys that we already have. The last patch fixes
the ftrace include path that so far worked by luck (and has been
addressed in other places in the tree).

Please pull,

       M.

The following changes since commit 92f35b751c71d14250a401246f2c792e3aa5b386:

  KVM: arm/arm64: vgic: Allow more than 256 vcpus for KVM_IRQ_LINE (2019-09-09 12:29:09 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-fixes-5.4-1

for you to fetch changes up to aac60f1a867773de9eb164013d89c99f3ea1f009:

  KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH (2019-09-11 16:36:19 +0100)

----------------------------------------------------------------
KVM/arm fixes for 5.4, take #1

- Remove the now obsolete hyp_alternate_select construct
- Fix the TRACE_INCLUDE_PATH macro in the vgic code

----------------------------------------------------------------
Marc Zyngier (3):
      arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220
      arm64: KVM: Replace hyp_alternate_select with has_vhe()
      arm64: KVM: Kill hyp_alternate_select()

Zenghui Yu (1):
      KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH

 arch/arm64/include/asm/kvm_hyp.h | 24 ------------------------
 arch/arm64/kvm/hyp/switch.c      | 17 ++---------------
 arch/arm64/kvm/hyp/tlb.c         | 36 ++++++++++++++++++++++--------------
 virt/kvm/arm/vgic/trace.h        |  2 +-
 4 files changed, 25 insertions(+), 54 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/4] arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220
  2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
@ 2019-10-01  9:20 ` Marc Zyngier
  2019-10-01  9:20 ` [PATCH 2/4] arm64: KVM: Replace hyp_alternate_select with has_vhe() Marc Zyngier
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2019-10-01  9:20 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

There is no reason for using hyp_alternate_select when checking
for ARM64_WORKAROUND_834220, as each of the capabilities is
also backed by a static key. Just replace the KVM-specific
construct with cpus_have_const_cap(ARM64_WORKAROUND_834220).

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
 arch/arm64/kvm/hyp/switch.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
index adaf266d8de8..a15baca9aca0 100644
--- a/arch/arm64/kvm/hyp/switch.c
+++ b/arch/arm64/kvm/hyp/switch.c
@@ -229,20 +229,6 @@ static void __hyp_text __hyp_vgic_restore_state(struct kvm_vcpu *vcpu)
 	}
 }
 
-static bool __hyp_text __true_value(void)
-{
-	return true;
-}
-
-static bool __hyp_text __false_value(void)
-{
-	return false;
-}
-
-static hyp_alternate_select(__check_arm_834220,
-			    __false_value, __true_value,
-			    ARM64_WORKAROUND_834220);
-
 static bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar)
 {
 	u64 par, tmp;
@@ -298,7 +284,8 @@ static bool __hyp_text __populate_fault_info(struct kvm_vcpu *vcpu)
 	 * resolve the IPA using the AT instruction.
 	 */
 	if (!(esr & ESR_ELx_S1PTW) &&
-	    (__check_arm_834220()() || (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) {
+	    (cpus_have_const_cap(ARM64_WORKAROUND_834220) ||
+	     (esr & ESR_ELx_FSC_TYPE) == FSC_PERM)) {
 		if (!__translate_far_to_hpfar(far, &hpfar))
 			return false;
 	} else {
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/4] arm64: KVM: Replace hyp_alternate_select with has_vhe()
  2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
  2019-10-01  9:20 ` [PATCH 1/4] arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220 Marc Zyngier
@ 2019-10-01  9:20 ` Marc Zyngier
  2019-10-01  9:20 ` [PATCH 3/4] arm64: KVM: Kill hyp_alternate_select() Marc Zyngier
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2019-10-01  9:20 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

Given that the TLB invalidation path is pretty rarely used, there
was never any advantage to using hyp_alternate_select() here.
has_vhe(), being a glorified static key, is the right tool for
the job.

Off you go.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
 arch/arm64/kvm/hyp/tlb.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/tlb.c
index c466060b76d6..eb0efc5557f3 100644
--- a/arch/arm64/kvm/hyp/tlb.c
+++ b/arch/arm64/kvm/hyp/tlb.c
@@ -67,10 +67,14 @@ static void __hyp_text __tlb_switch_to_guest_nvhe(struct kvm *kvm,
 	isb();
 }
 
-static hyp_alternate_select(__tlb_switch_to_guest,
-			    __tlb_switch_to_guest_nvhe,
-			    __tlb_switch_to_guest_vhe,
-			    ARM64_HAS_VIRT_HOST_EXTN);
+static void __hyp_text __tlb_switch_to_guest(struct kvm *kvm,
+					     struct tlb_inv_context *cxt)
+{
+	if (has_vhe())
+		__tlb_switch_to_guest_vhe(kvm, cxt);
+	else
+		__tlb_switch_to_guest_nvhe(kvm, cxt);
+}
 
 static void __hyp_text __tlb_switch_to_host_vhe(struct kvm *kvm,
 						struct tlb_inv_context *cxt)
@@ -98,10 +102,14 @@ static void __hyp_text __tlb_switch_to_host_nvhe(struct kvm *kvm,
 	write_sysreg(0, vttbr_el2);
 }
 
-static hyp_alternate_select(__tlb_switch_to_host,
-			    __tlb_switch_to_host_nvhe,
-			    __tlb_switch_to_host_vhe,
-			    ARM64_HAS_VIRT_HOST_EXTN);
+static void __hyp_text __tlb_switch_to_host(struct kvm *kvm,
+					    struct tlb_inv_context *cxt)
+{
+	if (has_vhe())
+		__tlb_switch_to_host_vhe(kvm, cxt);
+	else
+		__tlb_switch_to_host_nvhe(kvm, cxt);
+}
 
 void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
 {
@@ -111,7 +119,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
 
 	/* Switch to requested VMID */
 	kvm = kern_hyp_va(kvm);
-	__tlb_switch_to_guest()(kvm, &cxt);
+	__tlb_switch_to_guest(kvm, &cxt);
 
 	/*
 	 * We could do so much better if we had the VA as well.
@@ -154,7 +162,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
 	if (!has_vhe() && icache_is_vpipt())
 		__flush_icache_all();
 
-	__tlb_switch_to_host()(kvm, &cxt);
+	__tlb_switch_to_host(kvm, &cxt);
 }
 
 void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)
@@ -165,13 +173,13 @@ void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)
 
 	/* Switch to requested VMID */
 	kvm = kern_hyp_va(kvm);
-	__tlb_switch_to_guest()(kvm, &cxt);
+	__tlb_switch_to_guest(kvm, &cxt);
 
 	__tlbi(vmalls12e1is);
 	dsb(ish);
 	isb();
 
-	__tlb_switch_to_host()(kvm, &cxt);
+	__tlb_switch_to_host(kvm, &cxt);
 }
 
 void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu)
@@ -180,13 +188,13 @@ void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu)
 	struct tlb_inv_context cxt;
 
 	/* Switch to requested VMID */
-	__tlb_switch_to_guest()(kvm, &cxt);
+	__tlb_switch_to_guest(kvm, &cxt);
 
 	__tlbi(vmalle1);
 	dsb(nsh);
 	isb();
 
-	__tlb_switch_to_host()(kvm, &cxt);
+	__tlb_switch_to_host(kvm, &cxt);
 }
 
 void __hyp_text __kvm_flush_vm_context(void)
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/4] arm64: KVM: Kill hyp_alternate_select()
  2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
  2019-10-01  9:20 ` [PATCH 1/4] arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220 Marc Zyngier
  2019-10-01  9:20 ` [PATCH 2/4] arm64: KVM: Replace hyp_alternate_select with has_vhe() Marc Zyngier
@ 2019-10-01  9:20 ` Marc Zyngier
  2019-10-01  9:20 ` [PATCH 4/4] KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH Marc Zyngier
  2019-10-01 13:30 ` [PATCH 0/4] KVM/arm updates for 5.4-rc2 Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2019-10-01  9:20 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

hyp_alternate_select() is now completely unused. Goodbye.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
---
 arch/arm64/include/asm/kvm_hyp.h | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
index 86825aa20852..97f21cc66657 100644
--- a/arch/arm64/include/asm/kvm_hyp.h
+++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -47,30 +47,6 @@
 #define read_sysreg_el2(r)	read_sysreg_elx(r, _EL2, _EL1)
 #define write_sysreg_el2(v,r)	write_sysreg_elx(v, r, _EL2, _EL1)
 
-/**
- * hyp_alternate_select - Generates patchable code sequences that are
- * used to switch between two implementations of a function, depending
- * on the availability of a feature.
- *
- * @fname: a symbol name that will be defined as a function returning a
- * function pointer whose type will match @orig and @alt
- * @orig: A pointer to the default function, as returned by @fname when
- * @cond doesn't hold
- * @alt: A pointer to the alternate function, as returned by @fname
- * when @cond holds
- * @cond: a CPU feature (as described in asm/cpufeature.h)
- */
-#define hyp_alternate_select(fname, orig, alt, cond)			\
-typeof(orig) * __hyp_text fname(void)					\
-{									\
-	typeof(alt) *val = orig;					\
-	asm volatile(ALTERNATIVE("nop		\n",			\
-				 "mov	%0, %1	\n",			\
-				 cond)					\
-		     : "+r" (val) : "r" (alt));				\
-	return val;							\
-}
-
 int __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu);
 
 void __vgic_v3_save_state(struct kvm_vcpu *vcpu);
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 4/4] KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH
  2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
                   ` (2 preceding siblings ...)
  2019-10-01  9:20 ` [PATCH 3/4] arm64: KVM: Kill hyp_alternate_select() Marc Zyngier
@ 2019-10-01  9:20 ` Marc Zyngier
  2019-10-01 13:30 ` [PATCH 0/4] KVM/arm updates for 5.4-rc2 Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2019-10-01  9:20 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

From: Zenghui Yu <yuzenghui@huawei.com>

Commit 49dfe94fe5ad ("KVM: arm/arm64: Fix TRACE_INCLUDE_PATH") fixes
TRACE_INCLUDE_PATH to the correct relative path to the define_trace.h
and explains why did the old one work.

The same fix should be applied to virt/kvm/arm/vgic/trace.h.

Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 virt/kvm/arm/vgic/trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/trace.h b/virt/kvm/arm/vgic/trace.h
index 55fed77a9f73..4fd4f6db181b 100644
--- a/virt/kvm/arm/vgic/trace.h
+++ b/virt/kvm/arm/vgic/trace.h
@@ -30,7 +30,7 @@ TRACE_EVENT(vgic_update_irq_pending,
 #endif /* _TRACE_VGIC_H */
 
 #undef TRACE_INCLUDE_PATH
-#define TRACE_INCLUDE_PATH ../../../virt/kvm/arm/vgic
+#define TRACE_INCLUDE_PATH ../../virt/kvm/arm/vgic
 #undef TRACE_INCLUDE_FILE
 #define TRACE_INCLUDE_FILE trace
 
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/4] KVM/arm updates for 5.4-rc2
  2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
                   ` (3 preceding siblings ...)
  2019-10-01  9:20 ` [PATCH 4/4] KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH Marc Zyngier
@ 2019-10-01 13:30 ` Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2019-10-01 13:30 UTC (permalink / raw)
  To: Marc Zyngier, Radim Krčmář
  Cc: Andrew Jones, kvm, Suzuki K Poulose, Christoffer Dall,
	Masahiro Yamada, James Morse, linux-arm-kernel, Zenghui Yu,
	kvmarm, Julien Thierry

On 01/10/19 11:20, Marc Zyngier wrote:
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git tags/kvmarm-fixes-5.4-1

Pulled, thanks.

Paolo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-10-01 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01  9:20 [PATCH 0/4] KVM/arm updates for 5.4-rc2 Marc Zyngier
2019-10-01  9:20 ` [PATCH 1/4] arm64: KVM: Drop hyp_alternate_select for checking for ARM64_WORKAROUND_834220 Marc Zyngier
2019-10-01  9:20 ` [PATCH 2/4] arm64: KVM: Replace hyp_alternate_select with has_vhe() Marc Zyngier
2019-10-01  9:20 ` [PATCH 3/4] arm64: KVM: Kill hyp_alternate_select() Marc Zyngier
2019-10-01  9:20 ` [PATCH 4/4] KVM: arm/arm64: vgic: Use the appropriate TRACE_INCLUDE_PATH Marc Zyngier
2019-10-01 13:30 ` [PATCH 0/4] KVM/arm updates for 5.4-rc2 Paolo Bonzini

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