Received: by 10.192.165.148 with SMTP id m20csp2428744imm; Sun, 22 Apr 2018 06:59:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx49XlaRpZl72VAsWs/Vv/+Ms6EjKiXg/YiVzlOgGtq9T9rTTbdUGyQRE5X7c9NroJWUhdfqJ X-Received: by 10.99.121.69 with SMTP id u66mr5946707pgc.376.1524405552930; Sun, 22 Apr 2018 06:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405552; cv=none; d=google.com; s=arc-20160816; b=zhcITyK/lbrkTtYdGWPslJhQSZWwEgI4YW0NBR2xglH9QDqhR2RjLPDaGzpPxCHLuC L761pbzii36sA/qBk6otUlq0tRWlY65u02Rhq0sW+gqUNrIU0Ivkc80OZnWHhiyFmTLV RvD/pbN/wS9A99P1hXuux+3R0I2npFtVthBxokkTOW1OUrUnfDFG2zJq6oE8nbK8zFcD +isfZUXHjx0m35xedTNSqHTggkhbNP7xuDaw/67PMdnqzbCxBBSNkXktwSrMaE1yxxpI CKTJtim0dE9PZl+17NmFgyURc+KLtEgxYVx7LKbnwZxt7Mp0JJSD7Ix7RO6isPWDmT5L WOaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7DYaZdesBcOMZkI0Zxr/B/5lbzF0u6Pcew4Kti7ReRA=; b=eEFxcEEtTPDSeInpTkav/lJNEr3mHBGIU3VoZm0VC1QWjblyf0jowh13HnnCQvGqN9 vsJGLHE2/K68Ax1aRI+Up4DcLyOhVkn/PDLZYyhS2iBDpUyPnpNBH9CTdeMlj9u6eblc jx+oHPKvt16FSV4+2cKkxQqbQKf0dEJnKM7DyUwKovyFnhbEgY1C+LXV7CZRlllzopcV B7lNEko+E65QF8SilZd6A1CcF/Oh83R1+zz1aR4FOoYtEVzy3v2GBHd01PjemIt/OQBK ZJlvKPqtq6DsuJl5XXLEeAnMc18xhp/iCc0SGFm2WV7eGjO80D0PaLoyZx25y62zP5Zh MY4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18-v6si9647868plo.586.2018.04.22.06.58.59; Sun, 22 Apr 2018 06:59:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753973AbeDVN53 (ORCPT + 99 others); Sun, 22 Apr 2018 09:57:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45690 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753964AbeDVN5X (ORCPT ); Sun, 22 Apr 2018 09:57:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 96123727; Sun, 22 Apr 2018 13:57:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Nicholas Piggin Subject: [PATCH 4.16 068/196] powerpc/mm/radix: Fix checkstops caused by invalid tlbiel Date: Sun, 22 Apr 2018 15:51:28 +0200 Message-Id: <20180422135107.777570520@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman commit 2675c13b293a007b7b7f8229514126bd23df09a7 upstream. In tlbiel_radix_set_isa300() we use the PPC_TLBIEL() macro to construct tlbiel instructions. The instruction takes 5 fields, two of which are registers, and the others are constants. But because it's constructed with inline asm the compiler doesn't know that. We got the constraint wrong on the 'r' field, using "r" tells the compiler to put the value in a register. The value we then get in the macro is the *register number*, not the value of the field. That means when we mask the register number with 0x1 we get 0 or 1 depending on which register the compiler happens to put the constant in, eg: li r10,1 tlbiel r8,r9,2,0,0 li r7,1 tlbiel r10,r6,0,0,1 If we're unlucky we might generate an invalid instruction form, for example RIC=0, PRS=1 and R=0, tlbiel r8,r7,0,1,0, this has been observed to cause machine checks: Oops: Machine check, sig: 7 [#1] CPU: 24 PID: 0 Comm: swapper NIP: 00000000000385f4 LR: 000000000100ed00 CTR: 000000000000007f REGS: c00000000110bb40 TRAP: 0200 MSR: 9000000000201003 CR: 48002222 XER: 20040000 CFAR: 00000000000385d0 DAR: 0000000000001c00 DSISR: 00000200 SOFTE: 1 If the machine check happens early in boot while we have MSR_ME=0 it will escalate into a checkstop and kill the box entirely. To fix it we could change the inline asm constraint to "i" which tells the compiler the value is a constant. But a better fix is to just pass a literal 1 into the macro, which bypasses any problems with inline asm constraints. Fixes: d4748276ae14 ("powerpc/64s: Improve local TLB flush for boot and MCE on POWER9") Cc: stable@vger.kernel.org # v4.16+ Signed-off-by: Michael Ellerman Reviewed-by: Nicholas Piggin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/tlb-radix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/powerpc/mm/tlb-radix.c +++ b/arch/powerpc/mm/tlb-radix.c @@ -33,13 +33,12 @@ static inline void tlbiel_radix_set_isa3 { unsigned long rb; unsigned long rs; - unsigned int r = 1; /* radix format */ rb = (set << PPC_BITLSHIFT(51)) | (is << PPC_BITLSHIFT(53)); rs = ((unsigned long)pid << PPC_BITLSHIFT(31)); - asm volatile(PPC_TLBIEL(%0, %1, %2, %3, %4) - : : "r"(rb), "r"(rs), "i"(ric), "i"(prs), "r"(r) + asm volatile(PPC_TLBIEL(%0, %1, %2, %3, 1) + : : "r"(rb), "r"(rs), "i"(ric), "i"(prs) : "memory"); }