From patchwork Thu Jan 10 17:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 155247 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2176020jaa; Thu, 10 Jan 2019 09:51:57 -0800 (PST) X-Received: by 2002:aed:2cc4:: with SMTP id g62mr10483137qtd.192.1547142717010; Thu, 10 Jan 2019 09:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547142717; cv=none; d=google.com; s=arc-20160816; b=OXSV8QmjFOsTiQ9TAHbbp0Qlm1/YfNQSnmKqqAbSLaY4caShkndv7+nkpfWgUbf2qZ seVKN9W8AIuQk8PE04qBPFUlMI8hcBSlcaGT2dD9HX4cbxAbgLJR4qgnow7B0vkWfKAX 1D4CJpUKXOH9YGjheBH7Eh/PVZkOsDEju8KGVGrGX/7p6a+i3D2QNnYM0DL59l1RO4kQ FK5JcwJ05SZlHqRff3H9dJQ41cev91MdOlxDvugr2lkCy3X7SnhYQCKz6UlYYNY7bo05 s/v48ZDcI3eQdf3GvgSPfVl2nWxbMAcICzrECaNjOw40xZOkrua/GzaroQ1WKbdgYsbD iSgQ== 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=WgOHYK3l+0OE/b/Dv+SoLY6DHeBQZP46T21l4pUj3ISbJaNToOsKeIGTLHOTyftAL0 adKEZKbsPVIni0wKyrr0JUDZZU9ILykxvMKlL2/lTSawJkNGxWwq82uZWjWWAR0PXaul Shig5nwWII1tC2lRjAcvqjeewdG0wo0141aN1g40Wsg/xXQiU0V5k5QDBuuugEu+Dw/6 dMjEdFN9B6kN+fuFFE6lZ94D0phaTQpxWIZ5hzVPa0VJWT84R4HGCmQ6KG+E38LtPxbh YyX97U77NXs/mjWqM9AoSuGfwtprsZRj6VqmkHT5Mq5L0cLHlHSYx7gHqHic+dB5EQZ8 Pt7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iO5B4qK5; 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 f64sor75193204qtb.41.2019.01.10.09.51.56 for (Google Transport Security); Thu, 10 Jan 2019 09:51:56 -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=iO5B4qK5; 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=iO5B4qK5c4cEgpkYlHlzEeknhl6K2Ct9hrjHX84IN9+T6q8RyO12BUDqBLjAE2eG3v T44Haw/ATYzHFPwj3jf/pIizueHLkRkjxoNzFLnw3l0PB3htySXWVtwypMv4YNg600Dj CkEgHhUDwWEtCfmYXAlTJgY6fb+FmTEHz3sRQ= 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=2KcANZZu3B+b5HtApH0abXmIyTLE/qQis8j8nSO9A+k=; b=PRjoTk18q5F3kiRu1GY8aUmTnXEtw+OW87TzG8aJgWdjViVQH8fQPTk7gRn9CFt3a5 i5NJffvtYUkSp1WPeqR8V6yVzQ3JOdISjR1lO1YtoWgVEQwJqFeaZrRGopqprSOwyb9i mawlPSDP7mpLubit8VpS7NJQnF4yLdHpgej92Nm9Kac9s0a7IhZ/UO+t0UgU9SR49hQ5 2hTC0mUnjamsu99AoEaGcRdG4jLN+6TPIW5RkEJrLVzDhVj1ZMmhmTWzZoScckpsEb74 t5ge6xY4t81t2OWCOcVCD2xGyD5M/CZvK+W0zSIJrk5WooshyBDAphSnQvsZ26WBDcey Bc6w== X-Gm-Message-State: AJcUukeZQ8WtR441bUCJS3j81RIRiLd58U6DMkKVGpkMOi2DvTTcwRls ximgzzXFoyzcXfOcVnPsm5cpyq7G X-Google-Smtp-Source: ALg8bN4iCIly1RjudhxZ/Dsiplww/iEhpXxzUZNP0MsfxVtxR6wufdnUThIPC0w0yCIfiotzR89zqA== X-Received: by 2002:ac8:30ac:: with SMTP id v41mr10501410qta.51.1547142716725; Thu, 10 Jan 2019 09:51:56 -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 b8sm41815904qka.79.2019.01.10.09.51.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:51:56 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 03/17] ARM: 8791/1: vfp: use __copy_to_user() when saving VFP state Date: Thu, 10 Jan 2019 12:51:36 -0500 Message-Id: <20190110175150.5239-4-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-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 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);