All of lore.kernel.org
 help / color / mirror / Atom feed
From: julien.thierry@arm.com (Julien Thierry)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/9] ARM: signal: always use __copy_to_user to save iwmmxt context
Date: Mon, 10 Sep 2018 11:42:41 +0100	[thread overview]
Message-ID: <1536576168-40096-3-git-send-email-julien.thierry@arm.com> (raw)
In-Reply-To: <1536576168-40096-1-git-send-email-julien.thierry@arm.com>

When setting a dummy iwmmxt context, create a local instance and
use __copy_to_user both cases whether iwmmxt is being used or not.
This has the benefit of disabling/enabling PAN once for the whole copy
intead of once per write.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
---
 arch/arm/kernel/signal.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 76fe75d..464393d 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -77,8 +77,6 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame)
 		kframe->magic = IWMMXT_MAGIC;
 		kframe->size = IWMMXT_STORAGE_SIZE;
 		iwmmxt_task_copy(current_thread_info(), &kframe->storage);
-
-		err = __copy_to_user(frame, kframe, sizeof(*frame));
 	} else {
 		/*
 		 * For bug-compatibility with older kernels, some space
@@ -86,10 +84,14 @@ static int preserve_iwmmxt_context(struct iwmmxt_sigframe __user *frame)
 		 * Set the magic and size appropriately so that properly
 		 * written userspace can skip it reliably:
 		 */
-		__put_user_error(DUMMY_MAGIC, &frame->magic, err);
-		__put_user_error(IWMMXT_STORAGE_SIZE, &frame->size, err);
+		*kframe = (struct iwmmxt_sigframe) {
+			.magic = DUMMY_MAGIC,
+			.size  = IWMMXT_STORAGE_SIZE,
+		};
 	}
 
+	err = __copy_to_user(frame, kframe, sizeof(*kframe));
+
 	return err;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2018-09-10 10:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 10:42 [PATCH v3 0/9] ARM: spectre-v1.1 mitigations Julien Thierry
2018-09-10 10:42 ` [PATCH v3 1/9] ARM: signal: copy registers using __copy_to_user() Julien Thierry
2018-09-10 10:42 ` Julien Thierry [this message]
2018-09-10 10:42 ` [PATCH v3 3/9] ARM: vfp: use __copy_to_user() when saving VFP state Julien Thierry
2018-09-10 10:42 ` [PATCH v3 4/9] ARM: oabi-compat: copy oabi events using __copy_to_user() Julien Thierry
2018-09-10 10:42 ` [PATCH v3 5/9] ARM: signal: replace __put_user_error with __put_user Julien Thierry
2018-09-10 10:42 ` [PATCH v3 6/9] ARM: uaccess: Prevent speculative use of the current addr_limit Julien Thierry
2018-09-10 10:42 ` [PATCH v3 7/9] ARM: spectre-v1.1: use put_user() for __put_user() Julien Thierry
2018-09-10 10:42 ` [PATCH v3 8/9] ARM: spectre-v1, v1.1: provide helpers for address sanitization Julien Thierry
2018-09-10 10:42 ` [PATCH v3 9/9] ARM: spectre-v1.1: harden __copy_to_user Julien Thierry
2018-09-10 16:35 ` [PATCH v3 0/9] ARM: spectre-v1.1 mitigations Russell King - ARM Linux
2018-09-11  9:18   ` Julien Thierry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536576168-40096-3-git-send-email-julien.thierry@arm.com \
    --to=julien.thierry@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.