From patchwork Mon Aug 25 13:45:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aravinda Prasad X-Patchwork-Id: 382736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BE0C9140082 for ; Mon, 25 Aug 2014 23:47:07 +1000 (EST) Received: from localhost ([::1]:48270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLubx-0000YR-Sm for incoming@patchwork.ozlabs.org; Mon, 25 Aug 2014 09:47:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLub8-0007cC-RW for qemu-devel@nongnu.org; Mon, 25 Aug 2014 09:46:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLuay-0001Dp-Qf for qemu-devel@nongnu.org; Mon, 25 Aug 2014 09:46:14 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:47823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLuay-0001De-CR for qemu-devel@nongnu.org; Mon, 25 Aug 2014 09:46:04 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Aug 2014 07:46:03 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 25 Aug 2014 07:46:00 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 5326F19D8039; Mon, 25 Aug 2014 07:45:48 -0600 (MDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7PDk0t426607760; Mon, 25 Aug 2014 15:46:00 +0200 Received: from d03av05.boulder.ibm.com (localhost [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7PDjx8J025505; Mon, 25 Aug 2014 07:46:00 -0600 Received: from [127.0.1.1] ([9.79.209.72]) by d03av05.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s7PDjtAt025257; Mon, 25 Aug 2014 07:45:56 -0600 To: aik@au1.ibm.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org From: Aravinda Prasad Date: Mon, 25 Aug 2014 19:15:54 +0530 Message-ID: <20140825134554.2361.45051.stgit@aravindap> In-Reply-To: <20140825134353.2361.52046.stgit@aravindap> References: <20140825134353.2361.52046.stgit@aravindap> User-Agent: StGit/0.15 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14082513-1542-0000-0000-00000445880A X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.152 Cc: benh@au1.ibm.com, paulus@samba.org Subject: [Qemu-devel] [PATCH 5/5] target-ppc: Handle cases when multi-processors get machine-check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It is possible for multi-processors to experience machine check at or about the same time. As per PAPR, subsequent processors serialize waiting for the first processor to issue the ibm,nmi-interlock call. The second processor retries if the first processor which received a machine check is still reading the error log and is yet to issue ibm,nmi-interlock call. This patch implements this functionality. Signed-off-by: Aravinda Prasad --- hw/ppc/spapr_hcall.c | 13 +++++++++++++ hw/ppc/spapr_rtas.c | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index be063f4..542d0b7 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -94,6 +94,9 @@ struct rtas_mc_log { struct rtas_error_log err_log; }; +/* Whether machine check handling is in progress by any CPU */ +bool mc_in_progress; + static void do_spr_sync(void *arg) { struct SPRSyncState *s = arg; @@ -674,6 +677,16 @@ static target_ulong h_report_mc_err(PowerPCCPU *cpu, sPAPREnvironment *spapr, PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); /* + * No need for lock. Only one thread can be executing + * inside an hcall + */ + if (mc_in_progress == 1) { + return 0; + } + + mc_in_progress = 1; + + /* * We save the original r3 register in SPRG2 in 0x200 vector, * which is patched during call to ibm.nmi-register. Original * r3 is required to be included in error log diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 1135d2b..8fe4db2 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -36,6 +36,8 @@ #include +extern bool mc_in_progress; + static void rtas_display_character(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, @@ -303,6 +305,9 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, 0x6063f004, /* ori r3,r3,f004 */ /* Issue H_CALL */ 0x44000022, /* sc 1 */ + 0x2fa30000, /* cmplwi r3,0 */ + 0x409e0008, /* bne continue */ + 0x4800020a, /* retry KVMPPC_H_REPORT_ERR */ 0x7c9243a6, /* mtspr r4 sprg2 */ 0xe8830000, /* ld r4, 0(r3) */ 0x7c9a03a6, /* mtspr r4, srr0 */ @@ -333,7 +338,7 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, * machine check address requested by OS */ branch_inst |= guest_machine_check_addr; - memcpy(&trampoline[11], &branch_inst, sizeof(branch_inst)); + memcpy(&trampoline[14], &branch_inst, sizeof(branch_inst)); /* Handle all Host/Guest LE/BE combinations */ if ((*pcc->interrupts_big_endian)(cpu)) { @@ -359,6 +364,7 @@ static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, target_ulong args, uint32_t nret, target_ulong rets) { + mc_in_progress = 0; rtas_st(rets, 0, RTAS_OUT_SUCCESS); }