From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiAKC-0005CR-HT for qemu-devel@nongnu.org; Fri, 22 Jun 2012 16:19:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SiAKA-0001Ov-PR for qemu-devel@nongnu.org; Fri, 22 Jun 2012 16:19:24 -0400 From: Stuart Yoder Date: Fri, 22 Jun 2012 15:18:52 -0500 Message-ID: <1340396332-4552-1-git-send-email-stuart.yoder@freescale.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] PPC: e500: set has-idle in guest device tree List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de, qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, Stuart Yoder From: Stuart Yoder If the host kernel supports the idle hcall, then advertise that to the guest kernel via the device tree. Signed-off-by: Stuart Yoder --- hw/ppce500_mpc8544ds.c | 5 +++++ target-ppc/kvm.c | 26 +++++++++++++++++++++++--- target-ppc/kvm_ppc.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index b1a0b8c..7d111bb 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -124,6 +124,11 @@ static int mpc8544_load_device_tree(CPUPPCState *env, kvmppc_get_hypercall(env, hypercall, sizeof(hypercall)); qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions", hypercall, sizeof(hypercall)); + + /* add "has-idle" prop if KVM supports ePAPR idle */ + if (kvmppc_get_hasidle(env)) { + qemu_devtree_setprop(fdt, "/hypervisor", "has-idle", NULL, 0); + } } /* We need to generate the cpu nodes in reverse order, so Linux can pick diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index c09cc39..f986de3 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -705,16 +705,36 @@ uint32_t kvmppc_get_dfp(void) return kvmppc_read_int_cpu_dt("ibm,dfp"); } +static int kvmppc_get_pvinfo(CPUPPCState *env, struct kvm_ppc_pvinfo *pvinfo) +{ + if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) && + !kvm_vm_ioctl(env->kvm_state, KVM_PPC_GET_PVINFO, pvinfo)) { + return 0; + } + + return 1; +} + +int kvmppc_get_hasidle(CPUPPCState *env) +{ + struct kvm_ppc_pvinfo pvinfo; + + if (!kvmppc_get_pvinfo(env, &pvinfo) && + (pvinfo.flags & KVM_PPC_PVINFO_FLAGS_EV_IDLE)) { + return 1; + } + + return 0; +} + int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len) { uint32_t *hc = (uint32_t*)buf; struct kvm_ppc_pvinfo pvinfo; - if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) && - !kvm_vm_ioctl(env->kvm_state, KVM_PPC_GET_PVINFO, &pvinfo)) { + if (!kvmppc_get_pvinfo(env, &pvinfo)) { memcpy(buf, pvinfo.hcall, buf_len); - return 0; } diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 34ecad3..c2c75b6 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -19,6 +19,7 @@ uint32_t kvmppc_get_tbfreq(void); uint64_t kvmppc_get_clockfreq(void); uint32_t kvmppc_get_vmx(void); uint32_t kvmppc_get_dfp(void); +int kvmppc_get_hasidle(CPUPPCState *env); int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len); int kvmppc_set_interrupt(CPUPPCState *env, int irq, int level); void kvmppc_set_papr(CPUPPCState *env); -- 1.7.3.4