From patchwork Wed Mar 22 14:50:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 9639139 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 99391601E9 for ; Wed, 22 Mar 2017 14:58:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B1F428458 for ; Wed, 22 Mar 2017 14:58:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 800AD28475; Wed, 22 Mar 2017 14:58:14 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 02DD928458 for ; Wed, 22 Mar 2017 14:58:14 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=Rh8RKLfuLEFMx77QNw3skVOgCHFIol4/m/o73Rj+L7Q=; b=EWLzEasaICR6HGM/QxLn8iWFzG 5R27d4jXNERGdenVteqbSpBTWOGyQCi61nhOBHSkyWkHDUZH3rJHNZ9i44z9nqAPsA0Pyllljb42y w9VFwRnv3UA0D09Lc/thndrT1c9thluqffna8x+i9kjzJnu00H9MKKX45OvJVoKCqmDUWtz/PqWQx 79imlsiBJ5E6ggmwGi+/QOV1ZClH6sBmVyfeX7PfeCZv7fElE6SzGIxee3CBQlq2jdCuNMecKj8mr L8aSPFAEzgG2X734ePybX+9k4tGwfbx2pmNIm7rc6bej0cHlxLVKMuoZ5HS3J+PI7/vhi5l+T5+IR 96TYCp3w==; 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 1cqhiC-00063Z-U1; Wed, 22 Mar 2017 14:58:08 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqhdL-00085P-2f for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2017 14:54:10 +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 B4E24B16; Wed, 22 Mar 2017 07:52:46 -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 6DC403F575; Wed, 22 Mar 2017 07:52:45 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2 17/41] arm64/sve: signal: Dump Scalable Vector Extension registers to user stack Date: Wed, 22 Mar 2017 14:50:47 +0000 Message-Id: <1490194274-30569-18-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490194274-30569-1-git-send-email-Dave.Martin@arm.com> References: <1490194274-30569-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_075307_902093_D8F51A8F X-CRM114-Status: GOOD ( 10.54 ) 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: Florian Weimer , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon , Szabolcs Nagy , Joseph Myers MIME-Version: 1.0 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 This patch populates the sve_regs() area reserved on the user stack with the actual register context. Signed-off-by: Dave Martin --- arch/arm64/include/asm/fpsimd.h | 1 + arch/arm64/kernel/fpsimd.c | 3 +-- arch/arm64/kernel/signal.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 93ae8a7..be292c5 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -95,6 +95,7 @@ extern void sve_save_state(void *state, u32 *pfpsr); extern void sve_load_state(void const *state, u32 const *pfpsr); extern unsigned int sve_get_vl(void); extern void __init fpsimd_init_task_struct_size(void); +extern void *__sve_state(struct task_struct *task); #endif diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 801f4d3..1bdf7f2 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -93,7 +93,7 @@ static DEFINE_PER_CPU(struct fpsimd_state *, fpsimd_last_state); #ifdef CONFIG_ARM64_SVE -static void *__sve_state(struct task_struct *task) +void *__sve_state(struct task_struct *task) { return (char *)task + ALIGN(sizeof(*task), 16); } @@ -153,7 +153,6 @@ static void sve_to_fpsimd(struct task_struct *task) #else /* ! CONFIG_ARM64_SVE */ /* Dummy declarations for usage protected with IS_ENABLED(CONFIG_ARM64_SVE): */ -extern void *__sve_state(struct task_struct *task); extern void *sve_pffr(struct task_struct *task); extern void fpsimd_to_sve(struct task_struct *task); diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 113502e..6b83917 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -229,6 +229,14 @@ static int preserve_sve_context(struct sve_context __user *ctx) BUILD_BUG_ON(sizeof(ctx->__reserved) != sizeof(reserved)); err |= copy_to_user(&ctx->__reserved, reserved, sizeof(reserved)); + /* + * This assumes that the SVE state has already been saved to + * the task struct by calling preserve_fpsimd_context(). + */ + err |= copy_to_user((char __user *)ctx + SVE_SIG_REGS_OFFSET, + __sve_state(current), + SVE_SIG_REGS_SIZE(vq)); + return err ? -EFAULT : 0; }