From patchwork Thu Mar 23 04:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JeeHeng Sia X-Patchwork-Id: 73801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2725043wrt; Wed, 22 Mar 2023 22:05:10 -0700 (PDT) X-Google-Smtp-Source: AK7set/2rr9i7vuEJg9+dWKKCPDgVy6mwDETH1QzRbaL8UxVYxOcP6sD1v7ATFiI8KQl9HudxRb8 X-Received: by 2002:a17:906:c790:b0:880:a42d:dfb4 with SMTP id cw16-20020a170906c79000b00880a42ddfb4mr9414484ejb.16.1679547909971; Wed, 22 Mar 2023 22:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679547909; cv=none; d=google.com; s=arc-20160816; b=Rqe3yTbkzy0SayEJXoD7DzbfXAMpgXdi/GP8rfa129wbDoCRf/uh6iZt9tUTpcLNse P+k0jCi6jG2f+DO6wJSEXxYyrFvCLKPCcbpVKBVxxY016q39/Z7sY8k99Cn3IS0T59FP 8TgKcTGM2QU+Z0vOwc0P6c+DtcS9qBATc40FaQTTTHwcXqe82PeYLlTlrtLxlobhL5MH RHbQF/HPkZc7nLVw3YXau33gu7jewOcB+fSthOezQXBrYRTgn9U5p0lD6KWM6hQIfymN O9cAZzTDPknXMeiR9YMKsBZb8S70kszNPxKn5eKFflkeXPzoY/8Cwy1NRHuMoYCyV1Tm aUrg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020a17090632d400b009310372301csi9378709ejk.626.2023.03.22.22.04.31; Wed, 22 Mar 2023 22:05:09 -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 S230056AbjCWE4j 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 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?1761133629359228481?= X-GMAIL-MSGID: =?utf-8?q?1761133629359228481?= 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);