Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4184096pxk; Tue, 8 Sep 2020 12:54:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7tjGix/lAHXFRZQaiL3fmSEd7212W+jviqbAQB787m6JmTmA5tqxnTkYATYFURfkhakp/ X-Received: by 2002:a17:906:15c7:: with SMTP id l7mr105469ejd.208.1599594847396; Tue, 08 Sep 2020 12:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599594847; cv=none; d=google.com; s=arc-20160816; b=QvfcB8gi90jd6UC+aM7JVUpe/WHlwI4saPciGgvCy1ei+TU+JS+DvcbJfsR6QDYFfy rMXtBeHZn1rlOOCOITM2LlX3lmx4BSyFs8nqBPPMeIFVIopTynv+VkU5lJjmvNdOlSBV xJtvhCf9mmCYB/K1hv+sYKevvFsMCkJd5/lg7Lry3FCm1oun+xAP+lqPmjavY8Dw9rcb AUpHA793s9//qlJobCZLb9qB5DwXXZtbExUEpjMwacxgE3Rsmv0Kd8nd2T73xmMydMWd zpMJ4LfJPhDt3p9kmEHs20sqItNx6z6AgSvgBudEAdCROugnk2N0P2lxPBzCA3kLvJim +tsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2JMpcFXQSFu1Wclr9LkIyGav/9CYKXLaM4SOqKlqZwY=; b=z7yvlWr4OvbfnBCxJ3rzl974WV6X56K7yZP8JvGWD81On65XsIjQG8UFXq2XM9iFA+ PmeRDpVpDHZ61aS/k+Z9KJ0DVe8jl3Xvfy+4PiosTVW5pIQGAa6y/goXNKnKFp149rj8 4rUrKtnGG1sDIWrrSxuoa/wVdQl1wTnVZ71QzjIfoZLQjjgvEOI1C490+QixGnQ0dHfJ zp+rrHWCOLtW1C7djBuLYJABqjKCXPFcm6thrzrHhPNZ59MbpwZ8NwnqSmQT5yO8bI5U iOqDhdeWLEh1dCwHaGAVaJlnHmEgN5wfYSM2l1l2h6zNEdzOCYUuxZOa3SfVeC4tHur+ Tt5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fBm3MAHZ; 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=fail (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 s24si13980ejd.606.2020.09.08.12.53.44; Tue, 08 Sep 2020 12:54:07 -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=@kernel.org header.s=default header.b=fBm3MAHZ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732442AbgIHTxL (ORCPT + 99 others); Tue, 8 Sep 2020 15:53:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730680AbgIHPsE (ORCPT ); Tue, 8 Sep 2020 11:48:04 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E764C24826; Tue, 8 Sep 2020 15:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579860; bh=Pwz6JyR6e1oNJ4TyLdHjQ1h41POKg5lPv2Z58tgjOro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBm3MAHZUr8WK50mpLjTpzHrSkRBZvFcch8Ujjy4K02G0qXS7JtctHaCZ4e4B3S+V zcV6GvAvdeCEoSvwofEdyFpOuPJUEj/kdFM3KM+01ZHVCtumBa7ucBlhTFwNp058rj NBLz0ifJ7EqffK4GenZxF2xc13HUaVtFL4wyr1nE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Huang Pei , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.4 062/129] MIPS: add missing MSACSR and upper MSA initialization Date: Tue, 8 Sep 2020 17:25:03 +0200 Message-Id: <20200908152232.800290073@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Pei [ Upstream commit bb06748207cfb1502d11b90325eba7f8c44c9f02 ] In cc97ab235f3f ("MIPS: Simplify FP context initialization), init_fp_ctx just initialize the fp/msa context, and own_fp_inatomic just restore FCSR and 64bit FP regs from it, but miss MSACSR and upper MSA regs for MSA, so MSACSR and MSA upper regs's value from previous task on current cpu can leak into current task and cause unpredictable behavior when MSA context not initialized. Fixes: cc97ab235f3f ("MIPS: Simplify FP context initialization") Signed-off-by: Huang Pei Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/kernel/traps.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 6a25364600266..8282d0feb0b21 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -1240,6 +1240,18 @@ static int enable_restore_fp_context(int msa) err = own_fpu_inatomic(1); if (msa && !err) { enable_msa(); + /* + * with MSA enabled, userspace can see MSACSR + * and MSA regs, but the values in them are from + * other task before current task, restore them + * from saved fp/msa context + */ + write_msa_csr(current->thread.fpu.msacsr); + /* + * own_fpu_inatomic(1) just restore low 64bit, + * fix the high 64bit + */ + init_msa_upper(); set_thread_flag(TIF_USEDMSA); set_thread_flag(TIF_MSA_CTX_LIVE); } -- 2.25.1