Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2353045pxb; Mon, 20 Sep 2021 19:50:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+iNJOBRN6oZhX5VvbVuYkCc3/bZgtm+9RVI1XfSvGMHLsECbUvpwRYaMG56H15uY75if2 X-Received: by 2002:a92:dccc:: with SMTP id b12mr19093539ilr.304.1632192649996; Mon, 20 Sep 2021 19:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192649; cv=none; d=google.com; s=arc-20160816; b=ihgBPO00M5EM5fs99Snjau3d6WH4Rn2ISL4J+GfHDmHI4u9flpRQWFwTIpcUwrPQmG 6y9jJ8X/6I0Ul0PD/TEFXyEeFMYJIK8bjWr9ENgS9A02R7X8HomKNvEYTNqOHHrzt2Ju Ej6H1alVbe3qlh02TVvkUnIO1KAIk2oQlzacJgOwIjJdxu3RCXyeBPBRy0LcNhkYCNjg QQC6yXG3LN4rlzfT6guzPDYSbnOADkitoa00C7mSz8GtEqZwlDQFr4NWp3DyIBQyjTdD dV9TulYY4amXkJv+/w7yVfMwab+YvESnyGpxyXS78fRnrpA3LTKZOKbPhVuh1KBjmEKm hkKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PSJAnC/7t8p3T7vjKW8qWQes/sqrlu1lOdAZHaYUGk0=; b=XFATGGmX21+Z4NIIhwhx4XRPou2zfrOWqYcsAK2k+jCG0BsTfAmxxqUrT9tkr2/H7b sw/ZZGhRNyQIqO6uH09qRsxJQ2gdZpGU1pVISJEld9lqZarJB4mlg96gseAoFsl8UhAd 6i4vhxS4E2PaTNW/1ndWlLdUGqnwEHWTYWMQp8cbmw6UKYcnJeIq/TR7vPq+dmbWtkbX NYP1iXWwPUFCJAb6zMX0FvZmN3sTLpObzRr9yTgbkSLqQePDvcK0oMkLm9Uw4pf5d20S oU5xnXoLrHGZ7cagbkpDAN6a3DpTeSUIw9he7vD8mXcRdVQP3WHhVvVyR3VRoiZR73Sm 6SrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O2iqGJ8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si15350447iow.29.2021.09.20.19.50.39; Mon, 20 Sep 2021 19:50:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O2iqGJ8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349459AbhITSpD (ORCPT + 99 others); Mon, 20 Sep 2021 14:45:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382503AbhITSkb (ORCPT ); Mon, 20 Sep 2021 14:40:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AD1961AE4; Mon, 20 Sep 2021 17:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159087; bh=V7ZEbAs4e/bVbND/qFeUmE3tyZdZ3MQRAnDCypAfhX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2iqGJ8gWQT2JFqDDYoscaxajhP0iOKaIBU4JRBx0x7Dh66gOU67J9zuO1XeykI8k kBkoaDZNkhByjGihbs0Q6RqzTTLEy1qezUh7gmC6bWCZlpe8UioTNbh6vzkKGNELeJ TN+4meTsLtUiwuz3MlZbaaasocwv+5JEycizrhbw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eirik Fuller , Nicholas Piggin , Michael Ellerman Subject: [PATCH 5.14 071/168] powerpc/64s: system call rfscv workaround for TM bugs Date: Mon, 20 Sep 2021 18:43:29 +0200 Message-Id: <20210920163923.978486843@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Piggin commit ae7aaecc3f2f78b76ab3a8d6178610f55aadfa56 upstream. The rfscv instruction does not work correctly with the fake-suspend mode in POWER9, which can end up with the hypervisor restoring an incorrect checkpoint. Work around this by setting the _TIF_RESTOREALL flag if a system call returns to a transaction active state, causing rfid to be used instead of rfscv to return, which will do the right thing. The contents of the registers are irrelevant because they will be overwritten in this case anyway. Fixes: 7fa95f9adaee7 ("powerpc/64s: system call support for scv/rfscv instructions") Reported-by: Eirik Fuller Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210908101718.118522-1-npiggin@gmail.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/interrupt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/arch/powerpc/kernel/interrupt.c +++ b/arch/powerpc/kernel/interrupt.c @@ -140,6 +140,19 @@ notrace long system_call_exception(long irq_soft_mask_regs_set_state(regs, IRQS_ENABLED); /* + * If system call is called with TM active, set _TIF_RESTOREALL to + * prevent RFSCV being used to return to userspace, because POWER9 + * TM implementation has problems with this instruction returning to + * transactional state. Final register values are not relevant because + * the transaction will be aborted upon return anyway. Or in the case + * of unsupported_scv SIGILL fault, the return state does not much + * matter because it's an edge case. + */ + if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) && + unlikely(MSR_TM_TRANSACTIONAL(regs->msr))) + current_thread_info()->flags |= _TIF_RESTOREALL; + + /* * If the system call was made with a transaction active, doom it and * return without performing the system call. Unless it was an * unsupported scv vector, in which case it's treated like an illegal