KVM: PPC: Book3S HV: Host side kick VCPU when poked by real-mode KVM
authorSuresh Warrier <warrier@linux.vnet.ibm.com>
Thu, 17 Dec 2015 20:59:09 +0000 (14:59 -0600)
committerPaul Mackerras <paulus@samba.org>
Mon, 29 Feb 2016 05:25:06 +0000 (16:25 +1100)
This patch adds the support for the kick VCPU operation for
kvmppc_host_rm_ops. The kvmppc_xics_ipi_action() function
provides the function to be invoked for a host side operation
when poked by the real mode KVM. This is initiated by KVM by
sending an IPI to any free host core.

KVM real mode must set the rm_action to XICS_RM_KICK_VCPU and
rm_data to point to the VCPU to be woken up before sending the IPI.
Note that we have allocated one kvmppc_host_rm_core structure
per core. The above values need to be set in the structure
corresponding to the core to which the IPI will be sent.

Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_rm_xics.c

index ded8ddac7dcf92efaf4a314acb714524f26718b9..bc14e9e0e4fe702901b4f7185d9f9a2864078dff 100644 (file)
@@ -463,6 +463,7 @@ extern u64 kvmppc_xics_get_icp(struct kvm_vcpu *vcpu);
 extern int kvmppc_xics_set_icp(struct kvm_vcpu *vcpu, u64 icpval);
 extern int kvmppc_xics_connect_vcpu(struct kvm_device *dev,
                        struct kvm_vcpu *vcpu, u32 cpu);
+extern void kvmppc_xics_ipi_action(void);
 #else
 static inline void kvmppc_alloc_host_rm_ops(void) {};
 static inline void kvmppc_free_host_rm_ops(void) {};
index 16304d2c0cb7760cc4ef095b0b31646b6fceeefd..c3c731085c1f538d8e93ef7873b45b2b4579d651 100644 (file)
@@ -3126,6 +3126,8 @@ void kvmppc_alloc_host_rm_ops(void)
                ops->rm_core[core].rm_state.in_host = 1;
        }
 
+       ops->vcpu_kick = kvmppc_fast_vcpu_kick_hv;
+
        /*
         * Make the contents of the kvmppc_host_rm_ops structure visible
         * to other CPUs before we assign it to the global variable.
index 24f58076d49e1eada68920615c8ce2c3b1166744..43ffbfe2a18a8ef541cb337e9e6f50a4f1690f26 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/xics.h>
 #include <asm/debug.h>
 #include <asm/synch.h>
+#include <asm/cputhreads.h>
 #include <asm/ppc-opcode.h>
 
 #include "book3s_xics.h"
@@ -623,3 +624,38 @@ int kvmppc_rm_h_eoi(struct kvm_vcpu *vcpu, unsigned long xirr)
  bail:
        return check_too_hard(xics, icp);
 }
+
+/*  --- Non-real mode XICS-related built-in routines ---  */
+
+/**
+ * Host Operations poked by RM KVM
+ */
+static void rm_host_ipi_action(int action, void *data)
+{
+       switch (action) {
+       case XICS_RM_KICK_VCPU:
+               kvmppc_host_rm_ops_hv->vcpu_kick(data);
+               break;
+       default:
+               WARN(1, "Unexpected rm_action=%d data=%p\n", action, data);
+               break;
+       }
+
+}
+
+void kvmppc_xics_ipi_action(void)
+{
+       int core;
+       unsigned int cpu = smp_processor_id();
+       struct kvmppc_host_rm_core *rm_corep;
+
+       core = cpu >> threads_shift;
+       rm_corep = &kvmppc_host_rm_ops_hv->rm_core[core];
+
+       if (rm_corep->rm_data) {
+               rm_host_ipi_action(rm_corep->rm_state.rm_action,
+                                                       rm_corep->rm_data);
+               rm_corep->rm_data = NULL;
+               rm_corep->rm_state.rm_action = 0;
+       }
+}