From patchwork Fri Aug 18 10:07:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aravinda Prasad X-Patchwork-Id: 9908237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A304600CC for ; Fri, 18 Aug 2017 10:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED70A28C83 for ; Fri, 18 Aug 2017 10:15:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E247628C85; Fri, 18 Aug 2017 10:15:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB85B28C90 for ; Fri, 18 Aug 2017 10:15:37 +0000 (UTC) Received: from localhost ([::1]:40615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieIj-0008TA-Gj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Aug 2017 06:14:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieC2-0002id-8m for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dieBz-00085d-2U for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:07:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58346 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dieBy-00085U-SF for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:07:50 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7IA4KVx028625 for ; Fri, 18 Aug 2017 06:07:50 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cdwm5hp0r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 18 Aug 2017 06:07:50 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 Aug 2017 06:07:49 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 18 Aug 2017 06:07:46 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7IA7i5l59048074; Fri, 18 Aug 2017 10:07:44 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D16CB112040; Fri, 18 Aug 2017 06:07:33 -0400 (EDT) Received: from [127.0.1.1] (unknown [9.77.197.54]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 0B463112047; Fri, 18 Aug 2017 06:07:30 -0400 (EDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Fri, 18 Aug 2017 15:37:40 +0530 In-Reply-To: <150305073858.13788.4068645609072927349.stgit@aravinda> References: <150305073858.13788.4068645609072927349.stgit@aravinda> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17081810-0052-0000-0000-00000251ACFA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007566; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000223; SDB=6.00904046; UDB=6.00452940; IPR=6.00684258; BA=6.00005538; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016752; XFM=3.00000015; UTC=2017-08-18 10:07:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17081810-0053-0000-0000-000051B61EDE Message-Id: <150305086020.13788.12125046937924906125.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-18_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708180159 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v4 5/5] ppc: spapr: Enable FWNMI capability X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aik@ozlabs.ru, benh@au1.ibm.com, paulus@samba.org, sam.bobroff@au1.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Enable the KVM capability KVM_CAP_PPC_FWNMI so that the KVM causes guest exit with NMI as exit reason when it encounters a machine check exception on the address belonging to a guest. Without this capability enabled, KVM redirects machine check exceptions to guest's 0x200 vector. Signed-off-by: Aravinda Prasad --- hw/ppc/spapr_rtas.c | 17 +++++++++++++++++ target/ppc/kvm.c | 2 ++ 2 files changed, 19 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 2f3c47b..c2a361a 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -47,6 +47,8 @@ #include "trace.h" #include "hw/ppc/fdt.h" +extern int cap_fwnmi; + static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, @@ -354,7 +356,22 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, target_ulong args, uint32_t nret, target_ulong rets) { + int ret; + CPUState *cs = CPU(cpu); + + if (!cap_fwnmi) { + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); + return; + } + spapr->guest_machine_check_addr = rtas_ld(args, 1); + + ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_FWNMI, 0); + if (ret < 0) { + rtas_st(rets, 0, RTAS_OUT_HW_ERROR); + return; + } + rtas_st(rets, 0, RTAS_OUT_SUCCESS); } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index e9ea45f..7d37dba 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -90,6 +90,7 @@ static int cap_htm; /* Hardware transactional memory support */ static int cap_mmu_radix; static int cap_mmu_hash_v3; static int cap_resize_hpt; +int cap_fwnmi; static uint32_t debug_inst_opcode; @@ -147,6 +148,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mmu_radix = kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_RADIX); cap_mmu_hash_v3 = kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_HASH_V3); cap_resize_hpt = kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); + cap_fwnmi = kvm_check_extension(s, KVM_CAP_PPC_FWNMI); if (!cap_interrupt_level) { fprintf(stderr, "KVM: Couldn't find level irq capability. Expect the "