Skip to contentSkip to conversation

KVM: PPC: Book3S HV: add support for the XIVE native exploitation mode hcalls

RFC PATCH New Cédric Le Goater 1 participant 1 message Apr 23, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 11/16 KVM: PPC: Book3S HV: add support for the XIVE native exploitation mode hcalls

The XIVE native exploitation mode specs define a set of Hypervisor calls to configure the sources and the event queues :

- H_INT_GET_SOURCE_INFO

used to obtain the address of the MMIO page of the Event State Buffer (PQ bits) entry associated with the source.

- H_INT_SET_SOURCE_CONFIG

assigns a source to a "target".

- H_INT_GET_SOURCE_CONFIG

determines which "target" and "priority" is assigned to a source

- H_INT_GET_QUEUE_INFO

returns the address of the notification management page associated with the specified "target" and "priority".

- H_INT_SET_QUEUE_CONFIG

sets or resets the event queue for a given "target" and "priority". It is also used to set the notification configuration associated with the queue, only unconditional notification is supported for the moment. Reset is performed with a queue size of 0 and queueing is disabled in that case.

- H_INT_GET_QUEUE_CONFIG

returns the queue settings for a given "target" and "priority".

- H_INT_RESET

resets all of the guest's internal interrupt structures to their initial state, losing all configuration set via the hcalls H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.

- H_INT_SYNC

issue a synchronisation on a source to make sure all notifications have reached their queue.

Calls that still need to be addressed :

H_INT_SET_OS_REPORTING_LINE
H_INT_GET_OS_REPORTING_LINE

---
 arch/powerpc/include/asm/kvm_ppc.h             |  43 +++
 arch/powerpc/kvm/Makefile                      |   2 +
 arch/powerpc/kvm/book3s_hv.c                   |  31 +++
 arch/powerpc/kvm/book3s_hv_builtin.c           | 196 ++++++++++++++
 arch/powerpc/kvm/book3s_hv_rm_xive_native.c    |  47 ++++
 arch/powerpc/kvm/book3s_hv_rmhandlers.S        |  52 ++++
 arch/powerpc/kvm/book3s_xive.h                 |  54 ++++
 arch/powerpc/kvm/book3s_xive_native.c          | 322 ++++++++++++++++++++++-
 arch/powerpc/kvm/book3s_xive_native_template.c | 351 +++++++++++++++++++++++++
 9 files changed, 1096 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/kvm/book3s_hv_rm_xive_native.c
arch/powerpc/include/asm/kvm_ppc.h +43 -0
index bacbe4aaa357..b5fceb4d7776 100644
@@ -593,6 +593,7 @@ extern int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
 extern int kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu);
 extern void kvmppc_xive_native_init_module(void);
 extern void kvmppc_xive_native_exit_module(void);
+extern int kvmppc_xive_hcall(struct kvm_vcpu *vcpu, u32 cmd);
 
 #else
 static inline int kvmppc_xive_set_xive(struct kvm *kvm, u32 irq, u32 server,
@@ -624,6 +625,8 @@ static inline int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
 static inline int kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu) { return 0; }
 static inline void kvmppc_xive_native_init_module(void) { }
 static inline void kvmppc_xive_native_exit_module(void) { }
+static inline int kvmppc_xive_hcall(struct kvm_vcpu *vcpu, u32 cmd)
+	{ return 0; }
 
 #endif /* CONFIG_KVM_XIVE */
 
@@ -671,6 +674,46 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server,
 int kvmppc_rm_h_cppr(struct kvm_vcpu *vcpu, unsigned long cppr);
 int kvmppc_rm_h_eoi(struct kvm_vcpu *vcpu, unsigned long xirr);
 
+int kvmppc_rm_h_int_get_source_info(struct kvm_vcpu *vcpu,
+				    unsigned long flag,
+				    unsigned long lisn);
+int kvmppc_rm_h_int_set_source_config(struct kvm_vcpu *vcpu,
+				      unsigned long flag,
+				      unsigned long lisn,
+				      unsigned long target,
+				      unsigned long priority,
+				      unsigned long eisn);
+int kvmppc_rm_h_int_get_source_config(struct kvm_vcpu *vcpu,
+				      unsigned long flag,
+				      unsigned long lisn);
+int kvmppc_rm_h_int_get_queue_info(struct kvm_vcpu *vcpu,
+				   unsigned long flag,
+				   unsigned long target,
+				   unsigned long priority);
+int kvmppc_rm_h_int_set_queue_config(struct kvm_vcpu *vcpu,
+				     unsigned long flag,
+				     unsigned long target,
+				     unsigned long priority,
+				     unsigned long qpage,
+				     unsigned long qsize);
+int kvmppc_rm_h_int_get_queue_config(struct kvm_vcpu *vcpu,
+				     unsigned long flag,
+				     unsigned long target,
+				     unsigned long priority);
+int kvmppc_rm_h_int_set_os_reporting_line(struct kvm_vcpu *vcpu,
+					  unsigned long flag,
+					  unsigned long reportingline);
+int kvmppc_rm_h_int_get_os_reporting_line(struct kvm_vcpu *vcpu,
+					  unsigned long flag,
+					  unsigned long target,
+					  unsigned long reportingline);
+int kvmppc_rm_h_int_esb(struct kvm_vcpu *vcpu, unsigned long flag,
+			unsigned long lisn, unsigned long offset,
+			unsigned long data);
+int kvmppc_rm_h_int_sync(struct kvm_vcpu *vcpu, unsigned long flag,
+			 unsigned long lisn);
+int kvmppc_rm_h_int_reset(struct kvm_vcpu *vcpu, unsigned long flag);
+
 /*
  * Host-side operations we want to set up while running in real
  * mode in the guest operating on the xics.
arch/powerpc/kvm/Makefile +2 -0
index a9cc91b528bf..c6dd7a3ba7aa 100644
@@ -76,6 +76,8 @@ kvm-hv-y += \
 
 kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \
 	book3s_hv_rm_xics.o book3s_hv_rm_xive.o
+kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XIVE) += \
+	book3s_hv_rm_xive_native.o
 
 ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
 kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
arch/powerpc/kvm/book3s_hv.c +31 -0
index 4863ab81f663..805525d6d240 100644
@@ -882,6 +882,24 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
 			break;
 		}
 		return RESUME_HOST;
+
+	case H_INT_GET_SOURCE_INFO:
+	case H_INT_SET_SOURCE_CONFIG:
+	case H_INT_GET_SOURCE_CONFIG:
+	case H_INT_GET_QUEUE_INFO:
+	case H_INT_SET_QUEUE_CONFIG:
+	case H_INT_GET_QUEUE_CONFIG:
+	case H_INT_SET_OS_REPORTING_LINE:
+	case H_INT_GET_OS_REPORTING_LINE:
+	case H_INT_ESB:
+	case H_INT_SYNC:
+	case H_INT_RESET:
+		if (kvmppc_xive_enabled(vcpu)) {
+			ret = kvmppc_xive_hcall(vcpu, req);
+			break;
+		}
+		return RESUME_HOST;
+
 	case H_PUT_TCE:
 		ret = kvmppc_h_put_tce(vcpu, kvmppc_get_gpr(vcpu, 4),
 						kvmppc_get_gpr(vcpu, 5),
@@ -4261,6 +4279,19 @@ static unsigned int default_hcall_list[] = {
 	H_XIRR,
 	H_XIRR_X,
 #endif
+#ifdef CONFIG_KVM_XIVE
+	H_INT_GET_SOURCE_INFO,
+	H_INT_SET_SOURCE_CONFIG,
+	H_INT_GET_SOURCE_CONFIG,
+	H_INT_GET_QUEUE_INFO,
+	H_INT_SET_QUEUE_CONFIG,
+	H_INT_GET_QUEUE_CONFIG,
+	H_INT_SET_OS_REPORTING_LINE,
+	H_INT_GET_OS_REPORTING_LINE,
+	H_INT_ESB,
+	H_INT_SYNC,
+	H_INT_RESET,
+#endif
 	0
 };
 
arch/powerpc/kvm/book3s_hv_builtin.c +196 -0

208 lines not on this page · raw message

arch/powerpc/kvm/book3s_hv_rm_xive_native.c new file +47 -0

47 lines not on this page · raw message

arch/powerpc/kvm/book3s_hv_rmhandlers.S +52 -0

58 lines not on this page · raw message

arch/powerpc/kvm/book3s_xive.h +54 -0

59 lines not on this page · raw message

arch/powerpc/kvm/book3s_xive_native.c +318 -2

346 lines not on this page · raw message

arch/powerpc/kvm/book3s_xive_native_template.c +351 -0

360 lines not on this page · raw message

Signature · 1 line
2.13.6