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.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 68ED1C433FF for ; Fri, 9 Aug 2019 14:10:26 +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 3BD3421743 for ; Fri, 9 Aug 2019 14:10:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fnc+J1mk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BD3421743 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.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:Date: Message-ID:References:To:Subject:From:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BMD01ODdiWFYuFyqYamdtmueSp3FDK0zS/rfz2AabHw=; b=fnc+J1mkKsLnib Gjpx90OD4bxJRKw7hOiC9oVD37ipwswMKAdRts/LJhBaBeSCvBggft8L5LLEbPBHIxgQ99Kqq2XSV dqhCq4lW+Kct2VBGiioO9DyICig9F2NpC18Lxmsc4QpguDLWCrnowwZsRtIJbj3OyY1ss8tn0eEsq qei3wVcSdMivdZ8gq4NhSLy6c5CCIsMFQcRytH/G908XbgTQckUr1ePcWdMazvncd+1eXNgyPsoT4 c+vPEK5McgKzpMowxqZNhnvKs90FhsoDUCHAnyx9+xDVNZ/Wi6ZjAAq+l6tw94HPlGRKpfgB3+Lr5 bzvlXBCwpUmer6pJJh3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hw5b7-00016F-N8; Fri, 09 Aug 2019 14:10:25 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hw5b4-00015b-Bx for linux-arm-kernel@lists.infradead.org; Fri, 09 Aug 2019 14:10:23 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 07:10:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="182917945" Received: from devajeet-mobl2.amr.corp.intel.com (HELO [10.251.27.22]) ([10.251.27.22]) by FMSMGA003.fm.intel.com with ESMTP; 09 Aug 2019 07:10:19 -0700 From: Dave Hansen Subject: Re: [PATCH v7 1/2] arm64: Define Documentation/arm64/tagged-address-abi.rst To: Catalin Marinas References: <20190807155321.9648-1-catalin.marinas@arm.com> <20190807155321.9648-2-catalin.marinas@arm.com> <826a9ace-feac-c019-843e-07e23c9fd46c@intel.com> <20190808172730.GC37129@arrakis.emea.arm.com> Openpgp: preference=signencr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PftcQvBCCYuhKbZV9s5hjt9qn8CE86A5g5KqDf83Fxqm/ vXKgHNFHE5zgXGZnrmaf6resQzbvJHO0Fb0CcIohzrpPaL3YepcLDoCCgElGMGQjdCcSQ+Ci FCRl0Bvyj1YZUql+ZkptgGjikQARAQABiQIfBBgBAgAJBQJUY85qAhsMAAoJEGg1lTBwyZKw l4IQAIKHs/9po4spZDFyfDjunimEhVHqlUt7ggR1Hsl/tkvTSze8pI1P6dGp2XW6AnH1iayn yRcoyT0ZJ+Zmm4xAH1zqKjWplzqdb/dO28qk0bPso8+1oPO8oDhLm1+tY+cOvufXkBTm+whm +AyNTjaCRt6aSMnA/QHVGSJ8grrTJCoACVNhnXg/R0g90g8iV8Q+IBZyDkG0tBThaDdw1B2l asInUTeb9EiVfL/Zjdg5VWiF9LL7iS+9hTeVdR09vThQ/DhVbCNxVk+DtyBHsjOKifrVsYep WpRGBIAu3bK8eXtyvrw1igWTNs2wazJ71+0z2jMzbclKAyRHKU9JdN6Hkkgr2nPb561yjcB8 sIq1pFXKyO+nKy6SZYxOvHxCcjk2fkw6UmPU6/j/nQlj2lfOAgNVKuDLothIxzi8pndB8Jju KktE5HJqUUMXePkAYIxEQ0mMc8Po7tuXdejgPMwgP7x65xtfEqI0RuzbUioFltsp1jUaRwQZ MTsCeQDdjpgHsj+P2ZDeEKCbma4m6Ez/YWs4+zDm1X8uZDkZcfQlD9NldbKDJEXLIjYWo1PH hYepSffIWPyvBMBTW2W5FRjJ4vLRrJSUoEfJuPQ3vW9Y73foyo/qFoURHO48AinGPZ7PC7TF vUaNOTjKedrqHkaOcqB185ahG2had0xnFsDPlx5y Message-ID: <68354acd-e205-71cb-11c6-74a150178ae0@intel.com> Date: Fri, 9 Aug 2019 07:10:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190808172730.GC37129@arrakis.emea.arm.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190809_071022_455143_F83E4173 X-CRM114-Status: GOOD ( 34.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, Szabolcs Nagy , Andrey Konovalov , Kevin Brodsky , Will Deacon , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org 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 8/8/19 10:27 AM, Catalin Marinas wrote: > On Wed, Aug 07, 2019 at 01:38:16PM -0700, Dave Hansen wrote: > Extending the interface is still possible even with the current > proposal, by changing arg2 etc. We also don't seem to be consistent in > sys_prctl(). We are not consistent because it took a long time to learn this lesson, but I think this is a best-practice that we follow for new ones. >> Also, shouldn't this be converted over to an arch_prctl()? > > What do you mean by arch_prctl()? We don't have such thing, apart from > maybe arch_prctl_spec_ctrl_*(). We achieve the same thing with the > {SET,GET}_TAGGED_ADDR_CTRL macros. They could be renamed to > arch_prctl_tagged_addr_{set,get} or something but I don't see much > point. Silly me. We have an x86-specific: SYSCALL_DEFINE2(arch_prctl, int , option, unsigned long , arg2) I guess there's no ARM equivalent so you're stuck with the generic one. > What would be better (for a separate patch series) is to clean up > sys_prctl() and move the arch-specific options into separate > arch_prctl() under arch/*/kernel/. But it's not really for this series. I think it does make sense for truly arch-specific features to stay out of the arch-generic prctl(). Yes, I know I've personally violated this in the past. :) >> What is the scope of these prctl()'s? Are they thread-scoped or >> process-scoped? Can two threads in the same process run with different >> tagging ABI modes? > > Good point. They are thread-scoped and this should be made clear in the > doc. Two threads can have different modes. > > The expectation is that this is invoked early during process start (by > the dynamic loader or libc init) while in single-thread mode and > subsequent threads will inherit the same mode. However, other uses are > possible. If that's the expectation, it would be really nice to codify it. Basically, you can't enable the feature if another thread is already been forked off. > That said, do we have a precedent for changing user ABI from the kernel > cmd line? 'noexec32', 'vsyscall' I think come close. With the prctl() > for opt-in, controlling this from the cmd line is not too bad (though my > preference is still for the sysctl). There are certainly user-visible things like being able to select various CPU features. >>> +When a process has successfully enabled the new ABI by invoking >>> +prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE), the following >>> +behaviours are guaranteed: >>> + >>> +- Every currently available syscall, except the cases mentioned in section >>> + 3, can accept any valid tagged pointer. The same rule is applicable to >>> + any syscall introduced in the future. >>> + >>> +- The syscall behaviour is undefined for non valid tagged pointers. >> >> Do you really mean "undefined"? I mean, a bad pointer is a bad pointer. >> Why should it matter if it's a tagged bad pointer or an untagged bad >> pointer? > > Szabolcs already replied here. We may have tagged pointers that can be > dereferenced just fine but being passed to the kernel may not be well > defined (e.g. some driver doing a find_vma() that fails unless it > explicitly untags the address). It's as undefined as the current > behaviour (without these patches) guarantees. It might just be nicer to point out what this features *changes* about invalid pointer handling, which is nothing. :) Maybe: The syscall behaviour for invalid pointers is the same for both tagged and untagged pointers. >>> +- prctl(PR_SET_MM, ``*``, ...) other than arg2 PR_SET_MM_MAP and >>> + PR_SET_MM_MAP_SIZE. >>> + >>> +- prctl(PR_SET_MM, PR_SET_MM_MAP{,_SIZE}, ...) struct prctl_mm_map fields. >>> + >>> +Any attempt to use non-zero tagged pointers will lead to undefined >>> +behaviour. >> >> I wonder if you want to generalize this a bit. I think you're saying >> that parts of the ABI that modify the *layout* of the address space >> never accept tagged pointers. > > I guess our difficulty in specifying this may have been caused by > over-generalising. For example, madvise/mprotect came under the same > category but there is a use-case for malloc'ed pointers (and tagged) to > the kernel (e.g. MADV_DONTNEED). If we can restrict the meaning to > address space *layout* manipulation, we'd have mmap/mremap/munmap, > brk/sbrk, prctl(PR_SET_MM). Did I miss anything?. Other related syscalls > like mprotect/madvise preserve the layout while only changing permissions, > backing store, so the would be allowed to accept tags. shmat() comes to mind. I also did a quick grep for mmap_sem taken for write and didn't see anything else obvious jump out at me. >> It looks like the TAG_SHIFT and tag size are pretty baked into the >> aarch64 architecture. But, are you confident that no future >> implementations will want different positions or sizes? (obviously >> controlled by other TCR_EL1 bits) > > For the top-byte-ignore (TBI), that's been baked in the architecture > since ARMv8.0 and we'll have to keep the backwards compatible mode. As > the name implies, it's the top byte of the address and that's what the > document above refers to. > > With MTE, I can't exclude other configurations in the future but I'd > expect the kernel to present the option as a new HWCAP and the user to > explicitly opt in via a new prctl() flag. I seriously doubt we'd break > existing binaries. So, yes TAG_SHIFT may be different but so would the > prctl() above. Basically, what you have is a "turn tagging on" and "turn tagging off" call which are binary: all on or all off. How about exposing a mask: /* Replace hard-coded mask size/position: */ unsigned long mask = prctl(GET_POSSIBLE_TAGGED_ADDR_BITS); if (mask == 0) // no tagging is supported obviously prctl(SET_TAGGED_ADDR_BITS, mask); // now userspace knows via 'mask' where the tag bits are _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel