kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: PPC: epapr: Add idle hcall support for host
@ 2011-12-31  6:16 Liu Yu
  2011-12-31  6:16 ` [PATCH 2/2] KVM: PPC: epapr: Install ev_idle hcall for paravirt guest linux Liu Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Liu Yu @ 2011-12-31  6:16 UTC (permalink / raw)
  To: agraf; +Cc: kvm-ppc, kvm, Liu Yu

Add a new field opt_feature in struct kvm_ppc_pvinfo
to tell userspace whether it support hcall idle.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 arch/powerpc/include/asm/kvm_para.h |   18 ++++++++++++++----
 arch/powerpc/kvm/powerpc.c          |    9 +++++++++
 include/linux/kvm.h                 |    5 ++++-
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 50533f9..0686377 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -40,17 +40,27 @@ struct kvm_vcpu_arch_shared {
 	__u32 sr[16];
 };
 
+#ifdef __KERNEL__
+
 #define KVM_SC_MAGIC_R0		0x4b564d21 /* "KVM!" */
-#define HC_VENDOR_KVM		(42 << 16)
+
+#include <asm/epapr_hcalls.h>
+
+/* ePAPR Hypercall Vendor ID */
+#define HC_VENDOR_EPAPR		(EV_EPAPR_VENDOR_ID << 16)
+#define HC_VENDOR_KVM		(EV_KVM_VENDOR_ID << 16)
+
+/* ePAPR Hypercall Token */
+#define HC_EV_IDLE		EV_IDLE
+
+/* ePAPR Hypercall Return Codes */
 #define HC_EV_SUCCESS		0
-#define HC_EV_UNIMPLEMENTED	12
+#define HC_EV_UNIMPLEMENTED	EV_UNIMPLEMENTED
 
 #define KVM_FEATURE_MAGIC_PAGE	1
 
 #define KVM_MAGIC_FEAT_SR	(1 << 0)
 
-#ifdef __KERNEL__
-
 #ifdef CONFIG_KVM_GUEST
 
 #include <linux/of.h>
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index c33f6a7..786b34b 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -81,6 +81,10 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 
 		/* Second return value is in r4 */
 		break;
+	case HC_VENDOR_EPAPR | HC_EV_IDLE:
+		r = HC_EV_SUCCESS;
+		kvm_vcpu_block(vcpu);
+		break;
 	default:
 		r = HC_EV_UNIMPLEMENTED;
 		break;
@@ -772,6 +776,11 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
 	pvinfo->hcall[2] = inst_sc;
 	pvinfo->hcall[3] = inst_nop;
 
+	pvinfo->opt_features = 0;
+#ifdef CONFIG_BOOKE
+	pvinfo->opt_features |= KVM_PPC_PVINFO_HAS_EV_IDLE;
+#endif
+
 	return 0;
 }
 
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c107fae..5af21f3 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -426,9 +426,12 @@ struct kvm_ppc_pvinfo {
 	/* out */
 	__u32 flags;
 	__u32 hcall[4];
-	__u8  pad[108];
+	__u32 opt_features;
+	__u8  pad[104];
 };
 
+#define KVM_PPC_PVINFO_HAS_EV_IDLE   (1<<0)
+
 #define KVMIO 0xAE
 
 /*
-- 
1.6.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-04 19:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-31  6:16 [PATCH 1/2] KVM: PPC: epapr: Add idle hcall support for host Liu Yu
2011-12-31  6:16 ` [PATCH 2/2] KVM: PPC: epapr: Install ev_idle hcall for paravirt guest linux Liu Yu
2012-01-02 18:23   ` Scott Wood
2012-01-04  9:23     ` Liu Yu-B13201
2012-01-04 19:21       ` Scott Wood
2012-01-02 18:17 ` [PATCH 1/2] KVM: PPC: epapr: Add idle hcall support for host Scott Wood
2012-01-03 14:01 ` Avi Kivity
2012-01-03 14:13   ` Alexander Graf
2012-01-04 10:33     ` Avi Kivity
2012-01-04 12:04       ` Alexander Graf
2012-01-04 12:11         ` Avi Kivity
2012-01-04 19:25         ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).