Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2270034pxp; Mon, 21 Mar 2022 15:28:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwymaYJgwXM8I9S0p+SElhA2WBtRAnIeIi4o6ftpwxjuxbDTfXsOUABRkVTwyAkp1ax7BHK X-Received: by 2002:a17:903:3091:b0:153:9dcf:de71 with SMTP id u17-20020a170903309100b001539dcfde71mr14950761plc.7.1647901714976; Mon, 21 Mar 2022 15:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901714; cv=none; d=google.com; s=arc-20160816; b=IWOvUb0h1cdOBcYEhp1c8x+BkSIllR9fFCbl/AvtGWh7xeXYJ9kvqg1Z99osM1I1GX q2gl5bS4JMNyUrng4kCnXIOv7qYtrN4s7aEy2hE59i9o1mWTA3NZE6SwLRUpap+FX2i1 KIy+GwWnEwYYobXL1qSJs7ameeRvCdNnwYt91AqKLI8sof+5QPrFW/wm0YQ6erAxCEjE hlQOEE0QYfmlV0KimkZO8BTkmzyGE3BPqWZCaEyEOZ00zqGcjGQcUPBQPQUofqp2YmvA vdGpu/4fkIC954+h1l3HNDS3hIE0NQ406WsgrnESSh0SaiXnYJ7TFUn6So8RQi+7cbqT TCNw== 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=FOhZggdlSRS55jnNFtD+KycMgAyvMOIuq9+vwgwwSvc=; b=lphqoJXWA1/24c7rUv8Dq8rSJEqtTxIxMhseoBcg/2YjuhJRIPEWZIsR/mYTiqWylh bXbfPgw+PRZoohOUwX9ThD/njNey3E86rBFDQHLuJJhYxIhkqOevjclgP3QFwpeEvl0I +lhXhXu83NY57ZPUmGmr4l1UI0owkFfNMV1XDp1OIzI6XqA6xNOKYudUZt8vSDWZvkLT yvfHlI3IOXE45nxtor+nlFkdgkljCCsw2RfhH7Un/Fda5qsqwD7bYU13HMeZm6eoAovA j4vlJNL4b/yADY9yoFExrtQf4slY3u3jZaUxX3Eb31BP5JdtRw8PyOIoQT3gOp8OJb2t bW2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f2-20020a631f02000000b003816043ee5bsi14598963pgf.80.2022.03.21.15.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:28:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75B382986D9; Mon, 21 Mar 2022 14:42:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351326AbiCUQmg (ORCPT + 99 others); Mon, 21 Mar 2022 12:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244448AbiCUQmf (ORCPT ); Mon, 21 Mar 2022 12:42:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE7CD6CA72 for ; Mon, 21 Mar 2022 09:41:09 -0700 (PDT) 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 6646EB818A0 for ; 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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