Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1702490rwl; Wed, 29 Mar 2023 23:47:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/8ftrQ5OajUH/2d4xlg/j6sRr6Hih8cwjhW6GqNh4zgJoPTzlvamUEd+NsRljs+p+fgRt X-Received: by 2002:a05:6402:1e8e:b0:502:465:28e1 with SMTP id f14-20020a0564021e8e00b00502046528e1mr1539754edf.0.1680158839101; Wed, 29 Mar 2023 23:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680158839; cv=none; d=google.com; s=arc-20160816; b=roHBXZ9iijphe+yTpTP7E9Fz0ywfWNYSk4YM6P10F++biEwscb9D8EM8I2/bQio7Rh w+HSn8x3GnlGr/Asynt+S3udwLfbr4qSY9mffVEhb1EVRdEDr0VCMdDJtSqTwu1ALmGF 3F/ZlIXpsZaKkGM5jdvERKh6xzItr5RcxqirUWwvInfb6PyQg9bRN2I0kGQE+DFLY2rW ns9R4fieL6UvOFuNFIH4J58l6SORgxtc0kmMz9t3DmZn1bYM2pWlj/c3kuHQs+I1fJ+Q e3Vjo82sg4nocNCDbtqh6Y3Q3DK4g8f+lqIiw9DDdiIcwpjY2fo84VoFZ130QrL7oU8c SqxQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020aa7d444000000b00501db5ba638si23805623edr.6.2023.03.29.23.46.53; Wed, 29 Mar 2023 23:47:19 -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 S230156AbjC3Gnv 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 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