From patchwork Sat Dec 31 06:16:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Yu-B13201 X-Patchwork-Id: 133731 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 51285B6FCC for ; Sat, 31 Dec 2011 18:06:11 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750992Ab1LaHFu (ORCPT ); Sat, 31 Dec 2011 02:05:50 -0500 Received: from am1ehsobe002.messaging.microsoft.com ([213.199.154.205]:52774 "EHLO AM1EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938Ab1LaHFu (ORCPT ); Sat, 31 Dec 2011 02:05:50 -0500 Received: from mail15-am1-R.bigfish.com (10.3.201.252) by AM1EHSOBE002.bigfish.com (10.3.204.22) with Microsoft SMTP Server id 14.1.225.23; Sat, 31 Dec 2011 07:05:48 +0000 Received: from mail15-am1 (localhost [127.0.0.1]) by mail15-am1-R.bigfish.com (Postfix) with ESMTP id AE6C510036A; Sat, 31 Dec 2011 07:05:48 +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 mail15-am1 (localhost.localdomain [127.0.0.1]) by mail15-am1 (MessageSwitch) id 1325315148601010_8471; Sat, 31 Dec 2011 07:05:48 +0000 (UTC) Received: from AM1EHSMHS005.bigfish.com (unknown [10.3.201.246]) by mail15-am1.bigfish.com (Postfix) with ESMTP id 84606240046; Sat, 31 Dec 2011 07:05:48 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by AM1EHSMHS005.bigfish.com (10.3.207.105) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 31 Dec 2011 07:05:48 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.355.3; Sat, 31 Dec 2011 01:05:47 -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 pBV75j48022440; Sat, 31 Dec 2011 01:05:46 -0600 (CST) From: Liu Yu To: CC: , , Liu Yu Subject: [PATCH 1/2] KVM: PPC: epapr: Add idle hcall support for host Date: Sat, 31 Dec 2011 14:16:15 +0800 Message-ID: <1325312176-17697-1-git-send-email-yu.liu@freescale.com> X-Mailer: git-send-email 1.6.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Add a new field opt_feature in struct kvm_ppc_pvinfo to tell userspace whether it support hcall idle. Signed-off-by: Liu Yu --- 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 + +/* 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 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 /*