[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 27/31] PPC: KVM: set has-idle in guest device tree
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 27/31] PPC: KVM: set has-idle in guest device tree |
Date: |
Mon, 7 Jan 2013 16:38:56 +0100 |
From: Stuart Yoder <address@hidden>
On e500mc, the platform doesn't provide a way for the CPU to go idle.
To still not uselessly burn CPU time, expose an idle hypercall to the guest
if kvm supports it.
Signed-off-by: Stuart Yoder <address@hidden>
[agraf: adjust for current code base, add patch description]
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/e500.c | 4 ++++
target-ppc/kvm.c | 32 ++++++++++++++++++++++++++------
target-ppc/kvm_ppc.h | 1 +
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index b262f31..5d70618 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -225,6 +225,10 @@ static int ppce500_load_device_tree(CPUPPCState *env,
kvmppc_get_hypercall(env, hypercall, sizeof(hypercall));
qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions",
hypercall, sizeof(hypercall));
+ /* if KVM supports the idle hcall, set property indicating this */
+ if (kvmppc_get_hasidle(env)) {
+ qemu_devtree_setprop(fdt, "/hypervisor", "has-idle", NULL, 0);
+ }
}
/* Create CPU nodes */
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 436ca47..9fe949f 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -989,18 +989,38 @@ 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)
+ {
+ PowerPCCPU *cpu = ppc_env_get_cpu(env);
+ CPUState *cs = CPU(cpu);
+
+ if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO) &&
+ !kvm_vm_ioctl(cs->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)
{
- PowerPCCPU *cpu = ppc_env_get_cpu(env);
- CPUState *cs = CPU(cpu);
uint32_t *hc = (uint32_t*)buf;
-
struct kvm_ppc_pvinfo pvinfo;
- if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO) &&
- !kvm_vm_ioctl(cs->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 31eb9e6..dfb4ecf 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(PowerPCCPU *cpu, int irq, int level);
void kvmppc_set_papr(PowerPCCPU *cpu);
--
1.6.0.2
- [Qemu-devel] [PATCH 16/31] openpic: make ctpr signed, (continued)
- [Qemu-devel] [PATCH 16/31] openpic: make ctpr signed, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 17/31] openpic/fsl: critical interrupts ignore mask before v4.1, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 15/31] openpic: rework critical interrupt support, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 11/31] openpic: fix debug prints, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 20/31] openpic: use standard bitmap operations, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 13/31] ppc/booke: fix crit/mcheck/debug exceptions, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 18/31] openpic: always call IRQ_check from IRQ_get_next, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 12/31] openpic: lower interrupt when reading the MSI register, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 14/31] openpic: make register names correspond better with hw docs, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 31/31] PPC: linux-user: Calculate context pointer explicitly, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 27/31] PPC: KVM: set has-idle in guest device tree,
Alexander Graf <=
- [Qemu-devel] [PATCH 30/31] target-ppc: Error out for -cpu host on unknown PVR, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 26/31] kvm: Update kernel headers, Alexander Graf, 2013/01/07
- [Qemu-devel] [PATCH 28/31] PPC: Bring EPR support closer to reality, Alexander Graf, 2013/01/07
- Re: [Qemu-devel] [PULL 00/31] ppc patch queue 2013-01-07, Andreas Färber, 2013/01/07
- [Qemu-devel] [PATCH 21/31] openpic: add some bounds checking for IRQ numbers, Alexander Graf, 2013/01/07