Skip to contentSkip to conversation

KVM: PPC: Add support for ePAPR idle hcall in host kernel

PATCH Superseded Stuart Yoder 3 participants 3 messages Jun 22, 2012 – Jul 3, 2012

Subsystems (4)

v11 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

PATCH v11 4/8 KVM: PPC: Add support for ePAPR idle hcall in host kernel

From: Liu Yu-B13201 <[email protected]>

And add a new flag definition in kvm_ppc_pvinfo to indicate whether the host supports the EV_IDLE hcall.

[[email protected]: cleanup,fixes for conditions allowing idle]

---
-v11:
-added PV info flag definition in api.txt

 Documentation/virtual/kvm/api.txt |    7 +++++--
 arch/powerpc/include/asm/Kbuild   |    1 +
 arch/powerpc/kvm/powerpc.c        |   10 ++++++++--
 include/linux/kvm.h               |    2 ++
 4 files changed, 16 insertions(+), 4 deletions(-)
Documentation/virtual/kvm/api.txt +5 -2
index 310fe50..920c3c4 100644
@@ -1190,12 +1190,15 @@ struct kvm_ppc_pvinfo {
 This ioctl fetches PV specific information that need to be passed to the guest
 using the device tree or other means from vm context.
 
-For now the only implemented piece of information distributed here is an array
-of 4 instructions that make up a hypercall.
+The hcall array defines 4 instructions that make up a hypercall.
 
 If any additional field gets added to this structure later on, a bit for that
 additional piece of information will be set in the flags bitmap.
 
+The flags bitmap is defined as:
+
+   /* the host supports the ePAPR idle hcall
+   #define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)
 
 4.48 KVM_ASSIGN_PCI_DEVICE
 
arch/powerpc/include/asm/Kbuild +1 -0
index 7e313f1..13d6b7b 100644
@@ -34,5 +34,6 @@ header-y += termios.h
 header-y += types.h
 header-y += ucontext.h
 header-y += unistd.h
+header-y += epapr_hcalls.h
 
 generic-y += rwsem.h
arch/powerpc/kvm/powerpc.c +8 -2
index 30cf01c..53d4d45 100644
@@ -38,8 +38,7 @@
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
 {
-	return !(v->arch.shared->msr & MSR_WE) ||
-	       !!(v->arch.pending_exceptions) ||
+	return !!(v->arch.pending_exceptions) ||
 	       v->requests;
 }
 
@@ -86,6 +85,11 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 
 		/* Second return value is in r4 */
 		break;
+	case _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, EV_IDLE):
+		r = EV_SUCCESS;
+		kvm_vcpu_block(vcpu);
+		clear_bit(KVM_REQ_UNHALT, &vcpu->requests);
+		break;
 	default:
 		r = EV_UNIMPLEMENTED;
 		break;
@@ -767,6 +771,8 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
 	pvinfo->hcall[3] = inst_nop;
 #endif
 
+	pvinfo->flags = KVM_PPC_PVINFO_FLAGS_EV_IDLE;
+
 	return 0;
 }
 
include/linux/kvm.h +2 -0
index 2ce09aa..c03e59e 100644
@@ -473,6 +473,8 @@ struct kvm_ppc_smmu_info {
 	struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
 };
 
+#define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)
+
 #define KVMIO 0xAE
 
 /* machine type bits, to be used as argument to KVM_CREATE_VM */
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 66 lines · Stuart Yoder

From: Liu Yu-B13201 <[email protected]>

And add a new flag definition in kvm_ppc_pvinfo to indicate whether the host supports the EV_IDLE hcall.

[[email protected]: cleanup,fixes for conditions allowing idle]

---
-v11:
-added PV info flag definition in api.txt

