From patchwork Wed Jul 3 13:30:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Caraman X-Patchwork-Id: 2816921 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 248BE9F968 for ; Wed, 3 Jul 2013 13:31:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1BAA20188 for ; Wed, 3 Jul 2013 13:31:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12A962015B for ; Wed, 3 Jul 2013 13:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753793Ab3GCNbL (ORCPT ); Wed, 3 Jul 2013 09:31:11 -0400 Received: from co1ehsobe002.messaging.microsoft.com ([216.32.180.185]:26577 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752797Ab3GCNbJ (ORCPT ); Wed, 3 Jul 2013 09:31:09 -0400 Received: from mail158-co1-R.bigfish.com (10.243.78.248) by CO1EHSOBE036.bigfish.com (10.243.66.101) with Microsoft SMTP Server id 14.1.225.23; Wed, 3 Jul 2013 13:31:09 +0000 Received: from mail158-co1 (localhost [127.0.0.1]) by mail158-co1-R.bigfish.com (Postfix) with ESMTP id 11E93700509; Wed, 3 Jul 2013 13:31:09 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zcb8kzzz1f42h1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1d2eh1d3fh1dfeh1dffh1e23h1155h) Received: from mail158-co1 (localhost.localdomain [127.0.0.1]) by mail158-co1 (MessageSwitch) id 1372858266746363_27284; Wed, 3 Jul 2013 13:31:06 +0000 (UTC) Received: from CO1EHSMHS032.bigfish.com (unknown [10.243.78.230]) by mail158-co1.bigfish.com (Postfix) with ESMTP id A9B6344001D; Wed, 3 Jul 2013 13:31:06 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS032.bigfish.com (10.243.66.42) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 3 Jul 2013 13:31:03 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.2.328.11; Wed, 3 Jul 2013 13:31:01 +0000 Received: from fsr-fed1364-13.ea.freescale.net (fsr-fed1364-13.ea.freescale.net [10.171.81.124]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r63DUw7k032081; Wed, 3 Jul 2013 06:31:00 -0700 From: Mihai Caraman To: CC: , , Mihai Caraman Subject: [PATCH 2/2] KVM: PPC: Book3E: Emulate MCSRR0/1 SPR and rfmci instruction Date: Wed, 3 Jul 2013 16:30:55 +0300 Message-ID: <1372858255-19708-2-git-send-email-mihai.caraman@freescale.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1372858255-19708-1-git-send-email-mihai.caraman@freescale.com> References: <1372858255-19708-1-git-send-email-mihai.caraman@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some guests are making use of return from machine check instruction to do crazy things even though the 64-bit kernel doesn't handle yet this interrupt. Emulate MCSRR0/1 SPR and rfmci instruction accordingly. Signed-off-by: Mihai Caraman --- arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc/kvm/booke_emulate.c | 25 +++++++++++++++++++++++++ arch/powerpc/kvm/timing.c | 1 + 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index af326cd..0466789 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -148,6 +148,7 @@ enum kvm_exit_types { EMULATED_TLBWE_EXITS, EMULATED_RFI_EXITS, EMULATED_RFCI_EXITS, + EMULATED_RFMCI_EXITS, DEC_EXITS, EXT_INTR_EXITS, HALT_WAKEUP, diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c index 27a4b28..aaff1b7 100644 --- a/arch/powerpc/kvm/booke_emulate.c +++ b/arch/powerpc/kvm/booke_emulate.c @@ -23,6 +23,7 @@ #include "booke.h" +#define OP_19_XOP_RFMCI 38 #define OP_19_XOP_RFI 50 #define OP_19_XOP_RFCI 51 @@ -43,6 +44,12 @@ static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu) kvmppc_set_msr(vcpu, vcpu->arch.csrr1); } +static void kvmppc_emul_rfmci(struct kvm_vcpu *vcpu) +{ + vcpu->arch.pc = vcpu->arch.mcsrr0; + kvmppc_set_msr(vcpu, vcpu->arch.mcsrr1); +} + int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, unsigned int inst, int *advance) { @@ -65,6 +72,12 @@ int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, *advance = 0; break; + case OP_19_XOP_RFMCI: + kvmppc_emul_rfmci(vcpu); + kvmppc_set_exit_type(vcpu, EMULATED_RFMCI_EXITS); + *advance = 0; + break; + default: emulated = EMULATE_FAIL; break; @@ -138,6 +151,12 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) case SPRN_DBCR1: vcpu->arch.dbg_reg.dbcr1 = spr_val; break; + case SPRN_MCSRR0: + vcpu->arch.mcsrr0 = spr_val; + break; + case SPRN_MCSRR1: + vcpu->arch.mcsrr1 = spr_val; + break; case SPRN_DBSR: vcpu->arch.dbsr &= ~spr_val; break; @@ -284,6 +303,12 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val) case SPRN_DBCR1: *spr_val = vcpu->arch.dbg_reg.dbcr1; break; + case SPRN_MCSRR0: + *spr_val = vcpu->arch.mcsrr0; + break; + case SPRN_MCSRR1: + *spr_val = vcpu->arch.mcsrr1; + break; case SPRN_DBSR: *spr_val = vcpu->arch.dbsr; break; diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c index c392d26..670f63d 100644 --- a/arch/powerpc/kvm/timing.c +++ b/arch/powerpc/kvm/timing.c @@ -129,6 +129,7 @@ static const char *kvm_exit_names[__NUMBER_OF_KVM_EXIT_TYPES] = { [EMULATED_TLBSX_EXITS] = "EMUL_TLBSX", [EMULATED_TLBWE_EXITS] = "EMUL_TLBWE", [EMULATED_RFI_EXITS] = "EMUL_RFI", + [EMULATED_RFMCI_EXITS] = "EMUL_RFMCI", [DEC_EXITS] = "DEC", [EXT_INTR_EXITS] = "EXTINT", [HALT_WAKEUP] = "HALT",