From nobody Tue Nov 4 19:08:04 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 1503051322647181.4867799085289; Fri, 18 Aug 2017 03:15:22 -0700 (PDT) Received: from localhost ([::1]:40641 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieJF-0001QV-BW for importer@patchew.org; Fri, 18 Aug 2017 06:15:21 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+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 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; =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 "