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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE2CDC433EF for ; Tue, 5 Apr 2022 08:15:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DAC36B0071; Tue, 5 Apr 2022 04:14:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48AE76B0073; Tue, 5 Apr 2022 04:14:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3793E6B0074; Tue, 5 Apr 2022 04:14:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id 25D0F6B0071 for ; Tue, 5 Apr 2022 04:14:50 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C431818353709 for ; Tue, 5 Apr 2022 08:14:39 +0000 (UTC) X-FDA: 79322113878.24.5337246 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 173411A002B for ; Tue, 5 Apr 2022 08:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yTl7CnxscX3tM8Q2WvPQUxdf1oA0EUFe77KHAeexXLo=; b=guHAxSDl6KUIlPMY1ymkDtNzkp MSAuTErMX9PQeS+yG/hoG1AhcfFZPtqdmtXOvqnNUMaRhmQcl+1lgOKocA8nxjxYx/TLCQsLFf4QZ ZKjjyVPtCDHtZlzcndhBvZmStUOlGq2Iq/bagX5h7UbargEmGMfuEPRAMzdhhKTHKIBsV6LJx2Hlu hiWTUUHKTRtUGbt15qMEAqbY4pyc26FTuMMKm0LUwB4MhqsHUsNwsnAmHYeJn7hO4HOmCJkAA+wsN C+F5y6g3+d1bi6SyvKmi8oTjxJNWtVrwlzKOARg3fO4dgoKT92dGz02nVz2V9stsu/uAs1U3dNjgU 97fbqbvw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbeKa-006UbN-7s; Tue, 05 Apr 2022 08:14:28 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id CF2B2986B5B; Tue, 5 Apr 2022 10:14:27 +0200 (CEST) Date: Tue, 5 Apr 2022 10:14:27 +0200 From: Peter Zijlstra To: Bharata B Rao Cc: Andy Lutomirski , Linux Kernel Mailing List , linux-mm@kvack.org, the arch/x86 maintainers , "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Catalin Marinas , Will Deacon , shuah@kernel.org, Oleg Nesterov , ananth.narayan@amd.com Subject: Re: [RFC PATCH v0 0/6] x86/AMD: Userspace address tagging Message-ID: <20220405081427.GD30877@worktop.programming.kicks-ass.net> References: <20220310111545.10852-1-bharata@amd.com> <6a5076ad-405e-4e5e-af55-fe2a6b01467d@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 173411A002B X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=guHAxSDl; dmarc=none; spf=none (imf19.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=peterz@infradead.org X-Stat-Signature: i466cu656b5tha13if3xhaiks1kxiow8 X-HE-Tag: 1649146478-887123 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Mar 23, 2022 at 01:18:41PM +0530, Bharata B Rao wrote: > On 3/22/2022 3:59 AM, Andy Lutomirski wrote: > > I hate to be a pain, but I'm really not convinced that this feature > > is suitable for Linux. There are a few reasons: > > > > Right now, the concept that the high bit of an address determines > > whether it's a user or a kernel address is fairly fundamental to the > > x86_64 (and x86_32!) code. It may not be strictly necessary to > > preserve this, but violating it would require substantial thought. > > With UAI enabled, kernel and user addresses are, functionally, > > interleaved. This makes things like access_ok checks, and more > > generally anything that operates on a range of addresses, behave > > potentially quite differently. A lot of auditing of existing code > > would be needed to make it safe. > > Ok got that. However can you point to me a few instances in the current > kernel code where such assumption of high bit being user/kernel address > differentiator exists so that I get some idea of what it takes to > audit all such cases? The fact that you have to ask and can't readily find them should be a big honking clue on its own, no? Anyway, see here: arch/x86/events/perf_event.h:static inline bool kernel_ip(unsigned long ip) arch/x86/events/perf_event.h:{ arch/x86/events/perf_event.h:#ifdef CONFIG_X86_32 arch/x86/events/perf_event.h: return ip > PAGE_OFFSET; arch/x86/events/perf_event.h:#else arch/x86/events/perf_event.h: return (long)ip < 0; arch/x86/events/perf_event.h:#endif arch/x86/events/perf_event.h:}