From patchwork Tue Mar 14 05:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JeeHeng Sia X-Patchwork-Id: 69295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1576421wrd; Mon, 13 Mar 2023 22:30:34 -0700 (PDT) X-Google-Smtp-Source: AK7set+EN15uoVaj9G2VwBz5m1c+HifF67xEqahIF65f83UjOSVubhZHMiNUc6euupJ4E0j1oTsG X-Received: by 2002:a05:6a20:258a:b0:cb:7958:7071 with SMTP id k10-20020a056a20258a00b000cb79587071mr42900583pzd.19.1678771833909; Mon, 13 Mar 2023 22:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678771833; cv=none; d=google.com; s=arc-20160816; b=eQzepjCE6JnA9s5jC9KZyY/P3e4H3eM0jljBW+V25dyEcW13IjEcDchH/HNGpwxBFc ogcG5QuVJ1bPwO2X2VX7M3kVa2DzNl9AprSxZ80LhpXlh5D+pJZUXyJ6MO3AM401deC3 t3M8usCuixBnPhV2ngKOVgAwy7ZcnSQD/1rZ7AfKd0Tyu/5rLyptAXVdVBGNzHCcsKdD XgMSTNhj7VIpz4jtvpwtdJZFoAx4TttlMPrm4W0tNJDnZSOg0JADlLjG9UIOUn24ToJc DENzOtM1GHY1MF8urvKjDNPWWCqio0La1TrWAE5mj75n/ra7YT0rLrt3ecUhRaY7RF7A i6QQ== 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=AVkKS7LSh+qt3Hfhoid7GZtbk1K7FpnneljHTQROetipxlTnpWlRgi7lvY2FfsXSSe D3KUKLap3ElZ6kfG6x/lZxL86auAZFHHC5/UqgXJSW64VgxrJ2GTrVvX3FipOYqcYtty Hnt35kQIRk4dwoC07WAgVzgd/XL3+jQo7YYuZ2M0L3GVfBNMbQUQYWWoruMxy/LZd+U+ 60A9yNmTGzaxB/yJRt71yu7ld4CyGOagB8L1d9vxbev9N9RLq44lFJEBv6Rsl+0g7Emh 71XsujNehuW+ungHEzsSL+z3HMxu7TiY28Mtu2B8n1HMJqpr+V69qVyylxVxWbylCy7L qdHw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a056a00001000b00622b9204356si1376033pfk.204.2023.03.13.22.30.18; Mon, 13 Mar 2023 22:30:33 -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 S229909AbjCNFDv convert rfc822-to-8bit (ORCPT + 99 others); Tue, 14 Mar 2023 01:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjCNFDs (ORCPT ); Tue, 14 Mar 2023 01:03:48 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3509740FB for ; Mon, 13 Mar 2023 22:03:40 -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 ex01.ufhost.com (Postfix) with ESMTP id 577F024DBCE; Tue, 14 Mar 2023 13:03:37 +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; Tue, 14 Mar 2023 13:03:37 +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; Tue, 14 Mar 2023 13:03:33 +0800 From: Sia Jee Heng To: , , CC: , , , , , Andrew Jones , Alexandre Ghiti Subject: [PATCH v6 3/4] RISC-V: mm: Enable huge page support to kernel_page_present() function Date: Tue, 14 Mar 2023 13:03:15 +0800 Message-ID: <20230314050316.31701-4-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230314050316.31701-1-jeeheng.sia@starfivetech.com> References: <20230314050316.31701-1-jeeheng.sia@starfivetech.com> MIME-Version: 1.0 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760319854738803627?= X-GMAIL-MSGID: =?utf-8?q?1760319854738803627?= 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);