From patchwork Tue Oct 31 15:51:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10034865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E65E600C5 for ; Tue, 31 Oct 2017 16:03:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10A1B223C6 for ; Tue, 31 Oct 2017 16:03:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04F7A28409; Tue, 31 Oct 2017 16:03:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8326A28BF5 for ; Tue, 31 Oct 2017 16:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y7vAsa8gDIDs2v/NW+lcu9XGnsJZ6AMQ0SczbNRj/+A=; b=NMdT1JCGIbMX07 /A3csAWW9XlEIbYtpEr+3kvkeDTH2qNv5m3oDtJDdzBEUrLNx64zPoebCnOwVYsc9RQLN3d64P2xN v7ydGzBH6S0vKodzuQsRHe76cCPSGBTEllzFyyBIXGonrAVs8yBbCBhioWqoIN4lHni+K3pLyrjwS JHnK01WSO4J6CS42Zm6sfjDEtQDQ3b0neK59Xld4a1dsEeIVivWaf0AA2VD6AKHmoqAAwdZyZvKdN 6Q8jhhmC9qwhCBcFNIZkc85hYTB7ZNlqMW0AfCghWaXBMMsr9H+kO/1nfcigPgfRDrFxPtfVRb00l qeDTYV0dxARvS+bGhMlQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e9Z0F-0005qR-6q; Tue, 31 Oct 2017 16:02:59 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e9YuJ-0008Mk-Io for linux-arm-kernel@bombadil.infradead.org; Tue, 31 Oct 2017 15:56:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oCQYFb1Lj/dCyHZ0px/V7W0i0w8z6OrG8z1p5tEtrus=; b=OYBCDjuL03KukYcTrFA2KvjrY0 rsAw6YjFkJkpFIXGpNrAklQYpXBh8MOZLhtoePUKi1RGi8YtnirI70+N0Wb5JXTqQX3jWR2P4ju44 nyvVhiMX2W3ope96TZwedEFcKE/6gCwda2wV922Dd2f83aaQpo6PelVyfcsOhOinetBbbPi7OXOCB 3ya0mu9/Ir7kx7eK8lf3UnKFZQeQGZpy8+ndag0NtrH7m8lZE4dxydRCuSsOubMfLd/3O7CqSsBVo XS2NBVlCus5lhhSf4SPlQvO2GhqCz+Y1nZTGO6PpkltqwM9dnjoqmJGai8MA+0NUhkScHnMb37eM/ 0QNIOo7w==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e9YqF-000877-2N for linux-arm-kernel@lists.infradead.org; Tue, 31 Oct 2017 15:52:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7C066174E; Tue, 31 Oct 2017 08:52:08 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AF6BC3F24A; Tue, 31 Oct 2017 08:52:06 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 19/30] arm64/sve: Preserve SVE registers around kernel-mode NEON use Date: Tue, 31 Oct 2017 15:51:11 +0000 Message-Id: <1509465082-30427-20-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1509465082-30427-1-git-send-email-Dave.Martin@arm.com> References: <1509465082-30427-1-git-send-email-Dave.Martin@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171031_155239_328266_F8CDE4D1 X-CRM114-Status: UNSURE ( 9.03 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Okamoto Takayuki , libc-alpha@sourceware.org, Ard Biesheuvel , Szabolcs Nagy , Catalin Marinas , Will Deacon , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Kernel-mode NEON will corrupt the SVE vector registers, due to the way they alias the FPSIMD vector registers in the hardware. This patch ensures that any live SVE register content for the task is saved by kernel_neon_begin(). The data will be restored in the usual way on return to userspace. Signed-off-by: Dave Martin Reviewed-by: Ard Biesheuvel Reviewed-by: Alex BennĂ©e Reviewed-by: Catalin Marinas --- arch/arm64/kernel/fpsimd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index c112972..ae10ddb 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -885,8 +885,10 @@ void kernel_neon_begin(void) __this_cpu_write(kernel_neon_busy, true); /* Save unsaved task fpsimd state, if any: */ - if (current->mm && !test_and_set_thread_flag(TIF_FOREIGN_FPSTATE)) - fpsimd_save_state(¤t->thread.fpsimd_state); + if (current->mm) { + task_fpsimd_save(); + set_thread_flag(TIF_FOREIGN_FPSTATE); + } /* Invalidate any task state remaining in the fpsimd regs: */ __this_cpu_write(fpsimd_last_state, NULL);