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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED 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 81D63C5CFE7 for ; Mon, 9 Jul 2018 17:28:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3089D20864 for ; Mon, 9 Jul 2018 17:28:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="qFnKS/gj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3089D20864 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 S933985AbeGIR2v (ORCPT ); Mon, 9 Jul 2018 13:28:51 -0400 Received: from mail.efficios.com ([167.114.142.138]:51680 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933479AbeGIR2t (ORCPT ); Mon, 9 Jul 2018 13:28:49 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id BB98B231E67; Mon, 9 Jul 2018 13:28:48 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id pepZt0NiptLG; Mon, 9 Jul 2018 13:28:47 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 88C2D231E62; Mon, 9 Jul 2018 13:28:47 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 88C2D231E62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1531157327; bh=LgNTDtuqO0zQmGszxKog9yEF3mbujrQ9ubishaLzyLU=; h=Date:From:To:Message-ID:MIME-Version; b=qFnKS/gjzHR6gskjV+n7+3KKS48yDCM53iLsc3WFWbLQoGu4AmmPjRJfUga2bSPFR 7pHI5wlHRiNQBz10vJrLpo6eMrUI277ZCymKcrXws3saJUq1d7mgAYsl4bJ5hgS7KP G01loCou7XMxpXprgTV0J90Avmx3+68mJMhogBXxV1oXDg6zT5P5hoZlEujMbOTMD+ BIq2Dv9dPDI0DHFoV5lkK9wLp/cDUxSCb4OQqH7i4B4mPkjP/gsy5dZCRBv+VRtT0w Qe+o3OvKsxgGbjgrToJowGlGl4XCrbJP0VwUgqO6sZe75Czbh/S9ZUs4r8y0Vw77/2 VokP9EiARoEhg== 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 7NXI3Vbaa_YQ; Mon, 9 Jul 2018 13:28:47 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 6BB65231E5A; Mon, 9 Jul 2018 13:28:47 -0400 (EDT) Date: Mon, 9 Jul 2018 13:28:47 -0400 (EDT) From: Mathieu Desnoyers To: Thomas Gleixner Cc: linux-kernel , linux-api , 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 , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Andrew Hunter , linux-arm-kernel Message-ID: <854203778.2272.1531157327328.JavaMail.zimbra@efficios.com> In-Reply-To: <20180708210330.27324-3-mathieu.desnoyers@efficios.com> References: <20180708210330.27324-1-mathieu.desnoyers@efficios.com> <20180708210330.27324-3-mathieu.desnoyers@efficios.com> Subject: Re: [PATCH for 4.18 2/6] rseq: use get_user/put_user rather than __get_user/__put_user MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2096 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_1703) Thread-Topic: rseq: use get_user/put_user rather than __get_user/__put_user Thread-Index: iEYeEpnymP9svAGg5g0+upWV4iKVgQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jul 8, 2018, at 5:03 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: > 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. So, another twist to this story: ppc32 does not implement u64 get_user(). I am tempted to ditch this patch (leaving the __get_user()/__put_user as is for 32-bit accesses), and simply use __copy_from_user()/__copy_to_user() to load/store the rseq_cs pointer. Considering that we don't need to load/store the rseq_cs field with single-copy atomicity from the kernel anymore, it should be fine. Any objection ? tree: https://git.kernel.org/pub/scm/linux/kernel/git/rseq/linux-rseq.git rseq/dev head: a100323919af0c11a150a9ba58c3f8ac986ea42d commit: 23d0f99d280fa97ebcf8b915157468f457bc6e11 [4/21] rseq: uapi: declare rseq_cs field as union, update includes config: powerpc-ppc6xx_defconfig (attached as .config) compiler: powerpc-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 23d0f99d280fa97ebcf8b915157468f457bc6e11 # save the attached .config to linux build tree GCC_VERSION=7.2.0 make.cross ARCH=powerpc All errors (new ones prefixed by >>): kernel/rseq.o: In function `__rseq_handle_notify_resume': >> (.text+0x648): undefined reference to `__get_user_bad' --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation Thanks, Mathieu > > 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 -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com