From nobody Tue Nov 4 19:52:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502875163432660.1614080682156; Wed, 16 Aug 2017 02:19:23 -0700 (PDT) Received: from localhost ([::1]:33083 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhuTy-0007iR-4D for importer@patchew.org; Wed, 16 Aug 2017 05:19:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhuNx-0001Ld-32 for qemu-devel@nongnu.org; Wed, 16 Aug 2017 05:13:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhuNt-0004K3-PR for qemu-devel@nongnu.org; Wed, 16 Aug 2017 05:13:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49763 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 1dhuNt-0004Jo-Jg for qemu-devel@nongnu.org; Wed, 16 Aug 2017 05:13:05 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7G99w7r003679 for ; Wed, 16 Aug 2017 05:13:05 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cceskuenb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 16 Aug 2017 05:13:04 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Aug 2017 03:13:03 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 16 Aug 2017 03:13:01 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7G9CqIa61931698; Wed, 16 Aug 2017 02:12:52 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E12B78038; Wed, 16 Aug 2017 03:12:52 -0600 (MDT) Received: from [127.0.1.1] (unknown [9.124.35.220]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 29A2E78047; Wed, 16 Aug 2017 03:12:49 -0600 (MDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Wed, 16 Aug 2017 14:42:48 +0530 In-Reply-To: <150287457293.9760.17827532208744487789.stgit@aravinda> References: <150287457293.9760.17827532208744487789.stgit@aravinda> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 x-cbid: 17081609-0024-0000-0000-00001707B36A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007554; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000221; SDB=6.00903067; UDB=6.00452354; IPR=6.00683284; BA=6.00005536; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016717; XFM=3.00000015; UTC=2017-08-16 09:13:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17081609-0025-0000-0000-00004C4EE02D Message-Id: <150287476880.9760.9354459130009292681.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-16_04:, , 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-1708160152 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 v3 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 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" =20 +extern int cap_fwnmi; + static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spa= pr, 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 =3D CPU(cpu); + + if (!cap_fwnmi) { + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); + return; + } + spapr->guest_machine_check_addr =3D rtas_ld(args, 1); + + ret =3D 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); } =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 73f64ed..ca1ffa6 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; =20 static uint32_t debug_inst_opcode; =20 @@ -147,6 +148,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_mmu_radix =3D kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_RADIX); cap_mmu_hash_v3 =3D kvm_vm_check_extension(s, KVM_CAP_PPC_MMU_HASH_V3); cap_resize_hpt =3D kvm_vm_check_extension(s, KVM_CAP_SPAPR_RESIZE_HPT); + cap_fwnmi =3D kvm_check_extension(s, KVM_CAP_PPC_FWNMI); =20 if (!cap_interrupt_level) { fprintf(stderr, "KVM: Couldn't find level irq capability. Expect t= he "