Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1085695imj; Thu, 14 Feb 2019 00:43:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IbIhIUrhgIjJ7w158V+d2qg4Q4993w94L/QoXFSxLnjBOpPEaUN+XYheGLbAEG8r8NEEak6 X-Received: by 2002:a63:f141:: with SMTP id o1mr2740467pgk.134.1550133801539; Thu, 14 Feb 2019 00:43:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550133801; cv=none; d=google.com; s=arc-20160816; b=kenHqMu0iMO7KHMlbx/0Kh2bIORucBqlG0HVu1O24Y5h4PnUfzGdT887wynhEA7XSm b+WDOhXRRc8J+iuGfB2EYWKKSSJy3Mbn4alMqnnRnUGckBloEHGmTjqAmg1+WX3uOq+4 t+iUK4YDJJTYfEtYmARrIjwPwPq7Rn3wrDgIRX8ID0J1ieWgV3LbWi/UVOEAcJPeIiw7 5GzSt/bTMKLbmZQ4uH5laS5mRuhMiaXKi8fzcGmtjF3UVlpFBZ5OuYH1geq87sBDFJLt OqawuYAXq2euiylU/MT5PvbQdLf2QfF0kdMDw3ZWv21+t+fwVHZrGA0PxREsk/HS4Kri vI/Q== 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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=HOalbBKhcn+A1A3wr0Gco4nBMIiycpQlT8/ej00+NOuZp2RgxS9SQoHEzFL7xdWsM6 YqfXE8JSAHRrt45LQTfZGvzISFqxjWN7quJviBBab0jzQkRAFclJyP635Y0uZERrqNp9 bgZndDx7PcfEAD7DsOhkgix5x4LoZvnuVjeu/ht/dl/qtOeEiYbPCSv6W+PjeVqhrTvv skM2zm8vWlGBlieN6geKwC0NouuZCf8zsvluTaR6jynE3zcN56KYJQfyVruQ2kfKaEj4 JHZX3jyXvXnMCw3KpgvVobpU1JWaTTNVo1o+WPXrQSdC7TY84zyHJYcn+SwzaCiHcuye Vsgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwmhYKUZ; 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 d35si1997561pla.48.2019.02.14.00.43.05; Thu, 14 Feb 2019 00:43:21 -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=WwmhYKUZ; 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 S2436752AbfBMVcg (ORCPT + 99 others); Wed, 13 Feb 2019 16:32:36 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:34432 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394806AbfBMVcb (ORCPT ); Wed, 13 Feb 2019 16:32:31 -0500 Received: by mail-qt1-f195.google.com with SMTP id w4so4508656qtc.1 for ; Wed, 13 Feb 2019 13:32:30 -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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=WwmhYKUZtwqmZBPxddYcC8svjEnrpVRs3C6Z89jsp+3z/4O7ttPaFjqC840opkxTzf FSRR9Qt7lbgk7buXPR1/fWZv0rNJffk5Te7k3osJ621iUIeP7po0k10DVuSE5I6fS9hT zJqIW/o9lS1KJ5YIL/CI6XeOd5ngo+kIOJuoW0KBHRgf33uDshpWob5HTcZqR9I2fxsD hRmMokLfiBC++7mt4GVFx3TXqE2koSnqVh/zSqYl5jsUs/SduAItxUF+bDO24QFRy2AP Ct0ObW8+pGJfCb9h/+UrV84/MddJh06eQcI4Coor67KzH+8KON4WHtTjHk1x2+HfMSNI w9dQ== 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=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=tB70J1gwUXk5Kv9lbRI+sID8kPxLGaxmwEEswlsXnD9c2jWIT2M8SrQqWqAEGbSV8r RtpE0yibyeXIEPbWE8hpVeyIcqHIfkTNG71IHH4jdMPslxo7Wveas6yxIUW5Ot/89xk6 oGVK8DYuHkQGmofB8lwAItMiV3k8iZvtuPXH9f4Om7nUrdnJkz3AUBxAOFI0RrotLl3o VGvd7MPuxPgrdQuASSLkUDa5zVjOnXNIuVYMYDLyeeLYEqIkdekPctPp00vpTvBF/SYg eBJ9hTK4FEAi5HLHohIzwFl6GMtIScOO9poEGva031oNytf613ripiRY5nb4psZByhvN NeCA== X-Gm-Message-State: AHQUAuYEyuVzCJubWDtzfGPAFdgMMvj47RfxYaKVL+FF9DmNS4ST5KxP tLBzd+7y0tbUVlG40jyQ6wDnIQ== X-Received: by 2002:ac8:6643:: with SMTP id j3mr251608qtp.108.1550093550087; Wed, 13 Feb 2019 13:32:30 -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 8sm382675qtr.7.2019.02.13.13.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:29 -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.19 03/17] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Wed, 13 Feb 2019 16:32:09 -0500 Message-Id: <20190213213223.916-4-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-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 9b37b6ab27fe..8f55dc520a3e 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -121,8 +121,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 464393d241e1..1e2ecfe080bb 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -137,17 +137,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 dc7e6b50ef67..2b287d0d6bc2 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -553,12 +553,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); @@ -567,22 +566,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