Skip to contentSkip to conversation

add ARMv7 HYP API to flush VM TLBs without address param

PATCH Superseded Mario Smarduch 2 participants 2 messages Apr 17, 2014

Subsystems (2)

v1 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 add ARMv7 HYP API to flush VM TLBs without address param

Add HYP API to invalidate all VM TLBs without passing address parameter, that kvm_tlb_flush_vmid_ipa() uses. Hopefully this is a valid way to do it. Tests show nothing is broken.

The address parameter is confusing since whole VM is being invalidated.

---
 arch/arm/include/asm/kvm_asm.h  |    1 +
 arch/arm/include/asm/kvm_host.h |    2 ++
 arch/arm/kvm/interrupts.S       |    5 +++++
 arch/arm/kvm/mmu.c              |    9 +++++++++
 4 files changed, 17 insertions(+)
arch/arm/include/asm/kvm_asm.h +1 -0
index 661da11..090398d 100644
@@ -76,6 +76,7 @@ extern char __kvm_hyp_code_end[];
 
 extern void __kvm_flush_vm_context(void);
 extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
+extern void __kvm_tlb_flush_vm(struct kvm *kvm);
 
 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
 #endif
arch/arm/include/asm/kvm_host.h +2 -0
index 098f7dd..315e3f3 100644
@@ -228,4 +228,6 @@ int kvm_perf_teardown(void);
 u64 kvm_arm_timer_get_reg(struct kvm_vcpu *, u64 regid);
 int kvm_arm_timer_set_reg(struct kvm_vcpu *, u64 regid, u64 value);
 
+void kvm_tlb_flush_vm(struct kvm *kvm);
+
 #endif /* __ARM_KVM_HOST_H__ */
arch/arm/kvm/interrupts.S +5 -0
index 0d68d40..f81c228 100644
@@ -45,8 +45,13 @@ __kvm_hyp_code_start:
  *
  * As v7 does not support flushing per IPA, just nuke the whole TLB
  * instead, ignoring the ipa value.
+ *
+ * void __kvm_tlb_flush_vm(struct kvm *kvm) - alias on ARMv7 to flush all VM
+ * TLBs, with no need to pass IPA. Eliminate confusing code which flushes
+ * whole VM but still requires an IPA which is unused.
  */
 ENTRY(__kvm_tlb_flush_vmid_ipa)
+ENTRY(__kvm_tlb_flush_vm)
 	push	{r2, r3}
 
 	dsb	ishst
arch/arm/kvm/mmu.c +9 -0
index e8580e2..d7a1846 100644
@@ -56,6 +56,15 @@ static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
 		kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
 }
 
+/* Flushes entire VMs TLBs, for ARMv7 reuses __kvm_tlb_flush_vmid_ipa
+ * interface without the misleading address argument
+ */
+void kvm_tlb_flush_vm(struct kvm *kvm)
+{
+	if (kvm)
+		kvm_call_hyp(__kvm_tlb_flush_vm, kvm);
+}
+
 static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
 				  int min, int max)
 {
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 19 lines · Mario Smarduch

Add HYP API to invalidate all VM TLBs without passing address parameter, that kvm_tlb_flush_vmid_ipa() uses. Hopefully this is a valid way to do it. Tests show nothing is broken.

The address parameter is confusing since whole VM is being invalidated.

---
 arch/arm/include/asm/kvm_asm.h  |    1 +
 arch/arm/include/asm/kvm_host.h |    2 ++
 arch/arm/kvm/interrupts.S       |    5 +++++
 arch/arm/kvm/mmu.c              |    9 +++++++++
 4 files changed, 17 insertions(+)
arch/arm/include/asm/kvm_asm.h +0 -0
index 661da11..090398d 100644

arch/arm/include/asm/kvm_asm.h extern char __kvm_hyp_code_end[]; · line 79

Quoted 4 lines
arch/arm/include/asm/kvm_asm.h +1 -0
@@ -76,6 +76,7 @@ extern char __kvm_hyp_code_end[];
 
 extern void __kvm_flush_vm_context(void);
 extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
+extern void __kvm_tlb_flush_vm(struct kvm *kvm);

I'd prefer you retain the "vmid" acronym, instead of "vm". It helps showing that we're using an invalidation by VMID instead of another mechanism.

Quoted 19 lines
arch/arm/include/asm/kvm_asm.h +0 -0
 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
 #endif
arch/arm/include/asm/kvm_host.h +2 -0
index 098f7dd..315e3f3 100644
@@ -228,4 +228,6 @@ int kvm_perf_teardown(void);
 u64 kvm_arm_timer_get_reg(struct kvm_vcpu *, u64 regid);
 int kvm_arm_timer_set_reg(struct kvm_vcpu *, u64 regid, u64 value);
 
+void kvm_tlb_flush_vm(struct kvm *kvm);
+
 #endif /* __ARM_KVM_HOST_H__ */
arch/arm/kvm/interrupts.S +0 -0
index 0d68d40..f81c228 100644

arch/arm/kvm/interrupts.S __kvm_hyp_code_start: · line 51

Quoted 7 lines
arch/arm/kvm/interrupts.S +4 -0
@@ -45,8 +45,13 @@ __kvm_hyp_code_start:
  *
  * As v7 does not support flushing per IPA, just nuke the whole TLB
  * instead, ignoring the ipa value.
+ *
+ * void __kvm_tlb_flush_vm(struct kvm *kvm) - alias on ARMv7 to flush all VM
+ * TLBs, with no need to pass IPA. Eliminate confusing code which flushes
+ * whole VM but still requires an IPA which is unused.

Loose the comment about confusion. I don't think we're that confused ;-).

arch/arm/kvm/interrupts.S __kvm_hyp_code_start: · line 57

Quoted 6 lines
arch/arm/kvm/interrupts.S +1 -0
  */
 ENTRY(__kvm_tlb_flush_vmid_ipa)
+ENTRY(__kvm_tlb_flush_vm)
 	push	{r2, r3}
 
 	dsb	ishst

Missing ENDPROC(). This may cause issues on a Thumb2 kernel, and confuse the unwinder.

arch/arm/kvm/mmu.c static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) · line 61

Quoted 11 lines
arch/arm/kvm/mmu.c +3 -0
index e8580e2..d7a1846 100644
@@ -56,6 +56,15 @@ static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
 		kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, kvm, ipa);
 }
 
+/* Flushes entire VMs TLBs, for ARMv7 reuses __kvm_tlb_flush_vmid_ipa
+ * interface without the misleading address argument
+ */

Superfluous (and wrong) comment. The address argument is not misleading, but a concious design decision.

Quoted 9 lines
arch/arm/kvm/mmu.c +6 -0
+void kvm_tlb_flush_vm(struct kvm *kvm)
+{
+	if (kvm)
+		kvm_call_hyp(__kvm_tlb_flush_vm, kvm);
+}
+
 static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache,
 				  int min, int max)
 {
Signature · 1 line
Jazz is not dead. It just smells funny.