From patchwork Wed Mar 25 14:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11457977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 894C9139A for ; Wed, 25 Mar 2020 14:32:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EEFF20714 for ; Wed, 25 Mar 2020 14:32:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qByL82Fm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EEFF20714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH75A-0004ij-Dk for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Mar 2020 10:32:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34981) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH72i-00029b-4i for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH72g-0002eh-LL for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:04 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:41223) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jH72d-0002Zq-Uc; Wed, 25 Mar 2020 10:30:00 -0400 Received: by mail-pf1-x444.google.com with SMTP id z65so1110708pfz.8; Wed, 25 Mar 2020 07:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vitaAIcV4SE+7Zrx0kH3CXztZqs8gVnOhGiQ7IdvpsY=; b=qByL82Fm3sganSMcuYZGu0z3pY0IKcsth7eUB7rjgHCZICkPFa9uDLCDMZV1FC8P9O +sN2MsG2LLpEtfJicG6uw/ROrkZXv3a9h9DQYIGUOf7K0jH0EfWrWX6AnMVapXpt8q5f gYQBt+gYeq2/JRgA7eja0Qz5DKLN20troKYXmdpOyfluQbWyIlD6AVk6hQBMGeGWLLix /znwe+LnyFy4WPA2hIMx3z32eW/jBVkZF8lXLBFg887mpE40DwCnPmXyw7aaDlkj/ctK CtoGxdFIR41ILLZktk8lW3F+5p3fDj800p9Wfoad7cJ5EygjN0sq6EqLS6WW4o2Mg2sO orDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vitaAIcV4SE+7Zrx0kH3CXztZqs8gVnOhGiQ7IdvpsY=; b=pFyfsHr8usL2O4RegAikYqNRpxKnYpUDNeo2KLRBOlhwPWgnz0SYs5ntqswjYej2Ut AKlqznfAWdHCJPisI/YPtaxf0gOKQ03kl/FzZJrpydxIG8/CNQMiyfJb0REijHDg4l3u Q/EqQ/K8LnGQiYchYpuIJuXLDACg3+hKyegEK6i7BBGb6Ij8aR6vsW1lOLUL5Rv5XCmE /oA82Apxl9roeimzwnl4K4DKelFYitB4tz/175Nkjc+WueEMZiHahL3VPyZ4XprfZ4DF 45HZjboEitR3gwe2ECIhDEXXPejquSWxQcuJPJwvOH5griGq+kVvUpMP21ThD1UfmkFv 2sUw== X-Gm-Message-State: ANhLgQ2w4JY/AvvyImVOS/KgCEvoYoano9B5EmKsLY1vAJkfS8XmK3AS l6munL0k/T+7KhwmJGqhInqxcdGz X-Google-Smtp-Source: ADFU+vuYnYXaF3yO3ylFsubESiHYvROEoBbeHjtZG1gCHV4MuDCT12UPhhYUORd0oSv4YS97UPbzYg== X-Received: by 2002:a63:2:: with SMTP id 2mr3319504pga.102.1585146598704; Wed, 25 Mar 2020 07:29:58 -0700 (PDT) Received: from bobo.ibm.com (14-202-190-183.tpgi.com.au. [14.202.190.183]) by smtp.gmail.com with ESMTPSA id i20sm10609622pfd.89.2020.03.25.07.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 07:29:58 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 1/4] ppc/spapr: KVM FWNMI should not be enabled until guest requests it Date: Thu, 26 Mar 2020 00:29:03 +1000 Message-Id: <20200325142906.221248-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200325142906.221248-1-npiggin@gmail.com> References: <20200325142906.221248-1-npiggin@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Alexey Kardashevskiy , Mahesh Salgaonkar , qemu-devel@nongnu.org, Nicholas Piggin , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ganesh Goudar , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The KVM FWNMI capability should be enabled with the "ibm,nmi-register" rtas call. Although MCEs from KVM will be delivered as architected interrupts to the guest before "ibm,nmi-register" is called, KVM has different behaviour depending on whether the guest has enabled FWNMI (it attempts to do more recovery on behalf of a non-FWNMI guest). Signed-off-by: Nicholas Piggin Reviewed-by: Greg Kurz --- hw/ppc/spapr_caps.c | 7 ++++--- hw/ppc/spapr_rtas.c | 7 +++++++ target/ppc/kvm.c | 7 +++++++ target/ppc/kvm_ppc.h | 6 ++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 679ae7959f..eb54f94227 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -517,9 +517,10 @@ static void cap_fwnmi_apply(SpaprMachineState *spapr, uint8_t val, } if (kvm_enabled()) { - if (kvmppc_set_fwnmi() < 0) { - error_setg(errp, "Firmware Assisted Non-Maskable Interrupts(FWNMI) " - "not supported by KVM"); + if (!kvmppc_get_fwnmi()) { + error_setg(errp, +"Firmware Assisted Non-Maskable Interrupts(FWNMI) not supported by KVM."); + error_append_hint(errp, "Try appending -machine cap-fwnmi=off\n"); } } } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 9fb8c8632a..29abe66d01 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -437,6 +437,13 @@ static void rtas_ibm_nmi_register(PowerPCCPU *cpu, return; } + if (kvm_enabled()) { + if (kvmppc_set_fwnmi() < 0) { + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); + return; + } + } + spapr->fwnmi_system_reset_addr = sreset_addr; spapr->fwnmi_machine_check_addr = mce_addr; diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 597f72be1b..03d0667e8f 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -88,6 +88,7 @@ static int cap_ppc_safe_indirect_branch; static int cap_ppc_count_cache_flush_assist; static int cap_ppc_nested_kvm_hv; static int cap_large_decr; +static int cap_fwnmi; static uint32_t debug_inst_opcode; @@ -136,6 +137,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) kvmppc_get_cpu_characteristics(s); cap_ppc_nested_kvm_hv = kvm_vm_check_extension(s, KVM_CAP_PPC_NESTED_HV); cap_large_decr = kvmppc_get_dec_bits(); + cap_fwnmi = kvm_vm_check_extension(s, KVM_CAP_PPC_FWNMI); /* * Note: setting it to false because there is not such capability * in KVM at this moment. @@ -2064,6 +2066,11 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) } } +bool kvmppc_get_fwnmi(void) +{ + return cap_fwnmi; +} + int kvmppc_set_fwnmi(void) { PowerPCCPU *cpu = POWERPC_CPU(first_cpu); diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 332fa0aa1c..fcaf745516 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -27,6 +27,7 @@ void kvmppc_enable_h_page_init(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); +bool kvmppc_get_fwnmi(void); int kvmppc_set_fwnmi(void); int kvmppc_smt_threads(void); void kvmppc_error_append_smt_possible_hint(Error *const *errp); @@ -163,6 +164,11 @@ static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy) { } +static inline bool kvmppc_get_fwnmi(void) +{ + return false; +} + static inline int kvmppc_set_fwnmi(void) { return -1; From patchwork Wed Mar 25 14:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11457979 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E1FF139A for ; Wed, 25 Mar 2020 14:33:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2301520774 for ; Wed, 25 Mar 2020 14:33:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V1pARf1A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2301520774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH76P-0006MK-BJ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Mar 2020 10:33:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35020) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH72m-0002Fg-Gp for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH72l-0002kS-DF for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:08 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:44867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jH72i-0002fo-Nb; Wed, 25 Mar 2020 10:30:04 -0400 Received: by mail-pf1-x433.google.com with SMTP id b72so1104122pfb.11; Wed, 25 Mar 2020 07:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ENlqhDXY1VN8Te0oscoNTqgy8InnCmLXyV4U286tXj4=; b=V1pARf1AEwFaJ+wb0CsNADmTdrrFnQzC5apmBKxsoz+JG6WQbMSTKZVy6dC5aoEdUY SX2fLSDWfAbKO65M/sRIkpvGeMQmm9t3aFOi6o+LTPn/cdFCBfAt93ev2pqMDaMFDj7j f0GTMRwtBbOS2T6fEWxnM1rbnJICfAj50lCz06EzDxHS0FEcva1cvoS+hOyhSebZ6fzg U5hRVa2G2Kyastk6MITgmtItcsqAmKNmMgwqM9qoo/DXOEw7RXls9HXzwieUcotBWSNd HB0XB0y1fk+C6mKC+TAKahK1sXh1nsQSsFrPzRiVFeQSmuXZX3bSOW0YYts3lJpKCTkd Q9HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ENlqhDXY1VN8Te0oscoNTqgy8InnCmLXyV4U286tXj4=; b=sv+ShakEPE2zINP/uof8TAckxoBS5/0Qru/a1HzjQARyrQrjt9HL97gmsjwDZUrhg0 gjyVeZJT422AEQ6j+RtHVlDePgSZjVOL58FBXUwnNyBlFNzN/HYuajJzgcAo6xrGdM4U jEjq4y/hxAhp+Q0P6FGuZocBuLyWr0pYZNoDNAFbPSBZEskb0NPetVu1EiPlCqUEpcwr Fvg7YZzZENxzOQB41YjTKVSbWX+iLZvwdHu/m0MNGAyS4ox3e3MsiEdK/kWsGW7lIS9b i9oadzFNI2UE5tP6iHzTZbPiHwWORvAuCQqhbY78XXl3IhBwb0LOTWi9+xLa6m6+TP3V u3xw== X-Gm-Message-State: ANhLgQ38TpcTPpBOl8elPZr7RokHuO3E1GksPP3tYdh9L8aTC8EZtf7+ idUWc00rnnCIeutUMOfENeHBk64N X-Google-Smtp-Source: ADFU+vtWidIfdZFf3u0PUfXnNZKSaA+ych7BJZ8LeO5wSEHsdhiSTJU2UDDpH/mRjeU0m/wbx9RSxQ== X-Received: by 2002:a63:d7:: with SMTP id 206mr3323040pga.366.1585146603562; Wed, 25 Mar 2020 07:30:03 -0700 (PDT) Received: from bobo.ibm.com (14-202-190-183.tpgi.com.au. [14.202.190.183]) by smtp.gmail.com with ESMTPSA id i20sm10609622pfd.89.2020.03.25.07.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 07:30:03 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 2/4] ppc/spapr: Improve FWNMI machine check delivery corner case comments Date: Thu, 26 Mar 2020 00:29:04 +1000 Message-Id: <20200325142906.221248-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200325142906.221248-1-npiggin@gmail.com> References: <20200325142906.221248-1-npiggin@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::433 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Alexey Kardashevskiy , Mahesh Salgaonkar , qemu-devel@nongnu.org, Nicholas Piggin , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ganesh Goudar , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Some of the conditions are not as clearly documented as they could be. Also the non-FWNMI case does not need a large comment. Reviewed-by: Greg Kurz Signed-off-by: Nicholas Piggin --- hw/ppc/spapr_events.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index a4a540f43d..a908c5d0e9 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -860,17 +860,13 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) Error *local_err = NULL; if (spapr->fwnmi_machine_check_addr == -1) { - /* - * This implies that we have hit a machine check either when the - * guest has not registered FWNMI (i.e., "ibm,nmi-register" not - * called) or between system reset and "ibm,nmi-register". - * Fall back to the old machine check behavior in such cases. - */ + /* Non-FWNMI case, deliver it like an architected CPU interrupt. */ cs->exception_index = POWERPC_EXCP_MCHECK; ppc_cpu_do_interrupt(cs); return; } + /* Wait for FWNMI interlock. */ while (spapr->fwnmi_machine_check_interlock != -1) { /* * Check whether the same CPU got machine check error @@ -882,8 +878,13 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) return; } qemu_cond_wait_iothread(&spapr->fwnmi_machine_check_interlock_cond); - /* Meanwhile if the system is reset, then just return */ if (spapr->fwnmi_machine_check_addr == -1) { + /* + * If the machine was reset while waiting for the interlock, + * abort the delivery. The machine check applies to a context + * that no longer exists, so it wouldn't make sense to deliver + * it now. + */ return; } } @@ -894,7 +895,9 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) * We don't want to abort so we let the migration to continue. * In a rare case, the machine check handler will run on the target. * Though this is not preferable, it is better than aborting - * the migration or killing the VM. + * the migration or killing the VM. It is okay to call + * migrate_del_blocker on a blocker that was not added (which the + * nmi-interlock handler would do when it's called after this). */ warn_report("Received a fwnmi while migration was in progress"); } From patchwork Wed Mar 25 14:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11457993 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A3891392 for ; Wed, 25 Mar 2020 14:35:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10E7920777 for ; Wed, 25 Mar 2020 14:35:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DDy00brQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 10E7920777 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH77v-0008RZ-38 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Mar 2020 10:35:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35048) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH72r-0002NT-5Q for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH72q-0002rm-2Y for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:13 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:35805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jH72n-0002m7-N2; Wed, 25 Mar 2020 10:30:09 -0400 Received: by mail-pl1-x636.google.com with SMTP id g6so870720plt.2; Wed, 25 Mar 2020 07:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FriArxnM019D776ImdHSDTVH+8rk+AtrtUiHpYXliLw=; b=DDy00brQVfq7HtavWuuOAekUhAdlrQBExRIaR6gcYL4Ta9zjEJA6iIBzLrov0g1oY+ BTwHH9QOtwgBUk3hBPlsG7VqORT2iMSTvXk+1stn7GOisnkr8geEs9QJJCMLvQqABgC6 Xw+UkmJg926ShKPsxxU7YImMLHN8a/D+kwTsC/F9r7RCHEMrImIwl8MFjcn8hXznkv5g ctrTOsXvPnCCikE1GOsrXl9Rx81x3ppZj7lY7lQJXXQ5E/e54TbSYMHxmR72o0o075VJ 4vCDvE+LDn9I+uthAv/18UHEeHM2fY+T7N5TFQYBdRAm4cruVHlPxt53ZHWA+eYoCSgE W71g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FriArxnM019D776ImdHSDTVH+8rk+AtrtUiHpYXliLw=; b=aUjNRYCqJbMTJR4l6IUpDLbE2aN2NnbIs2lClN28gtidkNvEmQQ+zfYGzgnr+Yk9oV vcd4eL+ocquBpTTFOT1m7Hu9WAUYVyrBDbvUXIIDL3MEt8GzlUQg9RF1+thNO36XcTt1 SLvoux8hTu+T3cpaLVAXJshllNgthzHfXVxSgj59z5dVXsoa1b6ilHsHHEtZ2JXB4mkj APPYJoYNnraXlXTPxwNfsXHbgLqO52LpDa3C58siE0xV170zgVZnNRsre0NY1+0Z4PHk WIyvAPe0vCs7WiQz/4pz3SCe6M6g24QfwlS/5RWWIFpMJ4oUPEVVyuMmTmCu5dzpDQ3k mY1g== X-Gm-Message-State: ANhLgQ3PEGuXVz8J7PQB1ifk2+HJVAodA1vY0xM/WQq4TTiL56TIHXQg WCbuFJwjDZ/B/FHkdYOkowkVt2C9 X-Google-Smtp-Source: ADFU+vsdZK1O/6hcKrFldcyrmb23egqnikgILRhrpG5nHG8Hcx5jSklVCW5H3NcPdUlglsFljM141A== X-Received: by 2002:a17:90a:bd01:: with SMTP id y1mr4097427pjr.26.1585146608483; Wed, 25 Mar 2020 07:30:08 -0700 (PDT) Received: from bobo.ibm.com (14-202-190-183.tpgi.com.au. [14.202.190.183]) by smtp.gmail.com with ESMTPSA id i20sm10609622pfd.89.2020.03.25.07.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 07:30:08 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 3/4] ppc/spapr: Add FWNMI machine check delivery warnings Date: Thu, 26 Mar 2020 00:29:05 +1000 Message-Id: <20200325142906.221248-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200325142906.221248-1-npiggin@gmail.com> References: <20200325142906.221248-1-npiggin@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::636 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Alexey Kardashevskiy , Mahesh Salgaonkar , qemu-devel@nongnu.org, Nicholas Piggin , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ganesh Goudar , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Add some messages which explain problems and guest misbehaviour that may be difficult to diagnose in rare cases of machine checks. Signed-off-by: Nicholas Piggin Reviewed-by: Greg Kurz --- hw/ppc/spapr_events.c | 4 ++++ hw/ppc/spapr_rtas.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index a908c5d0e9..c8964eb25d 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -833,6 +833,8 @@ static void spapr_mce_dispatch_elog(PowerPCCPU *cpu, bool recovered) /* get rtas addr from fdt */ rtas_addr = spapr_get_rtas_addr(); if (!rtas_addr) { + error_report( +"FWNMI: Unable to deliver machine check to guest: rtas_addr not found."); qemu_system_guest_panicked(NULL); g_free(ext_elog); return; @@ -874,6 +876,8 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) * that CPU called "ibm,nmi-interlock") */ if (spapr->fwnmi_machine_check_interlock == cpu->vcpu_id) { + error_report( +"FWNMI: Unable to deliver machine check to guest: nested machine check."); qemu_system_guest_panicked(NULL); return; } diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 29abe66d01..bcac0d00e7 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -462,6 +462,9 @@ static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu, } if (spapr->fwnmi_machine_check_addr == -1) { + qemu_log_mask(LOG_GUEST_ERROR, +"FWNMI: ibm,nmi-interlock RTAS called with FWNMI not registered.\n"); + /* NMI register not called */ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; From patchwork Wed Mar 25 14:29:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 11457975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 591D11392 for ; Wed, 25 Mar 2020 14:31:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F80B2070A for ; Wed, 25 Mar 2020 14:31:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s4t0qHPE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F80B2070A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH73m-0003QA-AT for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Mar 2020 10:31:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH72w-0002US-EZ for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH72v-0002yZ-Be for qemu-devel@nongnu.org; Wed, 25 Mar 2020 10:30:18 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:40469) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jH72s-0002vK-Vz; Wed, 25 Mar 2020 10:30:15 -0400 Received: by mail-pf1-x443.google.com with SMTP id l184so1114076pfl.7; Wed, 25 Mar 2020 07:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4d62g15iywxB4Q10tLYc59koLC5xXVOvRd2UYcqqCI0=; b=s4t0qHPEhvjG76DaMtNZYU/TaznAP16MtG5IvwKbDVkmljUTc0zAhZ+PfP5nNBziet OuM1O5n5RDBpJQbQimrDmSLuaL1njYiF2QzCzD5PcOgMBV3uvqS6xPYH0N9MoDQj8AzG gpHKoSpRFC1G6vTJfJgms5LQkSYOYtjTqtKF7goWb6JgowywEERw8tDrIOVfz3dqKfzQ OImGjSRz/oEBGyTZ+lcC1Krma7psYoc23btFer+Xu0WTkaO8hDvjHG8rLoTbm+cz4N/S lv+ddJzLTi//RLtA9pJDAyUbULgtCl6P1LN+0pgEqrbjjcq4ywVdFvtrB0oI6Q5AjxoP lrqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4d62g15iywxB4Q10tLYc59koLC5xXVOvRd2UYcqqCI0=; b=ZzacVFKvJAS56FgeUM2t+5mlwuYRg079EqKkq4nEvaS7785gxfqHJlZcprDNJ3srCz IuOVU0VduzFbMKXUABgJ+EcEBOaJWI2V4zDbwVZ2qmXnm+P1cW6aT9BjKH4PZ/RCHq5N NzLnGVYwSCdx+fUV9MqTudRo8gFpM21Uv5DqE2r3NMo4+lTkwgKXHC46915Cvwqr5lk3 e808fy5dcHaqTM3ijKdltSel28gDCxoM9ws5cGnqO82tCVXEw13sXV8G0imQ+oUpHZpx syyAnLViVc7jjooaOVRhojyVYZOSrdJITQ+5J+ergqGKcD0vp0j1DG52gQ28FAwcoW9n rp/Q== X-Gm-Message-State: ANhLgQ1eD32jc7NHPgCJQaPQCNB5ml1OQCKG8lBJIU7XtZGC8MWW6b7F +SnuThloXtP6LFxcdMU2NqT0Zvrb X-Google-Smtp-Source: ADFU+vvIMh2NXitzpMM2PNqBukzI7e/A9Nb+uF60hlRa7RF4IENEV11GSxdtCLO5CHO4k02C91JG/Q== X-Received: by 2002:a62:6503:: with SMTP id z3mr3810532pfb.232.1585146613812; Wed, 25 Mar 2020 07:30:13 -0700 (PDT) Received: from bobo.ibm.com (14-202-190-183.tpgi.com.au. [14.202.190.183]) by smtp.gmail.com with ESMTPSA id i20sm10609622pfd.89.2020.03.25.07.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 07:30:13 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH v2 4/4] ppc/spapr: Don't kill the guest if a recovered FWNMI machine check delivery fails Date: Thu, 26 Mar 2020 00:29:06 +1000 Message-Id: <20200325142906.221248-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200325142906.221248-1-npiggin@gmail.com> References: <20200325142906.221248-1-npiggin@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Alexey Kardashevskiy , Mahesh Salgaonkar , qemu-devel@nongnu.org, Nicholas Piggin , Greg Kurz , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ganesh Goudar , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Try to be tolerant of FWNMI delivery errors if the machine check had been recovered by the host. Signed-off-by: Nicholas Piggin Reviewed-by: Greg Kurz --- hw/ppc/spapr_events.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index c8964eb25d..b90ecb8afe 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -833,13 +833,25 @@ static void spapr_mce_dispatch_elog(PowerPCCPU *cpu, bool recovered) /* get rtas addr from fdt */ rtas_addr = spapr_get_rtas_addr(); if (!rtas_addr) { - error_report( + if (!recovered) { + error_report( "FWNMI: Unable to deliver machine check to guest: rtas_addr not found."); - qemu_system_guest_panicked(NULL); + qemu_system_guest_panicked(NULL); + } else { + warn_report( +"FWNMI: Unable to deliver machine check to guest: rtas_addr not found. " +"Machine check recovered."); + } g_free(ext_elog); return; } + /* + * Must not set interlock if the MCE does not get delivered to the guest + * in the error case above. + */ + spapr->fwnmi_machine_check_interlock = cpu->vcpu_id; + stq_be_phys(&address_space_memory, rtas_addr + RTAS_ERROR_LOG_OFFSET, env->gpr[3]); cpu_physical_memory_write(rtas_addr + RTAS_ERROR_LOG_OFFSET + @@ -876,9 +888,15 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) * that CPU called "ibm,nmi-interlock") */ if (spapr->fwnmi_machine_check_interlock == cpu->vcpu_id) { - error_report( + if (!recovered) { + error_report( "FWNMI: Unable to deliver machine check to guest: nested machine check."); - qemu_system_guest_panicked(NULL); + qemu_system_guest_panicked(NULL); + } else { + warn_report( +"FWNMI: Unable to deliver machine check to guest: nested machine check. " +"Machine check recovered."); + } return; } qemu_cond_wait_iothread(&spapr->fwnmi_machine_check_interlock_cond); @@ -906,7 +924,6 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) warn_report("Received a fwnmi while migration was in progress"); } - spapr->fwnmi_machine_check_interlock = cpu->vcpu_id; spapr_mce_dispatch_elog(cpu, recovered); }