From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCD1DC6778A for ; Sun, 8 Jul 2018 21:04:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74E9C208AF for ; Sun, 8 Jul 2018 21:04:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="PfA+Lh0k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74E9C208AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933056AbeGHVDr (ORCPT ); Sun, 8 Jul 2018 17:03:47 -0400 Received: from mail.efficios.com ([167.114.142.138]:42078 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932365AbeGHVDl (ORCPT ); Sun, 8 Jul 2018 17:03:41 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id CACCB1C3ADD; Sun, 8 Jul 2018 17:03:40 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id znr5AuU1WhSu; Sun, 8 Jul 2018 17:03:40 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 47CC71C3AD2; Sun, 8 Jul 2018 17:03:40 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 47CC71C3AD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1531083820; bh=grB4IpJiSr9n+UJ08TJzKY/JEvxNQiRaLKNetIJn5/c=; h=From:To:Date:Message-Id; b=PfA+Lh0kacX/s66JnH3CiExJtqdQGXmFDPNv8Kb0daEUhdbKWMK+39j9JE0uuBzBb 1mr+PGp2huqWPUQMdUnEiQb4H1DYwdnxge271325giVj70TB09nyFaawHKuVgZq0N2 vw7/ZnXKFeldoJDsPEA//P1F0vW+jkDBYdsbnaehdDvlH+ET3h4pz5uNh2qMjs7Wb1 74EL8XdKMkkRPz37wMLph6oLOIrcM+n1zdgCUHEbxqJniXb3L1BSDl1D2CLCio7w0X QjVshsXV8thBlZdTshj0CVUevZSYz/THxzP4os/JzDXKERua45xd+RuBjMOUpdWx9E Yq7HlH+Z6+DEA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id 1oZ25BROWF1n; Sun, 8 Jul 2018 17:03:40 -0400 (EDT) Received: from thinkos.etherlink (cable-192.222.247.4.electronicbox.net [192.222.247.4]) by mail.efficios.com (Postfix) with ESMTPSA id CE5431C3AC2; Sun, 8 Jul 2018 17:03:39 -0400 (EDT) From: Mathieu Desnoyers To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H . Peter Anvin" , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Mathieu Desnoyers , Andrew Hunter , linux-arm-kernel@lists.infradead.org Subject: [PATCH for 4.18 2/6] rseq: use get_user/put_user rather than __get_user/__put_user Date: Sun, 8 Jul 2018 17:03:26 -0400 Message-Id: <20180708210330.27324-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180708210330.27324-1-mathieu.desnoyers@efficios.com> References: <20180708210330.27324-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to use __u64 for the rseq_cs pointer field, 32-bit architectures need to read this 64-bit value located in user-space addresses. __get_user is used to read this value, given that its access check has already been performed with access_ok() on rseq registration. arm does not implement 8-byte __get_user. Rather than trying to improve __get_user on ARM, use get_user/put_user across rseq instead. If those end up showing up in benchmarks, the proper approach would be to use user_access_begin() / unsafe_get/put_user() / user_access_end() anyway. Signed-off-by: Mathieu Desnoyers CC: Thomas Gleixner Cc: Joel Fernandes Cc: Peter Zijlstra Cc: Catalin Marinas Cc: Dave Watson Cc: Will Deacon Cc: Andi Kleen Cc: "H . Peter Anvin" Cc: Chris Lameter Cc: Russell King Cc: Andrew Hunter Cc: Michael Kerrisk Cc: "Paul E . McKenney" Cc: Paul Turner Cc: Boqun Feng Cc: Josh Triplett Cc: Steven Rostedt Cc: Ben Maurer Cc: linux-api@vger.kernel.org CC: linux-arm-kernel@lists.infradead.org Cc: Andy Lutomirski Cc: Andrew Morton Cc: Linus Torvalds --- kernel/rseq.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/rseq.c b/kernel/rseq.c index 16b38c5342f9..2c8463acb50d 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -85,9 +85,9 @@ static int rseq_update_cpu_id(struct task_struct *t) { u32 cpu_id = raw_smp_processor_id(); - if (__put_user(cpu_id, &t->rseq->cpu_id_start)) + if (put_user(cpu_id, &t->rseq->cpu_id_start)) return -EFAULT; - if (__put_user(cpu_id, &t->rseq->cpu_id)) + if (put_user(cpu_id, &t->rseq->cpu_id)) return -EFAULT; trace_rseq_update(t); return 0; @@ -100,14 +100,14 @@ static int rseq_reset_rseq_cpu_id(struct task_struct *t) /* * Reset cpu_id_start to its initial state (0). */ - if (__put_user(cpu_id_start, &t->rseq->cpu_id_start)) + if (put_user(cpu_id_start, &t->rseq->cpu_id_start)) return -EFAULT; /* * Reset cpu_id to RSEQ_CPU_ID_UNINITIALIZED, so any user coming * in after unregistration can figure out that rseq needs to be * registered again. */ - if (__put_user(cpu_id, &t->rseq->cpu_id)) + if (put_user(cpu_id, &t->rseq->cpu_id)) return -EFAULT; return 0; } @@ -120,7 +120,7 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs) u32 sig; int ret; - ret = __get_user(ptr, &t->rseq->rseq_cs); + ret = get_user(ptr, &t->rseq->rseq_cs); if (ret) return ret; if (!ptr) { @@ -163,7 +163,7 @@ static int rseq_need_restart(struct task_struct *t, u32 cs_flags) int ret; /* Get thread flags. */ - ret = __get_user(flags, &t->rseq->flags); + ret = get_user(flags, &t->rseq->flags); if (ret) return ret; @@ -203,7 +203,7 @@ static int clear_rseq_cs(struct task_struct *t) * * Set rseq_cs to NULL with single-copy atomicity. */ - return __put_user(0UL, &t->rseq->rseq_cs); + return put_user(0UL, &t->rseq->rseq_cs); } /* -- 2.11.0