Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6369488rwl; Mon, 9 Jan 2023 07:33:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1VbQLQR3Jxg+R5J52r1dywDNJ/LtY9lOzByi5dSzVHbkebxzb5rC+Dod2Qk19pdwuqLwd X-Received: by 2002:aa7:9e05:0:b0:582:7905:3030 with SMTP id y5-20020aa79e05000000b0058279053030mr30472790pfq.3.1673278390993; Mon, 09 Jan 2023 07:33:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673278390; cv=none; d=google.com; s=arc-20160816; b=Rwmr+IdeF1Uqp0yWaU0yM0EteQGuc1ve4CNujEMnevDYud+F3393N1fkIYLqikT7mm NaK4JECDUyGbWerr8McfLo6QAiKVDQvcdpghxXetrdnh0z9wpGkmXZzYkFRy6jFlS0Sp KMLfKkqGFDWSjSeQZ11E6CyKtA1In5IkDmNo4f7vbggxKaGEbR9z3ohjiWIJLUR7tmLK QJb8elD4hZFvaBuNYEtBX5/2pJ4l72gZKgstK6JTok9hWxF9FXHFNJ6acx/iuvZiPN77 P0Zh1GSfOupftZUxmKfimwCIBQIChc5fPfRxaVhXs+Z2ReTOKyJnL2GXX3QxNTundVrV +/fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=f4nomVRoCsc9GUqeoBFhY0eow9fFXNRDDHoKBG0FKZE=; b=gIRTEfUQaYvn30d7LoKkudYmIiOhLdb8AwPgWwAXZjw3dBHmf7MaK1Hf5CeJZVz886 iL1Q1o+CeCi5hlklqNjjPqkpMmRgTp8o0gjrjNTX8MpVaVL5cQYoBMbdOVZtmKf+17ld Zx1dYDDmfjHu0uq9HxG6Lb/RvBG4aE0Eanb489iCIQ9eUJiEAgXAoPsCupXTP3PNn48E pcVIfCCRwegu4t7GMsgmDnvVRPETCXrhimZnq40Q9amWgXzQNQSNwjbjpDO33vPBk+SK CI/Qvpfh2jsM7SLXPlmNh2y0tjP3zTYrYhVJJQiPuWuoghWCcjTTIuBxG+jwSzFDcMve yUEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QizTsEib; 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 k6-20020aa790c6000000b0056c37608f45si8672110pfk.348.2023.01.09.07.33.04; Mon, 09 Jan 2023 07:33:10 -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; dkim=pass header.i=@ventanamicro.com header.s=google header.b=QizTsEib; 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 S235258AbjAIOsJ (ORCPT + 53 others); Mon, 9 Jan 2023 09:48:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235041AbjAIOrq (ORCPT ); Mon, 9 Jan 2023 09:47:46 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25E91EAC6 for ; Mon, 9 Jan 2023 06:45:27 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id z5so7340131wrt.6 for ; Mon, 09 Jan 2023 06:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=f4nomVRoCsc9GUqeoBFhY0eow9fFXNRDDHoKBG0FKZE=; b=QizTsEib1Gz7Z0f2WIilfh/uo0XL7bV8O3B/m93vY5xO+Cu6BybzidsT4IiaLsPq72 vTxaM5IwgxexxggZDy2N3lXdIA8hGBBBQtPnUMmCbaE8OtlkN4tIPC1ptUeH+8e7B4yx 9Dsz5CPIavu4/OJpB/essGdiRKJvuNxKdgCHlb1jpRL1r548UhG19N3lKsrWEZZ3ppQl eRByWUhQ0jp2RXngN09RoLJKEZtermI83T0WR1FSvPp73I2oL4FPL3JEzQyJ2Wn1GAjO SGeJxHQmwdRM9P0LITCoYjtHMfSeuva8VgbOvbUwP8miAshCdR8aKoYhyTGeOumdHwrF UpOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=f4nomVRoCsc9GUqeoBFhY0eow9fFXNRDDHoKBG0FKZE=; b=D8aWJKX6D5hOJC3mufl8Ua/nu32vRnFoWscDrnBfA3X0WtcKYENs3vU42CWcBxwmbg ONVOhwObbDVIfGnaJzGb+kEmuk+031P3ZxeGttMKHz8qQtwUHMKzoKciQ998VGHpIstd IRelqfenPb2CVkQwWRoS92o+lV3dMDTQYj2TIQYNLRUt5ZAMd0l4NChm5ohwtoz90/QR k2MQ3rtFgflIfzzoM6E1j684uUQUEUJZooounh+b3hFi9Vkx2ObUl6jTttOLWyV01AkF r5p1VYtjZA4+HWYPmrRBvEV2z9CU5HWTjS+7AcuJOfDxKH6eW0Ae6eAJ013UVCRhiTjS A5pw== X-Gm-Message-State: AFqh2komzgs/xhbCF04pYOaZ7xme8FsDYcXFZgajDDTny8A1xhhQTstN ZR5n0p5pmtYL4mX7LcCgh3B20K2rh5DoaPgp X-Received: by 2002:adf:f3c9:0:b0:2bb:eb1d:bbb1 with SMTP id g9-20020adff3c9000000b002bbeb1dbbb1mr3064310wrp.7.1673275526508; Mon, 09 Jan 2023 06:45:26 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id e10-20020adfe38a000000b002bc7fcf08ddsm1389482wrm.103.2023.01.09.06.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 06:45:26 -0800 (PST) Date: Mon, 9 Jan 2023 15:45:25 +0100 From: Andrew Jones To: Sia Jee Heng Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, leyfoon.tan@starfivetech.com, mason.huo@starfivetech.com Subject: Re: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function Message-ID: <20230109144525.4xgnpeb6zcyyvx4j@orel> References: <20230109062407.3235-1-jeeheng.sia@starfivetech.com> <20230109062407.3235-3-jeeheng.sia@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230109062407.3235-3-jeeheng.sia@starfivetech.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 On Mon, Jan 09, 2023 at 02:24:06PM +0800, Sia Jee Heng wrote: > 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. > > Signed-off-by: Sia Jee Heng > Reviewed-by: Ley Foon Tan > Reviewed-by: Mason Huo > --- > arch/riscv/mm/pageattr.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > index 86c56616e5de..73fdec8c0a72 100644 > --- a/arch/riscv/mm/pageattr.c > +++ b/arch/riscv/mm/pageattr.c > @@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page) > p4d = p4d_offset(pgd, addr); > if (!p4d_present(*p4d)) > return false; > + if (p4d_leaf(*pud)) ^ p4d I guess you got lucky with the stack garbage in your testing. > + 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 > Thanks, drew