From patchwork Thu Mar 15 20:52:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Yoder X-Patchwork-Id: 147072 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 DC5A6B6EEC for ; Fri, 16 Mar 2012 07:52:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032250Ab2COUwd (ORCPT ); Thu, 15 Mar 2012 16:52:33 -0400 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:1601 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031833Ab2COUwc (ORCPT ); Thu, 15 Mar 2012 16:52:32 -0400 Received: from mail48-va3-R.bigfish.com (10.7.14.242) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 14.1.225.23; Thu, 15 Mar 2012 20:52:30 +0000 Received: from mail48-va3 (localhost [127.0.0.1]) by mail48-va3-R.bigfish.com (Postfix) with ESMTP id D1CD91601EF; Thu, 15 Mar 2012 20:52:30 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839hd24h) 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 mail48-va3 (localhost.localdomain [127.0.0.1]) by mail48-va3 (MessageSwitch) id 1331844749274412_5883; Thu, 15 Mar 2012 20:52:29 +0000 (UTC) Received: from VA3EHSMHS001.bigfish.com (unknown [10.7.14.248]) by mail48-va3.bigfish.com (Postfix) with ESMTP id 33F57180058; Thu, 15 Mar 2012 20:52:29 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS001.bigfish.com (10.7.99.11) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 15 Mar 2012 20:52:20 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.1.355.3; Thu, 15 Mar 2012 15:52:19 -0500 Received: from right.am.freescale.net (right.am.freescale.net [10.82.193.13]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id q2FKqHnY010569; Thu, 15 Mar 2012 13:52:19 -0700 From: Stuart Yoder To: , , Subject: [PATCH v10 3/5] KVM: PPC: Add support for ePAPR idle hcall in host kernel Date: Thu, 15 Mar 2012 15:52:15 -0500 Message-ID: <1331844737-30869-4-git-send-email-stuart.yoder@freescale.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1331844737-30869-1-git-send-email-stuart.yoder@freescale.com> References: <1331844737-30869-1-git-send-email-stuart.yoder@freescale.com> 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 From: Liu Yu-B13201 And add a new flag definition in kvm_ppc_pvinfo to indicate whether the host supports the EV_IDLE hcall. Signed-off-by: Liu Yu [stuart.yoder@freescale.com: cleanup,fixes for conditions allowing idle] Signed-off-by: Stuart Yoder --- -v10: -ePAPR definitions now addressed in separate patch -move clearing of KVM_REQ_UNHALT after kvm_vcpu_block() call arch/powerpc/include/asm/Kbuild | 1 + arch/powerpc/kvm/powerpc.c | 20 +++++++++++++++++--- include/linux/kvm.h | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index 7e313f1..13d6b7b 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -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 diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index d738626..7c4e5cc 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -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 = 0; /* success */ + kvm_vcpu_block(vcpu); + clear_bit(KVM_REQ_UNHALT, &vcpu->requests); + break; default: r = EV_UNIMPLEMENTED; break; @@ -732,9 +736,16 @@ int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf) static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) { + u32 inst_nop = 0x60000000; +#ifdef CONFIG_KVM_BOOKE_HV + u32 inst_sc1 = 0x44000022; + pvinfo->hcall[0] = inst_sc1; + pvinfo->hcall[1] = inst_nop; + pvinfo->hcall[2] = inst_nop; + pvinfo->hcall[3] = inst_nop; +#else u32 inst_lis = 0x3c000000; u32 inst_ori = 0x60000000; - u32 inst_nop = 0x60000000; u32 inst_sc = 0x44000002; u32 inst_imm_mask = 0xffff; @@ -751,6 +762,9 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) pvinfo->hcall[1] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask); pvinfo->hcall[2] = inst_sc; pvinfo->hcall[3] = inst_nop; +#endif + + pvinfo->flags = KVM_PPC_PVINFO_FLAGS_EV_IDLE; return 0; } diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 7a9dd4b..640ec5a 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -449,6 +449,8 @@ struct kvm_ppc_pvinfo { __u8 pad[108]; }; +#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1<<0) + #define KVMIO 0xAE /* machine type bits, to be used as argument to KVM_CREATE_VM */