Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp229539ybh; Tue, 17 Mar 2020 22:02:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu9RlR7wrV1GGqM1xUjYmRvlzK+GaZjzLsLPFySu12S9SUPiuRj0kM/aUVaskWN+E9IVmSw X-Received: by 2002:aca:c6d1:: with SMTP id w200mr1736148oif.43.1584507758374; Tue, 17 Mar 2020 22:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584507758; cv=none; d=google.com; s=arc-20160816; b=HF7op+dHImZDDS2Rieu+4RZGmKHNLIDmofIheTf+IPiIX6h3P3saSHc3VJ2BMdVSke 9FLUBNzEa8O1lBX3ooEJqIDyOVM3pyGWvrfCTiqRBnUAg6XPY746w9Qx2x9nNsGKrbBj smawBZZ+/Gv9WvIaXNer7KanPjbZBMmD3vJwxjX2lYqfd17tuh34NdOqVM/muhBedyt4 +9f+cyOYqzzryOG2k9iH3C5qGJl5wI8uMoTOi5H8slJc5rtuY7mnF+U1GTIhm9SNXkT4 AmSHEmjRY/SDmNdysjNIT2hnAg38IlIk/ssAJcplyMFGCPQu2xm8/unYPKalptOQUInp s3rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=FjmcdjjpmD4z8tQGvtL2D8qUMmmPxn/QCaaaJIZ72Lo=; b=EspIQqzR6eFa6vvB14VonolsZ3pdrIjCbrNgNKO6C5ENPfwudTW470Mmnhx1ux0F6J mtNgEFyRTDX9PAHCn+JopRHfGDfS7Q3cuL6XYZPgeueM20if2ZrzuAqTvLpvtPuXGV60 jKjmqun+TQekvEeLoBQhjm/Fe91iUmvzV3lweykHYAOZohs9Be/m1y0GOMNRtpUaULRt 9REwySUJpOwSNgx0Z3pWKM0BwXiwb119LSrIa8toFGrA8dB0h5NHM3fi9nn8z9UCgE1b Ufl8pbGeav2EgtgMMKKe10TsyKILUfMRAJqBCow7vnhnYpdF5p2eU59BeYl5qJlprBjO e7Jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si2751415oti.106.2020.03.17.22.02.10; Tue, 17 Mar 2020 22:02:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726596AbgCRFBn (ORCPT + 99 others); Wed, 18 Mar 2020 01:01:43 -0400 Received: from foss.arm.com ([217.140.110.172]:45564 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbgCRFBn (ORCPT ); Wed, 18 Mar 2020 01:01:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C26D1FB; Tue, 17 Mar 2020 22:01:42 -0700 (PDT) Received: from p8cg001049571a15.arm.com (unknown [10.163.1.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7D0353F67D; Tue, 17 Mar 2020 22:01:38 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , Andrew Morton , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/mm: Make pud_present() check _PAGE_PROTNONE and _PAGE_PSE as well Date: Wed, 18 Mar 2020 10:31:19 +0530 Message-Id: <1584507679-11976-1-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pud_present() should also check _PAGE_PROTNONE and _PAGE_PSE bits like in case pmd_present(). This makes a PUD entry test positive for pud_present() after getting invalidated with pud_mknotpresent(), hence standardizing the semantics with PMD helpers. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Dave Hansen Cc: Andrew Morton Cc: x86@kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- Even though pud_mknotpresent() is not used any where currently, there is a discrepancy between PMD and PUD. WARN_ON(!pud_present(pud_mknotpresent(pud_mkhuge(pud)))) -> Fail WARN_ON(!pmd_present(pmd_mknotpresent(pmd_mkhuge(pmd)))) -> Pass Though pud_mknotpresent() currently clears _PAGE_PROTNONE, pud_present() does not check it. This change fixes both inconsistencies. This has been build and boot tested on x86. arch/x86/include/asm/pgtable.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 7e118660bbd9..8adf1d00b506 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -857,7 +857,13 @@ static inline int pud_none(pud_t pud) static inline int pud_present(pud_t pud) { - return pud_flags(pud) & _PAGE_PRESENT; + /* + * Checking for _PAGE_PSE is needed too because + * split_huge_page will temporarily clear the present bit (but + * the _PAGE_PSE flag will remain set at all times while the + * _PAGE_PRESENT bit is clear). + */ + return pud_flags(pud) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE); } static inline unsigned long pud_page_vaddr(pud_t pud) -- 2.17.1