Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3111723rwi; Tue, 11 Oct 2022 19:05:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MjC87KqtFa7Gog0OPA3cDKXEazYTKr1BENFbBIbPPOnxYEoonDal3MT7cj7PU14aLfnGU X-Received: by 2002:a05:6402:2791:b0:45c:2675:7fe4 with SMTP id b17-20020a056402279100b0045c26757fe4mr11222246ede.409.1665540348368; Tue, 11 Oct 2022 19:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665540348; cv=none; d=google.com; s=arc-20160816; b=zGaxB0e7wLmT3NRUaVoU3GcOUGdNKekbDVWPJ4ZliIhacwPz2nhL6kbJGheSDjEZ0e 62UxsI0KCzO9rf32UazOyRrk+ayuj1bcr3Ym/Ohy4roreZCrEO5OUL5uecnqsVtyAQwp OyYpwag+LTsGhZJXdQS5Y7r8NfiUNdK+TTROwAgT8sGykFxMxit6xQ6MguU1aeROO7zA pzYK68VORGn5aWClTPWrsbKhjc2q8N1R0PK9JcKrWAQkB3Zihvbk3JaRg/wAXf9KsXaA nkvTA9L03ShcxA4F9sGgBVIl9Vu5m4bS0n/havovQjN/6cG0mEC8nv1OSktsxPU0NhJM wUvw== 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 :message-id:date:subject:cc:to:from; bh=6yEF/MVttpehIgNqcWVdzImam4XjW69Zhgj8gTLpBDo=; b=I+ot8yR16MWFtXPUwp696B7F84y92qQw90pMTHtcTKXa1oSCweUUQUljY6XRNkTb63 G8SRxfpXD+tad7+Zm88XU8ez1zl1QHt8wCwtB1XjbSknGIuvMkPXyQ06QXYZdEIiJVYL 8lPcia0P9THt0vP75BWPygeqgCYPnLUk9TsPfd/jDHXVMm0gmibAXbu++O++pWHlpYfS omTGvvGhl7pq3TYrvlLHnyLZnO3+yquopWn2CaEFn993JaS/lGbqik4tLoKBbBAxZjK9 M2viDaWuo9YxAK4D6sm+SCHoFLX6IGCAbhVfBVklsVAxV8yTKzi8enAxEkcNM+GR9x/d nb5A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz1-20020a1709072ce100b0073db512d918si16542130ejc.765.2022.10.11.19.05.15; Tue, 11 Oct 2022 19:05:48 -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 S229505AbiJLB6t (ORCPT + 99 others); Tue, 11 Oct 2022 21:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbiJLB6r (ORCPT ); Tue, 11 Oct 2022 21:58:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED802A346A for ; Tue, 11 Oct 2022 18:58:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 88B8F612A3 for ; Wed, 12 Oct 2022 01:58:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E56EFC433C1; Wed, 12 Oct 2022 01:58:43 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, Huacai Chen Subject: [PATCH] LoongArch: Flush TLB earlier at initialization Date: Wed, 12 Oct 2022 09:57:07 +0800 Message-Id: <20221012015707.2139728-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Move local_flush_tlb_all() earlier (just after setup_ptwalker() and before page allocation). This can avoid stale TLB entries misguiding the later page allocation. Without this patch the second kernel of kexec/kdump fails to boot SMP. BTW, move output_pgtable_bits_defines() into tlb_init() since it has nothing to do with tlb handler setup. Signed-off-by: Huacai Chen --- arch/loongarch/mm/tlb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/mm/tlb.c b/arch/loongarch/mm/tlb.c index 9818ce11546b..da3681f131c8 100644 --- a/arch/loongarch/mm/tlb.c +++ b/arch/loongarch/mm/tlb.c @@ -258,7 +258,7 @@ extern long exception_handlers[VECSIZE * 128 / sizeof(long)]; void setup_tlb_handler(int cpu) { setup_ptwalker(); - output_pgtable_bits_defines(); + local_flush_tlb_all(); /* The tlb handlers are generated only once */ if (cpu == 0) { @@ -301,6 +301,7 @@ void tlb_init(int cpu) write_csr_pagesize(PS_DEFAULT_SIZE); write_csr_stlbpgsize(PS_DEFAULT_SIZE); write_csr_tlbrefill_pagesize(PS_DEFAULT_SIZE); + setup_tlb_handler(cpu); - local_flush_tlb_all(); + output_pgtable_bits_defines(); } -- 2.31.1