From patchwork Wed May 16 07:28:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharat Bhushan X-Patchwork-Id: 159542 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 4AD9EB6FC3 for ; Wed, 16 May 2012 17:28:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759501Ab2EPH2b (ORCPT ); Wed, 16 May 2012 03:28:31 -0400 Received: from db3ehsobe005.messaging.microsoft.com ([213.199.154.143]:33218 "EHLO db3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759381Ab2EPH2a convert rfc822-to-8bit (ORCPT ); Wed, 16 May 2012 03:28:30 -0400 Received: from mail58-db3-R.bigfish.com (10.3.81.228) by DB3EHSOBE006.bigfish.com (10.3.84.26) with Microsoft SMTP Server id 14.1.225.23; Wed, 16 May 2012 07:28:22 +0000 Received: from mail58-db3 (localhost [127.0.0.1]) by mail58-db3-R.bigfish.com (Postfix) with ESMTP id 22E532A05E5; Wed, 16 May 2012 07:28:22 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzzz2dh2a8h668h839h8e2h8e3h944hd25hbe9i) 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 mail58-db3 (localhost.localdomain [127.0.0.1]) by mail58-db3 (MessageSwitch) id 1337153301139277_7512; Wed, 16 May 2012 07:28:21 +0000 (UTC) Received: from DB3EHSMHS009.bigfish.com (unknown [10.3.81.229]) by mail58-db3.bigfish.com (Postfix) with ESMTP id 1D96760065; Wed, 16 May 2012 07:28:21 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS009.bigfish.com (10.3.87.109) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 16 May 2012 07:28:21 +0000 Received: from 039-SN2MPN1-021.039d.mgd.msft.net ([169.254.1.19]) by 039-SN1MMR1-003.039d.mgd.msft.net ([10.84.1.16]) with mapi id 14.02.0298.005; Wed, 16 May 2012 02:28:26 -0500 From: Bhushan Bharat-R65777 To: Alexander Graf CC: Wood Scott-B07421 , Yoder Stuart-B08248 , "kvm-ppc@vger.kernel.org" Subject: Not emulated registers on BOOKE_HV (GS-mode) Thread-Topic: Not emulated registers on BOOKE_HV (GS-mode) Thread-Index: Ac0zNXom6IZY4ZXfSpi94yw3mGGdkQ== Date: Wed, 16 May 2012 07:28:25 +0000 Message-ID: <6A3DF150A5B70D4F9B66A25E3F7C888D03D13A1F@039-SN2MPN1-021.039d.mgd.msft.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.232.14.18] 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 Hi Alex, There is below comment in arch/powerpc/kvm/booke_emulate.c /* * NOTE: some of these registers are not emulated on BOOKE_HV (GS-mode). * Their backing store is in real registers, and these functions * will return the wrong result if called for them in another context * (such as debugging). */ "some of these registers are not emulated on BOOKE_HV (GS-mode)" 1) Is not that mtspr()/mfspr() for "not emulated" registers should follow EMULATE_FAIL path? So should be ifdef out for BOOKE_HV? Otherwise the emulation code execute. 2) Or These are not emulated because the GS mode have direct access to these registers, Right? So no trap? "and these functions will return the wrong result if called for them in another context (such as debugging)." 1) So do you mean that guest is not supposed to access these registers in normal scenario but the debugger (some command on gdb in guest) can access these register? then does it make sense to treat mtspr() as nop and mfspr returns 0/undefined? In our local repository Scott Wood removed this comment by ifdef out those registers for BOOKE_HV. Below is the change (extracted - not the exact patch which does this) diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c index 83c3796..6d78906 100644 --- a/arch/powerpc/kvm/booke_emulate.c +++ b/arch/powerpc/kvm/booke_emulate.c @@ -46,18 +46,21 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, switch (get_op(inst)) { case 19: switch (get_xop(inst)) { +#ifndef CONFIG_KVM_BOOKE_HV case OP_19_XOP_RFI: kvmppc_emul_rfi(vcpu); kvmppc_set_exit_type(vcpu, EMULATED_RFI_EXITS); *advance = 0; break; +#endif default: emulated = EMULATE_FAIL; break; } break; +#ifndef CONFIG_KVM_BOOKE_HV case 31: switch (get_xop(inst)) { @@ -89,6 +92,7 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, break; +#endif default: emulated = EMULATE_FAIL; } @@ -96,23 +100,19 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, return emulated; } -/* - * NOTE: some of these registers are not emulated on BOOKE_HV (GS-mode). - * Their backing store is in real registers, and these functions - * will return the wrong result if called for them in another context - * (such as debugging). - */ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) { int emulated = EMULATE_DONE; switch (sprn) { +#ifndef CONFIG_KVM_BOOKE_HV case SPRN_DEAR: vcpu->arch.shared->dar = spr_val; break; case SPRN_ESR: vcpu->arch.shared->esr = spr_val; break; +#endif case SPRN_DBCR0: vcpu->arch.dbcr0 = spr_val; break; @@ -223,6 +223,7 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val) int emulated = EMULATE_DONE; switch (sprn) { +#ifndef CONFIG_KVM_BOOKE_HV case SPRN_IVPR: *spr_val = vcpu->arch.ivpr; break; @@ -232,6 +233,7 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val) case SPRN_ESR: *spr_val = vcpu->arch.shared->esr; break; +#endif case SPRN_DBCR0: *spr_val = vcpu->arch.dbcr0; break;