Re: [PATCH v3] KVM: x86/xen: Implement hvm_op/HVMOP_flush_tlbs hypercall

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

 



On 18/04/2023 12:04, Kaya, Metin wrote:
On 18/04/2023 11:48, Paul Durrant wrote:
On 18/04/2023 11:13, Metin Kaya wrote:
Implement in-KVM support for Xen's HVMOP_flush_tlbs hypercall, which
allows the guest to flush all vCPU's TLBs. KVM doesn't provide an
ioctl() to precisely flush guest TLBs, and punting to userspace would
likely negate the performance benefits of avoiding a TLB shootdown in
the guest.

Signed-off-by: Metin Kaya <metikaya@xxxxxxxxxxxx>

---
v3:
    - Addressed comments for v2.
    - Verified with XTF/invlpg test case.

v2:
    - Removed an irrelevant URL from commit message.
---
   arch/x86/kvm/xen.c                 | 15 +++++++++++++++
   include/xen/interface/hvm/hvm_op.h |  3 +++
   2 files changed, 18 insertions(+)

diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index
40edf4d1974c..a63c48e8d8fa 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -21,6 +21,7 @@
   #include <xen/interface/vcpu.h>
   #include <xen/interface/version.h>
   #include <xen/interface/event_channel.h>
+#include <xen/interface/hvm/hvm_op.h>
   #include <xen/interface/sched.h>

   #include <asm/xen/cpuid.h>
@@ -1330,6 +1331,17 @@ static bool kvm_xen_hcall_sched_op(struct kvm_vcpu *vcpu, bool longmode,
       return false;
   }

+static bool kvm_xen_hcall_hvm_op(struct kvm_vcpu *vcpu, int cmd, u64
+arg, u64 *r) {
+     if (cmd == HVMOP_flush_tlbs && !arg) {
+             kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_TLB_FLUSH_GUEST);
+             *r = 0;
+             return true;
+     }
+
+     return false;
+}

This code structure means that arg != NULL will result in the guest seeing ENOSYS rather than EINVAL.

   Paul

Yes, because of this comment in David's email:
"I don't even know that we care about in-kernel acceleration for the
-EINVAL case. We could just return false for that, and let userspace
(report and) handle it."


Ok, fair enough.

Reviewed-by: Paul Durrant <paul@xxxxxxx>



[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