Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4518253rdh; Wed, 29 Nov 2023 03:56:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMOgMUUSs5HMxbPrVyKDwxt0AZR/xfJKJBquJS706j+PFanhB81xeCde6LHlYGCoyNjr3r X-Received: by 2002:a17:90b:1a88:b0:286:60c:349c with SMTP id ng8-20020a17090b1a8800b00286060c349cmr4420409pjb.11.1701258960965; Wed, 29 Nov 2023 03:56:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701258960; cv=none; d=google.com; s=arc-20160816; b=uHX8cOQhiDMzjoCcCj216i2EwOHv+gfvXUKsmepZqsp4vFqvZYYUfD6Sy7vFdR1MjI z3lB+tUFCGIRG3KuV0XdwuuMwHYigEYuKYtP348bT/l73ehqHtEd7q4thEeJJKE+pP3I lXVkhAZ+vJzK+8CoJvsQ3QKIAygz99JblVRB7aGzdoCWcRqHoon1cZlcUswwd1RR7wjr 4QhroFoYNAEGgH1B5EQgDeUTo5jYVHjPFVadT19E+gwYmzWwj9okgKeJ9MebuoGeMtO1 jFklohS5Dbtfct2GQTBo8keNPzMaLf4eA0oN9kv44LyS6E3x+wJ14T/x1GSXbDGOFJup Wx4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3HZBEdufaoAFivEtTbxTBKtmXrt0Zj5PyTeapCslDns=; fh=oVyZPWtm6mpH3d4qDAoXsAeagaN2dloHFHPyagpC8cc=; b=Ea68D/p+tBZ/CbIMjIEq8j8BtIFIB3wWAHpnpmZNSzSJNT3UEgudLPtjFTiR2UmsRl 7TFY0CYZfoYdtsHw/RaOUn8zrUCznzl69s25pveA+l1Ev76AesnJpgb/93HVeeemk5sb LRKG1TeRzDozxqNsfcGp+NjoumJEdETwAHRvdK3HOFqs6n+yEzbR7RccKKZsYVIqFD9I u4vIo5mwC4yCIKCkgem6tr/RprG6d9RbcHw6oeE4NQ2RkIKBMxLF539zkhSZp/iW9EnQ ayeW8QsuAeaz47ftwjmjFp1rOmoMcIMrOSEKIusDN8SbSk4gvo2/3PPIA6255Po5O0DR 5znw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s5-20020a17090ad48500b0026b71fdd505si1112491pju.177.2023.11.29.03.56.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:56:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BE9188031B3D; Wed, 29 Nov 2023 03:55:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbjK2Lzr (ORCPT + 99 others); Wed, 29 Nov 2023 06:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233429AbjK2Lzl (ORCPT ); Wed, 29 Nov 2023 06:55:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6417E1; Wed, 29 Nov 2023 03:55:47 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE3832F4; Wed, 29 Nov 2023 03:56:34 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 931583F5A1; Wed, 29 Nov 2023 03:55:42 -0800 (PST) Date: Wed, 29 Nov 2023 11:55:39 +0000 From: Alexandru Elisei To: David Hildenbrand Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, eugenis@google.com, kcc@google.com, hyesoo.yu@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2 19/27] mm: mprotect: Introduce PAGE_FAULT_ON_ACCESS for mprotect(PROT_MTE) Message-ID: References: <20231119165721.9849-1-alexandru.elisei@arm.com> <20231119165721.9849-20-alexandru.elisei@arm.com> <1c79ad05-cb52-4820-b2aa-bbe07ff82b19@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c79ad05-cb52-4820-b2aa-bbe07ff82b19@redhat.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:55:59 -0800 (PST) Hi, On Tue, Nov 28, 2023 at 06:55:18PM +0100, David Hildenbrand wrote: > On 19.11.23 17:57, Alexandru Elisei wrote: > > To enable tagging on a memory range, userspace can use mprotect() with the > > PROT_MTE access flag. Pages already mapped in the VMA don't have the > > associated tag storage block reserved, so mark the PTEs as > > PAGE_FAULT_ON_ACCESS to trigger a fault next time they are accessed, and > > reserve the tag storage on the fault path. > > That sounds alot like fake PROT_NONE. Would there be a way to unify hat Yes, arm64 basically defines PAGE_FAULT_ON_ACCESS as PAGE_NONE | PTE_TAG_STORAGE_NONE. > handling and simply reuse pte_protnone()? For example, could we special case > on VMA flags? > > Like, don't do NUMA hinting in these special VMAs. Then, have something > like: > > if (pte_protnone(vmf->orig_pte)) > return handle_pte_protnone(vmf); > > In there, special case on the VMA flags. Your suggestion from the follow-up reply that an arch should know if it needs to do something was spot on, arm64 can use the software bit in the translation table entry for that. So what you are proposing is this: * Rename do_numa_page->handle_pte_protnone * At some point in the do_numa_page (now renamed to handle_pte_protnone) flow, decide if pte_protnone() has been set for an arch specific reason or because of automatic NUMA balancing. * if pte_protnone() has been set by an architecture, then let the architecture handle the fault. If I understood you correctly, that's a good idea, and should be easy to implement. > > I *suspect* that handle_page_missing_tag_storage() stole (sorry :P) some Indeed, most of the code is taken as-is from do_numa_page(). > code from the prot_none handling path. At least the recovery path and > writability handling looks like it better be located shared in > handle_pte_protnone() as well. Yes, I agree. Thanks, Alex > > That might take some magic out of this patch. > > -- > Cheers, > > David / dhildenb >