Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5560941ybh; Wed, 7 Aug 2019 07:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBByaCX2eyL3Fujcb13tOHNla7SJiCo4NuZvXoAygYOKJ0E9rtNObbMZoixuVf8d1pu46W X-Received: by 2002:a63:3009:: with SMTP id w9mr8425512pgw.260.1565189934258; Wed, 07 Aug 2019 07:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565189934; cv=none; d=google.com; s=arc-20160816; b=IKs7eZTnpij7Vg+f52Fsk9p0JN3OCgZe66wtvcV4WUkdFR23lranRukkeLg7p+m6qk 3h1Vj+8lxmfp/iZTXZB0bDP0Fqum1lq/f4EU2/J2r7S9p6lbTYq61R6QtnzI7Jp6OrAZ lJ2Yd9ozVuAUZbazintgv9k1SPsDzOQwAkX5YnUc5hof6Xk1M61PBAygvdV8+CgX6rKg JpoDKLhbsDZJm2HqhzFLGFshGm9ShUdpqLtYFjx4wtt/aTL5bL9fZ9jLwd1i7TR7/jwX O3C3d/j/Iupw64Sf6ik3OLyFYndehA1JgKEOGPEc4FxpqiCxfaAohaac4Q9MPABo6K8q W2ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IYVCSXCSdVKrlJTyrQE0sJPomWsj6zAZ24kY6kld5ow=; b=JI3BiOP05R+hGhJ93nfNRIgwH/dVj4W7ZlptXWVYU7xwDmOEO1KZkYfvsnAgGq4Jmd XpmkBCUqhP7Nr1xq8XqH62fWtFCMDERqlUjGWArDJvWTUVe0zr3bTe0/I/vtWLo8UihD HonBkq/ri/5Uwy3mW/0eOem12iv8qjNriluy1k2uNJCZyb/yFwTeHGhh78GgncMDBTEB Cl8S9x5voJUj/3kvq+Wytpd2wpGb58jbcfAOMJccsiQ70595NmPudlfjyMX8bMOcQrAR P8IZ5kublfRLESZ0Pzc2YnyI88LS/YQbI9JcvTjUoIbXhXit+8d1kVDIzXmDeh1xHG53 kg4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=b0aXc0w5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w66si2832880pfw.65.2019.08.07.07.58.39; Wed, 07 Aug 2019 07:58:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=b0aXc0w5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388178AbfHGO5h (ORCPT + 99 others); Wed, 7 Aug 2019 10:57:37 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45635 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387915AbfHGO5g (ORCPT ); Wed, 7 Aug 2019 10:57:36 -0400 Received: by mail-pl1-f194.google.com with SMTP id y8so41229984plr.12 for ; Wed, 07 Aug 2019 07:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IYVCSXCSdVKrlJTyrQE0sJPomWsj6zAZ24kY6kld5ow=; b=b0aXc0w5stpFdykuQNDC5VQpPGT3qxFcUifm+BiUpXOcuzjhi78KYvYxmM7e3NiaIW ugPbv/PxCrpQoCB6bjehh5ZT/GJm1JmDwAmj6UnulltPLyIuFUo2Bo24TMF9t3dsxIFL at7vWvVw3QTErYni0u9+0Uq3RDpGd4VE2hQ4tM46QtjQTjD2FYx3sjtus1fQ2liM/QPl tO5zsn2vlJjmjPNRR6KSKWdWx/v7gzTNoQKYqwmJOHLekRzntyWGu3uM/Bo0mLZ4lO0M 4u/VgDdlr34tTxF08FpW3DOeHyXVienujBoZuh3bjIicpK0GpTM0YfmspiL0vimfpHKa PgOA== 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=IYVCSXCSdVKrlJTyrQE0sJPomWsj6zAZ24kY6kld5ow=; b=mnQgL9e4XvIb/hSKCQGrOMpLZKaK3o0S+q9AeNI0zDIAuxHvbY1/JDhhRHAg8/sOAN vAIZihlIgFnqnAK3wLH5BYBtplP/xmeYsEBfu0ssCRAMaeogbSSLFUZruEWJPkNEo+V6 NzrQwAiFpu3YTVohtP8/9wrwucaqaOr0l395BquPiXM6qTgbIk+VdIdlAxDxLL2MIqHo dVQxkFcjYX1RpxxXQlvfE6kMdhPtHP4VTm8K+UmxC6IQgL4MlMoJkwoC6EPL7FPpNhvb WGJFCSAx5sfaRhJuy6/9eVvPjNpfx7Crhyq00DyucmW1GBcWAIMJ8Z7v0ogvxUVTZdvm aN4A== X-Gm-Message-State: APjAAAW95vK7EqGLlc6kKUhYwOsU53ZNZFRZkWdq5ew5SgHO3GyfY+uA I7XgoXVGCxkdsn9o3xZ3SUPswA== X-Received: by 2002:aa7:8555:: with SMTP id y21mr9779082pfn.104.1565189855509; Wed, 07 Aug 2019 07:57:35 -0700 (PDT) Received: from santosiv.in.ibm.com.com ([183.82.17.96]) by smtp.gmail.com with ESMTPSA id l4sm93617475pff.50.2019.08.07.07.57.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 07:57:35 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev , Linux Kernel Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Reza Arbab , Balbir Singh , Chandan Rajendra , Michael Ellerman , Nicholas Piggin , christophe leroy Subject: [PATCH v8 6/7] powerpc/mce: Handle UE event for memcpy_mcsafe Date: Wed, 7 Aug 2019 20:26:59 +0530 Message-Id: <20190807145700.25599-7-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190807145700.25599-1-santosh@fossix.org> References: <20190807145700.25599-1-santosh@fossix.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we take a UE on one of the instructions with a fixup entry, set nip to continue execution at the fixup entry. Stop processing the event further or print it. Co-developed-by: Reza Arbab Signed-off-by: Reza Arbab Cc: Mahesh Salgaonkar Signed-off-by: Santosh Sivaraj --- arch/powerpc/include/asm/mce.h | 4 +++- arch/powerpc/kernel/mce.c | 18 ++++++++++++++++-- arch/powerpc/kernel/mce_power.c | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h index f3a6036b6bc0..e1931c8c2743 100644 --- a/arch/powerpc/include/asm/mce.h +++ b/arch/powerpc/include/asm/mce.h @@ -122,7 +122,8 @@ struct machine_check_event { enum MCE_UeErrorType ue_error_type:8; u8 effective_address_provided; u8 physical_address_provided; - u8 reserved_1[5]; + u8 ignore_event; + u8 reserved_1[4]; u64 effective_address; u64 physical_address; u8 reserved_2[8]; @@ -193,6 +194,7 @@ struct mce_error_info { enum MCE_Initiator initiator:8; enum MCE_ErrorClass error_class:8; bool sync_error; + bool ignore_event; }; #define MAX_MC_EVT 100 diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 8c0b471658a7..a80f5d6ef166 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -33,7 +33,6 @@ static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_ue_event_queue); static void machine_check_process_queued_event(struct irq_work *work); -static void machine_check_ue_event(struct machine_check_event *evt); static void machine_process_ue_event(struct work_struct *work); static struct irq_work mce_event_process_work = { @@ -144,6 +143,7 @@ void save_mce_event(struct pt_regs *regs, long handled, if (phys_addr != ULONG_MAX) { mce->u.ue_error.physical_address_provided = true; mce->u.ue_error.physical_address = phys_addr; + mce->u.ue_error.ignore_event = mce_err->ignore_event; } } return; @@ -256,8 +256,17 @@ static void machine_process_ue_event(struct work_struct *work) /* * This should probably queued elsewhere, but * oh! well + * + * Don't report this machine check because the caller has a + * asked us to ignore the event, it has a fixup handler which + * will do the appropriate error handling and reporting. */ if (evt->error_type == MCE_ERROR_TYPE_UE) { + if (evt->u.ue_error.ignore_event) { + __this_cpu_dec(mce_ue_count); + continue; + } + if (evt->u.ue_error.physical_address_provided) { unsigned long pfn; @@ -291,8 +300,13 @@ static void machine_check_process_queued_event(struct irq_work *work) index = __this_cpu_read(mce_queue_count) - 1; evt = this_cpu_ptr(&mce_event_queue[index]); - if (evt->error_type == MCE_ERROR_TYPE_UE) + if (evt->error_type == MCE_ERROR_TYPE_UE) { machine_check_ue_event(evt); + if (evt->u.ue_error.ignore_event) { + __this_cpu_dec(mce_queue_count); + continue; + } + } machine_check_print_event_info(evt, false, false); __this_cpu_dec(mce_queue_count); diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c index bed38a8e2e50..36ca45bbb273 100644 --- a/arch/powerpc/kernel/mce_power.c +++ b/arch/powerpc/kernel/mce_power.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include /* * Convert an address related to an mm to a physical address. @@ -558,9 +560,18 @@ static int mce_handle_derror(struct pt_regs *regs, return 0; } -static long mce_handle_ue_error(struct pt_regs *regs) +static long mce_handle_ue_error(struct pt_regs *regs, + struct mce_error_info *mce_err) { long handled = 0; + const struct exception_table_entry *entry; + + entry = search_kernel_exception_table(regs->nip); + if (entry) { + mce_err->ignore_event = true; + regs->nip = extable_fixup(entry); + return 1; + } /* * On specific SCOM read via MMIO we may get a machine check @@ -593,7 +604,7 @@ static long mce_handle_error(struct pt_regs *regs, &phys_addr); if (!handled && mce_err.error_type == MCE_ERROR_TYPE_UE) - handled = mce_handle_ue_error(regs); + handled = mce_handle_ue_error(regs, &mce_err); save_mce_event(regs, handled, &mce_err, regs->nip, addr, phys_addr); -- 2.20.1