Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2473161imj; Mon, 18 Feb 2019 06:37:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IadhE7GuIeU9FqNnxYH1fzrGw1+xFF16gbPeUmFyF1uuIltEd623KHWoB6Ka57767dvh7dt X-Received: by 2002:a17:902:d83:: with SMTP id 3mr25173501plv.43.1550500674557; Mon, 18 Feb 2019 06:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500674; cv=none; d=google.com; s=arc-20160816; b=q6N6HZswmYEcRjUTYKDWHXqDSRGIz708EZWCli3F6IU/pJnazVR4Y+mB4pIMlz32tl lW1CNi+hpwer1D91zw7Sld/EedbXSAvJHVFRRluaCCiK1S6Ksnx4V4gVd8lxNDCqY2cT bcJcZS3Fd1D1URrsSUd8fwpFyDlXMUQnk2uP2oRH2jiMaS8zB6OoyV/7kCtNQaNeBadf 5PNB7eEEkLRh/jNjNLlFmJSE81h5fMNW47ycPrgxi6+YcqjvGCmtGmlLHUxsz7ckQbhP 7SV3p+HkMwVyBOtelIeHfguIrfwZGCGrk26ixEn+uT5kgGyEoR1jFn5tz033u93zKdK4 pEYQ== 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=trFS4R1EdzYg7BAkt098pLdn7GYoYkN6f9yWlHONm+0=; b=F6PqF9aHHn8v0lxZiRTO7fln82s88Jhmq2Bqid/7rL2OvVClCTy8sl1r21UtIfaD06 TvHTWAZIxsH2RlsBtuo5HKuRSURsvjPhoq12Pqbly3vJfMx/P2qrU5Nr4EQbGxN0pR8/ NPN/7tncsjM7G/2gsxTYnNuPdjLZF78YegjdhiyySWxI13q5wqlvCXG+Gcni56dJbTfM 26nucopmbvJw1ByvZHhLpb7ar1xri8gIAe5T1mpbqgp+aiHj4uCeycE65XMIDyKVM5FM Bo46kYP5h/uKpKIO98Ec2yyXAklJ7FrmW2P0PpPXs9ohVFBneU+aAp3bU7Vygt1vkJ1l GNyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wJKAcseg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si12249860pga.212.2019.02.18.06.37.38; Mon, 18 Feb 2019 06:37:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wJKAcseg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387470AbfBRNzM (ORCPT + 99 others); Mon, 18 Feb 2019 08:55:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:35166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387460AbfBRNzJ (ORCPT ); Mon, 18 Feb 2019 08:55:09 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 BC06B20842; Mon, 18 Feb 2019 13:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498108; bh=3sjdB3Jt0MvJIXW5rVVKAi3Dtx8ccOpDAHUchl6zRyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wJKAcsegqtwn5yLMZvNOCIpbnGe9dWzVYPgA/iQYdVzbHVfHjUY4epsTDJj4RZEWk 1wPn+MNk8aHvB4MNA2YubyzwW9DMWN0zm+J4dXFa4vdVm2a8aLxcT4c5PUSf9AykIP saTGQB2klCTslFLt43wegiUd/MKmwOH4eSFyC9AE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Thierry , Russell King , "David A. Long" , Sasha Levin Subject: [PATCH 4.14 07/62] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Mon, 18 Feb 2019 14:43:13 +0100 Message-Id: <20190218133506.422505754@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ Commit 3aa2df6ec2ca6bc143a65351cca4266d03a8bc41 upstream. Use __copy_to_user() rather than __put_user_error() for individual members when saving VFP state. This has the benefit of disabling/enabling PAN once per copied struct intead of once per write. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long Reviewed-by: Julien Thierry Signed-off-by: Sasha Levin --- arch/arm/include/asm/thread_info.h | 4 ++-- arch/arm/kernel/signal.c | 13 +++++++------ arch/arm/vfp/vfpmodule.c | 20 ++++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 57d2ad9c75ca..df8420672c7e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -124,8 +124,8 @@ extern void vfp_flush_hwstate(struct thread_info *); struct user_vfp; struct user_vfp_exc; -extern int vfp_preserve_user_clear_hwstate(struct user_vfp __user *, - struct user_vfp_exc __user *); +extern int vfp_preserve_user_clear_hwstate(struct user_vfp *, + struct user_vfp_exc *); extern int vfp_restore_user_hwstate(struct user_vfp *, struct user_vfp_exc *); #endif diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index b12499cc3582..1eb83ee7e1cc 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -136,17 +136,18 @@ static int restore_iwmmxt_context(char __user **auxp) static int preserve_vfp_context(struct vfp_sigframe __user *frame) { - const unsigned long magic = VFP_MAGIC; - const unsigned long size = VFP_STORAGE_SIZE; + struct vfp_sigframe kframe; int err = 0; - __put_user_error(magic, &frame->magic, err); - __put_user_error(size, &frame->size, err); + memset(&kframe, 0, sizeof(kframe)); + kframe.magic = VFP_MAGIC; + kframe.size = VFP_STORAGE_SIZE; + err = vfp_preserve_user_clear_hwstate(&kframe.ufp, &kframe.ufp_exc); if (err) - return -EFAULT; + return err; - return vfp_preserve_user_clear_hwstate(&frame->ufp, &frame->ufp_exc); + return __copy_to_user(frame, &kframe, sizeof(kframe)); } static int restore_vfp_context(char __user **auxp) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 6abcd4af8274..6bacd69c9e81 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -554,12 +554,11 @@ void vfp_flush_hwstate(struct thread_info *thread) * Save the current VFP state into the provided structures and prepare * for entry into a new function (signal handler). */ -int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, - struct user_vfp_exc __user *ufp_exc) +int vfp_preserve_user_clear_hwstate(struct user_vfp *ufp, + struct user_vfp_exc *ufp_exc) { struct thread_info *thread = current_thread_info(); struct vfp_hard_struct *hwstate = &thread->vfpstate.hard; - int err = 0; /* Ensure that the saved hwstate is up-to-date. */ vfp_sync_hwstate(thread); @@ -568,22 +567,19 @@ int vfp_preserve_user_clear_hwstate(struct user_vfp __user *ufp, * Copy the floating point registers. There can be unused * registers see asm/hwcap.h for details. */ - err |= __copy_to_user(&ufp->fpregs, &hwstate->fpregs, - sizeof(hwstate->fpregs)); + memcpy(&ufp->fpregs, &hwstate->fpregs, sizeof(hwstate->fpregs)); + /* * Copy the status and control register. */ - __put_user_error(hwstate->fpscr, &ufp->fpscr, err); + ufp->fpscr = hwstate->fpscr; /* * Copy the exception registers. */ - __put_user_error(hwstate->fpexc, &ufp_exc->fpexc, err); - __put_user_error(hwstate->fpinst, &ufp_exc->fpinst, err); - __put_user_error(hwstate->fpinst2, &ufp_exc->fpinst2, err); - - if (err) - return -EFAULT; + ufp_exc->fpexc = hwstate->fpexc; + ufp_exc->fpinst = hwstate->fpinst; + ufp_exc->fpinst2 = ufp_exc->fpinst2; /* Ensure that VFP is disabled. */ vfp_flush_hwstate(thread); -- 2.19.1