From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4859C433F5 for ; Fri, 15 Apr 2022 04:56:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244898AbiDOE61 (ORCPT ); Fri, 15 Apr 2022 00:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349688AbiDOE4b (ORCPT ); Fri, 15 Apr 2022 00:56:31 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A303710F0 for ; Thu, 14 Apr 2022 21:53:59 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id r18so8420985ljp.0 for ; Thu, 14 Apr 2022 21:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=v2IHx3Qbgo3wM3/tOigomzLjD7v6BY2hlPBqUcu4Brs=; b=WA645uXAq8uzUS58O9L0qm/3eEl4U6ZixnBiBCalf+eeTjC0p1XzE35Hpdh3fSz7EP kJRdvPJh3nArYX64LSaxJzsjCvanYkoy8PSp1MIdZEiv4VQy9hpg6qGP67f3bL4KIrJP SmqDH5NJWUrqNQpA+cNWQBAzvl0s6I/RNCPasYC2exyDC/PQTZOVFnsMW1qO1QckF9Cr eIcYPbks3kAh38ZjN5Vho//fz/T2IRS8PqXCeuafNtB9T4TZhmWc+WJvfEYA1qckvmOd JH1bhDpCCoPjyMXC8Msbnys+CCm6OSoe3KMcODvaawDKtmyoRRNRzW3xEi1SsTK7O0Tk e79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=v2IHx3Qbgo3wM3/tOigomzLjD7v6BY2hlPBqUcu4Brs=; b=W24sj/9oCEBeNxdibtx4kMVC7EgZgjKlVG5xy5uaDap44Cx2aZiN2LbSWziYHpO8PZ Rc71dS/WnJhqf3gi3yKRxdPU8IMshVxPsswBHalyzWFCBBFHDThkBL80PEXdXii+4kNz Wt64tdyN6QBgvq185CForoR+WheQ0y76H8NHgZPPaZmrZdFg8CetUHd4AhrVnkQNv9KX n7pir9IeU3XXvVeiMDmpyluJJ5c3V18S65JK5iHO7ZjUZ+d6m28n3nyd8GO78Z5RlsXf WSvzkGCf9R+vddRE3WFj2CphU5zof9ngj/1ZE9vKsmBUIDlr6JgO2CJzL04GPPc9+1Nf ZN/Q== X-Gm-Message-State: AOAM531j/aPoaLE0uNYiSvsBHCZcPlekYay1yPTgCZm/PKOJpHgN5crv 932hALU5cnJD8gOfZ+5DrpwwO3IUsVvWJ64HmL4Z3w== X-Google-Smtp-Source: ABdhPJyMKLAknTpEqNiOsM8G4x8qCf78+X/p03s7TvJlmBITtJTWR0D+rx0cBX1ozLuRUjW1hvSeuesOng3qFvVZeTo= X-Received: by 2002:a2e:b6c3:0:b0:249:9b61:656f with SMTP id m3-20020a2eb6c3000000b002499b61656fmr3441389ljo.266.1649998437283; Thu, 14 Apr 2022 21:53:57 -0700 (PDT) MIME-Version: 1.0 References: <20220412033335.1384230-1-apatel@ventanamicro.com> <4c4c7a.17284.1802b8c14cc.Coremail.panqinglin2020@iscas.ac.cn> In-Reply-To: <4c4c7a.17284.1802b8c14cc.Coremail.panqinglin2020@iscas.ac.cn> From: Anup Patel Date: Fri, 15 Apr 2022 10:23:44 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: mm: Fix set_satp_mode() for platform not having Sv57 To: =?UTF-8?B?5r2Y5bqG6ZyW?= Cc: Palmer Dabbelt , Paul Walmsley , Alexandre Ghiti , Atish Patra , Alistair Francis , Anup Patel , linux-riscv , "linux-kernel@vger.kernel.org List" , Mayuresh Chitale Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 15, 2022 at 10:18 AM =E6=BD=98=E5=BA=86=E9=9C=96 wrote: > > Hi Anup, > > > > > When Sv57 is not available the satp.MODE test in set_satp_mode() wil= l > > fail and lead to pgdir re-programming for Sv48. The pgdir re-program= ming > > will fail as well due to pre-existing pgdir entry used for Sv57 and = as > > a result kernel fails to boot on RISC-V platform not having Sv57. > > > > To fix above issue, we should clear the pgdir memory in set_satp_mod= e() > > before re-programming. > > > > Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly") > > Reported-by: Mayuresh Chitale > > Signed-off-by: Anup Patel > > --- > > arch/riscv/mm/init.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > > index 9535bea8688c..b0793dc0c291 100644 > > --- a/arch/riscv/mm/init.c > > +++ b/arch/riscv/mm/init.c > > @@ -718,6 +718,7 @@ static __init void set_satp_mode(void) > > if (!check_l4) { > > disable_pgtable_l5(); > > check_l4 =3D true; > > + memset(early_pg_dir, 0, PAGE_SIZE); > > goto retry; > > } > > disable_pgtable_l4(); > > -- > > > I find it that the set_satp_mode function is in .init.text section which = begins at 0x80800000. > And its pgd_index in both Sv48 and Sv57 will be 0. So it may not be neces= sary to clear the > early_pg_dir when the kernel find Sv57 is not supported? And may I get th= e steps of reproduction > from you? We can't assume that it will be the same pgd_index for Sv48 and Sv57. For example, some hypothetical SoC might have RAM starting after 1TB space. We should ensure that early_pg_dir is cleaned entirely for detecting the ne= xt mode. Regards, Anup > > Yours, > Qinglin >