Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp94790imj; Thu, 14 Feb 2019 16:06:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IbVcb+Gn/nIax1jeGaL8cqK6zQ0QqX9S8vqOcNVAfEB28h3PjEX4WrDhBHADqCMLmvxKXoG X-Received: by 2002:a63:8f45:: with SMTP id r5mr2504277pgn.222.1550189185584; Thu, 14 Feb 2019 16:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550189185; cv=none; d=google.com; s=arc-20160816; b=jeK/2pfVz2Kk7PMcwcH4CQ5qi5/zEjT8RNMIm5gHQEx/bjSZwDF+E0RlAFa9lFB8HY lW7AiD/ZxukOP8QwmsHHl6YEWQx5kZAikQxSqxHcTlw3gtYf4oziFzku4PwV5BMV7mXm FUsgZ51B6j8rGxWP1cfmqN3aEPZ8wmBBs4R0arF9CLneNY8iHFBTUoBuxeQijHvWIf/a ssGM/KAP81NhvjUaRrvLQG3b4IMpgggL2vzEhLWcfmg/+0QSf79mfBmPRhtj8+6Y4odD mvlGoh4KXtyScVUM8LFIXt89Hgm2c7/5eMl8LPCOGWszVaS1gIrJX6K5Cd3Dd5fD1gb0 EI2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=IF/Bjw7ydVyMl9WiuqJ5qiJCQ3qB+zduGpumbFoBtZeieJSNA25jGt6Yy5f5ytTr5O uXWNiufmRqPXYc6lvj35CUnv1Q6ONuMnqXM++huRrKz5R7/D81L8tjDRRh54HTBe8AAl kB37GpIfZBvVX131ztPgQA50EGS3luHGi/Al4gV+kib7XDsm5fs7Aj2GVvMMX2l35ozm BFEmMyIlbvkfEGRWUr952V2XrppeM49ywPLZOZr+hPzQ5J7MZZAmj9L7EW389tp8XTDP 2gykVFY5mxure5S4v7f5VmxMKeDxCdLuGu7MvUwxfyKjMNY2AllDRQzihiA2wGuaMJlL rFRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/EIJY9B"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si3828547pll.126.2019.02.14.16.06.10; Thu, 14 Feb 2019 16:06:25 -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=@linaro.org header.s=google header.b="V/EIJY9B"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407295AbfBNOtl (ORCPT + 99 others); Thu, 14 Feb 2019 09:49:41 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:45370 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407266AbfBNOth (ORCPT ); Thu, 14 Feb 2019 09:49:37 -0500 Received: by mail-qt1-f195.google.com with SMTP id e5so7052039qtr.12 for ; Thu, 14 Feb 2019 06:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=V/EIJY9BGKspAndcNIdR3th42CLoUkdNivW75Klm61UNfZ5bUDb+8pQ9YgZ+aV9xaW quJp2RA+dWlDK3eGad2f+vpkapMMnVGuqwuBFVIeY57WfSscvObAdyBO/a6LuYnJCadR SgaQcUcVZQ9VbZVyPs8vu7TS/YXhoblTOO9nySwB//QuURMG2g6D+Xt/OnAAbNXrpCg/ ajqXQGM6wLjN5oPZjbGUWzhvuBMl7RKG5nWYW7Xk6NHxSgcMLNBmzTLRXB5T1IQp4JSc 2mgz3bRQMV60JYS8WdZTOmCJSwl2uxAbvYrhcmPI0rZ2LPEtN2DHL0L+SNIlWzfHL+Ru gRdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=60g7G9GsgPysXeQeRaphSyl4TAccnCLeHznr84gZrn0=; b=b2mskKJMf5SEvWn8fLmmOzdCQXHZqwgOok75uXJjGIK7E0acOS8bZdaPEnVGPAKTzz n9eSGlHca94i+njgpWDGmc2j5cSFvfR1+90VS6aDO6nOIfXaLa/sJ9szlsff0xI0TZYA yrvPEsundv+rCDtbsQ+KH74KDvA7XCdOP+w6IXHnwMNB2l+lYgZFFkrLxYrTaGzyoFwL mDgHxl1tDTwIbomnMKg4lyNN3TURdfjBWMrAdezrWbEz2nfDgQXPdrUy66PcFsCt+iSM 8UyNyTD1iSPbJZdbcwXmeHseCCnTpnbSn5BO2cjbrmZLzwh93HKb4Pkkh3WRXZ/m03+y x1BA== X-Gm-Message-State: AHQUAuZ2STcTPg0p1jzwV0eyIYQirgj+bKdgCmQAKYGe4X8lgljpgWXj OqwLRBkU6jccLa4v1YQ1s5knKg== X-Received: by 2002:a0c:b2d9:: with SMTP id d25mr3234605qvf.79.1550155775806; Thu, 14 Feb 2019 06:49:35 -0800 (PST) Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id k66sm1498919qkc.25.2019.02.14.06.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:35 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.9 02/16] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Thu, 14 Feb 2019 09:49:16 -0500 Message-Id: <20190214144930.27539-3-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214144930.27539-1-dave.long@linaro.org> References: <20190214144930.27539-1-dave.long@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julien Thierry 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 --- 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 fbb325ff8acc..135b1a8e12eb 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -94,17 +94,18 @@ static int restore_iwmmxt_context(struct iwmmxt_sigframe *frame) 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(struct vfp_sigframe __user *auxp) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 8e5e97989fda..df3fa52c0aa3 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.17.1