Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3464612pxb; Mon, 4 Apr 2022 17:50:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynvrUgc63c3j8sn+yQ0VBcwBnCpFhwWHZ30/pXIRo2WYcsJgwfNWxjpOEfLpHt4y6P46JU X-Received: by 2002:a17:90b:1d0e:b0:1c9:b74e:494 with SMTP id on14-20020a17090b1d0e00b001c9b74e0494mr1030840pjb.238.1649119809326; Mon, 04 Apr 2022 17:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649119809; cv=none; d=google.com; s=arc-20160816; b=VAt+/v8X0i5e7+Wdr4Oi8jtAxDp1smyPsrjSYn+W6+UQERk+bYk0YHOXgGOKKBEq4N kix0w3Pk3D4r2CrPE8SFxUj2OJR7et0un/m1xbnvHkGOiZorStQ6viZ12pqFhcbaDV+h rAZccZl0+YPl5V3pTd0y1hRB3qDnb5GaD5jIsmLvLSNAfqLXT2THLeX/fb1LIY8zopln KFyyQEgoczx710kzIfLIeGJmFo5ZttUuKVopFt1dbFc1v283SmpgiJW5gSHHw6KF04D4 LJg3NUqOVsdUEUxAR5vZh48xqQBE6ZiCWelTBUVYyUVDShkZYhXnAK3CHS4MIsS/yCbR 87IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YtiA3j+Jjk+cRpnnye85M/L835dWOB1YY5+Bh2TLaU4=; b=ta7zP/CkAfIW0g7ByWFEn54q3HhejvwD+rwuQJLvPMF0CD8DVMd/cJZW56fE+29An/ 0h7HyGdR2IwXzEy49arNvB1SnWVaYNZToxrKpbXuEggzTeeINnGngqlNi0q5q+76LyNj aYp5YqKJ9Qoc4VTsgL3Xx7dt1hLuDgA0tm0vVPw1K49vEDxxIy1VPS/73zVKMJ4zq1AR GVFtcvL6YZfXliykmY4e7omf1UagAJ7+4MAJaqLwfbRAwSgzh1gkz+thFVPg+kq/3/BC M3TJPnUnh5giH7C9TIQUIXIwwuha2t3l7xWau0SQYywFYZj4ryRNifq3HRUf9lAJxY7y +mbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xb0eErFS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b13-20020a63e70d000000b003816043f11bsi11303683pgi.784.2022.04.04.17.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:50:09 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Xb0eErFS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 710E0B7CD; Mon, 4 Apr 2022 16:59:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353668AbiDDJWH (ORCPT + 99 others); Mon, 4 Apr 2022 05:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241357AbiDDJWF (ORCPT ); Mon, 4 Apr 2022 05:22:05 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB377765F for ; Mon, 4 Apr 2022 02:20:07 -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 sin.source.kernel.org (Postfix) with ESMTPS id 4E134CE0F24 for ; Mon, 4 Apr 2022 09:20:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35249C2BBE4; Mon, 4 Apr 2022 09:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649064004; bh=HmQZ2Vn2Y/xndkTASq4gy6DwwGvg1neZwy0UTPq1zR8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xb0eErFS+ZwWKjgJMvXwUIsFSRgYAnKfU6QvOjUn+lR9Sqi3Vq39Mozf1PW6Tkv1N kggOxEhkEzRzxkAgEV6Kr9Ar6Sa+uWD5oz6n2F3B4Hx6vkbAyHpaUM59k/EjELNCOy ERsIT64hG40CgDfDTKBd99WfOuv+FA91+6M26MNr9jlB2quYtm8HNtwsl+QksABg4L 65CTmHN/Tf/4Om9ZEk33rG2oYkqnh878QxwMEV7+kbIg0Wte7CZRVE8qZv4URraDCj s+Rpz1bYfuDDevIc142CUFq1FD1Qo8HqxFq153uoZh7Us63oFBKTWUMr5T30T/84Ov eNo5UzQ5KdOKQ== Date: Mon, 4 Apr 2022 10:19:58 +0100 From: Will Deacon To: Muchun Song Cc: catalin.marinas@arm.com, akpm@linux-foundation.org, anshuman.khandual@arm.com, aneesh.kumar@linux.ibm.com, steven.price@arm.com, lengxujun2007@126.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, smuchun@gmail.com, duanxiongchun@bytedance.com, Qian Cai Subject: Re: [PATCH] arm64: mm: fix pmd_leaf() Message-ID: <20220404091957.GA22790@willie-the-truck> References: <20220403024928.4125-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220403024928.4125-1-songmuchun@bytedance.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sun, Apr 03, 2022 at 10:49:28AM +0800, Muchun Song wrote: > The pmd_leaf() is used to test a leaf mapped PMD, however, it misses > the PROT_NONE mapped PMD on arm64. Fix it. A real world issue [1] > caused by this was reported by Qian Cai. > > Link: https://patchwork.kernel.org/comment/24798260/ [1] > Fixes: 8aa82df3c123 ("arm64: mm: add p?d_leaf() definitions") > Reported-by: Qian Cai > Signed-off-by: Muchun Song > --- > arch/arm64/include/asm/pgtable.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 94e147e5456c..09eaae46a19b 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -535,7 +535,7 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, > PMD_TYPE_TABLE) > #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ > PMD_TYPE_SECT) > -#define pmd_leaf(pmd) pmd_sect(pmd) > +#define pmd_leaf(pmd) (pmd_present(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT)) > #define pmd_bad(pmd) (!pmd_table(pmd)) > > #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE) A bunch of the users of pmd_leaf() already check pmd_present() -- is it documented that we need to handle this check inside the macro? afaict x86 doesn't do this either. Will