From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EC52C282DD for ; Mon, 8 Apr 2019 06:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CA6D2084F for ; Mon, 8 Apr 2019 06:32:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=neuling.org header.i=@neuling.org header.b="TfJ2w6An" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbfDHGcz (ORCPT ); Mon, 8 Apr 2019 02:32:55 -0400 Received: from ozlabs.org ([203.11.71.1]:60691 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725881AbfDHGcz (ORCPT ); Mon, 8 Apr 2019 02:32:55 -0400 Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 44d0wN6Nqyz8t9Z; Mon, 8 Apr 2019 16:32:52 +1000 (AEST) Received: from spoke.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 44d0wM1dbqz9sNf; Mon, 8 Apr 2019 16:32:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=neuling.org; s=201811; t=1554705172; bh=XEbSgQOSfVvpyO7l4SBbGJdIvYc5Ec90sHBGbnBKBmU=; h=From:To:Cc:Subject:Date:From; b=TfJ2w6An737tGvOLXSWaba6kNSoSFsQDJqXFTeWLCFAmCqt8UpHdlFjJHst9/lDso XGk31Pp22XqZgBeGrGrJj9IyeyLmO+Z/7R6goG411B+2qq1r5f4ku6iS7Y3rwAODl7 gO7yszYn6Pqo0ZkSYDygCy4MJov+RcpwGU1ulWExkRS36r34ThJPUxr8mjRLTmpq5Z YUG1VBPKf0xkdd4AZqfBI5/mVt1LjH9qN4i0STptrs8rn1ys25KjiY0jyQ+vQ4aIXA 6AnhU1nHxQy19FetA0O+EAy6HvaEegKRIqcst7YatotpJqULqRPYipTiGfvDQUCJsO 2ltdeRpcXdSbg== Received: by spoke.localdomain (Postfix, from userid 1000) id 25A902A0345; Mon, 8 Apr 2019 16:32:51 +1000 (AEST) From: Michael Neuling To: stable@vger.kernel.org Cc: mikey@neuling.org, Fredrik Noring , Breno Leitao , Christoph Biedl , Michael Ellerman Subject: [PATCH 4.19] powerpc/tm: Limit TM code inside PPC_TRANSACTIONAL_MEM Date: Mon, 8 Apr 2019 16:32:38 +1000 Message-Id: <20190408063238.16181-1-mikey@neuling.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Breno Leitao commit 897bc3df8c5aebb54c32d831f917592e873d0559 upstream. Commit e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint") moved a code block around and this block uses a 'msr' variable outside of the CONFIG_PPC_TRANSACTIONAL_MEM, however the 'msr' variable is declared inside a CONFIG_PPC_TRANSACTIONAL_MEM block, causing a possible error when CONFIG_PPC_TRANSACTION_MEM is not defined. error: 'msr' undeclared (first use in this function) This is not causing a compilation error in the mainline kernel, because 'msr' is being used as an argument of MSR_TM_ACTIVE(), which is defined as the following when CONFIG_PPC_TRANSACTIONAL_MEM is *not* set: #define MSR_TM_ACTIVE(x) 0 This patch just fixes this issue avoiding the 'msr' variable usage outside the CONFIG_PPC_TRANSACTIONAL_MEM block, avoiding trusting in the MSR_TM_ACTIVE() definition. Cc: stable@vger.kernel.org Reported-by: Christoph Biedl Fixes: e1c3743e1a20 ("powerpc/tm: Set MSR[TS] just prior to recheckpoint") Signed-off-by: Breno Leitao Signed-off-by: Michael Ellerman Signed-off-by: Michael Neuling --- Greg: I think the original patch got rejected with a conflict. This correctly applies to v4.19.34. --- arch/powerpc/kernel/signal_64.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index bbd1c73243..14b0f5b6a3 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -755,12 +755,25 @@ SYSCALL_DEFINE0(rt_sigreturn) if (restore_tm_sigcontexts(current, &uc->uc_mcontext, &uc_transact->uc_mcontext)) goto badframe; - } - else - /* Fall through, for non-TM restore */ + } else #endif - if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) - goto badframe; + { + /* + * Fall through, for non-TM restore + * + * Unset MSR[TS] on the thread regs since MSR from user + * context does not have MSR active, and recheckpoint was + * not called since restore_tm_sigcontexts() was not called + * also. + * + * If not unsetting it, the code can RFID to userspace with + * MSR[TS] set, but without CPU in the proper state, + * causing a TM bad thing. + */ + current->thread.regs->msr &= ~MSR_TS_MASK; + if (restore_sigcontext(current, NULL, 1, &uc->uc_mcontext)) + goto badframe; + } if (restore_altstack(&uc->uc_stack)) goto badframe; -- 2.20.1