Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp41622lfe; Fri, 15 Apr 2022 18:29:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu8BscyUmplBEIf3ebh02l4/eUPCYUcgxnSPvwQWqAiWnXHLzPlfVJLxpdQqL4+x54kBtV X-Received: by 2002:a65:468d:0:b0:399:24bb:fdad with SMTP id h13-20020a65468d000000b0039924bbfdadmr1280012pgr.396.1650072550055; Fri, 15 Apr 2022 18:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650072550; cv=none; d=google.com; s=arc-20160816; b=xvzm6lXG2BglWhHd1HkpQEHox327onj/TE8w73gnaUf/h7dOXLXpBr9NqDI70HmXEv 5Y1NkGukaYqnWtZXTQOpm7z1jaAKRdzUxGdXRq7sUB0KniCS133YUW3GEcX43sHZgyUd P5bVlXQh41/85ZAp4i5F8t+fZ5Ur3h3vdg1emHzcQ9URfHcwN24jxJ86t2Tvt8ttiZEv /nXr4knPQTaUGOdS5sRnJtHazefZcxkw8n95/+IJcYijbP1vts/EsTV4KpNQIQGbA2BY RtJJFPgLypi0CAY4cO/03TzSzBIfQ7APrAoHO9edJSu5jEfQf8cOOLFEHYdzCuw58z6c rung== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=v2IHx3Qbgo3wM3/tOigomzLjD7v6BY2hlPBqUcu4Brs=; b=CVxNE2x2s4rpE3lEYs0L9x0u76egIwdEBz+KAv0TMkQD07Z1XipO5mwUohb5xBjEKd DDN5VSPZsdAVt3bMNJz/POM+lV7UypXEIxtDaPRttA/rQmgQxbJA95YoWO+OaShmC8n4 USiZGbrk1lpgP6nA+zXjSaRRJrlTbekiZVoljhZVCMDgRfS6j+HzWGw0pmLL2ESPO/Pa sZGv12J9mQi5+ahA+cGhGjEGnuqNINeiDYq0YTTz+BXWemM0r4OYclzgkJ4E23O8C7cK osPmcSwKG/12KTng4QLd0HPWY9izWZDFbXYugDBFN9KPPSULMm8iZW1fJ7AXZqSsGLCH AhVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WA645uXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q14-20020a63cc4e000000b0039d2d535554si2702918pgi.630.2022.04.15.18.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:29:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WA645uXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A097E149D11; Fri, 15 Apr 2022 17:59:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349676AbiDOE6W (ORCPT + 99 others); Fri, 15 Apr 2022 00:58:22 -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-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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 >