From patchwork Tue Apr 7 05:16:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267188 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xG3d2ksXz9sSG for ; Tue, 7 Apr 2020 15:21:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=O5VXA3h9; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xG3d0FmqzDqvw for ; Tue, 7 Apr 2020 15:21:32 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=O5VXA3h9; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xFzt40CmzDqdr for ; Tue, 7 Apr 2020 15:18:18 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id h11so790974plk.7 for ; Mon, 06 Apr 2020 22:18:18 -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=nLkpYa6ReHSstSFQCnO6w0riXaLuQvV4SStND/UEf1Y=; b=O5VXA3h9s2yRkCYIcZzdXtB6l2KW678hT0C//MiaT7pbuzVk5XPkop0Tv35CWoZyyL Z9qxi9c2Oq4AIIPmeQuspmYKEl3NHbEnzzgGTI2rQP2Q27fOGKZ6sWK5LxDWUwEfbSFW KP+iynHGiwQhVJ+S1AZoJc7ymYvhRmGZV62PCzvqsFUgHypFtRXlqbS2PE5sibVPAgr0 j7ESN26cfpaNWCyYxnm/3x9KxddM5OX01aWgfcURPtU4COXSImCqAZvdc/uIF6DQYF/7 3xDSXdAwwX/5rERVsxDOC/dFBq2hqgDXIIE5zSOq1vZIoYN3za7OgKY1Sk9kWIVJ0ffd zssw== 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=nLkpYa6ReHSstSFQCnO6w0riXaLuQvV4SStND/UEf1Y=; b=LRwE7f5ltB7ZTPc86WrIaaJ5Wahe4bICIQYUOau5Tp/B4i7eJf7hANgj1sSg3BMKXZ zyXsB9I+IydWfwQZygaKRM/vjKjHKWcy88nMXlemBCeM/JD3mFLzjEEDIsVUrA8g7Kzb x/66oPUziYB9qlbmX9AROBSig7/lFN9QUOct6i2nTE5oxenLt2OvF73Vtid5IxOjvqbM allp7O3FVpdKHbhg+zMxdeGeqYUIShECFd+q8ilRU5j086ezOXjD7hQ81Fue5oDF0jeU 2KLckqdq2SCvLLgkheYXL1s80F4DVdvqqriUV7cZvzWhTpO/be8n02R0bII5xvABDjBj /GkA== X-Gm-Message-State: AGi0PubAKU6Tl+ZV5oXWsWf/l0vi1TJQ9zqIA6zzdwpgV5B4kDeYPu3Q wg2zQHQG+GkR+3sPCGuGrdc+osxz X-Google-Smtp-Source: APiQypLVu4XZhLByHh7sS/IrodVkgykSFnIfIYYpuGY2qSwS/7JwJu8gmhcAgfgyd3BNoEebhVYsdA== X-Received: by 2002:a17:90b:3752:: with SMTP id ne18mr646324pjb.143.1586236694630; Mon, 06 Apr 2020 22:18:14 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:14 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 01/15] powerpc/64s/exception: Fix machine check no-loss idle wakeup Date: Tue, 7 Apr 2020 15:16:22 +1000 Message-Id: <20200407051636.648369-2-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The architecture allows for machine check exceptions to cause idle wakeups which resume at the 0x200 address which has to return via the idle wakeup code, but the early machine check handler is run first. The case of a no state-loss sleep is broken because the early handler uses non-volatile register r1 , which is needed for the wakeup protocol, but it is not restored. Fix this by loading r1 from the MCE exception frame before returning to the idle wakeup code. Also update the comment which has become stale since the idle rewrite in C. Fixes: 10d91611f426d ("powerpc/64s: Reimplement book3s idle code in C") Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 728ccb0f560c..bbf3109c5cba 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1224,17 +1224,19 @@ EXC_COMMON_BEGIN(machine_check_idle_common) bl machine_check_queue_event /* - * We have not used any non-volatile GPRs here, and as a rule - * most exception code including machine check does not. - * Therefore PACA_NAPSTATELOST does not need to be set. Idle - * wakeup will restore volatile registers. + * GPR-loss wakeups are relatively straightforward, because the + * idle sleep code has saved all non-volatile registers on its + * own stack, and r1 in PACAR1. * - * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce. + * For no-loss wakeups the r1 and lr registers used by the + * early machine check handler have to be restored first. r2 is + * the kernel TOC, so no need to restore it. * * Then decrement MCE nesting after finishing with the stack. */ ld r3,_MSR(r1) ld r4,_LINK(r1) + ld r1,GPR1(r1) lhz r11,PACA_IN_MCE(r13) subi r11,r11,1 @@ -1243,7 +1245,7 @@ EXC_COMMON_BEGIN(machine_check_idle_common) mtlr r4 rlwinm r10,r3,47-31,30,31 cmpwi cr1,r10,2 - bltlr cr1 /* no state loss, return to idle caller */ + bltlr cr1 /* no state loss, return to idle caller with r3=SRR1 */ b idle_return_gpr_loss #endif From patchwork Tue Apr 7 05:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267189 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xG5j02dDz9sQt for ; Tue, 7 Apr 2020 15:23:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=CF+jOCQ/; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xG5h6h7NzDqvY for ; Tue, 7 Apr 2020 15:23:20 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=CF+jOCQ/; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xFzw2Rl1zDqdr for ; Tue, 7 Apr 2020 15:18:20 +1000 (AEST) Received: by mail-pg1-x543.google.com with SMTP id m13so1162544pgd.8 for ; Mon, 06 Apr 2020 22:18:20 -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=ZtY2WfL1JPGj+fO1hNVGxKtL2inTNkP2M7UMo8aWaBA=; b=CF+jOCQ/+HZxkyS7J/G8FJ/nAMvhwHda6yqjcGxxRMRRexgpMJ1tfBxW7giReBvtl4 n7R00xdllU9owZvI/+Gx2SdNJhRdOAdmhMIsSSjYaXZb17JsoVexf/fa41Hkd4mMaAm3 J+MgI6/ZZYtLn9V5mQB5JBb9OFs4OgiQqoHSe31Y/K6EgrbwT8442IfWevlrg2FV/BGh +IN1lLj1H+qdxXsnZ6qsoROKzKkmGFrDDc8Nic4kcFyIOhNEh4mfKENLoWWBlUNWfBBB GYYgyWoqhrP6KknFMnt/BUVqNBk3jCzPoibeQrfwO61YuJlRp/q/Jf1aRRt1cVaiaT51 Ffwg== 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=ZtY2WfL1JPGj+fO1hNVGxKtL2inTNkP2M7UMo8aWaBA=; b=KVEckjG06JUduC6vn4sZohOhIko5oN9oJFVscsXnVvBG+nu4DAlk+rsRK+O1/kSds9 OCwTvS724e56q1ha2r7z+e6Mu3DEvwXpOpEzf0Grrjaljb1bmQYkCCH5LchW0wAkwNLv bCSy6ZkrnGg+9ZdCwqUnDmiuFAqGbGRRiqbN7tMbxKXlzOYZYvDHUJdGk7CNP5QZxYDj EceWgh3zjsIlFLmgDR1unQPN2LMEdqpEMEjLnN+cDFmT1yUdvmP/fusRYFwB1jeuQz9J dZVDpuiS1dIsI6izyMgJ07L0/yd5en3ZFykl+3Hv1kJKkNWdjgiLAdjVVO89mglsQ1rE 3RkA== X-Gm-Message-State: AGi0PubRyVKsHdg1hAe37KSqfIUplhdt5vyRbNIngbbM6KatodsnxqSK a1VGnqRifg48PW37GlP/vhDTCzcM X-Google-Smtp-Source: APiQypJT6EEU6sHKr7NKXUOvYB7rO/79wG4Eo8LovE6m4hWV8C1JU7q/X67Flln7G8+FLdIymrqbmg== X-Received: by 2002:a63:8848:: with SMTP id l69mr326293pgd.288.1586236698323; Mon, 06 Apr 2020 22:18:18 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:17 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 02/15] powerpc/64s/exceptions: Fix in_mce accounting in unrecoverable path Date: Tue, 7 Apr 2020 15:16:23 +1000 Message-Id: <20200407051636.648369-3-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Mahesh Salgaonkar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Acked-by: Mahesh Salgaonkar Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index bbf3109c5cba..3322000316ab 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1267,6 +1267,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) andc r10,r10,r3 mtmsrd r10 + lhz r12,PACA_IN_MCE(r13) + subi r12,r12,1 + sth r12,PACA_IN_MCE(r13) + /* Invoke machine_check_exception to print MCE event and panic. */ addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_exception From patchwork Tue Apr 7 05:16:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267190 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xG8D23YLz9sQt for ; Tue, 7 Apr 2020 15:25:32 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=eSwMkiLE; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xG8C6rDnzDqwf for ; Tue, 7 Apr 2020 15:25:31 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=eSwMkiLE; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG022wnczDqvY for ; Tue, 7 Apr 2020 15:18:26 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id m17so1169247pgj.5 for ; Mon, 06 Apr 2020 22:18:26 -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=ObCCMRtKkqm4cLMRI3tfvXaacA0omo0bqALi0UF8jqk=; b=eSwMkiLEQVWfVYCO6EqT52Nuu5AC5GO4AFvOdPnm1m5qsV6Qan2nW9a5sj1Zs/w30Y H6BhIXEBv2LwaI8TH2ev27GnAl+/ZY86vm7zM30pKW/fLP2Ybj65LDn4g/h/F9w6hnUk 5rJZSUCY45GubUMSz9aqmQxNOF2GG2lAgcOxJ6pUSuycjl1V6jdngEdVFSViK3siDy6Y hape9+7MWRbG83a8fLzQTi6YzGGqokourknK94rqvUxYi3aSIOZ5ZPs9IHNsoVThYDln ZeTbzLEK4VgVugAH9Qg/xL3Cl0UFrZuZ1adCt09kSAQuwygZbaLKPcKKQvanmD2djdgW VkTA== 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=ObCCMRtKkqm4cLMRI3tfvXaacA0omo0bqALi0UF8jqk=; b=XR/3jscElYx33fIM8Cx8btwMiikoXPf5nog6OlVFR5jGssITieeDwADinmpeFSSIJ0 HojP3bPW/uSyIYn7Eul7yogzDUUeL75hfcCo+1/5iV/8SUs4zdIuP22N/EFhKCWAeaGx 8pnMQ10S62ArcV0eOkYZGnrbZL9NfjQHO5Sz7KFn6+CEs+1Z20IYmuq/xmKeIFfTO9at YF2PNX+7rKFCyGElqRwPGzalBrw27HeEfpXTnFplGmzxXhB5BNCjv9f4ASKajHhUJLCV PrPz/KsSFSwdAW02HJYKOaQrRu9E4IFjD4yaZ8GcVTDpG4uk6KXGP6AGV/c7sZUUtbb0 Yrbg== X-Gm-Message-State: AGi0PuaNRR8SS/zpHJRTxU17Nh+iYlC9egXv/PPlP18WmapGbWWKRnOp 1B14AekF1I/Hz3pqdKpBVrJuI44v X-Google-Smtp-Source: APiQypKOwP8vShBOP3JXkLYLrACMTb3FTeVOClmjr3APBBtmPkWsvJ412CVglzlDle563IOoQ0hw9A== X-Received: by 2002:a63:fd11:: with SMTP id d17mr341377pgh.213.1586236701795; Mon, 06 Apr 2020 22:18:21 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:21 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 03/15] powerpc/64s/exceptions: Change irq reconcile for NMIs from reusing _DAR to RESULT Date: Tue, 7 Apr 2020 15:16:24 +1000 Message-Id: <20200407051636.648369-4-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" A spare interrupt stack slot is needed to save irq state when reconciling NMIs (sreset and decrementer soft-nmi). _DAR is used for this, but we want to reconcile machine checks as well, which do use _DAR. Switch to using RESULT instead, as it's used by system calls. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 3322000316ab..a42b73efb1a9 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -939,13 +939,13 @@ EXC_COMMON_BEGIN(system_reset_common) * the right thing. We do not want to reconcile because that goes * through irq tracing which we don't want in NMI. * - * Save PACAIRQHAPPENED to _DAR (otherwise unused), and set HARD_DIS + * Save PACAIRQHAPPENED to RESULT (otherwise unused), and set HARD_DIS * as we are running with MSR[EE]=0. */ li r10,IRQS_ALL_DISABLED stb r10,PACAIRQSOFTMASK(r13) lbz r10,PACAIRQHAPPENED(r13) - std r10,_DAR(r1) + std r10,RESULT(r1) ori r10,r10,PACA_IRQ_HARD_DIS stb r10,PACAIRQHAPPENED(r13) @@ -966,7 +966,7 @@ EXC_COMMON_BEGIN(system_reset_common) /* * Restore soft mask settings. */ - ld r10,_DAR(r1) + ld r10,RESULT(r1) stb r10,PACAIRQHAPPENED(r13) ld r10,SOFTE(r1) stb r10,PACAIRQSOFTMASK(r13) @@ -2743,7 +2743,7 @@ EXC_COMMON_BEGIN(soft_nmi_common) li r10,IRQS_ALL_DISABLED stb r10,PACAIRQSOFTMASK(r13) lbz r10,PACAIRQHAPPENED(r13) - std r10,_DAR(r1) + std r10,RESULT(r1) ori r10,r10,PACA_IRQ_HARD_DIS stb r10,PACAIRQHAPPENED(r13) @@ -2757,7 +2757,7 @@ EXC_COMMON_BEGIN(soft_nmi_common) /* * Restore soft mask settings. */ - ld r10,_DAR(r1) + ld r10,RESULT(r1) stb r10,PACAIRQHAPPENED(r13) ld r10,SOFTE(r1) stb r10,PACAIRQSOFTMASK(r13) From patchwork Tue Apr 7 05:16:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267191 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGBc4N69z9sSG for ; Tue, 7 Apr 2020 15:27:36 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lBg01+ut; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGBb6LY5zDqWf for ; Tue, 7 Apr 2020 15:27:35 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lBg01+ut; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG034WQTzDqwm for ; Tue, 7 Apr 2020 15:18:27 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id v23so783439ply.10 for ; Mon, 06 Apr 2020 22:18:27 -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=llJGzrIBeBpBel+keT4vSfRYbJxGrzgUBSqme/ux02M=; b=lBg01+utBNVnFH/SLpqAxLcQDt1mcSMWaKE2ic5m5ZYsLQYu2MHCDnI5tbWK52NZMd jbd2o87A33eWOt5YxIPL9WxhRLx7PLPsC3zu5YHDG+3rQOgz/WEC2GlM/qSygqZhc4wo YdBrst093mPHXpORP0rVYhvVYqZEvEc/dlzcQRVj//1Ja+rWUmgRqWjWD057bunm+j1t 0SZbcLfdukRIIzE/eQxsbvzhcqSRY+4tXdlgtbvStg+YbDIKnzXc/mhSWszyyhYqLGoa a5C9dgNCS27SyVuKBckEWsglbvUmgt65qmjNz1Q/bV96t84q8RuJWz/vGlLefjEuT7C4 ws2Q== 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=llJGzrIBeBpBel+keT4vSfRYbJxGrzgUBSqme/ux02M=; b=WcA0uKiurPU3YCwapmguZjbz9HSL6/AAssVHd5v9mVAXLE1pmManFNzIDll5E1/4VQ 4mnirPx5t8uIeuYioFI1g4fkNZXXRYMftvMRkQS1a/J2WcvEqC3HBxOXvWDhgnwF3q8b 6CoMbjGXeRosiTE7yYoYo7JLcwZGLMRzz0CHKSgnn1VLTD65C8LlmQirclSsuKwXWwbV zBr8T6qG7HFICTwoc+EkNOpwycs/mmiF7/HEICxp6jGSu4p60ShsQO/9SIVjh/dmmpha yKzv/urCuW1BcUxSaSuTlO64yZ4jalE6FkqbGFpam644kJQ8idXixMOIqkwKMoC+3RQp mbRQ== X-Gm-Message-State: AGi0PuZsvFHBv3P3in1mUIm3NnuQkcGVzNFDje6nIVdw7G2FSOzcpQF0 Yb/0fZoZu4qdpZrzd+OJmgc2V3oP X-Google-Smtp-Source: APiQypLL3bqlWLaDqb9GA8+bhqQwzwBTPsN7E9O77dAwmuD4y//clMXJsaQq+jzvjOlx8Kwik3iPDQ== X-Received: by 2002:a17:902:8647:: with SMTP id y7mr804398plt.87.1586236705326; Mon, 06 Apr 2020 22:18:25 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:24 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 04/15] powerpc/64s/exceptions: machine check reconcile irq state Date: Tue, 7 Apr 2020 15:16:25 +1000 Message-Id: <20200407051636.648369-5-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" pseries fwnmi machine check code pops the soft-irq checks in rtas_call (after the previous patch to remove rtas_token from this call path). Rather than play whack a mole with these and forever having fragile code, it seems better to have the early machine check handler perform the same kind of reconcile as the other NMI interrupts. WARNING: CPU: 0 PID: 493 at arch/powerpc/kernel/irq.c:343 CPU: 0 PID: 493 Comm: a Tainted: G W NIP: c00000000001ed2c LR: c000000000042c40 CTR: 0000000000000000 REGS: c0000001fffd38b0 TRAP: 0700 Tainted: G W MSR: 8000000000021003 CR: 28000488 XER: 00000000 CFAR: c00000000001ec90 IRQMASK: 0 GPR00: c000000000043820 c0000001fffd3b40 c0000000012ba300 0000000000000000 GPR04: 0000000048000488 0000000000000000 0000000000000000 00000000deadbeef GPR08: 0000000000000080 0000000000000000 0000000000000000 0000000000001001 GPR12: 0000000000000000 c0000000014a0000 0000000000000000 0000000000000000 GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 GPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 GPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 GPR28: 0000000000000000 0000000000000001 c000000001360810 0000000000000000 NIP [c00000000001ed2c] arch_local_irq_restore.part.0+0xac/0x100 LR [c000000000042c40] unlock_rtas+0x30/0x90 Call Trace: [c0000001fffd3b40] [c000000001360810] 0xc000000001360810 (unreliable) [c0000001fffd3b60] [c000000000043820] rtas_call+0x1c0/0x280 [c0000001fffd3bb0] [c0000000000dc328] fwnmi_release_errinfo+0x38/0x70 [c0000001fffd3c10] [c0000000000dcd8c] pseries_machine_check_realmode+0x1dc/0x540 [c0000001fffd3cd0] [c00000000003fe04] machine_check_early+0x54/0x70 [c0000001fffd3d00] [c000000000008384] machine_check_early_common+0x134/0x1f0 --- interrupt: 200 at 0x13f1307c8 LR = 0x7fff888b8528 Instruction dump: 60000000 7d2000a6 71298000 41820068 39200002 7d210164 4bffff9c 60000000 60000000 7d2000a6 71298000 4c820020 <0fe00000> 4e800020 60000000 60000000 Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index a42b73efb1a9..072772803b7c 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1116,11 +1116,30 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) li r10,MSR_RI mtmsrd r10,1 + /* + * Set IRQS_ALL_DISABLED and save PACAIRQHAPPENED (see + * system_reset_common) + */ + li r10,IRQS_ALL_DISABLED + stb r10,PACAIRQSOFTMASK(r13) + lbz r10,PACAIRQHAPPENED(r13) + std r10,RESULT(r1) + ori r10,r10,PACA_IRQ_HARD_DIS + stb r10,PACAIRQHAPPENED(r13) + addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_early std r3,RESULT(r1) /* Save result */ ld r12,_MSR(r1) + /* + * Restore soft mask settings. + */ + ld r10,RESULT(r1) + stb r10,PACAIRQHAPPENED(r13) + ld r10,SOFTE(r1) + stb r10,PACAIRQSOFTMASK(r13) + #ifdef CONFIG_PPC_P7_NAP /* * Check if thread was in power saving mode. We come here when any From patchwork Tue Apr 7 05:16:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267192 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGDg0SK4z9sQt for ; Tue, 7 Apr 2020 15:29:23 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=e5N9eDDR; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGDf59hCzDqZw for ; Tue, 7 Apr 2020 15:29:22 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=e5N9eDDR; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG092M0dzDqx0 for ; Tue, 7 Apr 2020 15:18:33 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id c20so261254pfi.7 for ; Mon, 06 Apr 2020 22:18:32 -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=000qLJcM9UmThdlyGYrm2N/2aeTJ82pdzdzyPCumz7c=; b=e5N9eDDRIhykFRZE3fYZcRqMjKB02lM3k7lgMmwjh2yhCsPNWPq75xYa0W/7sfBbfB 6c828Y6gkGgcC8qMlfh7kfotdzRC7Tg5N+88vHAGRQ7x55+LClLJAqoswz/SePUng+WA L5oQw8MGARA45AAgx7Z1+Y/7RyixsbW5g6jFS6kIQ0ynHG81FwBPkd48Nj7oNBKPbnFS 2g5NckV8fM/RI3DVZUK4TqjmzWznf4Dr8GpwYzi05xrGtAX0kkjrIpz/pBZp6wRZRRwv y2QjuRkE70zDaBAfEMT/FnYvVd7EsUwvd3G+bLhxxAvh0uvqAsREJcN+JNoU6kMUxrTr kzCA== 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=000qLJcM9UmThdlyGYrm2N/2aeTJ82pdzdzyPCumz7c=; b=F5hmJoaBKx4rFUQiJ9/j8MSHkcUeo5Ws0yWQ1VV2eV9/1VtWQREry7jWSf9uZfIRMf K/wgmhYqKtDyEqg5gixw3zqAkN3VzHYNXzKh4aBqQL7YBb7AdORsJ1AavGZ0xJbtToaK OR+Fr+dOxlOjD7wGemi2rUv7E7iAr1xq+rwrC98T7Vxz6akTUdrZlFRHPSlxqNbwMUsM um0o//jsVmRrESTBZCpqwH/0UC1jGzmQ3Hn9ZT5HgHclrK+5K1fQSX1/EKeT7CA0f183 hV4Ln+oFdddL4ECS60T3d24mVPby2oooEr5mA8L1A2iaRy+U1YjBaN/D4dI4JllAxsAC YWzA== X-Gm-Message-State: AGi0PuaX1R7QF/17dZAB1fksp/o5Siaodi5CkVWZ5tvMmcGqh5d5Yhb3 Gveqb97mOITH62Nxupq8WAKpAdvi X-Google-Smtp-Source: APiQypIk/QxeOzepsxjvGsOzfkOEMYAQJkQS0PpUBltGT3L18MkwC7oxduBohtXXYCknkNMH7SvXdQ== X-Received: by 2002:a63:a502:: with SMTP id n2mr298448pgf.449.1586236708986; Mon, 06 Apr 2020 22:18:28 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:28 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 05/15] powerpc/pseries/ras: avoid calling rtas_token in NMI paths Date: Tue, 7 Apr 2020 15:16:26 +1000 Message-Id: <20200407051636.648369-6-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Mahesh Salgaonkar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In the interest of reducing code and possible failures in the machine check and system reset paths, grab the "ibm,nmi-interlock" token at init time. Reviewed-by: Mahesh Salgaonkar Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/include/asm/firmware.h | 1 + arch/powerpc/platforms/pseries/ras.c | 2 +- arch/powerpc/platforms/pseries/setup.c | 14 ++++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h index ca33f4ef6cb4..6003c2e533a0 100644 --- a/arch/powerpc/include/asm/firmware.h +++ b/arch/powerpc/include/asm/firmware.h @@ -128,6 +128,7 @@ extern void machine_check_fwnmi(void); /* This is true if we are using the firmware NMI handler (typically LPAR) */ extern int fwnmi_active; +extern int ibm_nmi_interlock_token; extern unsigned int __start___fw_ftr_fixup, __stop___fw_ftr_fixup; diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index aa6208c8d4f0..972b95ebc867 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -458,7 +458,7 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) */ static void fwnmi_release_errinfo(void) { - int ret = rtas_call(rtas_token("ibm,nmi-interlock"), 0, 1, NULL); + int ret = rtas_call(ibm_nmi_interlock_token, 0, 1, NULL); if (ret != 0) printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret); } diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 0c8421dd01ab..dd234095ae4f 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -83,6 +83,7 @@ unsigned long CMO_PageSize = (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K); EXPORT_SYMBOL(CMO_PageSize); int fwnmi_active; /* TRUE if an FWNMI handler is present */ +int ibm_nmi_interlock_token; static void pSeries_show_cpuinfo(struct seq_file *m) { @@ -113,9 +114,14 @@ static void __init fwnmi_init(void) struct slb_entry *slb_ptr; size_t size; #endif + int ibm_nmi_register_token; - int ibm_nmi_register = rtas_token("ibm,nmi-register"); - if (ibm_nmi_register == RTAS_UNKNOWN_SERVICE) + ibm_nmi_register_token = rtas_token("ibm,nmi-register"); + if (ibm_nmi_register_token == RTAS_UNKNOWN_SERVICE) + return; + + ibm_nmi_interlock_token = rtas_token("ibm,nmi-interlock"); + if (WARN_ON(ibm_nmi_interlock_token == RTAS_UNKNOWN_SERVICE)) return; /* If the kernel's not linked at zero we point the firmware at low @@ -123,8 +129,8 @@ static void __init fwnmi_init(void) system_reset_addr = __pa(system_reset_fwnmi) - PHYSICAL_START; machine_check_addr = __pa(machine_check_fwnmi) - PHYSICAL_START; - if (0 == rtas_call(ibm_nmi_register, 2, 1, NULL, system_reset_addr, - machine_check_addr)) + if (0 == rtas_call(ibm_nmi_register_token, 2, 1, NULL, + system_reset_addr, machine_check_addr)) fwnmi_active = 1; /* From patchwork Tue Apr 7 05:16:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267193 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGGl1zGHz9sSG for ; Tue, 7 Apr 2020 15:31:11 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=h6ey34lK; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGGl1NXFzDqyx for ; Tue, 7 Apr 2020 15:31:11 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=h6ey34lK; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0D35RWzDqy9 for ; Tue, 7 Apr 2020 15:18:36 +1000 (AEST) Received: by mail-pg1-x541.google.com with SMTP id c23so1173732pgj.3 for ; Mon, 06 Apr 2020 22:18:36 -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=JRLs41yYdcYPkLphCnYT0V2CoBtaXPrFw05FqsMKt+0=; b=h6ey34lKJImpUNY5yXr/DYyLAIb+nu8rRnHAQUKFQu1k5e3eIMwn4O/ocvTuE+1gyS 3yUD4rGAN6JExM/pvs+e/I+x6zEuaE2FW4xODGTRxlQ+cOwGCUKiurea4ZCsmZDuuBC+ GZptZVM57cV+WVAXZ048iZqR5DRrS6JnoMr0bywB9k5rIigsYSlonsttpGHv6Ekn/8qn lmWcOh0i4Hwp6rtpBLghiSHXIwjHk1qgHceMNdSC+Jae2PNY7XxlOq/oexKDEhf8AYkz ovjOZLVMEtQY/T3hViqWScRR5GhpEEHcImF6P1vZevyqqug/mzoskP4SfinJkt3wcBVv gnyg== 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=JRLs41yYdcYPkLphCnYT0V2CoBtaXPrFw05FqsMKt+0=; b=KmseV4hBuk6pNeOorI3ttiepA3q5zKUD3vZgT0qAF3MhtYsg7D9xhdqyXUp/NOYqxU Lc8IIp53KxyYcJo+b5EG9uaiUoo2eqpDraSywaW7ZZ4CSalVNBM+ddEkWiBEOOqmEXTL nKZUB0nI5/BGcZd6C9mBL1p3uOO6daHenGgAVdvAVg8k39SmnHw5Chxo3FX9zivv0Jrb UjizqDD93ap9gOH3NlpH9VtbY4+mFWuNycwREBSaKnCIUMgKJSM6z/uZHbXL0QfRgjEs mjJHEFszFDq18L1Vb494tQOfAnUz63dnKkSVNTQqjT9cE3oXQiwwJrbWRNMoWWuejVAt Ed6Q== X-Gm-Message-State: AGi0PuaZZAhPBGbVdMdnx/eE3j+yaHSi2P7oUTS069Rf4nPhkfHp8nUt F4J29SC4UIKRL/EvEmEXg94d12wP X-Google-Smtp-Source: APiQypL1aRuxvrMTUyYgh0yapkvJPC2KXd3tSuOV3U0oSmKHCgGuOw9fkIStBoPpGe+hQvF01erh9g== X-Received: by 2002:a63:e80b:: with SMTP id s11mr338708pgh.350.1586236712660; Mon, 06 Apr 2020 22:18:32 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:32 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 06/15] powerpc/pseries/ras: FWNMI_VALID off by one Date: Tue, 7 Apr 2020 15:16:27 +1000 Message-Id: <20200407051636.648369-7-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Mahesh Salgaonkar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This was discovered developing qemu fwnmi sreset support. This off-by-one bug means the last 16 bytes of the rtas area can not be used for a 16 byte save area. It's not a serious bug, and QEMU implementation has to retain a workaround for old kernels, but it's good to tighten it. Acked-by: Mahesh Salgaonkar Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/pseries/ras.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 972b95ebc867..ed43c2e4d4ee 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -395,10 +395,11 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id) /* * Some versions of FWNMI place the buffer inside the 4kB page starting at * 0x7000. Other versions place it inside the rtas buffer. We check both. + * Minimum size of the buffer is 16 bytes. */ #define VALID_FWNMI_BUFFER(A) \ - ((((A) >= 0x7000) && ((A) < 0x7ff0)) || \ - (((A) >= rtas.base) && ((A) < (rtas.base + rtas.size - 16)))) + ((((A) >= 0x7000) && ((A) <= 0x8000 - 16)) || \ + (((A) >= rtas.base) && ((A) <= (rtas.base + rtas.size - 16)))) static inline struct rtas_error_log *fwnmi_get_errlog(void) { From patchwork Tue Apr 7 05:16:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267194 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGJh3W0kz9sQt for ; Tue, 7 Apr 2020 15:32:52 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=alikL2Ac; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGJh3DhbzDqwy for ; Tue, 7 Apr 2020 15:32:52 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=alikL2Ac; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0H0t1GzDqyf for ; Tue, 7 Apr 2020 15:18:38 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id b72so253227pfb.11 for ; Mon, 06 Apr 2020 22:18:38 -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=TzGgbHCt6e1nrOseXLAjl+lrG2sd3AGSgQgkA9L7r3Q=; b=alikL2AcQqCbkfRM9Vbrs4A8/NhtHm1ax1MulN81LdaNHYoMh+8KUZ3tu9hERP3+Eg JUTNHvAD+0tQrjbFSrki/guiLc6Kh2ezBVwBHnyiSG0ESIQAuZhKWMLjn0rkwdFPE2E8 xomAWSwUNQJDmQ5CauzD9Q8RjFekSQz7QjL1Jqitn/0qZg4ecfOOZ+oK8wXvV7FwtUqe MugX7AEMEZOzPY0SCXPQXYQbx7MN7S2zcoaqyHrN1naZL+NFRNg5UY1d4vJa92Jf4Iz7 GJMD2JQH9owUoIzgqutTMVQrRtF+1SsWw7ElrUbeyAVQ8mMcBFEHC8ZczSbz0Annc7Qj WflA== 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=TzGgbHCt6e1nrOseXLAjl+lrG2sd3AGSgQgkA9L7r3Q=; b=BUhkMI7KRIs7QE5b6No6pQP5ODmliFURiXf3TD8f5HXDNshrZeidwVwdyy51ZZzj46 rUd+Y7AQ7f82BTmmmSL40CyAkXNNVrTV4EgnXm9iQ0M6sxRBHvxsRqHaKNACXLcV5j3e rVHAGS8aeHV1fofEPogcBYXe92ZnOVNtBVFmwO/S2h0F77AN+yoUtsF55/1YqnIf2G3R UX+y9cOO3gx6PmPv/mhN7Cvdv+/tuBwiy7DRWlZFRNrlD/nyVlZGNVUdbpbPKvcsFuDF /e2IgJcNTYFvFMaYhZW+RhsJjrj83wlypOiZX+CdNOaVk1TJwxfKcCKecfa+GCj+CuN3 W7GA== X-Gm-Message-State: AGi0PuZoCr2rGPFMnqNFY0gZhRrx+JuWf7j1cew+0i+5fFyQU9qO3oOx CQrxvul4ehJhln2TaQkNOBe5k0l5 X-Google-Smtp-Source: APiQypLWMZvwSMPVu/vHqqau6s2ywhOzlNgM3R+4ik0GWUJzhJhu9LRhAO9P3uAzXQbOHFhf9QNmZw== X-Received: by 2002:aa7:984e:: with SMTP id n14mr893019pfq.291.1586236715925; Mon, 06 Apr 2020 22:18:35 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:35 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 07/15] powerpc/pseries/ras: fwnmi avoid modifying r3 in error case Date: Tue, 7 Apr 2020 15:16:28 +1000 Message-Id: <20200407051636.648369-8-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If there is some error with the fwnmi save area, r3 has already been modified which doesn't help with debugging. Only update r3 when to restore the saved value. Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/pseries/ras.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index ed43c2e4d4ee..2c60e2be1bc5 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -423,18 +423,19 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void) */ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) { + unsigned long savep_ra; unsigned long *savep; struct rtas_error_log *h; /* Mask top two bits */ - regs->gpr[3] &= ~(0x3UL << 62); + savep_ra = regs->gpr[3] & ~(0x3UL << 62); - if (!VALID_FWNMI_BUFFER(regs->gpr[3])) { + if (!VALID_FWNMI_BUFFER(savep_ra)) { printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]); return NULL; } - savep = __va(regs->gpr[3]); + savep = __va(savep_ra); regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */ h = (struct rtas_error_log *)&savep[1]; From patchwork Tue Apr 7 05:16:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267195 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGLR4zf9z9sQt for ; Tue, 7 Apr 2020 15:34:23 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=L/4Vp/zI; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGLR4fNMzDr6B for ; Tue, 7 Apr 2020 15:34:23 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1041; helo=mail-pj1-x1041.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=L/4Vp/zI; dkim-atps=neutral Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0L28tBzDqwr for ; Tue, 7 Apr 2020 15:18:42 +1000 (AEST) Received: by mail-pj1-x1041.google.com with SMTP id z3so256268pjr.4 for ; Mon, 06 Apr 2020 22:18:42 -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=J2d8SodfVq4cl53g6Zx9CF5p3xN2FuBCQ0uNfWfubMM=; b=L/4Vp/zIE7AeF9OycMqvREUm7Pe/6TNoJ59QXlfUkFxS9R+u75qEY0iooPNqIo+mrA cG7TtGdgpB6UJmJAKT2m5ca868qiFIrG3zwZuIlXHpwQZusAKjQ2Ne/KAEsWYXuaG/Zf IMsmE6fpofmRW82v7aUtgLH+F7Y2ZiQpQsrIQNZHDxQ85N1K2RNqQTKLcq9hO8EsLTh8 ED+oX67CUHEBGkZZmzBhgF+G6Qmefk8eR+Hgn6jXRKVnQOciD8ePOzUlU6OofGGiaTRU FjyhhPuJluyXDnOIMmVGiyhDdz4BwMqOc5UFToS5Cb3NC/iMtokU4SXfffI5oO8XrE5O azQQ== 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=J2d8SodfVq4cl53g6Zx9CF5p3xN2FuBCQ0uNfWfubMM=; b=P4TqH4LND7fCfucqWxxjAacJfllvLc1yR71Iamm3pmAuAxW1MaNPTkZYgv5joU8Odl kzROYg0m0+EyENb4MKp71Rdd97QABKh5ozJuDhDIeRwJnRUpkRAG8GN9Lk5oMLTgiTx9 YeAIlP3cfDMmFDhX1/Atb9nn5Dgs0MhhH2JgDMWgu3bM4esgkhfVnq3877H8aZMTmRbr gPRLXjWCC2gVbTvGxrzl6hM4OErzBlu/v12ZQWpmkSqLjeyEuwqU/qy1nntb2S8xUJn6 AqsrXfP49v6bqZRz3aiPQ02vIFLDBnCXUu692HM7zb2fg2RrzgmnymCd4cw5X1WwC7jf dqPg== X-Gm-Message-State: AGi0PuaNdbcyvk39KMTgfSQFtzQ8xmt+/fDAFy/pnICLf5ZT2NRMCmoB 8LXymTsF6aa/PPMK90oOGt1uFhk/ X-Google-Smtp-Source: APiQypKQBGAvlGWUsdcYgEduAp5IWNK26t01El9DVbFgBtXGcG+DZCexBXH8tSfv2kxTmSrEGnQ5zQ== X-Received: by 2002:a17:902:b617:: with SMTP id b23mr867241pls.194.1586236719229; Mon, 06 Apr 2020 22:18:39 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:38 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 08/15] powerpc/pseries/ras: fwnmi sreset should not interlock Date: Tue, 7 Apr 2020 15:16:29 +1000 Message-Id: <20200407051636.648369-9-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" PAPR does not specify that fwnmi sreset should be interlocked, and PowerVM (and therefore now QEMU) do not require it. These "ibm,nmi-interlock" calls are ignored by firmware, but there is a possibility that the sreset could have interrupted a machine check and release the machine check's interlock too early, corrupting it if another machine check came in. This is an extremely rare case, but it should be fixed for clarity and reducing the code executed in the sreset path. Firmware also does not provide error information for the sreset case to look at, so remove that comment. Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/pseries/ras.c | 46 +++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index 2c60e2be1bc5..d65bc38bcb8f 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -406,6 +406,20 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void) return (struct rtas_error_log *)local_paca->mce_data_buf; } +static unsigned long *fwnmi_get_savep(struct pt_regs *regs) +{ + unsigned long savep_ra; + + /* Mask top two bits */ + savep_ra = regs->gpr[3] & ~(0x3UL << 62); + if (!VALID_FWNMI_BUFFER(savep_ra)) { + printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]); + return NULL; + } + + return __va(savep_ra); +} + /* * Get the error information for errors coming through the * FWNMI vectors. The pt_regs' r3 will be updated to reflect @@ -423,20 +437,14 @@ static inline struct rtas_error_log *fwnmi_get_errlog(void) */ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) { - unsigned long savep_ra; unsigned long *savep; struct rtas_error_log *h; - /* Mask top two bits */ - savep_ra = regs->gpr[3] & ~(0x3UL << 62); - - if (!VALID_FWNMI_BUFFER(savep_ra)) { - printk(KERN_ERR "FWNMI: corrupt r3 0x%016lx\n", regs->gpr[3]); + savep = fwnmi_get_savep(regs); + if (!savep) return NULL; - } - savep = __va(savep_ra); - regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */ + regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */ h = (struct rtas_error_log *)&savep[1]; /* Use the per cpu buffer from paca to store rtas error log */ @@ -483,11 +491,21 @@ int pSeries_system_reset_exception(struct pt_regs *regs) #endif if (fwnmi_active) { - struct rtas_error_log *errhdr = fwnmi_get_errinfo(regs); - if (errhdr) { - /* XXX Should look at FWNMI information */ - } - fwnmi_release_errinfo(); + unsigned long *savep; + + /* + * Firmware (PowerVM and KVM) saves r3 to a save area like + * machine check, which is not exactly what PAPR (2.9) + * suggests but there is no way to detect otherwise, so this + * is the interface now. + * + * System resets do not save any error log or require an + * "ibm,nmi-interlock" rtas call to release. + */ + + savep = fwnmi_get_savep(regs); + if (savep) + regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */ } if (smp_handle_nmi_ipi(regs)) From patchwork Tue Apr 7 05:16:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267196 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGP00HHcz9sQt for ; Tue, 7 Apr 2020 15:36:36 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rBf/rKNZ; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGNz70M9zDr5Y for ; Tue, 7 Apr 2020 15:36:35 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1044; helo=mail-pj1-x1044.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rBf/rKNZ; dkim-atps=neutral Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0P5mLnzDqwW for ; Tue, 7 Apr 2020 15:18:45 +1000 (AEST) Received: by mail-pj1-x1044.google.com with SMTP id g9so263493pjp.0 for ; Mon, 06 Apr 2020 22:18:45 -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=nl437sNO9gLL74V/kqg7OkhBKl6Fq4kmvlP9ZCPnhp4=; b=rBf/rKNZwWHfIVBThjUFuNhvuS8y6ui1dTuIqfBCXf7PYYTVYsvkbZEJIgOHQginPQ nJKr+yj9W7zANgLnh0bmy7UDVUBv4mibgywSt/qVMKWXueHmbkWHeDOvbVpcH3yL62SJ unI4CybwBvxVTFIV0CdZaSL0iRs2WYbVVh5mEDCLetsGM8QESMANNai1Zr4eOgSg5wcX 8lHH/fnwX8jt04S3iDMKI+4Hu/tfGACT5CzhIxgv3rx02Ao5vRPjWPk3kDYq8yc03g1I /Lozc0C8aWO1Fa5Pw10cAIFEkN7+CuEwKqzEtOI3/N5AJhCx5jUxDdDdy4rrmLGenlZT qTnQ== 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=nl437sNO9gLL74V/kqg7OkhBKl6Fq4kmvlP9ZCPnhp4=; b=mzl1Hickwep03t+uGH8GOqTIdXNUid/gukDwmFk2yjhvLZogzCV82hP9/7DvfPqH8t sk/YkG6Pa13sJBnjAQqHAiDylc73iT6pCr4TKr1nu71MCMtQCV2C92EHS2l8urG3B8kA G+7C1IzJuJpS5+ipBYtjW/SSDEoVQnqvQXaUMvO5lzZtoEFawFRHvoX6gezZSuLfMGYa oibjIa/JWIEmcJGGejJParshRpYqINx2K1CSswHQeACjvLXb/+Gdh0NrhfK12wbR1+VM MOGjUrnL7C1a/DmGMBcp0/m8tcuEI8O/yehIPUGfNoQHJiQmLcmrEI2ZbWXRi8t5DQMy vf3g== X-Gm-Message-State: AGi0PuYuNJJRxX3Fo6bOwcfxfNjR7vwbaPcfJj00NP5WWT9eDqdimUuo wSJ0mrJ4/sJAv0Jn1QwuOhx8fTm0 X-Google-Smtp-Source: APiQypKwBHsxEiRNnzsly1hO3J6FEwJVjoKUlk+EteYL088oU3zZQmM9/zGjr40DGsd3YwNcAkvfJQ== X-Received: by 2002:a17:902:7896:: with SMTP id q22mr733654pll.75.1586236723085; Mon, 06 Apr 2020 22:18:43 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:42 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 09/15] powerpc/pseries: limit machine check stack to 4GB Date: Tue, 7 Apr 2020 15:16:30 +1000 Message-Id: <20200407051636.648369-10-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Mahesh Salgaonkar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This allows rtas_args to be put on the machine check stack, which avoids a lot of complications with re-entrancy deadlocks. Reviewed-by: Mahesh Salgaonkar Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/kernel/setup_64.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 438a9befce41..defe05b6b7a9 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -709,7 +709,7 @@ void __init exc_lvl_early_init(void) */ void __init emergency_stack_init(void) { - u64 limit; + u64 limit, mce_limit; unsigned int i; /* @@ -726,7 +726,16 @@ void __init emergency_stack_init(void) * initialized in kernel/irq.c. These are initialized here in order * to have emergency stacks available as early as possible. */ - limit = min(ppc64_bolted_size(), ppc64_rma_size); + limit = mce_limit = min(ppc64_bolted_size(), ppc64_rma_size); + + /* + * Machine check on pseries calls rtas, but can't use the static + * rtas_args due to a machine check hitting while the lock is held. + * rtas args have to be under 4GB, so the machine check stack is + * limited to 4GB so args can be put on stack. + */ + if (firmware_has_feature(FW_FEATURE_LPAR) && mce_limit > SZ_4G) + mce_limit = SZ_4G; for_each_possible_cpu(i) { paca_ptrs[i]->emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; @@ -736,7 +745,7 @@ void __init emergency_stack_init(void) paca_ptrs[i]->nmi_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; /* emergency stack for machine check exception handling. */ - paca_ptrs[i]->mc_emergency_sp = alloc_stack(limit, i) + THREAD_SIZE; + paca_ptrs[i]->mc_emergency_sp = alloc_stack(mce_limit, i) + THREAD_SIZE; #endif } } From patchwork Tue Apr 7 05:16:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267197 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGQv4rPSz9sQt for ; Tue, 7 Apr 2020 15:38:15 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=YkcdIn0t; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGQv3Yj4zDr4m for ; Tue, 7 Apr 2020 15:38:15 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=YkcdIn0t; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0S3X37zDqvP for ; Tue, 7 Apr 2020 15:18:48 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id a13so271799pfa.2 for ; Mon, 06 Apr 2020 22:18:48 -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=4FEaht7zxwBjHD8wzIED7TDrVFdT0iycKSLrGAMohws=; b=YkcdIn0tcT+72BWwnUaqlNV6Ag60YiBFuaR6DCtSrsySMha7X2gj/p6mSLbKOC7hN0 L5MKtFRZGJ4Lq94VdEvKiQ/gYi4Dq6JwfKFwJxqJIky1KLw/XfLqOGvKVYDX6oLp6ab8 hdUfxGxBkxk3765mw8p53Fq74QVCn1z0VBi30ep/cmj1k3VO2klA95IVOl6LcFlhBRJt IFvz+qPHvuMLfpv48fRIZE2N370AEdn2KVUZMruW4QIAgjcabIXoLdYOYMLNHcOT4m03 zcURCLT0qgE590mr0LJ1eP2yUs24afUpNIeaenGn8n38vLJ7deDy82XIYhNNAKdY5ctx zAeA== 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=4FEaht7zxwBjHD8wzIED7TDrVFdT0iycKSLrGAMohws=; b=PqvTt7hiOG7X58cdvpykof49iSDTVeVtaulOALmdCnJM3h1bBP0wixFPviZAfxjNmh mHe89ysHpn5JPY+Eo7FQru6EJt1y0YiS9u3JyGYgiQObDi11s+PBjXVFDeOIK6hC2Gr9 Z7js2yR5ABo+c8J2Uh6ansjni00jQnhYX/snW8wR7IFdI26JFXCTGiHzZm03Nl2aJERr UwyhzILs/wFwojNZVFR0/7UVtuNVYdgPyBp/tWlnaQ4DEUzrEhsDGGC1PCcwwLRc+fKk YJRzi038cKOkXZL8JK+QlO/FHpTMO5Yklz6Peg4XRmhtuA/nxYvOpAZVSkdb5o/DYqjp bVGQ== X-Gm-Message-State: AGi0PuZEwfXMBMEjqe4iGAoixtx6qlwfZzIs5k97YFeEn488sWcnhIRp /KFQvWVJcY8Z+m4yD7NMKkGzsJMB X-Google-Smtp-Source: APiQypKhrzvAC7gCas+7eA9yD2dED2VpZoUQw1qABA6Vl3dJf7mH0llYo2WGATVv9g2riCYcfgB14w== X-Received: by 2002:a63:a746:: with SMTP id w6mr367151pgo.76.1586236726383; Mon, 06 Apr 2020 22:18:46 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:46 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 10/15] powerpc/pseries: machine check use rtas_call_unlocked with args on stack Date: Tue, 7 Apr 2020 15:16:31 +1000 Message-Id: <20200407051636.648369-11-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" With the previous patch, machine checks can use rtas_call_unlocked which avoids the rtas spinlock which would deadlock if a machine check hits while making an rtas call. This also avoids the complex rtas error logging which has more rtas calls and includes kmalloc (which can return memory beyond RMA, which would also crash). Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/pseries/ras.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index d65bc38bcb8f..4fd138ae26fd 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -468,7 +468,15 @@ static struct rtas_error_log *fwnmi_get_errinfo(struct pt_regs *regs) */ static void fwnmi_release_errinfo(void) { - int ret = rtas_call(ibm_nmi_interlock_token, 0, 1, NULL); + struct rtas_args rtas_args; + int ret; + + /* + * On pseries, the machine check stack is limited to under 4GB, so + * args can be on-stack. + */ + rtas_call_unlocked(&rtas_args, ibm_nmi_interlock_token, 0, 1, NULL); + ret = be32_to_cpu(rtas_args.rets[0]); if (ret != 0) printk(KERN_ERR "FWNMI: nmi-interlock failed: %d\n", ret); } From patchwork Tue Apr 7 05:16:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267198 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGSs74L1z9sP7 for ; Tue, 7 Apr 2020 15:39:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=S1tit7Tf; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGSs38jYzDqp7 for ; Tue, 7 Apr 2020 15:39:57 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1044; helo=mail-pj1-x1044.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=S1tit7Tf; dkim-atps=neutral Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0X0PRvzDqvh for ; Tue, 7 Apr 2020 15:18:52 +1000 (AEST) Received: by mail-pj1-x1044.google.com with SMTP id kx8so254329pjb.5 for ; Mon, 06 Apr 2020 22:18:51 -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=hb4l5DDeeP4QLHvqpvnXYB6zun+jwC0osLBAO4GluFs=; b=S1tit7TfmlTBdv1nCpvLxsTNAPyWvQazrRn2M2clpyFlpvixQuwvBUBgiAi6yIviBg GHmgOMF3FiOEzKluSG9OirEzMnI/z2f7n7pHcD/mgMlfMyeK8Z8UT5K/Jao41J4tTKu2 ZtpZ8iJSR6x7HFXfo2MQkc9Ibqqop5uIl70weoNzRxjsNcgomOPtyOXOFbMrOHCkkW/8 SspiGjAMWqSolr9rRPumNltWN+9n5lSTRLsbHAIulPBzZxhx2ErpLEFB9wh6tVKclhd8 Nv2//r727ArErbeNx6Zg4+ypoXfmvxVifHvqTZnfAKfyGZ0F8MKT/eDuk7C7BBqVEEfB EcMw== 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=hb4l5DDeeP4QLHvqpvnXYB6zun+jwC0osLBAO4GluFs=; b=nHz7GVptBXVAW1BYoAWIsGnRqyHk0IbIHpSVV2ZgxF+aBTl4VWtytFWWegy76GJlWn l8p5UxcaOdUWM3n1v7df1K/O303pFA+bbLsykxUERiHMn5e8euNZVPODjA5E10bH2AWU kbyoTPWicNrRZX9/T4AE1z0jcBXFl+nwGOsm0pgczmyQn2iKWfhJpt0ROJtQv8E+XkVL cGCIk+lnQ5l0A4d6jeWukjFvBght7Qw13BWHX5gTWR5KOjelaeIdTRBDcxrvsvCnuuGE W6mD+PErNnV+6Osab8ar4DYwmLl7oGqcSlKzE9nFvUWD8xQEw5L9K2jS+foP2ad98LNm mXdA== X-Gm-Message-State: AGi0PuYFdLaTnxU5++cKiPRQzf4Uk24lT5CEVXOubv7uJNyhooLr+aKC 8/qhc7lii/7DmAV50NQaKK/hIHnO X-Google-Smtp-Source: APiQypI9Lz0XTqsy+mfhGbWHg4SCYrlshgeAq2bfgGljjDv1jdxeLE5OOmRnXsMTZeN07inQQQucAw== X-Received: by 2002:a17:902:a504:: with SMTP id s4mr852922plq.10.1586236729649; Mon, 06 Apr 2020 22:18:49 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:49 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 11/15] powerpc/64s: machine check interrupt update NMI accounting Date: Tue, 7 Apr 2020 15:16:32 +1000 Message-Id: <20200407051636.648369-12-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" machine_check_early is taken as an NMI, so nmi_enter is used there. machine_check_exception is no longer taken as an NMI (it's invoked via irq_work in the case a machine check hits in kernel mode), so remove the nmi_enter from that case. In NMI context, hash faults don't try to refill the hash table, which can lead to crashes accessing non-pinned kernel pages. System reset still has this potential problem. Signed-off-by: Nicholas Piggin Reported-by: kbuild test robot --- arch/powerpc/kernel/mce.c | 7 +++++++ arch/powerpc/kernel/process.c | 2 +- arch/powerpc/kernel/traps.c | 13 +------------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 8077b5fb18a7..be7e3f92a7b5 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -574,6 +574,9 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info); long machine_check_early(struct pt_regs *regs) { long handled = 0; + bool nested = in_nmi(); + if (!nested) + nmi_enter(); hv_nmi_check_nonrecoverable(regs); @@ -582,6 +585,10 @@ long machine_check_early(struct pt_regs *regs) */ if (ppc_md.machine_check_early) handled = ppc_md.machine_check_early(regs); + + if (!nested) + nmi_exit(); + return handled; } diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 9c21288f8645..44410dd3029f 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1421,7 +1421,7 @@ void show_regs(struct pt_regs * regs) pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr); #endif #ifdef CONFIG_PPC64 - pr_cont("IRQMASK: %lx ", regs->softe); + pr_cont("IRQMASK: %lx IN_NMI:%d IN_MCE:%d", regs->softe, (int)get_paca()->in_nmi, (int)get_paca()->in_mce); #endif #ifdef CONFIG_PPC_TRANSACTIONAL_MEM if (MSR_TM_ACTIVE(regs->msr)) diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 3fca22276bb1..9f221772eb73 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -823,9 +823,6 @@ int machine_check_generic(struct pt_regs *regs) void machine_check_exception(struct pt_regs *regs) { int recover = 0; - bool nested = in_nmi(); - if (!nested) - nmi_enter(); __this_cpu_inc(irq_stat.mce_exceptions); @@ -851,20 +848,12 @@ void machine_check_exception(struct pt_regs *regs) if (check_io_access(regs)) goto bail; - if (!nested) - nmi_exit(); - die("Machine check", regs, SIGBUS); +bail: /* Must die if the interrupt is not recoverable */ if (!(regs->msr & MSR_RI)) nmi_panic(regs, "Unrecoverable Machine check"); - - return; - -bail: - if (!nested) - nmi_exit(); } void SMIException(struct pt_regs *regs) From patchwork Tue Apr 7 05:16:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267200 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGVx2j2Xz9sP7 for ; Tue, 7 Apr 2020 15:41:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nZopXDEZ; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGVw4LjzzDr3P for ; Tue, 7 Apr 2020 15:41:44 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1043; helo=mail-pj1-x1043.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nZopXDEZ; dkim-atps=neutral Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0d11sszDqwf for ; Tue, 7 Apr 2020 15:18:56 +1000 (AEST) Received: by mail-pj1-x1043.google.com with SMTP id m15so258756pje.3 for ; Mon, 06 Apr 2020 22:18:56 -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=SHMWd8uDETi2/vN6LtZbQlAB8sad8yzKlsSJQhf9LQ0=; b=nZopXDEZUpQeBDkC+oMnum4baCXXtGEabxS4lM43/fJ3b7QFVsdbJYLGBl49uh5H4N xonlCuI0eC1LIbFnAqLDSf4INiM86HsiNLRBQegEvX2cvNBsvbLC7hdgBjgUs12omtD4 Qs4OM43ZVdfPcGXJzhFH2nw67q/KDDfBaSBvb6omsudvfpvHWgw3oKCtOgPdnz8CgW1Y Ptro9WlloWxltLiBSmBFFoULoMXV/S8FjcQ9JhRxKKn63iEyClnDV97aF7nKL2jht6Ch 2XyH8amsw5dP+NNmp5jQK9R8sOm0yte4wF1O4OSpVuYZTSmGTDV6NEO4aMrkfVMx8mll hiSA== 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=SHMWd8uDETi2/vN6LtZbQlAB8sad8yzKlsSJQhf9LQ0=; b=PXz2CAw46W8snDey+zLWb216PgKTOL2JQSVMW9a5MJp01ZYCKQ2ysHjoXQsGGHfwmm VNH3yFbQfAdJUbsukW9F2srVSS/1qSUWdr0Mjx1hx1A36DfN+o4/GCT0l1ujfIj/pTn8 zPEkA2vPBDMntSO288QcRNZSKuT3tkZtKHHzSw7v7lPfbabn1spLXnx1KJhZ/TYi82SH ISwCFf9o6jKrvnb0CUxW0wEfxEHbUPe7MG2srv5hRqEzF5hlNkLPspoR7qEupILjr3Ri MfySoS6eNPNUTMfLjmCPnSSy7uz+7FaTAtr8jbjSVtC2EzQV2xBe6ga8u4uz2EZ8GlFL fKXw== X-Gm-Message-State: AGi0PuaaBEXkNPSnQAFxZqUVSYwECY3aP0I2/rqU00X+We7wGDxuQnEL x9c2Z35ftwm/WjGNVJs/MlWc6haH X-Google-Smtp-Source: APiQypLDRgQYS3vLdXnF/kujT4TLu4v5Rr9NKUxgkDrVI9UJcoOONJcS6ycwK/k67kmxPh8jiKGa+Q== X-Received: by 2002:a17:90b:8e:: with SMTP id bb14mr661233pjb.13.1586236733333; Mon, 06 Apr 2020 22:18:53 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:52 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 12/15] powerpc: ftrace_enabled helper Date: Tue, 7 Apr 2020 15:16:33 +1000 Message-Id: <20200407051636.648369-13-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , "Naveen N . Rao" , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/include/asm/ftrace.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index f54a08a2cd70..bc76970b6ee5 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -108,9 +108,23 @@ static inline void this_cpu_enable_ftrace(void) { get_paca()->ftrace_enabled = 1; } + +/* Disable ftrace on this CPU if possible (may not be implemented) */ +static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) +{ + get_paca()->ftrace_enabled = ftrace_enabled; +} + +static inline u8 this_cpu_get_ftrace_enabled(void) +{ + return get_paca()->ftrace_enabled; +} + #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } +static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } +static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ From patchwork Tue Apr 7 05:16:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267201 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGXz2Tlyz9sP7 for ; Tue, 7 Apr 2020 15:43:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=bJzZa2Yl; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGXz0g6yzDr3N for ; Tue, 7 Apr 2020 15:43:31 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=bJzZa2Yl; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0h26CtzDqvY for ; Tue, 7 Apr 2020 15:19:00 +1000 (AEST) Received: by mail-pl1-x641.google.com with SMTP id g2so802479plo.3 for ; Mon, 06 Apr 2020 22:19:00 -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=42wLPPdXyYKEvDZmkwAhMl7uSbdEKZoG24TcsZYBVnc=; b=bJzZa2YlGFdVdVeNSwkOuzesp2/5Jo0FqXDjY3IicTPCByG0O0/aBnpWrj8W427Y11 JVOTYKtqZa5CsfNeML0y8618ISgrrCTd+TrhgH5VaZpeTcelqriX410E6k0IY0FhjBok egJ37jj/Ya7WxPhnAXb6Wmd3T76sQOqJDt5dmw+OsUm9oXkxSqeEgKxEEJGrJcrCFtBy 450tomUP9DOngWeV/YuZCnctJ0ITDO8BCekt4xtcmZCjU5W4UxDEFlwCmPxeA0qQrD4L c2dlzIkWurC9W5kClhLUcBwqDFmdZDADC0i0YTaST1d5aL9aQ5Yxz5Oomfo/o0nH/JwL l8mg== 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=42wLPPdXyYKEvDZmkwAhMl7uSbdEKZoG24TcsZYBVnc=; b=a9e3A7weFJMRi4edxwn9Dj5SfYrqcwHwoyTIExfJ0Ws6+PtTSjHtTzT38SbNqyXgtO x2ca+1jWrBB87t+GuFyKKOy/tDlN2jMxiXH9gvhQMtKwX6GndyPbMhykJnM5gLnG1mT2 jRwPfCy309Z5k4cfz581jBr29J9dGVcstkbniH6yXPKgyQvfUmFc1vR/35AwxF6BW/Mw 6UnHXomJz9uwb0mtAmOB+BZrqDucen/SGy1OD7EI4/U3Kko7SIjbEbx04f5dJgcFWoxq NTnIfPAVmIASzUZmufhYIP37FxHHQN+u7yoiYOHsQOywqTRP3hT3UjORYMhgt6+LeGHN uToA== X-Gm-Message-State: AGi0PuZ7p5yJI9ZdoyFfhUaHtxwkz4zSa03wmJKG60UGebUxC24ggr6n W1wRPlZEznkyvD+/tXpitPHvv2yE X-Google-Smtp-Source: APiQypLOHXm7deNsFDncXTpLyj5MFgU0oAMLkzQtkWUupdH58xdYdAqDzQdh+xyrzVMjdxX5BZSw5g== X-Received: by 2002:a17:90b:1b04:: with SMTP id nu4mr627745pjb.81.1586236737107; Mon, 06 Apr 2020 22:18:57 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:18:56 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 13/15] powerpc/64s: machine check do not trace real-mode handler Date: Tue, 7 Apr 2020 15:16:34 +1000 Message-Id: <20200407051636.648369-14-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , "Naveen N . Rao" , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Rather than notrace annotations throughout a significant part of the machine check code across kernel/ pseries/ and powernv/ which can easily be broken and is infrequently tested, use paca->ftrace_enabled to blanket-disable tracing of the real-mode non-maskable handler. Acked-by: Naveen N. Rao Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/kernel/mce.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index be7e3f92a7b5..fd90c0eda229 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -571,10 +572,14 @@ EXPORT_SYMBOL_GPL(machine_check_print_event_info); * * regs->nip and regs->msr contains srr0 and ssr1. */ -long machine_check_early(struct pt_regs *regs) +long notrace machine_check_early(struct pt_regs *regs) { long handled = 0; bool nested = in_nmi(); + u8 ftrace_enabled = this_cpu_get_ftrace_enabled(); + + this_cpu_set_ftrace_enabled(0); + if (!nested) nmi_enter(); @@ -589,6 +594,8 @@ long machine_check_early(struct pt_regs *regs) if (!nested) nmi_exit(); + this_cpu_set_ftrace_enabled(ftrace_enabled); + return handled; } From patchwork Tue Apr 7 05:16:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267202 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGbC6TZVz9sP7 for ; Tue, 7 Apr 2020 15:45:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nZ1yfvvB; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGbC4VRdzDqlL for ; Tue, 7 Apr 2020 15:45:27 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nZ1yfvvB; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0k6xLdzDqwr for ; Tue, 7 Apr 2020 15:19:02 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id k15so263290pfh.6 for ; Mon, 06 Apr 2020 22:19:02 -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=7OlubOQimkHngZ3g1RBEj6WP5pjIG24DCmWr1fgRpV4=; b=nZ1yfvvBEVauaIUm6CWCjhBKeQTPpQ2poCGXC1idE5agGopvhFHWsthZRxXeoOS7mF QCro+pxUffUhWYkpEHU7lxz5qBL25pc9WlRW3y/JpXiixgMmMCrYPpmpV0kCD+9WDpXk CHtJ8gSs5JnY1Vpas55t4nQlDlF0tlg45+AeqPRfpKjOK8ug6M5cq5qx1Tduv98Wn604 oXRmYU1sJSTA0pysVeCjoLL8nT8Q2hlKSmcmnEcRK8VlqqBgw9dU+ruwBiADo+6AAWuG rRYl/O8L9Cgo2uo7Dg24IDnh54SRiEo91Ub2JpN98dqj6ZR2ulHhVH+/PXCa2joue5hw zeYQ== 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=7OlubOQimkHngZ3g1RBEj6WP5pjIG24DCmWr1fgRpV4=; b=Rxdku4CwDlXD60YWuayjwI+k6oibZTWIol3EeopHkWrllIj3OOfBvxalGJL1KlneFJ IZgF0BUxKdMPcdaCk700mMYlcycXbzeXfmC94r5kVVXVxB/iA0uTHR23jiaS1CNfh8Mq y5h23tklIu/MKFr9FeairZg/FARzfKQzPIzmbq+t+rGL3Y7N8KzuC2MDjVHvfrXSAukw TeeN3//2083r+LSsaYn28XDEAzCX85fPYym2vcpSZybdHpdxJFwviQc1L3Mu/keirsEz +ZaO0SLusWs4BYUMDlICkosNskHz/Ps4biazU7G6K3wt6NF6i8WcQ5gQ4vzD5+CIgV6T ZdRQ== X-Gm-Message-State: AGi0PuZYOy8UGusi8/g6CptZQvBgwhOTGJ20fPtvayft3z7fehsXg0q8 8y7ig5/1nHuw6hwqvpVh7snWEevR X-Google-Smtp-Source: APiQypKmMbiPEspZgw637P3B0JnA8nGTjsSkqOaDZXcxUAYOuSd4uNZaqhEN03ndr8DfDODQh5OL9A== X-Received: by 2002:a63:2254:: with SMTP id t20mr340842pgm.121.1586236740636; Mon, 06 Apr 2020 22:19:00 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:19:00 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 14/15] powerpc/64s: system reset do not trace Date: Tue, 7 Apr 2020 15:16:35 +1000 Message-Id: <20200407051636.648369-15-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , "Naveen N . Rao" , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Similarly to the previous patch, do not trace system reset. This code is used when there is a crash or hang, and tracing disturbs the system more and has been known to crash in the crash handling path. Acked-by: Naveen N. Rao Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 9f221772eb73..1beae89bb871 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -443,6 +443,9 @@ void system_reset_exception(struct pt_regs *regs) unsigned long hsrr0, hsrr1; bool nested = in_nmi(); bool saved_hsrrs = false; + u8 ftrace_enabled = this_cpu_get_ftrace_enabled(); + + this_cpu_set_ftrace_enabled(0); /* * Avoid crashes in case of nested NMI exceptions. Recoverability @@ -524,6 +527,8 @@ void system_reset_exception(struct pt_regs *regs) if (!nested) nmi_exit(); + this_cpu_set_ftrace_enabled(ftrace_enabled); + /* What should we do here? We could issue a shutdown or hard reset. */ } From patchwork Tue Apr 7 05:16:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1267203 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xGdd6sB0z9sP7 for ; Tue, 7 Apr 2020 15:47:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=U11KZoGh; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48xGdd15N6zDqXZ for ; Tue, 7 Apr 2020 15:47:33 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::441; helo=mail-pf1-x441.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=U11KZoGh; dkim-atps=neutral Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48xG0p4yv8zDqwg for ; Tue, 7 Apr 2020 15:19:06 +1000 (AEST) Received: by mail-pf1-x441.google.com with SMTP id a13so272087pfa.2 for ; Mon, 06 Apr 2020 22:19:06 -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=jihMKlMJVkAPxpzXawv9A4UZu5xnq3ijgXSpiO4HgmI=; b=U11KZoGhj/pZC+DhoeAZO24gWv3Q0DLicEwuNFQ8cqTAf5JTE8Y13HiTYeSL94i7kO Z5RLrRCXwauDbTSG42i/v9oxa7PE0xwDME5e+IoqwA2WlSBGqluiHJnyJ4QjIyoMfcM2 HiaA0Dizk3gJEVbHweHg8dJVTnj02xuUu2lkaJVehFD+sFUuslMcF9n33cm8Vnf74GmP dSnZpUFE47RATtLWSpWf6L0D3zAYNPrjTh0D+oiJxYexTvdBPMxOJNDMuu7eV8zun3SL gd3e4D1bYKi4bGBmW2GRPF5491yF0U9GANnQ43gVdMsXhwXtOs8DVVzFZMV95diqRYY3 H0lQ== 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=jihMKlMJVkAPxpzXawv9A4UZu5xnq3ijgXSpiO4HgmI=; b=uiI3j/nVw0Go/Ftr2z7+iCAd9iXMYgy/BXrBJnmxPNRus2EF2EWYPXftuJ1h+aKej5 JROR7X1kg6i0tChr4qDeqYa8tDbW14LCVLmcCsSaubfWFMmpj4IBkGfc9ORzhhBOcVus Nu8QCs6iwarwRSNZYK6vITU+U6hik9mbvKrEjePiKDE7kawSNjK+u9yUlI5GPW1YwehW Ew0o98Cp2PrungrATYDJJYryvBpIYcs9vQud/iA+y8lzOceDXfRV6MNn5cTqjnGyM027 dL6zQwhzAIawuIC7qRnw5vKwQTBuGyLHJfnIyw1PLewmfigNz089KNL7Xd/hZBwuCN3c tOnQ== X-Gm-Message-State: AGi0Pub5D1qCiA1t6vhRj2VaThoumP/4lme7sfObgDEt92cI9QLa1dgY DEZe1OY6JWKWU/CAigsExyffMfX2 X-Google-Smtp-Source: APiQypJ/SCeUhm76IqqWPM4dyMkWgLEZdMYv2a8JJSz98eBtakYyimsTiCV6dJSo8qL5RoF/12Gc1w== X-Received: by 2002:a63:b954:: with SMTP id v20mr303021pgo.381.1586236744210; Mon, 06 Apr 2020 22:19:04 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id y17sm12866486pfl.104.2020.04.06.22.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 22:19:03 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3 15/15] powerpc: make unrecoverable NMIs die instead of panic Date: Tue, 7 Apr 2020 15:16:36 +1000 Message-Id: <20200407051636.648369-16-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200407051636.648369-1-npiggin@gmail.com> References: <20200407051636.648369-1-npiggin@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahesh Salgaonkar , Ganesh Goudar , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" System Reset and Machine Check interrupts that are not recoverable due to being nested or interrupting when RI=0 currently panic. This is not necessary, and can often just kill the current context and recover. Signed-off-by: Nicholas Piggin Reviewed-by: Christophe Leroy --- arch/powerpc/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 1beae89bb871..afed3de33a9a 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -513,11 +513,11 @@ void system_reset_exception(struct pt_regs *regs) #ifdef CONFIG_PPC_BOOK3S_64 BUG_ON(get_paca()->in_nmi == 0); if (get_paca()->in_nmi > 1) - nmi_panic(regs, "Unrecoverable nested System Reset"); + die("Unrecoverable nested System Reset", regs, SIGABRT); #endif /* Must die if the interrupt is not recoverable */ if (!(regs->msr & MSR_RI)) - nmi_panic(regs, "Unrecoverable System Reset"); + die("Unrecoverable System Reset", regs, SIGABRT); if (saved_hsrrs) { mtspr(SPRN_HSRR0, hsrr0); @@ -858,7 +858,7 @@ void machine_check_exception(struct pt_regs *regs) bail: /* Must die if the interrupt is not recoverable */ if (!(regs->msr & MSR_RI)) - nmi_panic(regs, "Unrecoverable Machine check"); + die("Unrecoverable Machine check", regs, SIGBUS); } void SMIException(struct pt_regs *regs)