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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3314FC433F5 for ; Mon, 21 Mar 2022 16:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=ocCFKC0FI5L6savUSd5cXhL4IpWGROyjRtvfIGTUjLo=; b=3tYBhG47Khg/p+ GCh04tpfC60aSrbNqKyhnDPIBGAk7ocWy/IiM4EA+JsCINUMBwUWYqePQIE6PYOWk5gqCnpJPPa30 QfJvtxhH4YVz60PT+IhqRk9cY1YfFgSKNjJ3IRt3qhOoNEPVzEvxoB1HLheDZx+bZuJJi98QVbqIJ wYzUO/QfNqow6245QJOXaj6ykzyODQ7nFwoANGwq5WRP7VsSQ6FWnIwXRrz5kZ1bOvCHVt9gz7D1g yC31OIGTLrgwG3ImNeBv5aHBLRg7bgC8gGfEDNmG1nEoQuZ/+yJxMIuUZN/oLzK1wS1T3sFs//3wF cOqmdNKG9Bb3xTVgJ4hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWL5m-008POt-Np; Mon, 21 Mar 2022 16:41:14 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWL5i-008PNY-Uo; Mon, 21 Mar 2022 16:41:12 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 817AFB8189F; Mon, 21 Mar 2022 16:41:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A22EFC340F0; Mon, 21 Mar 2022 16:41:03 +0000 (UTC) Date: Mon, 21 Mar 2022 16:40:59 +0000 From: Catalin Marinas To: Tong Tiangen Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Pasha Tatashin , Andrew Morton , Will Deacon , Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH -next 3/4] arm64: mm: add support for page table check Message-ID: References: <20220317141203.3646253-1-tongtiangen@huawei.com> <20220317141203.3646253-4-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220321_094111_188781_9DED90A4 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 21, 2022 at 02:15:36PM +0800, Tong Tiangen wrote: > Considering all your suggestions, The final logic should be: > > +#define pte_user(pte) (!!(pte_val(pte) & PTE_USER)) > > +#define pmd_user(pmd) pte_user(pmd_pte(pmd)) > +#define pmd_user_exec(pmd) pte_user_exec(pmd_pte(pmd)) > > +#define pud_user(pud) pte_user(pud_pte(pud)) > > +static inline bool pte_user_accessible_page(pte_t pte) > +{ > + return pte_present(pte) && (pte_user(pte)|| pte_user_exec(pte)); > +} This is fine. > +static inline bool pmd_user_accessible_page(pmd_t pmd) > +{ > + return pmd_present(pmd) && (pmd_user(pmd)|| pmd_user_exec(pmd)); > +} That's fine as well assuming that the function is only called on the set_pmd_at() path where we know that the pmd would be a block mapping (huge page). I think that's the case from a quick look at the current x86 implementation. > +static inline bool pud_user_accessible_page(pud_t pud) > +{ > + return pud_present(pud) && pud_user(pud); > +} Same here. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel