Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3055436rwe; Mon, 29 Aug 2022 05:13:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wIcSu5CKujJpLI2NNe5yraUFykUlgfOuHx3uxJUz+XQBRTgXaHvA81aG1jQamO1NbZlAE X-Received: by 2002:a05:6a00:4147:b0:52e:2d56:17c8 with SMTP id bv7-20020a056a00414700b0052e2d5617c8mr16313213pfb.51.1661775230192; Mon, 29 Aug 2022 05:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775230; cv=none; d=google.com; s=arc-20160816; b=mPN+HlQHAOywrp5dq3OZZVe/SfHMR2xK4Yl2hlg2l4FBTYgUHrvIQv7H8TauqLiJzA BlkPpbQWOOzgtyUi6+HUWax9MAWBlKdMWZmoJEUQSU6FIYEzAQX86neYHdb4PvVvYfM6 Xu6lMJkD3L85zzAqEop0EbTo5+YOD7+v2s1vJcc6IVlSz0y1ZjNrl2YuC29VQW+MFkxP 88KK2NDtbwbl1S+zyM1/u7XxHW1/+gFdpyFfGqi7s7GJ9XIkZYAdX+8I+uU8Q4DesuZ+ Xy4GmKrrRDfWaE7wszKmJHERX25S0dxZR914Ne1poiBx1NhmX99sZNmy5YbmwL9SvrPr ZnQA== 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=esmEegE69f8EcLIwOU0uWAMPjLjJZ9vu5QK6Ltce1LM=; b=N5bl6Z0p3sQtMNNRI4g+S6ucOcgsOxQuSIulNQsVLYWrjLQ19alHYaL0t9V8l7aJdm 11RdTqa3PygkVpWNZG6Hm7nqBolrKyjkZaKDi2xHjgO6uvm/hUwtKMWSLtSq3/U6Dl7H LT4fZO11cXTfbopZO+9H67xFhDkdK2dhaJiQriclMRnptMwm9acEQjvXRLLF1keyJkIM VZI5p/162LoWStohZFjnU2Nqu1P+Kj9Qipx5EbeiwuuUPbvdUdcxO3J7rgAPd+PK4jrb NpEhsrkj6HeVadPel8fBldXxJSnXyRW+qGmgt9YAV11uiPJpML2QQaWhSvvCrbnnqfit /JFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HiiVbT6k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a17090a148500b001f559b2fd12si8720494pja.138.2022.08.29.05.13.37; Mon, 29 Aug 2022 05:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HiiVbT6k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231519AbiH2LhL (ORCPT + 99 others); Mon, 29 Aug 2022 07:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiH2LgU (ORCPT ); Mon, 29 Aug 2022 07:36:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E18CC7E81D; Mon, 29 Aug 2022 04:20:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B9C4D611DA; Mon, 29 Aug 2022 11:19:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AADA3C433C1; Mon, 29 Aug 2022 11:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771946; bh=GNnnKDLaV1EeyAGca63gKpCDTI3RHXneSwbgyR9HMPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HiiVbT6ksRnZ7yam+HqiXM0mzY34w7ykbldSOTdm09AJgetVMKPOfTMq3nLXkXqNg joCHPRkC82JycyFC9KA5jSYu4QaPIOoi2nLDBS99NygRO+69HSd3w3hvzZKXNcdN4k dE8D8vXCwjzKGg8Z/a56jK55K0XGDOu4MQ7IQvJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Catalin Marinas , Will Deacon Subject: [PATCH 5.19 148/158] arm64/signal: Flush FPSIMD register state when disabling streaming mode Date: Mon, 29 Aug 2022 12:59:58 +0200 Message-Id: <20220829105815.304300751@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Brown commit ea64baacbc36a0d552aec0d87107182f40211131 upstream. When handling a signal delivered to a context with streaming mode enabled we will disable streaming mode for the signal handler, when doing so we should also flush the saved FPSIMD register state like exiting streaming mode in the hardware would do so that if that state is reloaded we get the same behaviour. Without this we will reload whatever the last FPSIMD state that was saved for the task was. Fixes: 40a8e87bb328 ("arm64/sme: Disable ZA and streaming mode when handling signals") Signed-off-by: Mark Brown Reviewed-by: Catalin Marinas Link: https://lore.kernel.org/r/20220817182324.638214-3-broonie@kernel.org Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/signal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -922,6 +922,16 @@ static void setup_return(struct pt_regs /* Signal handlers are invoked with ZA and streaming mode disabled */ if (system_supports_sme()) { + /* + * If we were in streaming mode the saved register + * state was SVE but we will exit SM and use the + * FPSIMD register state - flush the saved FPSIMD + * register state in case it gets loaded. + */ + if (current->thread.svcr & SVCR_SM_MASK) + memset(¤t->thread.uw.fpsimd_state, 0, + sizeof(current->thread.uw.fpsimd_state)); + current->thread.svcr &= ~(SVCR_ZA_MASK | SVCR_SM_MASK); sme_smstop();