Documentation/virtual/kvm/api.txt |    7 +++++--
arch/powerpc/include/asm/Kbuild   |    1 +
arch/powerpc/kvm/powerpc.c        |   10 ++++++++--
include/linux/kvm.h               |    2 ++
4 files changed, 16 insertions(+), 4 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index 310fe50..920c3c4 100644
@@ -1190,12 +1190,15 @@ struct kvm_ppc_pvinfo {

This ioctl fetches PV specific information that need to be passed to the guest using the device tree or other means from vm context.

Documentation/virtual/kvm/api.txt +1 -2
-For now the only implemented piece of information distributed here is an array
-of 4 instructions that make up a hypercall.
+The hcall array defines 4 instructions that make up a hypercall.

If any additional field gets added to this structure later on, a bit for that additional piece of information will be set in the flags bitmap.

Documentation/virtual/kvm/api.txt +4 -0
+The flags bitmap is defined as:
+
+   /* the host supports the ePAPR idle hcall
+   #define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)

4.48 KVM_ASSIGN_PCI_DEVICE

arch/powerpc/include/asm/Kbuild +0 -0
index 7e313f1..13d6b7b 100644
@@ -34,5 +34,6 @@ header-y += termios.h

header-y += types.h
header-y += ucontext.h
header-y += unistd.h
+header-y += epapr_hcalls.h

generic-y += rwsem.h

arch/powerpc/kvm/powerpc.c +1 -2
index 30cf01c..53d4d45 100644
@@ -38,8 +38,7 @@
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
 {
-	return !(v->arch.shared->msr & MSR_WE) ||
-	       !!(v->arch.pending_exceptions) ||
+	return !!(v->arch.pending_exceptions) ||
 	       v->requests;
 }
 

arch/powerpc/kvm/powerpc.c int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) · line 88

Quoted 4 lines
arch/powerpc/kvm/powerpc.c +1 -0
@@ -86,6 +85,11 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 
 		/* Second return value is in r4 */
 		break;
+	case _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, EV_IDLE):

include/asm/epapr_hcalls.h:#define EV_HCALL_TOKEN(hcall_num) _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, hcall_num)

So we're better off using the non-_ version here, no? :)

Alex

#2 lore raw
Quoted 79 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alexander Graf
Sent: Monday, July 02, 2012 7:18 AM
To: Yoder Stuart-B08248
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v11 4/8] KVM: PPC: Add support for ePAPR idle hcall in host kernel

Quoted 67 lines · Stuart Yoder

From: Liu Yu-B13201 <[email protected]>

And add a new flag definition in kvm_ppc_pvinfo to indicate whether the host supports the EV_IDLE hcall.

[[email protected]: cleanup,fixes for conditions allowing idle]

---
-v11:
-added PV info flag definition in api.txt

Documentation/virtual/kvm/api.txt |    7 +++++--
arch/powerpc/include/asm/Kbuild   |    1 +
arch/powerpc/kvm/powerpc.c        |   10 ++++++++--
include/linux/kvm.h               |    2 ++
4 files changed, 16 insertions(+), 4 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index 310fe50..920c3c4 100644
@@ -1190,12 +1190,15 @@ struct kvm_ppc_pvinfo {

This ioctl fetches PV specific information that need to be passed to the guest using the device tree or other means from vm context.

Documentation/virtual/kvm/api.txt +1 -2
-For now the only implemented piece of information distributed here is an array
-of 4 instructions that make up a hypercall.
+The hcall array defines 4 instructions that make up a hypercall.

If any additional field gets added to this structure later on, a bit for that additional piece of information will be set in the flags bitmap.

Documentation/virtual/kvm/api.txt +4 -0
+The flags bitmap is defined as:
+
+   /* the host supports the ePAPR idle hcall
+   #define KVM_PPC_PVINFO_FLAGS_EV_IDLE   (1<<0)

4.48 KVM_ASSIGN_PCI_DEVICE

arch/powerpc/include/asm/Kbuild +0 -0
index 7e313f1..13d6b7b 100644
@@ -34,5 +34,6 @@ header-y += termios.h

header-y += types.h
header-y += ucontext.h
header-y += unistd.h
+header-y += epapr_hcalls.h

generic-y += rwsem.h

arch/powerpc/kvm/powerpc.c +1 -2
index 30cf01c..53d4d45 100644
@@ -38,8 +38,7 @@
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
 {
-	return !(v->arch.shared->msr & MSR_WE) ||
-	       !!(v->arch.pending_exceptions) ||
+	return !!(v->arch.pending_exceptions) ||
 	       v->requests;
 }
 
@@ -86,6 +85,11 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 
Quoted 8 lines

arch/powerpc/kvm/powerpc.c int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) · line 88

Quoted 3 lines
arch/powerpc/kvm/powerpc.c +1 -0
 		/* Second return value is in r4 */
 		break;
+	case _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, EV_IDLE):

include/asm/epapr_hcalls.h:#define EV_HCALL_TOKEN(hcall_num) _EV_HCALL_TOKEN(EV_EPAPR_VENDOR_ID, hcall_num)

So we're better off using the non-_ version here, no? :)

Yes, will fix that.

Stuart