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=-8.5 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable 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 C4F1FC28CC6 for ; Tue, 4 Jun 2019 12:38:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CCC2240B7 for ; Tue, 4 Jun 2019 12:38:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bUBMnyfB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CCC2240B7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p/SPXJdUOjklgu4SWzRRdkwI5daSiCIk7CvTjGVBvS8=; b=bUBMnyfB9fDd7v Lo0hXCSrUROYwJe2wBArUZTsAXNr/Z+7yd9xBaboNmplVRHGiX6KzjqSKHAQNNf4DPjDzekw9lqYl LVt41J6ldyKKvoKfwh0PcVfNGOipl3uU97gK3Ld6oR2KMzDZh0XejweR9tgzoUBBHekIAxxtcyHi6 5ygAKnwmKiRe+9WLMdVvcoI4jDzsEA7lWl+3KA1evzXPQr2VwmZU0oij5leoRAAw0RWbLZmnAGeyq KoMA0BpJI8ksHxP8A5PEy79KiQoxOVGWLI5kVoraZidoekSrypoY40AJPfQc7CTR4HhG5FY6R35li yVMSGX0EWnhccPkLlmXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY8hf-0002nS-Q7; Tue, 04 Jun 2019 12:38:11 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY8hd-0002mi-6z for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2019 12:38:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 623BCA78; Tue, 4 Jun 2019 05:38:08 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A86153F690; Tue, 4 Jun 2019 05:38:02 -0700 (PDT) Date: Tue, 4 Jun 2019 13:38:00 +0100 From: Catalin Marinas To: Jason Gunthorpe Subject: Re: [PATCH v2] uaccess: add noop untagged_addr definition Message-ID: <20190604123759.GA6610@arrakis.emea.arm.com> References: <20190604122841.GB15385@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190604122841.GB15385@ziepe.ca> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_053809_265569_F30D852D X-CRM114-Status: GOOD ( 23.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Szabolcs Nagy , Will Deacon , linux-mm@kvack.org, Khalid Aziz , sparclinux@vger.kernel.org, Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , Christoph Hellwig , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Ramana Radhakrishnan , Robin Murphy , Alex Williamson , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , linux-kernel@vger.kernel.org, Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Linus Torvalds , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 04, 2019 at 09:28:41AM -0300, Jason Gunthorpe wrote: > On Tue, Jun 04, 2019 at 02:04:47PM +0200, Andrey Konovalov wrote: > > Architectures that support memory tagging have a need to perform untagging > > (stripping the tag) in various parts of the kernel. This patch adds an > > untagged_addr() macro, which is defined as noop for architectures that do > > not support memory tagging. The oncoming patch series will define it at > > least for sparc64 and arm64. > > > > Acked-by: Catalin Marinas > > Reviewed-by: Khalid Aziz > > Signed-off-by: Andrey Konovalov > > include/linux/mm.h | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 0e8834ac32b7..dd0b5f4e1e45 100644 > > +++ b/include/linux/mm.h > > @@ -99,6 +99,17 @@ extern int mmap_rnd_compat_bits __read_mostly; > > #include > > #include > > > > +/* > > + * Architectures that support memory tagging (assigning tags to memory regions, > > + * embedding these tags into addresses that point to these memory regions, and > > + * checking that the memory and the pointer tags match on memory accesses) > > + * redefine this macro to strip tags from pointers. > > + * It's defined as noop for arcitectures that don't support memory tagging. > > + */ > > +#ifndef untagged_addr > > +#define untagged_addr(addr) (addr) > > Can you please make this a static inline instead of this macro? Then > we can actually know what the input/output types are supposed to be. > > Is it > > static inline unsigned long untagged_addr(void __user *ptr) {return ptr;} > > ? > > Which would sort of make sense to me. This macro is used mostly on unsigned long since for __user ptr we can deference them in the kernel even if tagged. So if we are to use types here, I'd rather have: static inline unsigned long untagged_addr(unsigned long addr); In addition I'd like to avoid the explicit casting to (unsigned long) and use some userptr_to_ulong() or something. We are investigating in parallel on how to leverage static checking (sparse, smatch) for better tracking these conversions. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel