Re: [PATCH] LoongArch: KVM: Delay secondary mmu tlb flush before guest entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sean,

Thanks for reviewing the patch, we are not familiar with open source community, it gives us much helps.

On 2024/6/17 下午10:49, Sean Christopherson wrote:
On Sat, Jun 15, 2024, Bibo Mao wrote:
diff --git a/arch/loongarch/include/asm/kvm_host.h b/arch/loongarch/include/asm/kvm_host.h
index c87b6ea0ec47..98078e01dd55 100644
--- a/arch/loongarch/include/asm/kvm_host.h
+++ b/arch/loongarch/include/asm/kvm_host.h
@@ -30,6 +30,7 @@
  #define KVM_PRIVATE_MEM_SLOTS		0
#define KVM_HALT_POLL_NS_DEFAULT 500000
+#define KVM_REQ_TLB_FLUSH_GPA		KVM_ARCH_REQ(0)
#define KVM_GUESTDBG_SW_BP_MASK \
  	(KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)
@@ -190,6 +191,7 @@ struct kvm_vcpu_arch {
/* vcpu's vpid */
  	u64 vpid;
+	unsigned long flush_gpa;

Side topic, GPAs should really use "gpa_t" instead of "unsigned long", otherwise
32-bit kernels running on CPUs with 64-bit physical addresses will fail miserably
(which may or may not be a problem in practice for LoongArch).
Sure, will modify.


diff --git a/arch/loongarch/kvm/tlb.c b/arch/loongarch/kvm/tlb.c
index 02535df6b51f..55f7f3621e38 100644
--- a/arch/loongarch/kvm/tlb.c
+++ b/arch/loongarch/kvm/tlb.c
@@ -21,12 +21,9 @@ void kvm_flush_tlb_all(void)
  	local_irq_restore(flags);
  }
+/* Called with irq disabled */

Rather than add a comment, add:

	lockdep_assert_irqs_disabled()
Good point, will modify.


in the function.

  void kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa)
  {
-	unsigned long flags;
-
-	local_irq_save(flags);
  	gpa &= (PAGE_MASK << 1);
  	invtlb(INVTLB_GID_ADDR, read_csr_gstat() & CSR_GSTAT_GID, gpa);
-	local_irq_restore(flags);
  }
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 9e8030d45129..ae9ae88c11db 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -51,6 +51,16 @@ static int kvm_check_requests(struct kvm_vcpu *vcpu)
  	return RESUME_GUEST;
  }
+/* Check pending request with irq disabled */

Same thing here.
Will modify in next version.

Regards
Bibo Mao





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux