From patchwork Fri Feb 17 09:59:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yu-B13201 X-Patchwork-Id: 141876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1D8FBB6EE7 for ; Sat, 18 Feb 2012 03:55:36 +1100 (EST) Received: from localhost ([::1]:53766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyR5l-0003N2-3e for incoming@patchwork.ozlabs.org; Fri, 17 Feb 2012 11:55:29 -0500 Received: from eggs.gnu.org ([140.186.70.92]:56015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyKf3-0000Y3-3T for qemu-devel@nongnu.org; Fri, 17 Feb 2012 05:03:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyKex-0006pR-8B for qemu-devel@nongnu.org; Fri, 17 Feb 2012 05:03:28 -0500 Received: from ch1ehsobe001.messaging.microsoft.com ([216.32.181.181]:23454 helo=ch1outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyKel-0006np-70; Fri, 17 Feb 2012 05:03:11 -0500 Received: from mail67-ch1-R.bigfish.com (10.43.68.254) by CH1EHSOBE007.bigfish.com (10.43.70.57) with Microsoft SMTP Server id 14.1.225.23; Fri, 17 Feb 2012 10:03:10 +0000 Received: from mail67-ch1 (localhost [127.0.0.1]) by mail67-ch1-R.bigfish.com (Postfix) with ESMTP id 32A3B18019D; Fri, 17 Feb 2012 10:03:10 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI Received: from mail67-ch1 (localhost.localdomain [127.0.0.1]) by mail67-ch1 (MessageSwitch) id 1329472988277560_3946; Fri, 17 Feb 2012 10:03:08 +0000 (UTC) Received: from CH1EHSMHS021.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.249]) by mail67-ch1.bigfish.com (Postfix) with ESMTP id 3F4C0480046; Fri, 17 Feb 2012 10:03:08 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS021.bigfish.com (10.43.70.21) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 17 Feb 2012 10:03:07 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.355.3; Fri, 17 Feb 2012 04:03:05 -0600 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id q1HA34CU008753; Fri, 17 Feb 2012 04:03:04 -0600 (CST) From: Liu Yu To: Date: Fri, 17 Feb 2012 17:59:00 +0800 Message-ID: <1329472740-8173-1-git-send-email-yu.liu@freescale.com> X-Mailer: git-send-email 1.6.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-detected-operating-system: by eggs.gnu.org: Windows XP/2000 (RFC1323+, w+, tstamp-) X-Received-From: 216.32.181.181 X-Mailman-Approved-At: Fri, 17 Feb 2012 11:55:15 -0500 Cc: B07421@freescale.com, Liu Yu , qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] kvmppc: update "has-idle" property in hypervisor node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Check if host support ev_idle hypercall via pvinfo->flags, If so, then set "has-idle" property in guest dts. Signed-off-by: Liu Yu --- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppce500_mpc8544ds.c | 6 +++++- scripts/update-linux-headers.sh | 3 +++ target-ppc/kvm.c | 6 +++++- target-ppc/kvm_ppc.h | 3 ++- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 506187b..3b9ee11 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -398,7 +398,7 @@ static void ppc_core99_init (ram_addr_t ram_size, fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); hypercall = g_malloc(16); - kvmppc_get_hypercall(env, hypercall, 16); + kvmppc_get_hypercall(env, hypercall, 16, NULL); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 9295a34..384e425 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -313,7 +313,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq()); hypercall = g_malloc(16); - kvmppc_get_hypercall(env, hypercall, 16); + kvmppc_get_hypercall(env, hypercall, 16, NULL); fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid()); #endif diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c index d69f78c..1fc80d4 100644 --- a/hw/ppce500_mpc8544ds.c +++ b/hw/ppce500_mpc8544ds.c @@ -112,6 +112,8 @@ static int mpc8544_load_device_tree(CPUState *env, fprintf(stderr, "couldn't set /chosen/bootargs\n"); if (kvm_enabled()) { + uint32_t pv_flags; + /* Read out host's frequencies */ clock_freq = kvmppc_get_clockfreq(); tb_freq = kvmppc_get_tbfreq(); @@ -119,9 +121,11 @@ static int mpc8544_load_device_tree(CPUState *env, /* indicate KVM hypercall interface */ qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible", "linux,kvm"); - kvmppc_get_hypercall(env, hypercall, sizeof(hypercall)); + kvmppc_get_hypercall(env, hypercall, sizeof(hypercall), &pv_flags); qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions", hypercall, sizeof(hypercall)); + if(pv_flags & KVM_PPC_PVINFO_FLAGS_EV_IDLE) + 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/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh index 9d2a4bc..a8513f6 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -39,6 +39,9 @@ for arch in x86 powerpc s390; do if [ $arch = x86 ]; then cp "$tmpdir/include/asm/hyperv.h" "$output/linux-headers/asm-x86" fi + if [ $arch = powerpc ]; then + cp "$tmpdir/include/asm/epapr_hcalls.h" "$output/linux-headers/asm-powerpc" + fi done rm -rf "$output/linux-headers/linux" diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 50cfa02..96b522d 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -704,7 +704,8 @@ uint32_t kvmppc_get_dfp(void) return kvmppc_read_int_cpu_dt("ibm,dfp"); } -int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len) +int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len, + uint32_t *flags) { uint32_t *hc = (uint32_t*)buf; @@ -713,6 +714,9 @@ int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len) if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) && !kvm_vm_ioctl(env->kvm_state, KVM_PPC_GET_PVINFO, &pvinfo)) { memcpy(buf, pvinfo.hcall, buf_len); + if (flags) { + *flags = pvinfo.flags; + } return 0; } diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index f9c0198..68129fb 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -19,7 +19,8 @@ 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_hypercall(CPUState *env, uint8_t *buf, int buf_len); +int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len, + uint32_t *flags); int kvmppc_set_interrupt(CPUState *env, int irq, int level); void kvmppc_set_papr(CPUState *env); int kvmppc_smt_threads(void);