From patchwork Wed Jul 3 07:54:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126675 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 45dtmV6tXlz9s00 for ; Wed, 3 Jul 2019 17:59:22 +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.b="b6SQkpLR"; 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 45dtmV5trKzDqQR for ; Wed, 3 Jul 2019 17:59: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 (mailfrom) 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.b="b6SQkpLR"; 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 45dthJ3y2jzDqNZ for ; Wed, 3 Jul 2019 17:55:44 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id g15so790768pgi.4 for ; Wed, 03 Jul 2019 00:55:44 -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=gJqecc7z/Wt3DHiADBssOtE0uLDjQM8bKcxpApRr0MA=; b=b6SQkpLRqkH0NEHju3bo+Zm79fTLWfD/RCe2hlIQCEKY1BWnh/4KgmuLt3ZqfbQ+4h G8BgjOefvQ6IU0vZC1wGa/VQgPmYWZcThpa6uwp9/THF8SGyMuUpvcVNuILFkUSzqzJK oLaVOFRIfd2FgJijeW4o5TWxEe1lwLQ2C0u9H6g6PV7wMxRArroFgEQEQjyM3xOt/3LH fNbKSQAcrbRW4q+KJpGKnanFvaTKIwLRMcuxadFDz8iXVJym2dUySDaaBdQaLDsMedjI aI+NKPufQDOGb8yCSXKxSm/9wcIZgOBMPo5+ZxQIJyRpGXsn/cF9BfmWsvCKTM2lRVok W7tw== 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=gJqecc7z/Wt3DHiADBssOtE0uLDjQM8bKcxpApRr0MA=; b=dsTQ43HMy/b0EW5X2AVteoWYxC75biAwRdCUOn0b6ODoW/uHrWg2tsvRooZXoKNk2g grki1TWDtdnEw5cpl76mSMC7RTt/rX5RAVwO2JbyicXhH6Z40b1xHod/WJop6rWR2aS8 T3qPkNnEXFSM0PdtjxKVOZd0hXkpAX0JZ4gUVCo/HsDGd1uwJEi5WvwIyZb6slODTX+r MOi56V5at5yvg5/JHBwMQCLVmQiB/uxCMQclmi5Q1dVeM84Lks0DTYr64IRCeAkGiuh6 oRLf3tAeu1ECHQYJOsCykw2AmeknIof1vyg4XGAAZEZISfTdyWDPrQ4ieFLAJNoIE4hf Ldag== X-Gm-Message-State: APjAAAWX4tDhin/Y5CE2yfqpt2pCqidb3qEgifVnZUxZBiHfL6vlus5A AVHoXNAvSOZuJyh7jdbGFhi1tJR2 X-Google-Smtp-Source: APXvYqzZzqjfysRDhjQDaqomxDDOoafuMGprTMAH79rAWE7vKYddcyuptimMa3Dm2A0zX9S+Bz94nA== X-Received: by 2002:a63:c34c:: with SMTP id e12mr34653666pgd.195.1562140542082; Wed, 03 Jul 2019 00:55:42 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:41 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 01/14] powerpc/64s/exception: machine check fwnmi remove HV case Date: Wed, 3 Jul 2019 17:54:31 +1000 Message-Id: <20190703075444.19005-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" fwnmi does not trigger in HV mode, so remove always-true feature test. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 53c1b0a2ebce..db7ef8c8566f 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1026,9 +1026,8 @@ TRAMP_REAL_BEGIN(machine_check_pSeries) .globl machine_check_fwnmi machine_check_fwnmi: EXCEPTION_PROLOG_0 PACA_EXMC -BEGIN_FTR_SECTION b machine_check_common_early -END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE) + machine_check_pSeries_0: EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 /* From patchwork Wed Jul 3 07:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126677 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 45dtpl0L20z9s00 for ; Wed, 3 Jul 2019 18:01:19 +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.b="HQyc15p1"; 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 45dtpk6440zDqQR for ; Wed, 3 Jul 2019 18:01:18 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="HQyc15p1"; 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 45dthM3gYrzDqQJ for ; Wed, 3 Jul 2019 17:55:47 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id w24so782330plp.2 for ; Wed, 03 Jul 2019 00:55:47 -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=Ee9qLF/RJ+7mXd4GiTRK8Dspx6rtpH65SXbucIncObU=; b=HQyc15p18sDixuNni4H5pwWcU7K2UGdio0PWpDsdQ8SLP7y9REPfq0a7Y/Rh4Mx1jB x97heN4ehKzdEFtAKkD/pNlS2WC4Zs93vgQYvjD6HeHSmfInZV2BsfacMkOuYUGcYv55 fGPOdJTAnIcVqAY0ixLNhUd3RFCnljfIrZFKfbhve6QibPLaAEcNCFDTjvqnMSi2SfZu vA4PbonTJvXlNnprBcPQ6ScqMun+GpgKQ1Qoe6d7xOvSvZJowlBkc9pXdU876dWHJVwu cKUr6X3J/+npjpWKNGjwfM9C4sXUSgql3qJmTcfTYKK4XSvjpkMoJtlMJ09resThrLUD /Bvg== 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=Ee9qLF/RJ+7mXd4GiTRK8Dspx6rtpH65SXbucIncObU=; b=taHXjzX3GwUU9SSKIlma2gQ+Kz5lL0Yz9RGzvPudVCL6NhwROJhQH6nW5Xq5aVV5tQ CCu/Rcm6/b2YAPCipUhuP6RSgLuI32kzY3+qWg3ODiebT8Y2UK1/dXUaAlyol7cxRZ4+ w8pkPjfvGJMnkUJY25xhSTsgpBl8gPSXoInSiMzaj49uWpJJocyuiiuJ7U13T18BOaYw sdwaXd67Wcp/E92ltRBBCknqQSQJFbILt18IEp0mEQpOVSkO0EbxTmjzc44GmtnrNYk/ ENbI7ziib+NKEIHCjRomZi5s7sE2xiTSLFS/W14GPzOi9lakVt1PkViESn6aP3BOx+0k cIpA== X-Gm-Message-State: APjAAAUTqOm5qKy7Pv3mf7jOllUqhiiGtGBJAzGtlrFKGODzqUV1Svtj f4zAEyLfdddDQWZ4fpPSLsbOCKOj X-Google-Smtp-Source: APXvYqxsqswn/eYdjAtHzFIit8iFb6U+47R9JTOiLxbuSFN7srqpuuEgJgxNJElWA7+kg/cU5JfVDg== X-Received: by 2002:a17:902:8f81:: with SMTP id z1mr39781355plo.290.1562140544857; Wed, 03 Jul 2019 00:55:44 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:44 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 02/14] powerpc/64s/exception: machine check remove bitrotted comment Date: Wed, 3 Jul 2019 17:54:32 +1000 Message-Id: <20190703075444.19005-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index db7ef8c8566f..e8734a1dfdb9 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -933,10 +933,6 @@ EXC_COMMON_BEGIN(system_reset_common) EXC_REAL_BEGIN(machine_check, 0x200, 0x100) - /* This is moved out of line as it can be patched by FW, but - * some code path might still want to branch into the original - * vector - */ EXCEPTION_PROLOG_0 PACA_EXMC BEGIN_FTR_SECTION b machine_check_common_early From patchwork Wed Jul 3 07:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126678 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 45dtrp24dZz9s00 for ; Wed, 3 Jul 2019 18:03:06 +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.b="oNfu9RAN"; 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 45dtrn6XNCzDqKV for ; Wed, 3 Jul 2019 18:03:05 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="oNfu9RAN"; 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 45dthQ6qhKzDqRN for ; Wed, 3 Jul 2019 17:55:50 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id i189so818438pfg.10 for ; Wed, 03 Jul 2019 00:55:50 -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=JPpgYhewlwO9TqQ03LrhR75ijbMW8NzdnCXiXDw1zFM=; b=oNfu9RANClref1zwoifvawkpD1QUwFyjty5bv0ZhjcSc4ZhldOipgiG8x4HmUAKDfJ Kvk2WrzKTLmZdCtvvGp5Xom6/KRN5M+HtBveAULN1W1dkdFj8XcTYF2Rg6XVdbR8LZwK gyin7y3a42fFHl5XssbKSgZ5YbI0u8KxEFV+FRfTc+iRYj/SP6t+ta/+ue4pTKkKnwe/ Wvpxukz2jUPSZmy+bWfvHd3u4WyLKBX3JOgDHR4POxpZsztk6/5KnVfbceFedB9u1qfc Fo0O7KCoaT5EB68vIgTMN0FF31r51YZXzgTC31nCFlF8lo3oIXQm1CUnN84IW9nfmaC4 vQCw== 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=JPpgYhewlwO9TqQ03LrhR75ijbMW8NzdnCXiXDw1zFM=; b=fyHrNl2kBIJfk3JzsyfzwV6yZxcugEJtyMHy8mmyCF1fch8NN52vVYybLJVYs4VB5Y 23Y6YYTSW80zdElQWXgFcAdqpsj7QPtJeY7/QKUF7KUpRNwYDYKbSdOWQAS5+Q4XsZ3y Fo2Exp2G3TQMGI6xk/sIucIIKCAS1lCriKmVipa00XFnrFQRX4GbfZ+e9Jpwmk7QRbPw jrZYJZT0R6PeFgQr+PgrA2QIsFEX0vJKE/mjpjN3O5aQ7v4FJLonItUUcSi2iQJh4Q/i f2Z323jSQNAuvDsDpYXZjUKKb1Bbis/NGNpgYAUPet5d+kUhekQM4y+po1yBigjfTQm0 8sgQ== X-Gm-Message-State: APjAAAXDWonzBVKic0JZeZgpvhpvKT8DtRfwxFr2pXz7i2t6EBM3tzsg elbhDnQuZojd4DClgKYUpdb4MOeh X-Google-Smtp-Source: APXvYqykorMscgBepd0vmoooiolQR9vmHBQiq4weINk15qvZXoCymL8qaW+VutKrV+cbWuGdyBz7SQ== X-Received: by 2002:a63:788a:: with SMTP id t132mr17944842pgc.332.1562140548164; Wed, 03 Jul 2019 00:55:48 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:47 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 03/14] powerpc/64s/exception: machine check fix KVM guest test Date: Wed, 3 Jul 2019 17:54:33 +1000 Message-Id: <20190703075444.19005-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The machine_check_handle_early hypervisor guest test is skipped if !HVMODE or MSR[HV]=0, which is wrong for PR or nested hypervisors that could be running a guest in this state. Test HSTATE_IN_GUEST up front and use that to branch out to the KVM handler, then MSR[PR] alone can test for this kernel's userspace. This matches all other interrupt handling. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 33 +++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index e8734a1dfdb9..5789a00691f9 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1108,11 +1108,8 @@ EXC_COMMON_BEGIN(machine_check_handle_early) bl machine_check_early std r3,RESULT(r1) /* Save result */ ld r12,_MSR(r1) -BEGIN_FTR_SECTION - b 4f -END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE) -#ifdef CONFIG_PPC_P7_NAP +#ifdef CONFIG_PPC_P7_NAP /* * Check if thread was in power saving mode. We come here when any * of the following is true: @@ -1128,30 +1125,26 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) #endif - /* - * Check if we are coming from hypervisor userspace. If yes then we - * continue in host kernel in V mode to deliver the MC event. - */ - rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */ - beq 5f -4: andi. r11,r12,MSR_PR /* See if coming from user. */ - bne 9f /* continue in V mode if we are. */ - -5: #ifdef CONFIG_KVM_BOOK3S_64_HANDLER -BEGIN_FTR_SECTION /* - * We are coming from kernel context. Check if we are coming from - * guest. if yes, then we can continue. We will fall through - * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest. + * Check if we are coming from guest. If yes, then run the normal + * exception handler which will take the do_kvm_200->kvmppc_interrupt + * branch to deliver the MC event to guest. */ lbz r11,HSTATE_IN_GUEST(r13) cmpwi r11,0 /* Check if coming from guest */ bne 9f /* continue if we are. */ -END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) #endif + + /* + * Check if we are coming from userspace. If yes, then run the normal + * exception handler which will deliver the MC event to this kernel. + */ + andi. r11,r12,MSR_PR /* See if coming from user. */ + bne 9f /* continue in V mode if we are. */ + /* - * At this point we are not sure about what context we come from. + * At this point we are coming from kernel context. * Queue up the MCE event and return from the interrupt. * But before that, check if this is an un-recoverable exception. * If yes, then stay on emergency stack and panic. From patchwork Wed Jul 3 07:54:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126679 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 45dttf6SKbz9s00 for ; Wed, 3 Jul 2019 18:04:42 +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.b="XFhzwfrJ"; 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 45dttf4l2bzDqLP for ; Wed, 3 Jul 2019 18:04:42 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="XFhzwfrJ"; 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 45dthT6mzWzDqQd for ; Wed, 3 Jul 2019 17:55:53 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id p184so824940pfp.7 for ; Wed, 03 Jul 2019 00:55:53 -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=GObua8H54fup3mM+gXxoZ439qwDeiSqF74A3rMTO8s0=; b=XFhzwfrJGpek7ei17Q4kW1Nx8rabPjrwaPP369ghMSjgEuYU2lOJCmJxuHmhc/ClQk HxS9voTUAtmoph36YyCE9NRYps+4hKNvGaP8cxKIqp2NLhLtnKt8cSjnwkx7Bc4qodLo ZeQ5Abj5TN2vmi/6mWplHtZCbL3N/BYpLN5XE5+KYA4xdZ0sNgcmYxLWxAVCM0v9F9k/ wsh9fvUWGSBYZLMCbvpEUbUi6WVGBwDSjHXxWJ46erS0xtEwIC2uqQVoO/xl2+mv99iC FTZrlmcROD+NQx45Gt4DWtGWIWeKFrsPRJdvXQx7zQVCZJEOgxA/ZD/TxSo+k7DZIeEV AsPg== 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=GObua8H54fup3mM+gXxoZ439qwDeiSqF74A3rMTO8s0=; b=EqkGmncPbewumLjLjvO9IaXmLNZcwNqYsHZKMk1MtkEVtUjiXICuLszYjXaXQlnabS tjUICTc6jjt9Jdk5w4gVtmNxIaUqniR7euqH7D6Cxc2kljrzQi3wFffzRXvwcgRQ+n3L Uucdz5gx+YZPuGufFJ27Q/6EmLkRrZFcKMZWsu6bsMCvMHQeifIE4Uo+16e3gABdNAxG UvdFIBXVRvFcX680fieVdgI6CI7VMIsq/Gm2jb49dbeMKwND2F7Q5Rvx5e+TDyWmSJRN 20inl0LTb8rA0di3m7OXDrFfCtdJvHwxUEiKyDR6zSeyca/jAj3+t+/kki7MzDKpSy9H qyWA== X-Gm-Message-State: APjAAAXtEQvkQWQKeCQ835MJOxw9Hk/AUQxf42wSCrDmdq1CSyTo0aH0 DTAQTCoy0BO7xItyfQ5109MjtMs1 X-Google-Smtp-Source: APXvYqyfndHQxwaJhrbm2FTEpj+KD6OVTSAjcsOa24pmO8k4OC3mB1M3zhX+ROf4gEK/nzeKRtjpYw== X-Received: by 2002:a65:640d:: with SMTP id a13mr26203662pgv.256.1562140550813; Wed, 03 Jul 2019 00:55:50 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:50 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 04/14] powerpc/64s/exception: machine check adjust RFI target Date: Wed, 3 Jul 2019 17:54:34 +1000 Message-Id: <20190703075444.19005-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The host kernel delivery case for powernv does RFI_TO_USER_OR_KERNEL, but should just use RFI_TO_KERNEL which makes it clear this is not a user case. This is not a bug because RFI_TO_USER_OR_KERNEL deals with kernel returns just fine. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 5789a00691f9..0186a44bb981 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1184,7 +1184,7 @@ BEGIN_FTR_SECTION */ bl machine_check_queue_event MACHINE_CHECK_HANDLER_WINDUP - RFI_TO_USER_OR_KERNEL + RFI_TO_KERNEL FTR_SECTION_ELSE /* * pSeries: Return from MC interrupt. Before that stay on emergency From patchwork Wed Jul 3 07:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126680 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 45dtwl2ymBz9s00 for ; Wed, 3 Jul 2019 18:06: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.b="XsqxA+Ax"; 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 45dtwl2338zDqKV for ; Wed, 3 Jul 2019 18:06: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 (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.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.b="XsqxA+Ax"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 45dthW5hD2zDqRZ for ; Wed, 3 Jul 2019 17:55:55 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id i8so769377pgm.13 for ; Wed, 03 Jul 2019 00:55:55 -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=p+jjIAIMslx172lTxJVoXHhGXL+fIcfc+rKiQb14IpE=; b=XsqxA+AxSxb+gc3v9rxi1g3CAeFEyFmfavtaw1oZ1PrDsfqUM5squDr6THXvD0SgrR 4k6ujXrbz3g0TVDAe37VwM10dAKCPbozvBxiRxT14yxQm1jm4b6p+d/3eziKX/AmCJJ4 lN3Ag+Kyk7+vUVVwMeYnA031yTE1WjOFU7Q8bHFFhu8007TM6umq3O9LJyl8WBGXkV0L xm/IS08k/IXIdBLr6xIVgfpNb6YL96hA2GCcVPdP5vzJ3LQh+fN44aLt/B57tZKqwU8M VOCFSquyG668Ouspr8jReZEYi2h/ACIxU9VefXfOEfkKchpsVCt3kt/WsrbkkqSoawJz p4Fw== 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=p+jjIAIMslx172lTxJVoXHhGXL+fIcfc+rKiQb14IpE=; b=tT7S8OWu0tsEC0kK++Bom7H8mkKub5Kkzp6FYcI5fdibP6wtdJm+S9LT2hLy7AQ6h7 OaBQJdn5MVAbtgrwRV3DFhw6iGJWw/5znq3IkgF6JHY828I4U9zsGIZ3u8X3J9qlvJIA HlcHMHoGQ/Pi/uClrPXDYTadpzjU3wY6MFP3xt7MvEnk4Ue/PNvi7b6Fd4m7lx1sZ6oX g7hAWK+sfQGquVghgaMTZS8p4Ceha+JF3YWQRp6OQ2CBXDTKTHmGCAoUWBoz3fwMGgw5 cv0yY1vWo/LPqhh+KDEGJUf3PenNQGnn6F/N33EkHSnblPjuzBveOP/8/1ct9Dme9E3P GyUw== X-Gm-Message-State: APjAAAVezqU/pZ5t7yvHFZK5iz6ABwAzEPLjHSm9YDG+jpTT2pJUID6L hB1OWyok4op3PuMBU+XSRiU1eDzJ X-Google-Smtp-Source: APXvYqwAFMSzKzGb2l6VySMBkSqmSHu6QCZ+KgQZAjFHt7adkoO7NUZYO5WG2vN/OBUmwgfTKwiVyA== X-Received: by 2002:a17:90a:2506:: with SMTP id j6mr11381803pje.129.1562140553529; Wed, 03 Jul 2019 00:55:53 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:53 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 05/14] powerpc/64s/exception: machine check pseries should always run the early handler Date: Wed, 3 Jul 2019 17:54:35 +1000 Message-Id: <20190703075444.19005-6-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Now that pseries with fwnmi registered runs the early machine check handler, there is no good reason to special case the non-fwnmi case and skip the early handler. Reducing the code and number of paths is a top priority for asm code, it's better to handle this in C where possible (and the pseries early handler is a no-op if fwnmi is not registered). Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 0186a44bb981..a69ceb28cf4c 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -934,11 +934,7 @@ EXC_COMMON_BEGIN(system_reset_common) EXC_REAL_BEGIN(machine_check, 0x200, 0x100) EXCEPTION_PROLOG_0 PACA_EXMC -BEGIN_FTR_SECTION b machine_check_common_early -FTR_SECTION_ELSE - b machine_check_pSeries_0 -ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) EXC_REAL_END(machine_check, 0x200, 0x100) EXC_VIRT_NONE(0x4200, 0x100) TRAMP_REAL_BEGIN(machine_check_common_early) From patchwork Wed Jul 3 07:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126681 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 45dtyh39Twz9s00 for ; Wed, 3 Jul 2019 18:08:12 +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.b="oTY04i6I"; 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 45dtyh15gQzDqSZ for ; Wed, 3 Jul 2019 18:08:12 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::436; helo=mail-pf1-x436.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.b="oTY04i6I"; dkim-atps=neutral Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) (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 45dthb23H8zDqQQ for ; Wed, 3 Jul 2019 17:55:59 +1000 (AEST) Received: by mail-pf1-x436.google.com with SMTP id y15so830063pfn.5 for ; Wed, 03 Jul 2019 00:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q5nzEZzoD8r4bBmmvSx3fN5G38mG8QhyHILVVojissE=; b=oTY04i6ItiXYlzkQsyT+mPp/DaCiDiU7HfnXHY5AQRk+nVIQ2d3EpBq8KRsNN+fDma rbcXXB75VFM6D7Zzih70hacFAQvNJ9BvPfZXCz79yqdzFI9qxWNj48oKXfx87C0hysQN Eo8IfNxpk6HDFWFgpiHZsIBChjtPQP9x+tDUZ5KuYm5l1+5UZvZ5MYWMabGp7a5GTMJC yGpRZQRUSN68ZIDaTykI6vfZl0stbNY8g0f5p3BgxUDqSXkhF3W7zkoOfrGjAfviha4j sxKEbZRTPnv5FifBG1ImbEU01ettgCcbzU02hJl9Bb+8IOwctnoXQmZSKeVdwetdIbC5 PEhg== 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=Q5nzEZzoD8r4bBmmvSx3fN5G38mG8QhyHILVVojissE=; b=beGP3dBjpNQadfePtDEiMRZrBru3hYLbZ0arCg8M1/yluqCTyEhq0GnX3DP7EJQFlj 1gzGbr+4EOiCnIhx9NwyjMnUVkssM3oVkj05fbMmItI8EUHhcuxpkG1O0J//xOV8Jcdf OYfU3VPdDJPFJr06nzdfoi73ZhVV68EfDxt/4K2GEvvuZZyRkb9iQ1aAVw9ibfxAXbGX cmsOeECEQ/Q2AU9s068vr2t/J58k89HgR96k8/6s2n2Dbjwr86wzHATFGSex9I4b0pbu cjjpKYxYTrC4nz2nXLPRmZe2Fw+fig0ByQeBX6/NwxqGUOr6H0Tqrl17KVp1iV5ixUWr UECA== X-Gm-Message-State: APjAAAUwOvIvKE3BGKeKioHIy/zSZbUOdMSE+F35w3aKDBwjSHgyCKnM YgVFvEmECXmyJt5baV44sBE+IqeN X-Google-Smtp-Source: APXvYqxJFAOJlR55il4Itt1GDshtFCSEr57MGBBEvlMHi6Hdr8eNK5b12YVqc3kwGpuemTm8dV734g== X-Received: by 2002:a65:538d:: with SMTP id x13mr35825390pgq.190.1562140556152; Wed, 03 Jul 2019 00:55:56 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:55 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 06/14] powerpc/64s/exception: machine check remove machine_check_pSeries_0 branch Date: Wed, 3 Jul 2019 17:54:36 +1000 Message-Id: <20190703075444.19005-7-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This label has only one caller, so unwind the branch and move it inline. The location of the comment is adjusted to match similar one in system reset. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index a69ceb28cf4c..54ca2b189d43 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1014,20 +1014,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) b 1b b . /* prevent speculative execution */ -TRAMP_REAL_BEGIN(machine_check_pSeries) - .globl machine_check_fwnmi -machine_check_fwnmi: +#ifdef CONFIG_PPC_PSERIES +TRAMP_REAL_BEGIN(machine_check_fwnmi) EXCEPTION_PROLOG_0 PACA_EXMC b machine_check_common_early - -machine_check_pSeries_0: - EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 - /* - * MSR_RI is not enabled, because PACA_EXMC is being used, so a - * nested machine check corrupts it. machine_check_common enables - * MSR_RI. - */ - EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0 +#endif TRAMP_KVM_SKIP(PACA_EXMC, 0x200) @@ -1197,7 +1188,13 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) /* Deliver the machine check to host kernel in V mode. */ MACHINE_CHECK_HANDLER_WINDUP EXCEPTION_PROLOG_0 PACA_EXMC - b machine_check_pSeries_0 + EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 + EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0 + /* + * MSR_RI is not enabled, because PACA_EXMC is being used, so a + * nested machine check corrupts it. machine_check_common enables + * MSR_RI. + */ EXC_COMMON_BEGIN(unrecover_mce) /* Invoke machine_check_exception to print MCE event and panic. */ From patchwork Wed Jul 3 07:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126682 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 45dv0Z3nv5z9s00 for ; Wed, 3 Jul 2019 18:09:50 +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.b="e6pFMRAq"; 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 45dv0Z2pBwzDqKH for ; Wed, 3 Jul 2019 18:09:50 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="e6pFMRAq"; 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 45dthd43PqzDqQM for ; Wed, 3 Jul 2019 17:56:01 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id g15so791131pgi.4 for ; Wed, 03 Jul 2019 00:56:01 -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=AQeLG+f8ET5u/YrOrVFZ7LJHLtCq+lw80ktcqY0BsDk=; b=e6pFMRAqhwRNP+xb9vBuTcT5OSI+39Me71VWsPUbIBsANWBak1SAFMk3syiSK9ieR4 MFe0OZ61E6qHX2jOnsKNL6Pig/IAqZ/Bb1PavWFBd56idZu1qb/YfIp/6hKFmYSD53Rc 0izMWRmEYtEcnwloRfrT7DgZjKlGfrvYHidiIEKcqxMAGU0n5ojHwg7aiMvo7YU3CheT yHPD40sEfYa0rluRUG4BOheu2LRKMdVJDP09Hz4G5y1jNkR2dtKgL6CJv50SUT4ApGxB mYND9pd1TM42yRabX4BAZpfwW5p9xOHHdKQdMbBzHawocmlk6gmPV+KNkVseIMny1g8H MWRg== 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=AQeLG+f8ET5u/YrOrVFZ7LJHLtCq+lw80ktcqY0BsDk=; b=qAIO2RRC/6LmQVaSTAIsuQhl4XXPM29ZRsDS2a13A1pfVzKSteYRTPCmnxxgsoKhV1 SvP7MOa7xxNrTcUl0QpM8RoRVNCGUcXM8PjHlVPZrmwFhAKsEEeCYJPqBf5IJT902pew JNjQE4GmLANiOHtAj7bjLjBNICxGXX6omBYutYKwlA2qZLtvGDajk0PvNJZLLRQOwY3j /ip6Guf2cbyDJtykB0SpS+5CJN3AQe2EGR1+ozXZgHLztHh4QOArUXNe+GYYMYGzPaCM cTYOfFNPF/w6JnYahaOf7us+4R9pUc0SrVHtzNsePP9Yze2VJUBNiI+wW5IsBWdFo0hs 4AiA== X-Gm-Message-State: APjAAAXo5hztKG2DAzszwIYKCiuWGFvO/KwNgLhH/dJafKd0fA8JRiQ+ DCqfkyUU1yL9ZA7DWbgg58D7BiNt X-Google-Smtp-Source: APXvYqxtA93wFsFyk8bdISKzUHDQYZcKK645drshjvVaGpLTys3ee9U/T+IHE3wZvhUs2gy0/iz6nA== X-Received: by 2002:a17:90a:1c1:: with SMTP id 1mr11162599pjd.72.1562140559065; Wed, 03 Jul 2019 00:55:59 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:55:58 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 07/14] powerpc/64s/exception: machine check use correct cfar for late handler Date: Wed, 3 Jul 2019 17:54:37 +1000 Message-Id: <20190703075444.19005-8-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Bare metal machine checks run an "early" handler in real mode before running the main handler which reports the event. The main handler runs exactly as a normal interrupt handler, after the "windup" which sets registers back as they were at interrupt entry. CFAR does not get restored by the windup code, so that will be wrong when the handler is run. Restore the CFAR to the saved value before running the late handler. 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 54ca2b189d43..f2c24a4ae723 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1186,6 +1186,10 @@ FTR_SECTION_ELSE ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) 9: /* Deliver the machine check to host kernel in V mode. */ +BEGIN_FTR_SECTION + ld r10,ORIG_GPR3(r1) + mtspr SPRN_CFAR,r10 +END_FTR_SECTION_IFSET(CPU_FTR_CFAR) MACHINE_CHECK_HANDLER_WINDUP EXCEPTION_PROLOG_0 PACA_EXMC EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 From patchwork Wed Jul 3 07:54:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126683 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 45dv3H0wqDz9s3Z for ; Wed, 3 Jul 2019 18:12: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.b="AuQAhq9y"; 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 45dv3H04QTzDqJM for ; Wed, 3 Jul 2019 18:12: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 (mailfrom) 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.b="AuQAhq9y"; 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 45dthh2sT3zDqQd for ; Wed, 3 Jul 2019 17:56:04 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id 81so811253pfy.13 for ; Wed, 03 Jul 2019 00:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QAqLvOiIWa2iF2XzugUdl7vcFvizV1HF8RoF45ufhkQ=; b=AuQAhq9yoaJY1iCG+ToFqmZ6KNIckjajtB26sN6wz6RzfLh/nnXjZ8HXBdmLNfxrLN eENcMy1XowWc/y0JhjloxTHm+m2jnyzPVRJlu3InfP6VkdxLxY+5J70AR8mmhbem0GL1 PfedACtzcGmDq01yQGiLrdk+comaaHLnSR384Q5tHinKOapI4vXbvVO5ujetrq3/Jxsj 4DJ/HqTONxzMGI9kMBDd0staG15joF3BF5Cty8ZEJFGVSP+gRiXX3TJC1qJ3We0jN+ks PNQjEhBaX/Ogj0PLOuGHYhqWLFS+beZ/1HgwcPVaK9TD1Oq+Rl8Re7s/duduM1+xVdv8 2kNQ== 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=QAqLvOiIWa2iF2XzugUdl7vcFvizV1HF8RoF45ufhkQ=; b=dufTqLxtMj54NCz06ra5Qz4JOSyq0qTQqO7F79ZtnzRrHdIbW6AgyaYYHrPZF/80S9 cvfuYN6uFq0AG5Utr7P504ZEuLq3mrlSmtUk7VK2FbiN1TmR8Urm7LPHkHHzg+krcVQX gGUrwc4ow4DtxpH63+u1FOmv552hwbjSbuMlOyEDwFe7dJIL7CZd5DF0oqY29PBwVSq7 2MQCpVA5E/szqi3nNfKI/P1iOt7g0PawmD+ptTGNAzCIaKCv0vNjz/nXBwbN1eQqppHQ sUqjEoHWdX5eKsnt7pwsUQcKKgSTH7b/FGNyewFn3shmUjP34TB7tKR/BcfLVU0Z5s4M gaFw== X-Gm-Message-State: APjAAAXf8G6qtUu9L5bWoMf84H2VEBAt29l4ORw+Zaq4L8LF0QYVw4jF 5ve8ch7nqQEySq/S7yhcAAB082iY X-Google-Smtp-Source: APXvYqykfTX8TEhvpmIx1sBbyH13sogAga6GJNJaeINYLKjgtGYJt1N0W+d+dnmgTUe3QQJ1XYcjdQ== X-Received: by 2002:a17:90a:3590:: with SMTP id r16mr11195517pjb.44.1562140561749; Wed, 03 Jul 2019 00:56:01 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.55.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:01 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 08/14] powerpc/64s/exception: machine check pseries should skip the late handler for host kernel MCEs Date: Wed, 3 Jul 2019 17:54:38 +1000 Message-Id: <20190703075444.19005-9-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The powernv machine check handler copes with taking a MCE from one of three contexts, guest, host kernel, and host user. In each case the early handler runs first on a special stack. Then: - The guest case branches to the KVM interrupt handler (via standard interrupt macros). - The host user case will run the "late" handler which is like a normal interrupt that runs in virtual mode and uses the regular kernel stack. - The host kernel case queues the event and schedules it for processing with irq work. The last case is important, it must not enable virtual memory because the MMU state may not be set up to deal with that (e.g., SLB might be clear), it must not use the regular kernel stack for similar reasons (e.g., might be in OPAL with OPAL stack in r1), and the kernel does not expect anything to touch its stack if interrupts are disabled. The pseries handler does not do this queueing, but instead it always runs the late handler for host MCEs, which has some of the same problems. Rather than special casing pseries, just have it follow what powernv is doing and queue up these events. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index f2c24a4ae723..ac7b5bb614d9 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1163,7 +1163,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) cmpdi r3,0 /* see if we handled MCE successfully */ beq 1b /* if !handled then panic */ -BEGIN_FTR_SECTION + /* * Return from MC interrupt. * Queue up the MCE event so that we can log it later, while @@ -1172,18 +1172,7 @@ BEGIN_FTR_SECTION bl machine_check_queue_event MACHINE_CHECK_HANDLER_WINDUP RFI_TO_KERNEL -FTR_SECTION_ELSE - /* - * pSeries: Return from MC interrupt. Before that stay on emergency - * stack and call machine_check_exception to log the MCE event. - */ - LOAD_HANDLER(r10,mce_return) - mtspr SPRN_SRR0,r10 - ld r10,PACAKMSR(r13) - mtspr SPRN_SRR1,r10 - RFI_TO_KERNEL - b . -ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) + 9: /* Deliver the machine check to host kernel in V mode. */ BEGIN_FTR_SECTION @@ -1212,13 +1201,6 @@ EXC_COMMON_BEGIN(unrecover_mce) bl unrecoverable_exception b 1b -EXC_COMMON_BEGIN(mce_return) - /* Invoke machine_check_exception to print MCE event and return. */ - addi r3,r1,STACK_FRAME_OVERHEAD - bl machine_check_exception - MACHINE_CHECK_HANDLER_WINDUP - RFI_TO_KERNEL - b . EXC_REAL_BEGIN(data_access, 0x300, 0x80) EXCEPTION_PROLOG_0 PACA_EXGEN From patchwork Wed Jul 3 07:54:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126684 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 45dv5N08CNz9s3Z for ; Wed, 3 Jul 2019 18:14:00 +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.b="K0iFDuGy"; 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 45dv5M2G0TzDqHw for ; Wed, 3 Jul 2019 18:13:59 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.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.b="K0iFDuGy"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 45dthk4q8BzDqQV for ; Wed, 3 Jul 2019 17:56:06 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id c13so796004pgg.3 for ; Wed, 03 Jul 2019 00:56: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=PCs8eSgWybCHSB1nMZu06bU5YDzW3YpvI3lD71aJLwU=; b=K0iFDuGykkeIs8FseVDUqATgwzphxGFqMyhBuxCkG/OEt/0bk15or3kJqEvL8DjLAt 2D9l6z5fDYSNIsCl81dHfF9zmekcY5xpm4NmSeAbj7xf6WsfJg6Mpq8ROVaivu63Hgfg MwBvVbeVsQNKGtnjTsqJhX55q4+ccb8RM5rzE+Zcin8Ab+Vi7zaeSW+YUdDe+RCJqIdV TjemsZjrBGh6bDwnyy/XH+M7zmdvYk7uO/iWr60yuQxAKIGm9PNor/zGpLalzBPN4a9Z WC9LopB5irMqvRXutwz7PDCCBoHV+nIH3HLUivNAQzN4KQJF0+xM2O2ozLiN9D0oG4QO fJfA== 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=PCs8eSgWybCHSB1nMZu06bU5YDzW3YpvI3lD71aJLwU=; b=gO404BCq+NWuX4J3sYNmbgDG9dd9qv56HusgzYZq8jH6yqjsLsRZZlWrk92l9wGZbp zNe/UVk++aZljOVjJ0gUr2acyQNfD9mxiLCaKMFj65MQoI0FPh2ri12T1F7OGqvwNkc1 wBZqKt7gaMp4Wuax9YfUCiQ5Bt1pNFslpDWde2qF7U/2b+ordvsskJ0qISzfCD9uRlqG y2xa3iQ26A0P5rGRtDIndAn6ii3vBIfQ2GA5wxJMJzVhmZ4oOU3kuNtjyYPVf0maHilY lb256hEWcWYxiDfdhiPw4Z9XZqD5NTByrd6VuXGG1UA0iKecTGuxBnSMyet+Abyweegc Dz2A== X-Gm-Message-State: APjAAAXAYAm4ns0ZnCRvAXA2sQ3DYH00ZnuOf+LumomWA0jOCFxRDixY 6WuE3+4cdgNaZqypH7U2gUesvGdA X-Google-Smtp-Source: APXvYqyR4KQodI+aoRFBFvk9HoZeLQwkHAlvTAtOBqDMcr4t3qfHgYPcWqOpoVJfeb3bwkw1B4VwBQ== X-Received: by 2002:a65:4348:: with SMTP id k8mr36371699pgq.219.1562140564397; Wed, 03 Jul 2019 00:56:04 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:03 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 09/14] powerpc/64s/exception: machine check restructure to reuse common macros Date: Wed, 3 Jul 2019 17:54:39 +1000 Message-Id: <20190703075444.19005-10-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Follow the pattern of sreset and HMI handlers more closely: use EXCEPTION_PROLOG_COMMON_1 rather than open-coding it, and run the handler at the relocated location. This helps later simplification and code sharing. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 71 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index ac7b5bb614d9..3cc5ee6e4b56 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -934,17 +934,23 @@ EXC_COMMON_BEGIN(system_reset_common) EXC_REAL_BEGIN(machine_check, 0x200, 0x100) EXCEPTION_PROLOG_0 PACA_EXMC - b machine_check_common_early + EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0 + mfctr r10 /* save ctr, even for !RELOCATABLE */ + BRANCH_TO_C000(r11, machine_check_early_common) + /* + * MSR_RI is not enabled, because PACA_EXMC is being used, so a + * nested machine check corrupts it. machine_check_common enables + * MSR_RI. + */ EXC_REAL_END(machine_check, 0x200, 0x100) EXC_VIRT_NONE(0x4200, 0x100) -TRAMP_REAL_BEGIN(machine_check_common_early) - EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 0, 0, 0 + +EXC_COMMON_BEGIN(machine_check_early_common) + mtctr r10 /* Restore ctr */ + mfspr r11,SPRN_SRR0 + mfspr r12,SPRN_SRR1 + /* - * Register contents: - * R13 = PACA - * R9 = CR - * Original R9 to R13 is saved on PACA_EXMC - * * Switch to mc_emergency stack and handle re-entrancy (we limit * the nested MCE upto level 4 to avoid stack overflow). * Save MCE registers srr1, srr0, dar and dsisr and then set ME=1 @@ -965,32 +971,30 @@ TRAMP_REAL_BEGIN(machine_check_common_early) * the machine check is handled then the idle wakeup code is called * to restore state. */ - mr r11,r1 /* Save r1 */ lhz r10,PACA_IN_MCE(r13) cmpwi r10,0 /* Are we in nested machine check */ - bne 0f /* Yes, we are. */ - /* First machine check entry */ - ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */ -0: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ + cmpwi cr1,r10,MAX_MCE_DEPTH /* Are we at maximum nesting */ addi r10,r10,1 /* increment paca->in_mce */ sth r10,PACA_IN_MCE(r13) + + mr r10,r1 /* Save r1 */ + bne 1f + /* First machine check entry */ + ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */ +1: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ /* Limit nested MCE to level 4 to avoid stack overflow */ - cmpwi r10,MAX_MCE_DEPTH - bgt 2f /* Check if we hit limit of 4 */ - std r11,GPR1(r1) /* Save r1 on the stack. */ - std r11,0(r1) /* make stack chain pointer */ - mfspr r11,SPRN_SRR0 /* Save SRR0 */ - std r11,_NIP(r1) - mfspr r11,SPRN_SRR1 /* Save SRR1 */ - std r11,_MSR(r1) - mfspr r11,SPRN_DAR /* Save DAR */ - std r11,_DAR(r1) - mfspr r11,SPRN_DSISR /* Save DSISR */ - std r11,_DSISR(r1) - std r9,_CCR(r1) /* Save CR in stackframe */ + bge cr1,2f /* Check if we hit limit of 4 */ + + EXCEPTION_PROLOG_COMMON_1() /* We don't touch AMR here, we never go to virtual mode */ - /* Save r9 through r13 from EXMC save area to stack frame. */ EXCEPTION_PROLOG_COMMON_2(PACA_EXMC) + EXCEPTION_PROLOG_COMMON_3(0x200) + + ld r3,PACA_EXMC+EX_DAR(r13) + lwz r4,PACA_EXMC+EX_DSISR(r13) + std r3,_DAR(r1) + std r4,_DSISR(r1) + mfmsr r11 /* get MSR value */ BEGIN_FTR_SECTION ori r11,r11,MSR_ME /* turn on ME bit */ @@ -1016,8 +1020,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) #ifdef CONFIG_PPC_PSERIES TRAMP_REAL_BEGIN(machine_check_fwnmi) + /* See comment at machine_check exception, don't turn on RI */ EXCEPTION_PROLOG_0 PACA_EXMC - b machine_check_common_early + EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0 + mfctr r10 /* save ctr */ + BRANCH_TO_C000(r11, machine_check_early_common) #endif TRAMP_KVM_SKIP(PACA_EXMC, 0x200) @@ -1088,8 +1095,6 @@ EXC_COMMON_BEGIN(machine_check_idle_common) * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack. */ EXC_COMMON_BEGIN(machine_check_handle_early) - std r0,GPR0(r1) /* Save r0 */ - EXCEPTION_PROLOG_COMMON_3(0x200) bl save_nvgprs addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_early @@ -1180,14 +1185,10 @@ BEGIN_FTR_SECTION mtspr SPRN_CFAR,r10 END_FTR_SECTION_IFSET(CPU_FTR_CFAR) MACHINE_CHECK_HANDLER_WINDUP + /* See comment at machine_check exception, don't turn on RI */ EXCEPTION_PROLOG_0 PACA_EXMC EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0 - /* - * MSR_RI is not enabled, because PACA_EXMC is being used, so a - * nested machine check corrupts it. machine_check_common enables - * MSR_RI. - */ EXC_COMMON_BEGIN(unrecover_mce) /* Invoke machine_check_exception to print MCE event and panic. */ From patchwork Wed Jul 3 07:54:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126685 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 45dv8l5H4Lz9s3Z for ; Wed, 3 Jul 2019 18:16:55 +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.b="dEGsuLIW"; 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 45dv8l3sYVzDqTQ for ; Wed, 3 Jul 2019 18:16:55 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="dEGsuLIW"; 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 45dthp1bnBzDqQM for ; Wed, 3 Jul 2019 17:56:10 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id i8so769681pgm.13 for ; Wed, 03 Jul 2019 00:56:10 -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=aH9Od/uGcopCsR+aSiuxuN3b+LlKfbwQOdrrN08mV8E=; b=dEGsuLIWDBUb478R2DHVHUdUJV5763bWpth0Njb9Sx18jBNw5SV+li7ZOiKTbzVyvJ zy3AMwIR7lbw4tnOQzwo6sEM3VHF66+P7wCqRptZntjQzt4P7KI3CBgLD3HzKBVdHBUj Cu4lUVViCBozGm18VTtFkEA47XGqcW8TkMfs45zVA7lVEp9Mah+ZXkjMBubtOwRQiG7R Re/nYMsa3oXMlEVCzocHGSChuzUCqw2YOj38irOsoO4GY7w/ylqHNZq5rLsY3+ajpcf0 RIMVB7b8NGs7YkCpBkuQCPoAdiRrWKno23ddZLw7xkp3TJqinw8WKBr9da8l/rpzRtii rKuw== 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=aH9Od/uGcopCsR+aSiuxuN3b+LlKfbwQOdrrN08mV8E=; b=c+BfB034tGZ1gOWLn7K0pujeud9iDO9TzP+VR6b3A2SdxyVKLG+fvYhG8FyTzCf27s QNK4CzWdqHH15BV5Q++vA73up3Tfp4ldQmncX1aI5zDAz4CzvC8juMDpcXd1C8TixAam dxNCv2GSDe5F9KGe9YiaaVTlP9DM8RlHowtKB7aKvjeolMbFmnG+dlfvMC/28bItPwIy GP1eVjbNVLTfk70E8PgFmLIaUKjOIx5ilxI5bjlvZeNpEVhLnmOxFuERLzq7LRgOqscO to5k3LKvFtYv3zL7e58dBdOM+ys7bn1HoXEVkdd9IgdY8nM86VnNvInc53yrncG6iELF sI4g== X-Gm-Message-State: APjAAAUcO2+jTkxKZZY17S8nrLX1akFuoBMTOO9RkaxpRDMwlEu71nlA IbZWJihq6+wvvintYeoJUABwy2u3 X-Google-Smtp-Source: APXvYqx18SknUDBd4QCPDSezvxk7Hc0uzD38MyryD7fRhd2kRsMMn0YyeGQsTjreabNvwl1HbETDRA== X-Received: by 2002:a63:f746:: with SMTP id f6mr35365257pgk.56.1562140567006; Wed, 03 Jul 2019 00:56:07 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:06 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 10/14] powerpc/64s/exception: machine check move tramp code Date: Wed, 3 Jul 2019 17:54:40 +1000 Message-Id: <20190703075444.19005-11-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Following convention, move the tramp code (unrelocated) above the common handlers (relocated). Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 3cc5ee6e4b56..9bb8c89e9e77 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -945,6 +945,17 @@ EXC_REAL_BEGIN(machine_check, 0x200, 0x100) EXC_REAL_END(machine_check, 0x200, 0x100) EXC_VIRT_NONE(0x4200, 0x100) +#ifdef CONFIG_PPC_PSERIES +TRAMP_REAL_BEGIN(machine_check_fwnmi) + /* See comment at machine_check exception, don't turn on RI */ + EXCEPTION_PROLOG_0 PACA_EXMC + EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0 + mfctr r10 /* save ctr */ + BRANCH_TO_C000(r11, machine_check_early_common) +#endif + +TRAMP_KVM_SKIP(PACA_EXMC, 0x200) + EXC_COMMON_BEGIN(machine_check_early_common) mtctr r10 /* Restore ctr */ mfspr r11,SPRN_SRR0 @@ -1018,17 +1029,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) b 1b b . /* prevent speculative execution */ -#ifdef CONFIG_PPC_PSERIES -TRAMP_REAL_BEGIN(machine_check_fwnmi) - /* See comment at machine_check exception, don't turn on RI */ - EXCEPTION_PROLOG_0 PACA_EXMC - EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 0, 0x200, 1, 1, 0 - mfctr r10 /* save ctr */ - BRANCH_TO_C000(r11, machine_check_early_common) -#endif - -TRAMP_KVM_SKIP(PACA_EXMC, 0x200) - EXC_COMMON_BEGIN(machine_check_common) /* * Machine check is different because we use a different From patchwork Wed Jul 3 07:54:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126687 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 45dvC224djz9s3Z for ; Wed, 3 Jul 2019 18:18:54 +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.b="L1kDHBv9"; 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 45dvC16ZDfzDqQf for ; Wed, 3 Jul 2019 18:18:53 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) 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.b="L1kDHBv9"; 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 45dthq5CwDzDqQB for ; Wed, 3 Jul 2019 17:56:11 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id d126so839206pfd.2 for ; Wed, 03 Jul 2019 00:56:11 -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=PhemTXFBg1IxE39/94nLrNA81QUuZG2uBfW/TSvVahM=; b=L1kDHBv9tzvZfDcK6z1n8PkZ2sbzlLKe/wFEt3VdrsDD/lxMRQgfxlMVNEnPZwWKfZ HQtQmlr02qyVVi/vDnZFTdq6SmEkmc0AiUvqj7srhZ9Dlc45KOG4N8zhi6V06npSFflg O20MxBxM4DsIJCHJekQGcKxBcTd1tg8frJd4Kgdk/jWglNrGYfIXuNPSPV03+HhoipNu IG89DAp/FmFafh7qZw8K6KYlMALdASxjZXE8v9tqln7E8Kt4lVTbfVGh2iLIk58TmXo8 V1g7LAwGlY+z9aNjCLhDUYvxnuJVx+JczNVzQnggQDwMh9i6j/mzAE/gjRFUb/HKFZt5 wLpg== 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=PhemTXFBg1IxE39/94nLrNA81QUuZG2uBfW/TSvVahM=; b=qmhdnyuccmb4DR65Oo9nSuWSDBUvp6Pwvt5NI/+DVvxYoaNTIaU2G9ItlcpC2s2zFX 28mhOWNsbKvPoiWrdQVEoavfU/RSeb/L5KpLsIOs0U5zFQMIhQtTtgY9y2Ro+zr1CvLh Ref3bhs/Xm8B3r6RXdnf/ffucqhla6iwZp6puECfxVTEBjQ3Sd9gkXNvu9KK7iGvCcZq ThDUnN0AxmVgmAHNa/LICb98KaS9ds6VVQidk2kLJQjcm3Sr9jtaQDv6SWMdQGXq+b3Q 5uH5Auoqe9E26hGHKSHUuc/qOVeflYrpUMt02k0E8UPcN8/x4wzwwKqeuUpcP0SyHR9v iHhA== X-Gm-Message-State: APjAAAWMJ/s7dJ8Qp8j4uzma6CgRfl3cIxkPJO0e+Y/RvXCtM7B9UAUl 6giUvPQG9DN/tAGZ1YYKrwY8bdd9 X-Google-Smtp-Source: APXvYqysuN+QMR9d3ESYIRFQrRSefIzN66pGaG8i2/YihgQlVEl2nHsNjn7kw4P1DLko9MzIsKD4TQ== X-Received: by 2002:a63:5463:: with SMTP id e35mr11576390pgm.451.1562140569720; Wed, 03 Jul 2019 00:56:09 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:09 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 11/14] powerpc/64s/exception: simplify machine check early path Date: Wed, 3 Jul 2019 17:54:41 +1000 Message-Id: <20190703075444.19005-12-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" machine_check_handle_early_common can reach machine_check_handle_early directly now that it runs at the relocated address, so just branch directly. The rfi sequence is required to enable MSR[ME] but that step is moved into a helper function, making the code easier to follow. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 9bb8c89e9e77..fcc3e6d5807f 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1006,16 +1006,13 @@ EXC_COMMON_BEGIN(machine_check_early_common) std r3,_DAR(r1) std r4,_DSISR(r1) - mfmsr r11 /* get MSR value */ + li r10,MSR_RI + mtmsrd r10,1 BEGIN_FTR_SECTION - ori r11,r11,MSR_ME /* turn on ME bit */ + bl enable_machine_check END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) - ori r11,r11,MSR_RI /* turn on RI bit */ - LOAD_HANDLER(r12, machine_check_handle_early) -1: mtspr SPRN_SRR0,r12 - mtspr SPRN_SRR1,r11 - RFI_TO_KERNEL - b . /* prevent speculative execution */ + b machine_check_handle_early + 2: /* Stack overflow. Stay on emergency stack and panic. * Keep the ME bit off while panic-ing, so that if we hit @@ -1026,7 +1023,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) LOAD_HANDLER(r12, unrecover_mce) li r10,MSR_ME andc r11,r11,r10 /* Turn off MSR_ME */ - b 1b + mtspr SPRN_SRR0,r12 + mtspr SPRN_SRR1,r11 + RFI_TO_KERNEL b . /* prevent speculative execution */ EXC_COMMON_BEGIN(machine_check_common) @@ -2270,6 +2269,19 @@ CLOSE_FIXED_SECTION(virt_trampolines); USE_TEXT_SECTION() +enable_machine_check: + mflr r0 + bcl 20,31,$+4 +0: mflr r3 + addi r3,r3,(1f - 0b) + mtspr SPRN_SRR0,r3 + mfmsr r3 + ori r3,r3,MSR_ME + mtspr SPRN_SRR1,r3 + RFI_TO_KERNEL +1: mtlr r0 + blr + /* * Hash table stuff */ From patchwork Wed Jul 3 07:54:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126688 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 45dvFk0pWKz9s3Z for ; Wed, 3 Jul 2019 18:21:14 +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.b="TF6OCDLX"; 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 45dvFj4h91zDqFh for ; Wed, 3 Jul 2019 18:21:13 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::530; helo=mail-pg1-x530.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.b="TF6OCDLX"; dkim-atps=neutral Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 45dthx1jVFzDqQD for ; Wed, 3 Jul 2019 17:56:17 +1000 (AEST) Received: by mail-pg1-x530.google.com with SMTP id o13so772545pgp.12 for ; Wed, 03 Jul 2019 00:56:17 -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=aJfeZxs8A84mS88gXKSLtBP2zP9JHxYu9Z3nIQ2WYS4=; b=TF6OCDLXI1upcKl6OCpqbgJNUIWhU4o6j7aTtptQnQ0/PGwuEZY9zPUH/LrZ0BUJ7H 39fGKDC8fw0Kp9jwZ5HLhznS8I0iPaWUb+5FD5D/CJTEBUH0kFbvrwS2zQ8r/W9r1z3L 23rximW8Ur8A2jeZyOPBcAyrNux/d/5bJLknzfgeafBWK+DWhz8Nnm6AKiRq7VXHr66X GB6BBJYgqFnS+iZJeUajMm7HiZPhw5hG/IxFudDPlTBh43rWX4iNkr6pCH0p5ga4YMP7 CdmgekwwF+I5gLbdrESYEzHU4sijtZXr0cHXpUUwfKO+x5QaMQ369pY3/e5MuhkRjksv x/7w== 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=aJfeZxs8A84mS88gXKSLtBP2zP9JHxYu9Z3nIQ2WYS4=; b=ahQXVrhoX/an4zOWK5e9CAxjxuAQuoJH5x8/JWRZ/GuWrkVrqFq5sNB+Snnctcxzhc lkUjEYC90ucjHESNe/ltOhgrdNaLd1LkWQW8FHEjnn7MLcUohvBwFuTII0DAdhZGB2Cw azxBg0qJavWPvDytSbhN2WJ8gSVjAR/cbE+/JI8qNSDAzSPJbfdtGL9jj0rV/r3TOhMd 535BK+gXFC18RKFDM761uRb+iS+VXPkk6I5TWmSg4Zq9c1/qGhjKRn9GQO0Ylu6lICUE ea05tFVn5Zm12vqZ9vR9DCdcM/CTa48RvioQsbWsACYRwUxZWG2xegmKziQPDudLE5Zu wAtA== X-Gm-Message-State: APjAAAWYj2peKIQieYNgTcDZ9ipFsFOxKr9U9rL/fwACdxhWleDpIjUh m/2WSTdyk/lZQx+4mKooqdqyOTwB X-Google-Smtp-Source: APXvYqywIQvOmyJP3GlPjIHowncWIgukzNqqrT78WHftlem44TAO5X3ezUgOmSQ20c6D+wDtjZDN5w== X-Received: by 2002:a63:2b0c:: with SMTP id r12mr4825951pgr.206.1562140572596; Wed, 03 Jul 2019 00:56:12 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:12 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 12/14] powerpc/64s/exception: machine check move unrecoverable handling out of line Date: Wed, 3 Jul 2019 17:54:42 +1000 Message-Id: <20190703075444.19005-13-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Similarly to the previous change, all callers of the unrecoverable handler run relocated so can reach it with a direct branch. This makes it easy to move out of line, which makes the "normal" path less cluttered and easier to follow. MSR[ME] manipulation still requires the rfi, so that is moved out of line to its own function. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 82 +++++++++++++--------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index fcc3e6d5807f..88bcdd5b2dc7 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -992,9 +992,9 @@ EXC_COMMON_BEGIN(machine_check_early_common) bne 1f /* First machine check entry */ ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */ -1: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ - /* Limit nested MCE to level 4 to avoid stack overflow */ - bge cr1,2f /* Check if we hit limit of 4 */ +1: /* Limit nested MCE to level 4 to avoid stack overflow */ + bgt cr1,unrecoverable_mce /* Check if we hit limit of 4 */ + subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */ EXCEPTION_PROLOG_COMMON_1() /* We don't touch AMR here, we never go to virtual mode */ @@ -1013,21 +1013,6 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) b machine_check_handle_early -2: - /* Stack overflow. Stay on emergency stack and panic. - * Keep the ME bit off while panic-ing, so that if we hit - * another machine check we checkstop. - */ - addi r1,r1,INT_FRAME_SIZE /* go back to previous stack frame */ - ld r11,PACAKMSR(r13) - LOAD_HANDLER(r12, unrecover_mce) - li r10,MSR_ME - andc r11,r11,r10 /* Turn off MSR_ME */ - mtspr SPRN_SRR0,r12 - mtspr SPRN_SRR1,r11 - RFI_TO_KERNEL - b . /* prevent speculative execution */ - EXC_COMMON_BEGIN(machine_check_common) /* * Machine check is different because we use a different @@ -1141,32 +1126,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) * If yes, then stay on emergency stack and panic. */ andi. r11,r12,MSR_RI - bne 2f -1: mfspr r11,SPRN_SRR0 - LOAD_HANDLER(r10,unrecover_mce) - mtspr SPRN_SRR0,r10 - ld r10,PACAKMSR(r13) - /* - * We are going down. But there are chances that we might get hit by - * another MCE during panic path and we may run into unstable state - * with no way out. Hence, turn ME bit off while going down, so that - * when another MCE is hit during panic path, system will checkstop - * and hypervisor will get restarted cleanly by SP. - */ - li r3,MSR_ME - andc r10,r10,r3 /* Turn off MSR_ME */ - mtspr SPRN_SRR1,r10 - RFI_TO_KERNEL - b . -2: + beq unrecoverable_mce + /* * Check if we have successfully handled/recovered from error, if not * then stay on emergency stack and panic. */ ld r3,RESULT(r1) /* Load result */ cmpdi r3,0 /* see if we handled MCE successfully */ - - beq 1b /* if !handled then panic */ + beq unrecoverable_mce /* if !handled then panic */ /* * Return from MC interrupt. @@ -1189,17 +1157,31 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0 -EXC_COMMON_BEGIN(unrecover_mce) +EXC_COMMON_BEGIN(unrecoverable_mce) + /* + * We are going down. But there are chances that we might get hit by + * another MCE during panic path and we may run into unstable state + * with no way out. Hence, turn ME bit off while going down, so that + * when another MCE is hit during panic path, system will checkstop + * and hypervisor will get restarted cleanly by SP. + */ + bl disable_machine_check + ld r10,PACAKMSR(r13) + li r3,MSR_ME + andc r10,r10,r3 + mtmsrd r10 + /* Invoke machine_check_exception to print MCE event and panic. */ addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_exception + /* - * We will not reach here. Even if we did, there is no way out. Call - * unrecoverable_exception and die. + * We will not reach here. Even if we did, there is no way out. + * Call unrecoverable_exception and die. */ -1: addi r3,r1,STACK_FRAME_OVERHEAD + addi r3,r1,STACK_FRAME_OVERHEAD bl unrecoverable_exception - b 1b + b . EXC_REAL_BEGIN(data_access, 0x300, 0x80) @@ -2282,6 +2264,20 @@ enable_machine_check: 1: mtlr r0 blr +disable_machine_check: + mflr r0 + bcl 20,31,$+4 +0: mflr r3 + addi r3,r3,(1f - 0b) + mtspr SPRN_SRR0,r3 + mfmsr r3 + li r4,MSR_ME + andc r3,r3,r4 + mtspr SPRN_SRR1,r3 + RFI_TO_KERNEL +1: mtlr r0 + blr + /* * Hash table stuff */ From patchwork Wed Jul 3 07:54:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126690 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 45dvHt3T4pz9s3Z for ; Wed, 3 Jul 2019 18:23:06 +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.b="mG8twAdK"; 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 45dvHs2mx1zDqJk for ; Wed, 3 Jul 2019 18:23:05 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::52a; helo=mail-pg1-x52a.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.b="mG8twAdK"; dkim-atps=neutral Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 45dthx62W9zDqQD for ; Wed, 3 Jul 2019 17:56:17 +1000 (AEST) Received: by mail-pg1-x52a.google.com with SMTP id i18so776204pgl.11 for ; Wed, 03 Jul 2019 00:56:17 -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=VVVGiYS5Q6FkipZNNA8ELLJ87Qz7BjpommTr3hGQEy8=; b=mG8twAdKPruUulT9bmwkSif3ttwArwpO0mSHyOKFw533QDQoaZCx+wOIGBolyl7aRn xg/ccKtgHf6woMnbvCcXX0qBid5Ah/C1lgUAMXcLsWoCqrI5CdFdoZOoVea/T66E4xjU V/0T1Tv/IOWNexQIClXC3lU+wd44f2ytklkn0VdPYU/GG9Y7z9QzMkEdedva2XZxRpeX fqDafTp8BrYqYJAwDd2+o4vtAy8Bo55tW6V3l5NFRbrZlqG2dYlGeRq8+LzHky56+M5s J90n8aZeGN2MIoE2+c9iEdQvrnJveZoEwk4BDE4v/RrPBi5cYa4L24JFni9byQDZw21a aNcQ== 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=VVVGiYS5Q6FkipZNNA8ELLJ87Qz7BjpommTr3hGQEy8=; b=lIEICQiDLTInu5DjEpXEtLwpXzpbUpoSdAA6jCASOtACULF6SbwV//jWLAsGOnUZaN 5LYQJA8wuE9Md7GXldGPEw6tRUBMMiyqE+o7347tQh8AOYayDlF6htTmQDum9lPqA9UU nyvPcEGejlOrihPddnK0f1f0DIej+WWIJJJv/kgp8yEhKshgIDtgrDntfe0lahDlvgg/ e3KFLwzxmhvmLL9jwRYnaE+ajY4Q2A9Z7YHSOEPwvs6Ffn7L+pG0b6h2tUIxnD5zog4a V6lks5m/4eugxbBBY3y90K0pCDiz8H6TXrweoLamuX4NZn+1Gxw6bVXv3zLFOZR7IC0s 6I+A== X-Gm-Message-State: APjAAAXVA17u+E0VvE+n9BMSM1838i2wIJHUoMJ4DVAE2fkjtHoSr36z rY967Qax1tennT8Tf/lXBMM/vXx7 X-Google-Smtp-Source: APXvYqyk+ouzehoMzA6zMFpYPBpNnJxAz2JON9+nkH93poTNI9iFoOhPJA8JEIS5clpNaEL1gs6KfA== X-Received: by 2002:a63:e156:: with SMTP id h22mr35176227pgk.370.1562140575141; Wed, 03 Jul 2019 00:56:15 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:14 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 13/14] powerpc/64s/exception: untangle early machine check handler branch Date: Wed, 3 Jul 2019 17:54:43 +1000 Message-Id: <20190703075444.19005-14-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" machine_check_early_common now branches to machine_check_handle_early which is its only caller. Move interleaving code out of the way, and remove the branch. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 129 +++++++++++++-------------- 1 file changed, 62 insertions(+), 67 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 88bcdd5b2dc7..8e16578cf932 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -956,6 +956,16 @@ TRAMP_REAL_BEGIN(machine_check_fwnmi) TRAMP_KVM_SKIP(PACA_EXMC, 0x200) +#define MACHINE_CHECK_HANDLER_WINDUP \ + /* Clear MSR_RI before setting SRR0 and SRR1. */\ + li r9,0; \ + mtmsrd r9,1; /* Clear MSR_RI */ \ + /* Decrement paca->in_mce now RI is clear. */ \ + lhz r12,PACA_IN_MCE(r13); \ + subi r12,r12,1; \ + sth r12,PACA_IN_MCE(r13); \ + EXCEPTION_RESTORE_REGS EXC_STD + EXC_COMMON_BEGIN(machine_check_early_common) mtctr r10 /* Restore ctr */ mfspr r11,SPRN_SRR0 @@ -1011,74 +1021,7 @@ EXC_COMMON_BEGIN(machine_check_early_common) BEGIN_FTR_SECTION bl enable_machine_check END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) - b machine_check_handle_early -EXC_COMMON_BEGIN(machine_check_common) - /* - * Machine check is different because we use a different - * save area: PACA_EXMC instead of PACA_EXGEN. - */ - EXCEPTION_COMMON(PACA_EXMC, 0x200) - FINISH_NAP - RECONCILE_IRQ_STATE(r10, r11) - ld r3,PACA_EXMC+EX_DAR(r13) - lwz r4,PACA_EXMC+EX_DSISR(r13) - /* Enable MSR_RI when finished with PACA_EXMC */ - li r10,MSR_RI - mtmsrd r10,1 - std r3,_DAR(r1) - std r4,_DSISR(r1) - bl save_nvgprs - addi r3,r1,STACK_FRAME_OVERHEAD - bl machine_check_exception - b ret_from_except - -#define MACHINE_CHECK_HANDLER_WINDUP \ - /* Clear MSR_RI before setting SRR0 and SRR1. */\ - li r9,0; \ - mtmsrd r9,1; /* Clear MSR_RI */ \ - /* Decrement paca->in_mce now RI is clear. */ \ - lhz r12,PACA_IN_MCE(r13); \ - subi r12,r12,1; \ - sth r12,PACA_IN_MCE(r13); \ - EXCEPTION_RESTORE_REGS EXC_STD - -#ifdef CONFIG_PPC_P7_NAP -/* - * This is an idle wakeup. Low level machine check has already been - * done. Queue the event then call the idle code to do the wake up. - */ -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. - * - * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce. - * - * Then decrement MCE nesting after finishing with the stack. - */ - ld r3,_MSR(r1) - ld r4,_LINK(r1) - - lhz r11,PACA_IN_MCE(r13) - subi r11,r11,1 - sth r11,PACA_IN_MCE(r13) - - mtlr r4 - rlwinm r10,r3,47-31,30,31 - cmpwi cr1,r10,2 - bltlr cr1 /* no state loss, return to idle caller */ - b idle_return_gpr_loss -#endif - /* - * Handle machine check early in real mode. We come here with - * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack. - */ -EXC_COMMON_BEGIN(machine_check_handle_early) bl save_nvgprs addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_early @@ -1157,6 +1100,58 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) EXCEPTION_PROLOG_1 EXC_STD, PACA_EXMC, 1, 0x200, 1, 1, 0 EXCEPTION_PROLOG_2_REAL machine_check_common, EXC_STD, 0 +EXC_COMMON_BEGIN(machine_check_common) + /* + * Machine check is different because we use a different + * save area: PACA_EXMC instead of PACA_EXGEN. + */ + EXCEPTION_COMMON(PACA_EXMC, 0x200) + FINISH_NAP + RECONCILE_IRQ_STATE(r10, r11) + ld r3,PACA_EXMC+EX_DAR(r13) + lwz r4,PACA_EXMC+EX_DSISR(r13) + /* Enable MSR_RI when finished with PACA_EXMC */ + li r10,MSR_RI + mtmsrd r10,1 + std r3,_DAR(r1) + std r4,_DSISR(r1) + bl save_nvgprs + addi r3,r1,STACK_FRAME_OVERHEAD + bl machine_check_exception + b ret_from_except + +#ifdef CONFIG_PPC_P7_NAP +/* + * This is an idle wakeup. Low level machine check has already been + * done. Queue the event then call the idle code to do the wake up. + */ +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. + * + * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce. + * + * Then decrement MCE nesting after finishing with the stack. + */ + ld r3,_MSR(r1) + ld r4,_LINK(r1) + + lhz r11,PACA_IN_MCE(r13) + subi r11,r11,1 + sth r11,PACA_IN_MCE(r13) + + mtlr r4 + rlwinm r10,r3,47-31,30,31 + cmpwi cr1,r10,2 + bltlr cr1 /* no state loss, return to idle caller */ + b idle_return_gpr_loss +#endif + EXC_COMMON_BEGIN(unrecoverable_mce) /* * We are going down. But there are chances that we might get hit by From patchwork Wed Jul 3 07:54:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1126693 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 45dvL64s3nz9s3Z for ; Wed, 3 Jul 2019 18:25:02 +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.b="mFi9tm3K"; 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 45dvL642vqzDqPG for ; Wed, 3 Jul 2019 18:25:02 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::62f; helo=mail-pl1-x62f.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.b="mFi9tm3K"; dkim-atps=neutral Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 45dtj05V6zzDqNZ for ; Wed, 3 Jul 2019 17:56:20 +1000 (AEST) Received: by mail-pl1-x62f.google.com with SMTP id b7so776878pls.6 for ; Wed, 03 Jul 2019 00:56: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=YxVJ7sF+ALWIc2kdonCGyXBG5JYvZnmgV3XMGIhMBS8=; b=mFi9tm3KTIUsrrG5umzvpXdLl/mMPIg/PabLjjrln2YZjPco/UcmpqX7/X0jo33HLy 086tI5Nn2dNQxyNhKRrb/vKymRg/+cRdkJnxUzxmPgdPMgg5wg8KfOGfZ2UN8o8OrnV0 P6NV0ZmsZQUVmfjBGfVjdtdeFNyu2bOvhWJVVxiWdrXXDLDHwmJ1Ld2TAH+lLafjWGlt sc1EA/IYTNeT97TENO0iODQxs1vUt3PnqP7ZogyI2zIIIRR53vg1OsyaRgZSAONHPW0K zZcLx40WetyHiK/SyJUwizp/K8qXEaUpzbP/rcyca9zeqnZCNVWauaAiCRwiaqCzpwNo C2aQ== 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=YxVJ7sF+ALWIc2kdonCGyXBG5JYvZnmgV3XMGIhMBS8=; b=HNnVH4NbX5PW9HnZ+xgvNhcybYjF1imHZaKGOR+7dxT5N+SWqcDyOAioIsf654FjzW JyomsfN+NKmH/7hzONhuQKZP5i3D/3jMkA/PrgvxEM7tLTNzmMz2npA6rg6Zuqx3tLah MzXfwd190r72SGvH/ljgJYst4338z5RDObCzW5KxLZJJyBXu2aCfDB0G9BxYEb2V4UWo kdyEVUxDPApjDpc9FbiZIT/AlgI4VmEV9AV7b3SkdataR3re9VvDJfmELi3jrG6WD7jS yd77SGnHgOC7oKqTEPAFwBAv7balVjxttl7lMQUGwzpK7xUrtqEz9mxmqa9j/GceIxBa utsA== X-Gm-Message-State: APjAAAU8I5ITtqBVQYxDg/lFJGhDVN/e2pBnh1nD9nRkKWYWN4mXnr/2 yME99/qlLCE3kXcJr76T1giSyBi7 X-Google-Smtp-Source: APXvYqzKoHv4eEetDqpyhKa5Qgs4V4H23Z9N78wnGxELHwr51Eky0c9DN2O/bLtxLDnrF1etRrFxGQ== X-Received: by 2002:a17:902:704c:: with SMTP id h12mr41132984plt.214.1562140578245; Wed, 03 Jul 2019 00:56:18 -0700 (PDT) Received: from bobo.local0.net (193-116-88-34.tpgi.com.au. [193.116.88.34]) by smtp.gmail.com with ESMTPSA id p68sm2955849pfb.80.2019.07.03.00.56.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 00:56:17 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 14/14] powerpc/64s/exception: machine check improve labels and comments Date: Wed, 3 Jul 2019 17:54:44 +1000 Message-Id: <20190703075444.19005-15-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703075444.19005-1-npiggin@gmail.com> References: <20190703075444.19005-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 , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Short forward and backward branches can be given number labels, but larger significant divergences in code path a more readable if they're given descriptive names. Also adjusts a comment to account for guest delivery. Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/exceptions-64s.S | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 8e16578cf932..0676a0f4c2d5 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1052,7 +1052,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) */ lbz r11,HSTATE_IN_GUEST(r13) cmpwi r11,0 /* Check if coming from guest */ - bne 9f /* continue if we are. */ + bne mce_deliver /* continue if we are. */ #endif /* @@ -1060,7 +1060,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) * exception handler which will deliver the MC event to this kernel. */ andi. r11,r12,MSR_PR /* See if coming from user. */ - bne 9f /* continue in V mode if we are. */ + bne mce_deliver /* continue in V mode if we are. */ /* * At this point we are coming from kernel context. @@ -1088,8 +1088,14 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206) MACHINE_CHECK_HANDLER_WINDUP RFI_TO_KERNEL -9: - /* Deliver the machine check to host kernel in V mode. */ +mce_deliver: + /* + * This is a host user or guest MCE. Restore all registers, then + * run the "late" handler. For host user, this will run the + * machine_check_exception handler in virtual mode like a normal + * interrupt handler. For guest, this will trigger the KVM test + * and branch to the KVM interrupt similarly to other interrupts. + */ BEGIN_FTR_SECTION ld r10,ORIG_GPR3(r1) mtspr SPRN_CFAR,r10