From nobody Fri May 3 02:57:03 2024 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 1506595209180656.7201634832137; Thu, 28 Sep 2017 03:40:09 -0700 (PDT) Received: from localhost ([::1]:58371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWEV-0004mT-0D for importer@patchew.org; Thu, 28 Sep 2017 06:39:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWCc-0003c5-Rp for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:37:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWCZ-0007bx-09 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:37:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55558) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxWCY-0007bc-Nf for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:37:54 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAXukE055708 for ; Thu, 28 Sep 2017 06:37:49 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d8vf09taq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:37:49 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Sep 2017 04:37:47 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Sep 2017 04:37:45 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAbhCS4260268; Thu, 28 Sep 2017 03:37:43 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63070C60D6; Thu, 28 Sep 2017 04:37:43 -0600 (MDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 57995C60D8; Thu, 28 Sep 2017 04:37:40 -0600 (MDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:07:38 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-0024-0000-0000-000017430725 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703677; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:37:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-0025-0000-0000-00004CE560EA Message-Id: <150659505839.25889.2018054058894535368.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_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-1709280158 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 1/6] ppc: spapr: Register and handle HCALL to receive updated RTAS region 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 Receive updates from SLOF about the updated rtas-base. A separate patch for SLOF [1] (commit f9a60de3) adds functionality to invoke a private HCALL whenever OS issues instantiate-rtas with a new rtas-base. This is required as QEMU needs to know the updated rtas-base as it allocates error reporting structure in RTAS space upon a machine check exception. [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-August/120386.html Signed-off-by: Aravinda Prasad Reviewed-by: David Gibson --- hw/ppc/spapr.c | 11 +++++++++++ hw/ppc/spapr_hcall.c | 8 ++++++++ include/hw/ppc/spapr.h | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ff87f15..5deae30 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1675,6 +1675,16 @@ static const VMStateDescription vmstate_spapr_patb_e= ntry =3D { }, }; =20 +static const VMStateDescription vmstate_spapr_rtas_addr =3D { + .name =3D "spapr_rtas_addr", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(rtas_addr, sPAPRMachineState), + VMSTATE_END_OF_LIST() + }, +}; + static const VMStateDescription vmstate_spapr =3D { .name =3D "spapr", .version_id =3D 3, @@ -1694,6 +1704,7 @@ static const VMStateDescription vmstate_spapr =3D { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, &vmstate_spapr_pending_events, + &vmstate_spapr_rtas_addr, NULL } }; diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8d72bb7..c15a93c 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1088,6 +1088,13 @@ static target_ulong h_rtas(PowerPCCPU *cpu, sPAPRMac= hineState *spapr, nret, rtas_r3 + 12 + 4*nargs); } =20 +static target_ulong h_rtas_update(PowerPCCPU *cpu, sPAPRMachineState *spap= r, + target_ulong opcode, target_ulong *args) +{ + spapr->rtas_addr =3D args[0]; + return 0; +} + static target_ulong h_logical_load(PowerPCCPU *cpu, sPAPRMachineState *spa= pr, target_ulong opcode, target_ulong *args) { @@ -1750,6 +1757,7 @@ static void hypercall_register_types(void) =20 /* qemu/KVM-PPC specific hcalls */ spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas); + spapr_register_hypercall(KVMPPC_H_RTAS_UPDATE, h_rtas_update); =20 /* ibm,client-architecture-support support */ spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index c1b365f..b395aa7 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -90,6 +90,7 @@ struct sPAPRMachineState { =20 hwaddr rma_size; int vrma_adjust; + hwaddr rtas_addr; ssize_t rtas_size; void *rtas_blob; long kernel_size; @@ -400,7 +401,8 @@ struct sPAPRMachineState { #define KVMPPC_H_LOGICAL_MEMOP (KVMPPC_HCALL_BASE + 0x1) /* Client Architecture support */ #define KVMPPC_H_CAS (KVMPPC_HCALL_BASE + 0x2) -#define KVMPPC_HCALL_MAX KVMPPC_H_CAS +#define KVMPPC_H_RTAS_UPDATE (KVMPPC_HCALL_BASE + 0x3) +#define KVMPPC_HCALL_MAX KVMPPC_H_RTAS_UPDATE =20 typedef struct sPAPRDeviceTreeUpdateHeader { uint32_t version_id; From nobody Fri May 3 02:57:03 2024 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 1506595301903149.68488667290092; Thu, 28 Sep 2017 03:41:41 -0700 (PDT) Received: from localhost ([::1]:58384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWG5-00065j-4e for importer@patchew.org; Thu, 28 Sep 2017 06:41:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWCl-0003h1-DV for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWCh-0007fW-FJ for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:07 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42738 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 1dxWCh-0007fP-8n for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:03 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAXtCH046228 for ; Thu, 28 Sep 2017 06:38:00 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2d8sda2j3n-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:37:59 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Sep 2017 04:37:59 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Sep 2017 04:37:56 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAbsHl29032516; Thu, 28 Sep 2017 03:37:54 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD8716E10F; Thu, 28 Sep 2017 04:37:54 -0600 (MDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 7FDEC6E10D; Thu, 28 Sep 2017 04:37:51 -0600 (MDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:07:48 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-8235-0000-0000-00000C55B4CC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703677; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:37:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-8236-0000-0000-00003DD3EF93 Message-Id: <150659506894.25889.3558250496380782854.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_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-1709280158 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 v5 2/6] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls 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 This patch adds support in QEMU to handle "ibm,nmi-register" and "ibm,nmi-interlock" RTAS calls. The machine check notification address is saved when the OS issues "ibm,nmi-register" RTAS call. This patch also handles the case when multiple processors experience machine check at or about the same time by handling "ibm,nmi-interlock" call. In such cases, as per PAPR, subsequent processors serialize waiting for the first processor to issue the "ibm,nmi-interlock" call. The second processor waits till the first processor, which also received a machine check error, is done reading the error log. The first processor issues "ibm,nmi-interlock" call when the error log is consumed. This patch implements the releasing part of the error-log while subsequent patch (which builds error log) handles the locking part. Signed-off-by: Aravinda Prasad --- hw/ppc/spapr.c | 8 ++++++++ hw/ppc/spapr_rtas.c | 35 +++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 11 ++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5deae30..d568ea6 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1477,6 +1477,11 @@ static void ppc_spapr_reset(void) first_ppc_cpu->env.nip =3D SPAPR_ENTRY_POINT; =20 spapr->cas_reboot =3D false; + + spapr->mc_status =3D -1; + spapr->guest_machine_check_addr =3D 0; + qemu_cond_destroy(&spapr->mc_delivery_cond); + qemu_cond_init(&spapr->mc_delivery_cond); } =20 static void spapr_create_nvram(sPAPRMachineState *spapr) @@ -2598,6 +2603,9 @@ static void ppc_spapr_init(MachineState *machine) =20 kvmppc_spapr_enable_inkernel_multitce(); } + + spapr->mc_status =3D -1; + qemu_cond_init(&spapr->mc_delivery_cond); } =20 static int spapr_kvm_type(const char *vm_type) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index cdf0b60..08e9a5e 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -348,6 +348,37 @@ static void rtas_get_power_level(PowerPCCPU *cpu, sPAP= RMachineState *spapr, rtas_st(rets, 1, 100); } =20 +static void rtas_ibm_nmi_register(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, + uint32_t nret, target_ulong rets) +{ + spapr->guest_machine_check_addr =3D rtas_ld(args, 1); + rtas_st(rets, 0, RTAS_OUT_SUCCESS); +} + +static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, + uint32_t nret, target_ulong rets) +{ + if (!spapr->guest_machine_check_addr) { + /* NMI register not called */ + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); + } else { + /* + * VCPU issuing "ibm,nmi-interlock" is done with NMI handling, + * hence unset mc_status. + */ + spapr->mc_status =3D -1; + qemu_cond_signal(&spapr->mc_delivery_cond); + rtas_st(rets, 0, RTAS_OUT_SUCCESS); + } +} + + static struct rtas_call { const char *name; spapr_rtas_fn fn; @@ -489,6 +520,10 @@ static void core_rtas_register_types(void) rtas_set_power_level); spapr_rtas_register(RTAS_GET_POWER_LEVEL, "get-power-level", rtas_get_power_level); + spapr_rtas_register(RTAS_IBM_NMI_REGISTER, "ibm,nmi-register", + rtas_ibm_nmi_register); + spapr_rtas_register(RTAS_IBM_NMI_INTERLOCK, "ibm,nmi-interlock", + rtas_ibm_nmi_interlock); } =20 type_init(core_rtas_register_types) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index b395aa7..28b6e2e 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -124,6 +124,13 @@ struct sPAPRMachineState { * occurs during the unplug process. */ QTAILQ_HEAD(, sPAPRDIMMState) pending_dimm_unplugs; =20 + /* State related to "ibm,nmi-register" and "ibm,nmi-interlock" calls */ + target_ulong guest_machine_check_addr; + /* mc_status is set to -1 if mc is not in progress, else is set to the= CPU + * handling the mc. */ + int mc_status; + QemuCond mc_delivery_cond; + /*< public >*/ char *kvm_type; MemoryHotplugState hotplug_memory; @@ -520,8 +527,10 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_u= long opcode, #define RTAS_IBM_CREATE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x27) #define RTAS_IBM_REMOVE_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x28) #define RTAS_IBM_RESET_PE_DMA_WINDOW (RTAS_TOKEN_BASE + 0x29) +#define RTAS_IBM_NMI_REGISTER (RTAS_TOKEN_BASE + 0x2A) +#define RTAS_IBM_NMI_INTERLOCK (RTAS_TOKEN_BASE + 0x2B) =20 -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2A) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2C) =20 /* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 From nobody Fri May 3 02:57:03 2024 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 1506595208585919.0791292796556; Thu, 28 Sep 2017 03:40:08 -0700 (PDT) Received: from localhost ([::1]:58372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWEc-0004qa-Q5 for importer@patchew.org; Thu, 28 Sep 2017 06:40:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWCt-0003ms-Cd for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWCp-0007jQ-EZ for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:15 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34816 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 1dxWCp-0007jJ-8E for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:11 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAZ0E0004674 for ; Thu, 28 Sep 2017 06:38:10 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2d8vvqguyu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:38:10 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Sep 2017 06:38:10 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Sep 2017 06:38:06 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAc5Cq58261678; Thu, 28 Sep 2017 10:38:05 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 588C82810E; Thu, 28 Sep 2017 06:37:58 -0400 (EDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 229AB280F8; Thu, 28 Sep 2017 06:37:54 -0400 (EDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:08:00 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-0048-0000-0000-000001ECA0FF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703677; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:38:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-0049-0000-0000-000042B43A30 Message-Id: <150659508020.25889.6902174235452755801.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_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-1709280158 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 v5 3/6] Wrapper function to wait on condition for the main loop mutex 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 Introduce a wrapper function to wait on condition for the main loop mutex. This function atomically releases the main loop mutex and causes the calling thread to block on the condition. Signed-off-by: Aravinda Prasad --- cpus.c | 5 +++++ include/qemu/main-loop.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/cpus.c b/cpus.c index c9a6240..60be7f2 100644 --- a/cpus.c +++ b/cpus.c @@ -1589,6 +1589,11 @@ void qemu_mutex_unlock_iothread(void) qemu_mutex_unlock(&qemu_global_mutex); } =20 +void qemu_cond_wait_iothread(QemuCond *cond) +{ + qemu_cond_wait(cond, &qemu_global_mutex); +} + static bool all_vcpus_paused(void) { CPUState *cpu; diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 6b4b60b..618cb2f 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -279,6 +279,14 @@ void qemu_mutex_lock_iothread(void); */ void qemu_mutex_unlock_iothread(void); =20 +/** + * qemu_cond_wait_iothread: Wait on condition for the main loop mutex + * + * This function atomically releases the main loop mutex and causes + * the calling thread to block on the condition. + */ +void qemu_cond_wait_iothread(QemuCond *cond); + /* internal interfaces */ =20 void qemu_fd_register(int fd); From nobody Fri May 3 02:57:03 2024 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 1506595345906261.5261094206164; Thu, 28 Sep 2017 03:42:25 -0700 (PDT) Received: from localhost ([::1]:58386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWGr-0006mD-3M for importer@patchew.org; Thu, 28 Sep 2017 06:42:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWD6-0003ym-Si for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWD2-0007nW-7c for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxWD1-0007nE-UX for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:24 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAYwG2013852 for ; Thu, 28 Sep 2017 06:38:20 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d8wyk5fc5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:38:20 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Sep 2017 04:38:19 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Sep 2017 04:38:17 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAcFsU9437458; Thu, 28 Sep 2017 03:38:15 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD50313603A; Thu, 28 Sep 2017 04:38:15 -0600 (MDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 81A9A1360F8; Thu, 28 Sep 2017 04:38:12 -0600 (MDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:08:10 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-0004-0000-0000-000012FCADFC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703677; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:38:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-0005-0000-0000-000084449709 Message-Id: <150659509034.25889.15033474935802042526.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_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-1709280158 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 4/6] target/ppc: Handle NMI guest exit 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 Memory error such as bit flips that cannot be corrected by hardware are passed on to the kernel for handling. If the memory address in error belongs to guest then the guest kernel is responsible for taking suitable action. Patch [1] enhances KVM to exit guest with exit reason set to KVM_EXIT_NMI in such cases. This patch handles KVM_EXIT_NMI exit. If the guest OS has registered the machine check handling routine by calling "ibm,nmi-register", then the handler builds the error log and invokes the registered handler else invokes the handler at 0x200. Note that FWNMI handles synchronous machine check exceptions triggered by the hardware and hence we do not extend such support to the "nmi" command available in the QEMU monitor. Hence, "nmi" command from the monitor will always go through 0x200 vector. [1] https://www.spinics.net/lists/kvm-ppc/msg12637.html (e20bbd3d and related commits) Signed-off-by: Aravinda Prasad Signed-off-by: Mahesh Salgaonkar --- hw/ppc/spapr.c | 4 +++ hw/ppc/spapr_events.c | 62 ++++++++++++++++++++++++++++++++++++++++++++= ++++ include/hw/ppc/spapr.h | 6 +++++ target/ppc/kvm.c | 62 ++++++++++++++++++++++++++++++++++++++++++++= ++++ target/ppc/kvm_ppc.h | 14 +++++++++++ 5 files changed, 148 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d568ea6..7780434 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2453,6 +2453,10 @@ static void ppc_spapr_init(MachineState *machine) error_report("Could not get size of LPAR rtas '%s'", filename); exit(1); } + + /* Resize blob to accommodate error log. */ + spapr->rtas_size =3D spapr_get_rtas_size(); + spapr->rtas_blob =3D g_malloc(spapr->rtas_size); if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0)= { error_report("Could not load LPAR rtas '%s'", filename); diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index e377fc7..ac93a7b 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -41,6 +41,7 @@ #include "qemu/bcd.h" #include "hw/ppc/spapr_ovec.h" #include +#include =20 #define RTAS_LOG_VERSION_MASK 0xff000000 #define RTAS_LOG_VERSION_6 0x06000000 @@ -174,6 +175,22 @@ struct epow_extended_log { struct rtas_event_log_v6_epow epow; } QEMU_PACKED; =20 +/* + * Data format in RTAS Blob + * + * This structure contains error information related to Machine + * Check exception. This is filled up and copied to rtas blob + * upon machine check exception. The address of rtas blob is + * passed on to OS registered machine check notification + * routines upon machine check exception. + */ +struct rtas_event_log_mce { + target_ulong r3; + struct rtas_error_log rtas_error_log; + unsigned char buffer[1]; /* Start of extended log */ +} QEMU_PACKED; + + union drc_identifier { uint32_t index; uint32_t count; @@ -623,6 +640,51 @@ void spapr_hotplug_req_remove_by_count_indexed(sPAPRDR= ConnectorType drc_type, RTAS_LOG_V6_HP_ACTION_REMOVE, drc_type, &drc_i= d); } =20 +ssize_t spapr_get_rtas_size(void) +{ + return RTAS_ERRLOG_OFFSET + sizeof(struct rtas_event_log_mce); +} + +target_ulong spapr_mce_req_event(target_ulong r3, hwaddr rtas_addr, + uint16_t flags, bool err_type, bool le) +{ + struct rtas_event_log_mce mc_log; + uint32_t summary; + + /* Set error log fields */ + mc_log.r3 =3D r3; + + summary =3D RTAS_LOG_SEVERITY_ERROR_SYNC; + + if (flags & KVM_RUN_PPC_NMI_DISP_FULLY_RECOV) { + summary |=3D RTAS_LOG_DISPOSITION_FULLY_RECOVERED; + } else { + summary |=3D RTAS_LOG_DISPOSITION_NOT_RECOVERED; + } + + summary |=3D (RTAS_LOG_INITIATOR_MEMORY | RTAS_LOG_TARGET_MEMORY); + + if (err_type) { + summary |=3D RTAS_LOG_TYPE_ECC_UNCORR; + } else { + summary |=3D RTAS_LOG_TYPE_ECC_CORR; + } + + mc_log.rtas_error_log.summary =3D cpu_to_be32(summary); + + /* Handle all Host/Guest LE/BE combinations */ + if (le) { + mc_log.r3 =3D cpu_to_le64(mc_log.r3); + } else { + mc_log.r3 =3D cpu_to_be64(mc_log.r3); + } + + cpu_physical_memory_write(rtas_addr + RTAS_ERRLOG_OFFSET, + &mc_log, sizeof(mc_log)); + + return rtas_addr + RTAS_ERRLOG_OFFSET; +} + static void check_exception(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 28b6e2e..a75e9cf 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -556,6 +556,9 @@ target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ul= ong opcode, #define DIAGNOSTICS_RUN_MODE_IMMEDIATE 2 #define DIAGNOSTICS_RUN_MODE_PERIODIC 3 =20 +/* Offset from rtas-base where error log is placed */ +#define RTAS_ERRLOG_OFFSET 0x200 + static inline uint64_t ppc64_phys_to_real(uint64_t addr) { return addr & ~0xF000000000000000ULL; @@ -675,6 +678,9 @@ int spapr_hpt_shift_for_ramsize(uint64_t ramsize); void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift, Error **errp); void spapr_clear_pending_events(sPAPRMachineState *spapr); +ssize_t spapr_get_rtas_size(void); +target_ulong spapr_mce_req_event(target_ulong r3, hwaddr rtas_addr, + uint16_t flags, bool err_type, bool le); =20 /* CPU and LMB DRC release callbacks. */ void spapr_core_release(DeviceState *dev); diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 171d3d8..7e4ce02 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -1798,6 +1798,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_ru= n *run) ret =3D 0; break; =20 + case KVM_EXIT_NMI: + DPRINTF("handle NMI exception\n"); + ret =3D kvm_handle_nmi(cpu, run); + break; + default: fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason); ret =3D -1; @@ -2746,6 +2751,63 @@ int kvm_arch_msi_data_to_gsi(uint32_t data) return data & 0xffff; } =20 +int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run) +{ + CPUPPCState *env =3D &cpu->env; + sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + target_ulong msr =3D 0; + bool type, le; + + cpu_synchronize_state(CPU(cpu)); + + /* + * Properly set bits in MSR before we invoke the handler. + * SRR0/1, DAR and DSISR are properly set by KVM + */ + if (!(*pcc->interrupts_big_endian)(cpu)) { + msr |=3D (1ULL << MSR_LE); + } + + if (env->msr && (1ULL << MSR_SF)) { + msr |=3D (1ULL << MSR_SF); + } + + msr |=3D (1ULL << MSR_ME); + env->msr =3D msr; + + if (!spapr->guest_machine_check_addr) { + /* + * If OS has not registered with "ibm,nmi-register" + * jump to 0x200 + */ + env->nip =3D 0x200; + return 0; + } + + while (spapr->mc_status !=3D -1) { + /* + * Check whether the same CPU got machine check error + * while still handling the mc error (i.e., before + * that CPU called "ibm,nmi-interlock" + */ + if (spapr->mc_status =3D=3D cpu->vcpu_id) { + qemu_system_guest_panicked(NULL); + } + qemu_cond_wait_iothread(&spapr->mc_delivery_cond); + } + + spapr->mc_status =3D cpu->vcpu_id; + + type =3D !!(env->spr[SPR_DSISR] & P7_DSISR_MC_UE); + le =3D !!(env->msr & (1ULL << MSR_LE)); + env->gpr[3] =3D spapr_mce_req_event(env->gpr[3], spapr->rtas_addr, + run->flags, type, le); + env->nip =3D spapr->guest_machine_check_addr; + + return 0; +} + int kvmppc_enable_hwrng(void) { if (!kvm_enabled() || !kvm_check_extension(kvm_state, KVM_CAP_PPC_HWRN= G)) { diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index d6be38e..0139dae 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -71,6 +71,20 @@ bool kvmppc_pvr_workaround_required(PowerPCCPU *cpu); =20 bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); =20 +int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run *run); + +/* + * Currently KVM only passes on the uncorrected machine + * check memory error to guest. Other machine check errors + * such as SLB multi-hit and TLB multi-hit are recovered + * in KVM and are not passed on to guest. + * + * DSISR Bit for uncorrected machine check error. Based + * on arch/powerpc/include/asm/mce.h + */ +#define PPC_BIT(bit) (0x8000000000000000ULL >> bit) +#define P7_DSISR_MC_UE (PPC_BIT(48)) /* P8 too */ + #else =20 static inline uint32_t kvmppc_get_tbfreq(void) From nobody Fri May 3 02:57:03 2024 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 1506595377433342.3519762255779; Thu, 28 Sep 2017 03:42:57 -0700 (PDT) Received: from localhost ([::1]:58390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWHQ-0007Iv-Ks for importer@patchew.org; Thu, 28 Sep 2017 06:42:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWDE-00044n-DA for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWDA-0007qH-Dq for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57854 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 1dxWDA-0007qB-86 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:32 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAYAPf071931 for ; Thu, 28 Sep 2017 06:38:31 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d8w9mqkq4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:38:31 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Sep 2017 04:38:30 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Sep 2017 04:38:28 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAcQoc65208512; Thu, 28 Sep 2017 03:38:26 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 725916A0E6; Thu, 28 Sep 2017 04:38:26 -0600 (MDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 0B12D6A0EF; Thu, 28 Sep 2017 04:38:22 -0600 (MDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:08:21 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-0020-0000-0000-00000CC61FDA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703677; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:38:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-0021-0000-0000-00005E4EAB34 Message-Id: <150659510129.25889.17733386928036958909.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_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-1709280158 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 v5 5/6] 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 | 15 +++++++++++++++ target/ppc/kvm.c | 13 +++++++++++++ target/ppc/kvm_ppc.h | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 08e9a5e..d017a67 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -46,6 +46,7 @@ #include "qemu/cutils.h" #include "trace.h" #include "hw/ppc/fdt.h" +#include "kvm_ppc.h" =20 static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spa= pr, uint32_t token, uint32_t nargs, @@ -354,6 +355,20 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, target_ulong args, uint32_t nret, target_ulong rets) { + int ret; + + ret =3D kvmppc_fwnmi_enable(cpu); + + if (ret =3D=3D 1) { + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); + return; + } + + if (ret < 0) { + rtas_st(rets, 0, RTAS_OUT_HW_ERROR); + return; + } + spapr->guest_machine_check_addr =3D rtas_ld(args, 1); rtas_st(rets, 0, RTAS_OUT_SUCCESS); } diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 7e4ce02..59b3322 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -92,6 +92,7 @@ static int cap_mmu_radix; static int cap_mmu_hash_v3; static int cap_resize_hpt; static int cap_ppc_pvr_compat; +static int cap_fwnmi; =20 static uint32_t debug_inst_opcode; =20 @@ -150,6 +151,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); /* * Note: setting it to false because there is not such capability * in KVM at this moment. @@ -2142,6 +2144,17 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic= _proxy) } } =20 +int kvmppc_fwnmi_enable(PowerPCCPU *cpu) +{ + CPUState *cs =3D CPU(cpu); + + if (!cap_fwnmi) { + return 1; + } + + return kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_FWNMI, 0); +} + int kvmppc_smt_threads(void) { return cap_ppc_smt ? cap_ppc_smt : 1; diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 0139dae..55b6df2 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -28,6 +28,7 @@ void kvmppc_enable_clear_ref_mod_hcalls(void); void kvmppc_set_papr(PowerPCCPU *cpu); int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr); void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy); +int kvmppc_fwnmi_enable(PowerPCCPU *cpu); int kvmppc_smt_threads(void); void kvmppc_hint_smt_possible(Error **errp); int kvmppc_set_smt_threads(int smt); @@ -157,6 +158,11 @@ static inline void kvmppc_set_mpic_proxy(PowerPCCPU *c= pu, int mpic_proxy) { } =20 +int kvmppc_fwnmi_enable(PowerPCCPU *cpu) +{ + return 1; +} + static inline int kvmppc_smt_threads(void) { return 1; From nobody Fri May 3 02:57:03 2024 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 1506595486600489.3915833098438; Thu, 28 Sep 2017 03:44:46 -0700 (PDT) Received: from localhost ([::1]:58398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWJ8-0000JH-LC for importer@patchew.org; Thu, 28 Sep 2017 06:44:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxWDX-0004KA-I5 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxWDT-0007wz-Kw for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxWDT-0007wi-B9 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 06:38:51 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8SAcobB081710 for ; Thu, 28 Sep 2017 06:38:50 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2d8v752tcn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 28 Sep 2017 06:38: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 ; Thu, 28 Sep 2017 06:38:40 -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; Thu, 28 Sep 2017 06:38:39 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8SAcbOx3539320; Thu, 28 Sep 2017 10:38:37 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81B39B20B7; Thu, 28 Sep 2017 06:35:56 -0400 (EDT) Received: from [127.0.1.1] (unknown [9.84.218.194]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 1872FB20B6; Thu, 28 Sep 2017 06:35:52 -0400 (EDT) From: Aravinda Prasad To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, david@gibson.dropbear.id.au Date: Thu, 28 Sep 2017 16:08:31 +0530 In-Reply-To: <150659494872.25889.2069124544245723984.stgit@aravinda> References: <150659494872.25889.2069124544245723984.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: 17092810-0052-0000-0000-00000268FE6F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007804; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000232; SDB=6.00923539; UDB=6.00464295; IPR=6.00703678; BA=6.00005611; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017301; XFM=3.00000015; UTC=2017-09-28 10:38:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092810-0053-0000-0000-000052268878 Message-Id: <150659511184.25889.10868411111377268218.stgit@aravinda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-28_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709280159 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v5 6/6] migration: Block migration while handling machine check 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 Block VM migration requests until the machine check error handling is complete as (i) these errors are specific to the source hardware and is irrelevant on the target hardware, (ii) these errors cause data corruption and should be handled before migration. Signed-off-by: Aravinda Prasad --- hw/ppc/spapr_rtas.c | 3 +++ include/hw/ppc/spapr.h | 2 ++ target/ppc/kvm.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index d017a67..17f6567 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -47,6 +47,7 @@ #include "trace.h" #include "hw/ppc/fdt.h" #include "kvm_ppc.h" +#include "migration/blocker.h" =20 static void rtas_display_character(PowerPCCPU *cpu, sPAPRMachineState *spa= pr, uint32_t token, uint32_t nargs, @@ -390,6 +391,8 @@ static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, spapr->mc_status =3D -1; qemu_cond_signal(&spapr->mc_delivery_cond); rtas_st(rets, 0, RTAS_OUT_SUCCESS); + migrate_del_blocker(spapr->migration_blocker); + error_free(spapr->migration_blocker); } } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index a75e9cf..0890a44 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -7,6 +7,7 @@ #include "hw/ppc/spapr_drc.h" #include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" +#include "qapi/error.h" =20 struct VIOsPAPRBus; struct sPAPRPHBState; @@ -136,6 +137,7 @@ struct sPAPRMachineState { MemoryHotplugState hotplug_memory; =20 const char *icp_type; + Error *migration_blocker; }; =20 #define H_SUCCESS 0 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 59b3322..58de7ea 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -52,6 +52,7 @@ #endif #include "elf.h" #include "sysemu/kvm_int.h" +#include "migration/blocker.h" =20 //#define DEBUG_KVM =20 @@ -2770,10 +2771,26 @@ int kvm_handle_nmi(PowerPCCPU *cpu, struct kvm_run = *run) sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); target_ulong msr =3D 0; + Error *local_err =3D NULL; + int ret; bool type, le; =20 cpu_synchronize_state(CPU(cpu)); =20 + error_setg(&spapr->migration_blocker, + "Live migration not supported during machine check error handl= ing"); + ret =3D migrate_add_blocker(spapr->migration_blocker, &local_err); + if (ret < 0) { + /* + * We don't want to abort and let the migration to continue. In a + * rare case, the machine check handler will run on the target + * hardware. Though this is not preferable, it is better than abor= ting + * the migration or killing the VM. + */ + error_free(spapr->migration_blocker); + fprintf(stderr, "Warning: Machine check during VM migration\n"); + } + /* * Properly set bits in MSR before we invoke the handler. * SRR0/1, DAR and DSISR are properly set by KVM