Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7087089rwl; Wed, 22 Mar 2023 21:59:02 -0700 (PDT) X-Google-Smtp-Source: AK7set8JRWoRIvw0lzHkBt3BHp2rQUmL0nigAC1M2w7NTxi29lLJJejD8nPuSeopzb8obUdeRubv X-Received: by 2002:a17:907:7e8e:b0:922:cb10:ad06 with SMTP id qb14-20020a1709077e8e00b00922cb10ad06mr10901304ejc.43.1679547541979; Wed, 22 Mar 2023 21:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679547541; cv=none; d=google.com; s=arc-20160816; b=OdGHjy5R5xf2ozogm3M16imcGbM78ewhGvREnLZduuzz9jSsKEg9bTq7hTm0uMtEec 9srMx6wq4fVty6Ujw6Z6tzQEmEuRkfq587Qu05jbUIx7pEFCre8JxRD8kBBYI80Ew4yt ZriGUk/ZwoxPH+4OXHbGS3aurDqtpN2UPrId9HUKRP8FiSauIiseNdZWIAmloO5d3MTS TJCAtTUj3B9N+HmgVG9WizIJzeX+sQolQQK93QNb1qzK3uUBjSL91hOzicNJyso1rmkF kSbYQ4DCptEBUTh7BgrjCygQgYb6QkHiQbhmdUFSEbRk9yEGkSMgr2LKNWqWwRKMrsqs mICw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=i0CRmpxjI5qUa12ZWFk/wKxrupLACfmaobZUHYYLg68=; b=rvLHfI5T0zeNcyVp33PbWAlQcumPISI4y0T1AMDrv8ZmBnqXqZ70me+BYJ3ly4qrDC P49ciRJIG7885SI9ZOgL+HwQG0f9nLp75g9PNUrptKk8//hPIQT6/ySmYsVAu+4GzZUQ yt1dBgH7ukSScr4uIjX/iUuQnIR0a/dVFLTAVRQ+kpmPmTFJVkMq2Q0lwdvIL6RWt1cW 16YhYaCHyTwMpAhqLEIMi6yT/OwFihlVcxOEOsiU+esTtbKliozXUxS422JA0eO6CL3Z FtgT6R3sNvFFqR6FdZLa+tgF0/sp470WJX1G10qSCANX5QU6DPKaFEFknjfbWqc+ZSN1 C7HA== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dy19-20020a05640231f300b005020ef37a34si675186edb.175.2023.03.22.21.58.37; Wed, 22 Mar 2023 21:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbjCWE4j convert rfc822-to-8bit (ORCPT + 99 others); Thu, 23 Mar 2023 00:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjCWE42 (ORCPT ); Thu, 23 Mar 2023 00:56:28 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B0D42A982 for ; Wed, 22 Mar 2023 21:56:27 -0700 (PDT) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 795F224E3E3; Thu, 23 Mar 2023 12:56:25 +0800 (CST) Received: from EXMBX066.cuchost.com (172.16.7.66) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 23 Mar 2023 12:56:25 +0800 Received: from jsia-virtual-machine.localdomain (202.188.176.82) by EXMBX066.cuchost.com (172.16.6.66) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 23 Mar 2023 12:56:21 +0800 From: Sia Jee Heng To: , , CC: , , , , , Andrew Jones , Alexandre Ghiti Subject: [PATCH v7 3/4] RISC-V: mm: Enable huge page support to kernel_page_present() function Date: Thu, 23 Mar 2023 12:56:03 +0800 Message-ID: <20230323045604.536099-4-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230323045604.536099-1-jeeheng.sia@starfivetech.com> References: <20230323045604.536099-1-jeeheng.sia@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [202.188.176.82] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX066.cuchost.com (172.16.6.66) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS 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 Currently kernel_page_present() function doesn't support huge page detection causes the function to mistakenly return false to the hibernation core. Add huge page detection to the function to solve the problem. Fixes: 9e953cda5cdf ("riscv: Introduce huge page support for 32/64bit kernel") Signed-off-by: Sia Jee Heng Reviewed-by: Ley Foon Tan Reviewed-by: Mason Huo Reviewed-by: Andrew Jones Reviewed-by: Alexandre Ghiti --- arch/riscv/mm/pageattr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c index 86c56616e5de..ea3d61de065b 100644 --- a/arch/riscv/mm/pageattr.c +++ b/arch/riscv/mm/pageattr.c @@ -217,18 +217,26 @@ bool kernel_page_present(struct page *page) pgd = pgd_offset_k(addr); if (!pgd_present(*pgd)) return false; + if (pgd_leaf(*pgd)) + return true; p4d = p4d_offset(pgd, addr); if (!p4d_present(*p4d)) return false; + if (p4d_leaf(*p4d)) + return true; pud = pud_offset(p4d, addr); if (!pud_present(*pud)) return false; + if (pud_leaf(*pud)) + return true; pmd = pmd_offset(pud, addr); if (!pmd_present(*pmd)) return false; + if (pmd_leaf(*pmd)) + return true; pte = pte_offset_kernel(pmd, addr); return pte_present(*pte); -- 2.34.1