From patchwork Wed Mar 8 08:06:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JeeHeng Sia X-Patchwork-Id: 66069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp205100wrd; Wed, 8 Mar 2023 00:19:17 -0800 (PST) X-Google-Smtp-Source: AK7set+nirFY/s0hfN+AUBbnGJBSykGqHZN42KDyl+IHORuT/Mv1NRVULynEcoG8avhst2ryjbsd X-Received: by 2002:a05:6a20:5487:b0:c6:d37c:2a62 with SMTP id i7-20020a056a20548700b000c6d37c2a62mr23670226pzk.11.1678263557174; Wed, 08 Mar 2023 00:19:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678263557; cv=none; d=google.com; s=arc-20160816; b=yzTyll9p1Qw+s/seSNzxWaS7PD16FRDx3ZItsga+7t3fxoy0KviV/+qQUddxXHmkAz z7H0tpXDjM0cxbaO8ToZ9a92s/DGldMl/4E8Fje8rKVSfZZvXRVQmwsG31Bv1dgSVKzB jNCJEBXPES3c6hFfCn6XS3QXdyNBdSGMEiXK6ZZmdPORS/WF/xZKxOMhpB7dKs0r400o o5VOgyHIn6B3/2uYIxOGLxCswMPD/m6jKUAzsXJUGhMTZmvuwSnNYV5JuOIX8XWncogt lfv89Fwp6dZYTtV17B/Oo1Wel+QHuFrXY21dTtwR9JGC7WlDCoedfRHFbzhGuruvX7tg sd7Q== 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=0W5lFyBJQ0+6LtyAuWZXobg55rkU2TpGBmwEruIjIAI=; b=OBK7ri69dID2K7kxR/rv5cFm/cgDe3d0PZWWT3LZAPx0dhsJnFujZRL5wfN4aHuWfM 2BSY5qSw2RpAhRqmtxTJ86hiQz5ieH8qNsc1ss5qw1+XnYU7ml7VxGrbRErSx9DO8ofb Q6xKB+QmZsTl6dJpsSdjvxf7676+9HaaMkvJJwvzCdGwXWktMDlG9vDoj0HjGimSPDBM Zs3hFwQp6bjo3yMG9bS53ou4XUofnMILcEDiPBFq/bcuCWOH88eoVY4dh2GOuB79aUlf X0reJcGjoGiTC5QnAYN0NM1muGPkQ6bifhKcYtKGAcWjzZTp06NAZ5a343IPdK1VuAT5 /fRA== 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 x13-20020a634a0d000000b004fc29a62bbbsi13798103pga.229.2023.03.08.00.19.04; Wed, 08 Mar 2023 00:19:17 -0800 (PST) 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 S229983AbjCHIGv convert rfc822-to-8bit (ORCPT + 99 others); Wed, 8 Mar 2023 03:06:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbjCHIGq (ORCPT ); Wed, 8 Mar 2023 03:06:46 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C2D9BE24 for ; Wed, 8 Mar 2023 00:06:37 -0800 (PST) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 3BC2B24E32C; Wed, 8 Mar 2023 16:06:35 +0800 (CST) Received: from EXMBX066.cuchost.com (172.16.7.66) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 8 Mar 2023 16:06:35 +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; Wed, 8 Mar 2023 16:06:32 +0800 From: Sia Jee Heng To: , , CC: , , , , , Andrew Jones , Alexandre Ghiti Subject: [PATCH v5 3/4] RISC-V: mm: Enable huge page support to kernel_page_present() function Date: Wed, 8 Mar 2023 16:06:11 +0800 Message-ID: <20230308080612.122398-4-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308080612.122398-1-jeeheng.sia@starfivetech.com> References: <20230308080612.122398-1-jeeheng.sia@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [202.188.176.82] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX066.cuchost.com (172.16.6.66) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,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?1759786888054776775?= X-GMAIL-MSGID: =?utf-8?q?1759786888054776775?= 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);