From patchwork Wed Feb 13 21:32:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158255 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560773jaa; Wed, 13 Feb 2019 13:32:30 -0800 (PST) X-Received: by 2002:a37:4892:: with SMTP id v140mr204934qka.71.1550093550347; Wed, 13 Feb 2019 13:32:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093550; cv=none; d=google.com; s=arc-20160816; b=PH8ecXBlsjjr8EqdU3j3zBVPzFuBcublNbaMIzhAoUHIOiqsB/KpZxUea/xSbodRHw UPflFZ+7UnoQut5lcpuMTM0BGrNn/Q6gFrHHM7N9drhhdNV7iyU6YnAo5A9JafSu+j3a DWFioTB+cY6NVtAWrOr8GmoB0XYlTpaOxjV8TPeIrL6ME8T2vPPiL8zhBWoA7QzdpW3f hMg+J7qztHBRsjOT3MDRUhtkzdq3KXeCEnQkibBWYftbxV2TdcDV64NkydV/rXo8eql8 RuF0RG4y4t6aJ7VlnBD0GA/Bc2WEq9ADXpR+uYFdZmu8n66UFbX82ktONxYCM4vO5AjE +Vog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3wa6rXoZSMbFMmWTug8sDAz2t0wRwAm1naoRdniYFLc=; b=S+0a4xGqix4nXpSJQUsbsOSpMMgLQQttj47SEor3usVFyYxoU4YsaXDu2+f/RcwHMj GzkdNXypPWQ2+ZBxKMO7pcA+csNmpcEIEWhQ+OxVhg/N1Sx1T4EiV8xVSkKvXN4YAsCS g+uTpvUkqlMa+wURm5XdKZdjSgjDkXnCtXEgPJHaGMSDhPx95eunF2mdaRlMBqmw6Eid yEJnVYDYyuyodRoeSl7GfQKYL8WLX3ySFFzkZgHY4Dad6An3aiTMH+KGh2aGRAxWL46W E0TDjJ8eocVKJ+Bc2nKTK/rHrwYoJkRb+Xr5Uah0fWJZ6zs5/U1yCvfru/pAEHyWp80/ 2hPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwmhYKUZ; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l6sor570597qte.24.2019.02.13.13.32.30 for (Google Transport Security); Wed, 13 Feb 2019 13:32:30 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WwmhYKUZ; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=fXyuARN6o6dMvR6K+5iaVhlombAQeeqk/wmDbrm37+zHyrmMNL5OtZ/Kk8SBe5OwYz bGoZzrbE2+9I0G7R7hu1YpdXrdosIehuYLWp56LreltA9C7D73Ifj6spfxincCMzdTO3 vUreblCIklJOPaHdZFQdmYP8vjwlTgNStzsFyk3dS3BON/sIW99r5FX86Q7Rk6zBX3rI cwGoS+tab52ygaBClI7UisfJyN0CGROcK4GE3N4e/XbAxpjiPLrV55xYSmmIFKYJLF5W 3gbzkkfjKVDcBzFoqt/sEukWxikwHBxU4r607u1KB+Y5rsTS5IegIO8yttxsGVFynWVO yZdQ== X-Gm-Message-State: AHQUAuZyMA0E+nO5Gb3M+LCvWSc/ZIuL3qF2ja8NgTnC+lAm40it0Do5 /SBk+T6ob0ozgG7TW4vB240y4pWZ X-Google-Smtp-Source: AHgI3IaRqUchb0ljK7x+5kla1RpF7roRiiW6Th5b/C3qiraVvKmJpiIlYIUbPfB95SObg+mo1zguTA== X-Received: by 2002:ac8:6643:: with SMTP id j3mr251608qtp.108.1550093550087; Wed, 13 Feb 2019 13:32:30 -0800 (PST) Return-Path: 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> 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(-) -- 2.17.1 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);