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 X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A499C433EF for ; Fri, 24 Sep 2021 05:11:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 104836103B for ; Fri, 24 Sep 2021 05:11:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 104836103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A4FED6B0071; Fri, 24 Sep 2021 01:11:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FEE86B0073; Fri, 24 Sep 2021 01:11:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C8BA6B0074; Fri, 24 Sep 2021 01:11:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 7C8856B0071 for ; Fri, 24 Sep 2021 01:11:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 34C2B8249980 for ; Fri, 24 Sep 2021 05:11:40 +0000 (UTC) X-FDA: 78621294360.14.1DAA8FE Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf20.hostedemail.com (Postfix) with ESMTP id C2898D0000A6 for ; Fri, 24 Sep 2021 05:11:39 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id CEF686103D for ; Fri, 24 Sep 2021 05:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632460298; bh=JBV4wUFyqvPA6JDZml2Lwl/RV5UFuo9v+vAuM5LVucY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j80bLqbdwj6oiiWU8WnCjOw3HOzFrrmbAdCfE5aEyAKKlCpPsmBiFZUOXQY+9UxzA TqalUSxaWGb4pmcfVObstlK4q2tG/PAPSlG6TlbZODBngLcZlZey8eI6QX9kIQ6Cue yQtQ8sjm0XG2qnnBJoIr44ltIGuRAqfH1WWZxTOyiKiYsZStJ5DxiztMBfNmxjg+Hr jEJV7zQrIBlsAXK6gvbUkPpkGswDADgxcsbN09YbTwgyvfHCZP0Yel4iydh2Olg1hP j8wiu/WORKahVtka/Nps7Jy0liD2HTLT2MRA9Ehbc7mafPRfO3trMVB9kVr5hEOp4b yH3h6mBGiLfkA== Received: by mail-vs1-f50.google.com with SMTP id n17so8773283vsr.10 for ; Thu, 23 Sep 2021 22:11:38 -0700 (PDT) X-Gm-Message-State: AOAM530qHJLx4vLqNoP4NXVlyPMB15sObgakkFvU0pzjiIFHOCpB08fZ YqWB8+FYl0O43p/8F1g6uqL+cNpZybc13l5ybuc= X-Google-Smtp-Source: ABdhPJz+S3tx4XKSaFcdk5DOBZ+n2y4iQ1eHTFWFhE8ShvQuPpGoOE+wZv3Et1SRJ1s2sVBvACtsgwzusjcKF55m7o4= X-Received: by 2002:a67:2f96:: with SMTP id v144mr7718145vsv.33.1632460298043; Thu, 23 Sep 2021 22:11:38 -0700 (PDT) MIME-Version: 1.0 References: <20210921201815.284412-1-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Fri, 24 Sep 2021 13:11:27 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm: debug_vm_pgtable: Don't use __P000 directly To: Anshuman Khandual Cc: Andrew Morton , Linux-MM , Linux Kernel Mailing List , Guo Ren Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: C2898D0000A6 X-Stat-Signature: 9a6qihs5n48d9exsrzepe7zj9n7obex5 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=j80bLqbd; spf=pass (imf20.hostedemail.com: domain of guoren@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=guoren@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-HE-Tag: 1632460299-462763 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 Fri, Sep 24, 2021 at 11:30 AM Anshuman Khandual wrote: > > Hello Guo, > > On 9/22/21 1:48 AM, guoren@kernel.org wrote: > > From: Guo Ren > > > > The __Pxxx/__Sxxx macros are only for init protection_map[]. All > > s/init protection_map[]/protection_map[] int/ ^^^ Okay, protection_map[] init > > Or rephrase with something similar. > > > usage of them in linux should come from protection_map array. > > Agreed. > > > > > Becasue a lot of architectures would re-initilize protection_map[] > > s/Becasue/Because/ > > ./scripts/checkpatch.pl ./0001-mm-debug_vm_pgtable-Don-t-use-__P000-directly.patch > WARNING: 'Becasue' may be misspelled - perhaps 'Because'? > #9: > Becasue a lot of architectures would re-initilize protection_map[] > ^^^^^^^ > > total: 0 errors, 1 warnings, 15 lines checked I would use checkpatch.pl next time, thx. > > > array, eg: x86-mem_encrypt, m68k-motorola, mips, arm, sparc. > > > > Using __P000 maybe won't cause bug because hw would deny access > > Not very clear. Could you please rephrase. Using __P000 directly wouldn't equal protection_map[0] in many arches, but the reason why it didn't cause the problem is the hardware ignores the other bits when prot-attribute is denied. > > > with PROT_NONE permission, but it's not rigorous. > > Agreed. > > > > > Signed-off-by: Guo Ren > > Cc: Andrew Morton > > --- > > mm/debug_vm_pgtable.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > > index 1403639302e4..a6ebbf6e53dd 100644 > > --- a/mm/debug_vm_pgtable.c > > +++ b/mm/debug_vm_pgtable.c > > @@ -1104,13 +1104,13 @@ static int __init init_args(struct pgtable_debug_args *args) > > /* > > * Initialize the debugging data. > > * > > - * __P000 (or even __S000) will help create page table entries with > > + * __P000 (protection_map[0]) will help create page table entries with > > Please just replace __P000 and __S000 with protection_map[0] and > protection_map[8] respectively. Also reformat this comment section > if required. > > > * PROT_NONE permission as required for pxx_protnone_tests(). > > */ > > memset(args, 0, sizeof(*args)); > > args->vaddr = get_random_vaddr(); > > args->page_prot = vm_get_page_prot(VMFLAGS); > > - args->page_prot_none = __P000; > > + args->page_prot_none = protection_map[0]; > > args->is_contiguous_page = false; > > args->pud_pfn = ULONG_MAX; > > args->pmd_pfn = ULONG_MAX; > > > > With the above changes in place. > > Reviewed-by: Anshuman Khandual -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/