From patchwork Thu Mar 30 06:43:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JeeHeng Sia X-Patchwork-Id: 76911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp925886vqo; Wed, 29 Mar 2023 23:59:44 -0700 (PDT) X-Google-Smtp-Source: AKy350blGE2Ut3mx46rpjs/xd9LTGiFJhbN6NGCeNkxdmm+L8PUfGVfQ81GFyc7tEmGGnd1jtHm4 X-Received: by 2002:a17:907:3f97:b0:93f:505b:9742 with SMTP id hr23-20020a1709073f9700b0093f505b9742mr21783206ejc.65.1680159583844; Wed, 29 Mar 2023 23:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680159583; cv=none; d=google.com; s=arc-20160816; b=K3qAtcDh6vFu+9XLhPhp3T0faGgqUYgcXqoC6hz2/6I7faZ9X2YlF5pnZacB6ka8UV PhzqpTS8/MaNLhZPDBRYR480MKDp3eK1AMNNCvmtwZoz/09eJer5751AbCWm5EofD0uk lN3RIRQ9RO1OCgw33Z/qKejvyemLtFIUPE7eRJhbLNKEv2kRKglEhEV8W/kzEe9BkH+X O5X1KV9hqRB/yA9NnkgC2gjVxjfQX0vnVrlKkW8KUjD8+1hsdKfKyEW6T+0OXfuIo0P6 +Ac0WhQK5JUfu2BmgAnmUe3PLOOUyLVv9UInLvSNxH8nqY5e1qtjXbupjY00n97L6DSz EOxw== 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=o1bQN6nR/sU7EEz1/6BPawoH8y6MAqdWi347AqwxVjoQSnz34vHqCDu9Hq/PJ9RU9N 1T9O2kEGJCfrSWF0z4AcsBX9rmlpDF8jImvy5nWxwy7VN54GFHShvLb0GNcF5dXCqAbV 6pZ0WSSuOkLuRZmZKBUbKOq+XaJNle/RTq3CaF7a+Kf1CH5wAimQFgWvYyMeWgEhdgyK ZYjqjw3/a0i0Rt2WWq0BHKHum0fGWxyu4cEdeHQjqtCcJW0HutJ2/mCN1xCyxak/DLze /MvjJ5btgCnltcDdNYaIXxY/sT0OuSrJGI1n/GWtNCzAkz90o0k2d/K/dMSP2BVQj7bU jnhA== 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 hu19-20020a170907a09300b0093d16dd337csi16818080ejc.290.2023.03.29.23.59.19; Wed, 29 Mar 2023 23:59:43 -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 S229852AbjC3Gnv convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Mar 2023 02:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjC3Gnp (ORCPT ); Thu, 30 Mar 2023 02:43:45 -0400 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17BEC46AA for ; Wed, 29 Mar 2023 23:43:44 -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 F0BB424E2EE; Thu, 30 Mar 2023 14:43:41 +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, 30 Mar 2023 14:43:41 +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, 30 Mar 2023 14:43:38 +0800 From: Sia Jee Heng To: , , CC: , , , , , Andrew Jones , Alexandre Ghiti Subject: [PATCH v8 3/4] RISC-V: mm: Enable huge page support to kernel_page_present() function Date: Thu, 30 Mar 2023 14:43:20 +0800 Message-ID: <20230330064321.1008373-4-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330064321.1008373-1-jeeheng.sia@starfivetech.com> References: <20230330064321.1008373-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=-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761775016121964813?= X-GMAIL-MSGID: =?utf-8?q?1761775016121964813?= 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);