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 38FC8C433EF for ; Mon, 21 Mar 2022 16:41:37 +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=vefXAQhzDT3xewbFW/9KcZTw31CUTdMKBWhKQfOdKWk=; b=YmZu+MX7BfcW6M SkbKasbctNLU3XVG+jnDvvD8v+XqVwoFKRu/O63Wazm5lEX9+jWu6p9TWaha9Fqha/BfYx4wNkk7Q eUFA/SWHsaeW3DpJPM46UMvchopZjcHTzn4W18YWkJl829uK3bqme1AJ/6fCoZnVuOLgdhdsC4wAO /pdeY4nIA19Iz68HUMQ0SIzJ4UeVWAjerZg9AU3PC32CJxktNLVjK9HZVhw6o4OKKcURaaEp3XZDE ige/rmRuVNZa9yEI5ef4rGZLb7vVudR2HCGJnK91SSEm6AknOLluHLHuI5VIPh6m+h01jsNSRanTP Nb4zhz3DVPVxBg1Fx3Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWL5v-008PRt-NF; Mon, 21 Mar 2022 16:41:23 +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-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv