From patchwork Tue Jul 15 07:01:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 369861 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 ACDFA140171 for ; Tue, 15 Jul 2014 17:03:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757889AbaGOHDa (ORCPT ); Tue, 15 Jul 2014 03:03:30 -0400 Received: from mail-by2lp0241.outbound.protection.outlook.com ([207.46.163.241]:32133 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757819AbaGOHDa (ORCPT ); Tue, 15 Jul 2014 03:03:30 -0400 Received: from CH1PR03CA006.namprd03.prod.outlook.com (10.255.156.151) by BLUPR03MB392.namprd03.prod.outlook.com (10.141.78.28) with Microsoft SMTP Server (TLS) id 15.0.985.8; Tue, 15 Jul 2014 07:03:27 +0000 Received: from BN1BFFO11FD045.protection.gbl (10.255.156.132) by CH1PR03CA006.outlook.office365.com (10.255.156.151) with Microsoft SMTP Server (TLS) id 15.0.985.8 via Frontend Transport; Tue, 15 Jul 2014 07:03:27 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD045.mail.protection.outlook.com (10.58.145.0) with Microsoft SMTP Server (TLS) id 15.0.980.11 via Frontend Transport; Tue, 15 Jul 2014 07:03:26 +0000 Received: from kvm.ap.freescale.net (kvm.ap.freescale.net [10.232.14.24]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s6F73IPp011522; Tue, 15 Jul 2014 00:03:23 -0700 From: Bharat Bhushan To: , CC: , , , Bharat Bhushan Subject: [PATCH 1/6] kvm: ppc: booke: Enhance wrapper functions to handle shadow registers Date: Tue, 15 Jul 2014 12:31:27 +0530 Message-ID: <1405407692-32075-2-git-send-email-Bharat.Bhushan@freescale.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1405407692-32075-1-git-send-email-Bharat.Bhushan@freescale.com> References: <1405407692-32075-1-git-send-email-Bharat.Bhushan@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(189002)(199002)(50226001)(104016003)(87286001)(93916002)(77156001)(83072002)(19580395003)(47776003)(48376002)(86362001)(77982001)(87936001)(106466001)(229853001)(85852003)(68736004)(74662001)(31966008)(88136002)(64706001)(19580405001)(81542001)(95666004)(76176999)(44976005)(76482001)(50986999)(26826002)(85306003)(104166001)(4396001)(99396002)(81342001)(97736001)(6806004)(74502001)(92566001)(36756003)(102836001)(21056001)(62966002)(83322001)(89996001)(80022001)(46102001)(107046002)(84676001)(50466002)(79102001)(20776003)(92726001)(105606002); DIR:OUT; SFP:; SCL:1; SRVR:BLUPR03MB392; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 027367F73D Received-SPF: Fail (: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=Bharat.Bhushan@freescale.com; X-OriginatorOrg: freescale.com Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org There are shadow registers like, GSPRG[0-3], GSRR0, GSRR1 etc on BOOKE-HV and these shadow registers are guest accessible. So these shadow registers needs to be updated on BOOKE-HV. This patch enhance the existing macros to handle shadow registers. Signed-off-by: Bharat Bhushan --- arch/powerpc/include/asm/kvm_ppc.h | 59 ++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index f3f7611..627d61e 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -475,37 +475,52 @@ static inline bool kvmppc_shared_big_endian(struct kvm_vcpu *vcpu) #endif } -#define SHARED_WRAPPER_GET(reg, size) \ -static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu) \ +static inline bool is_e500hv(void) +{ +#ifdef CONFIG_KVM_BOOKE_HV + return true; +#else + return false; +#endif +} + +#define SHARED_WRAPPER_GET(reg, size, e500hv_spr) \ +static inline u##size kvmppc_get_##reg(struct kvm_vcpu *vcpu) \ { \ + if (is_e500hv() && e500hv_spr) \ + return mfspr(e500hv_spr); \ + \ if (kvmppc_shared_big_endian(vcpu)) \ return be##size##_to_cpu(vcpu->arch.shared->reg); \ else \ return le##size##_to_cpu(vcpu->arch.shared->reg); \ } \ -#define SHARED_WRAPPER_SET(reg, size) \ +#define SHARED_WRAPPER_SET(reg, size, e500hv_spr) \ static inline void kvmppc_set_##reg(struct kvm_vcpu *vcpu, u##size val) \ { \ + if (is_e500hv() && e500hv_spr) \ + mtspr(e500hv_spr, val); \ + \ if (kvmppc_shared_big_endian(vcpu)) \ vcpu->arch.shared->reg = cpu_to_be##size(val); \ else \ vcpu->arch.shared->reg = cpu_to_le##size(val); \ } \ -#define SHARED_WRAPPER(reg, size) \ - SHARED_WRAPPER_GET(reg, size) \ - SHARED_WRAPPER_SET(reg, size) \ - -SHARED_WRAPPER(critical, 64) -SHARED_WRAPPER(sprg0, 64) -SHARED_WRAPPER(sprg1, 64) -SHARED_WRAPPER(sprg2, 64) -SHARED_WRAPPER(sprg3, 64) -SHARED_WRAPPER(srr0, 64) -SHARED_WRAPPER(srr1, 64) -SHARED_WRAPPER(dar, 64) -SHARED_WRAPPER_GET(msr, 64) +#define SHARED_WRAPPER(reg, size, e500hv_spr) \ + SHARED_WRAPPER_GET(reg, size, e500hv_spr) \ + SHARED_WRAPPER_SET(reg, size, e500hv_spr) \ + +SHARED_WRAPPER(critical, 64, 0) +SHARED_WRAPPER(sprg0, 64, SPRN_GSPRG0) +SHARED_WRAPPER(sprg1, 64, SPRN_GSPRG1) +SHARED_WRAPPER(sprg2, 64, SPRN_GSPRG2) +SHARED_WRAPPER(sprg3, 64, SPRN_GSPRG3) +SHARED_WRAPPER(srr0, 64, SPRN_GSRR0) +SHARED_WRAPPER(srr1, 64, SPRN_GSRR1) +SHARED_WRAPPER(dar, 64, SPRN_GDEAR) +SHARED_WRAPPER_GET(msr, 64, 0) static inline void kvmppc_set_msr_fast(struct kvm_vcpu *vcpu, u64 val) { if (kvmppc_shared_big_endian(vcpu)) @@ -513,12 +528,12 @@ static inline void kvmppc_set_msr_fast(struct kvm_vcpu *vcpu, u64 val) else vcpu->arch.shared->msr = cpu_to_le64(val); } -SHARED_WRAPPER(dsisr, 32) -SHARED_WRAPPER(int_pending, 32) -SHARED_WRAPPER(sprg4, 64) -SHARED_WRAPPER(sprg5, 64) -SHARED_WRAPPER(sprg6, 64) -SHARED_WRAPPER(sprg7, 64) +SHARED_WRAPPER(dsisr, 32, 0) +SHARED_WRAPPER(int_pending, 32, 0) +SHARED_WRAPPER(sprg4, 64, 0) +SHARED_WRAPPER(sprg5, 64, 0) +SHARED_WRAPPER(sprg6, 64, 0) +SHARED_WRAPPER(sprg7, 64, 0) static inline u32 kvmppc_get_sr(struct kvm_vcpu *vcpu, int nr) {