Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp231196lqo; Tue, 7 May 2024 19:25:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjKL+BpP+8rENtAi8m2rELX1ZXJPWL2scHuwwLeGqER5IX/UKGIhEoSAx6dnfCw3nzJAqTR5VNqBvfDw3ICHErFYyhJJmEHfLU2r5Law== X-Google-Smtp-Source: AGHT+IE/CwMrG6cBBGU4W4xtNIWxl2xK1TlL7Gm6kmaincv53aASKio+uWLDBeeNMooonfIB8qOV X-Received: by 2002:a05:6870:2dc2:b0:23d:5bd3:f74c with SMTP id 586e51a60fabf-240979e02ddmr1622718fac.10.1715135136365; Tue, 07 May 2024 19:25:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715135136; cv=pass; d=google.com; s=arc-20160816; b=AhUSUGUmOhHd7WzRcq9CEpOFkfEczFCvu33yiWLK2naqRln/NBx1uvj52Jr54mmvWC JgVH+YBmMRDuCMlsWcA7lIdIZjGbHVM+D22euV5wkzuC2F+hns/WpYTmYHlj3JJjR+lh omftGPzKayqEgOQ5cncbzYIzfcBHyWIxbutc9Ivzd60om79lrxBicrmtgdSPgnd38aHt SgJUfl52KCGOYnaU+6XNnt8Uy84VO+smgXNQlrnrfy2z2bgrfPAsPhQSJpY3gr0YU+zd MlkemqLyGbp43sHYJxjDk90COrPHa4FMOVvLct1IExpuOyOgcY7vFgd8dURNAp3fMRMr Qinw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=4TOJO2TgucOnMCTJMIJIVkCaQ27EmlhBbO24n6BSyEY=; fh=kW5fBm5d+xksCFad1TAAYS7gBvoz8HZAN7XvzlaEMvI=; b=ibBCqGiEZyb15fOisaZ+eo9dJsngOmHSAqgXrSSyBUbFNKyNCBz0W4X4mQBcbAFIyG ttF9Wk0n50h5I/yBIYALjgWFI8+HqIdrAobgwMk7urzdSQFL0x6CBto422RIheWrwnAF uD8/MExNtWbm6gS3hXZxmIdE5vNyk55VmM8VAml1y6/LucXGhpZsQ60bScu2o6HovqcC HVZwkNVbsvNz5WDasObAVFyHVGXgWp34Vtw+yi7QI4xk4CvOtIpd1CT6+YJjFXu6u3H7 dXBgHr29jXSGg02NHna9qII7FgVRqO6t9BrTHAbXQ0GWS96/+LIWG0ptR9i11AZU/IEk QzSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=cyYxd4qc; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-172624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a37-20020a630b65000000b005f07209a2efsi11764718pgl.760.2024.05.07.19.25.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 19:25:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=cyYxd4qc; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-172624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BDA9B28256C for ; Wed, 8 May 2024 02:25:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F260BA2E; Wed, 8 May 2024 02:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="cyYxd4qc" Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CBD22563 for ; Wed, 8 May 2024 02:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.50.219 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715135126; cv=none; b=QM4h3EQ+RWEom0QRQ1RyyQIHdTXmTcLTcXQbYh1cjuuROeYw9FY022M+1xNSO3Q35U7vsvk9DLzyjY3b6TCxEPUDIQbsEr8NDOLJ8PIBrpetS+DJoejz7ZKv5D2leuyUho32S551fnOulia1NxbiZktwz7xoz2Q1pM/7D4VfrA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715135126; c=relaxed/simple; bh=5tbyX3SwS8frmzkccOkqaaboGO9PBxBAh4KHyxVjCy8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VoATPedW+s0x55pBPNpUDbf/NNnmCkC26m5kkTnO9wXFpPQJfMbFbrE1L06By+XlUe0yTaJ7YyxP4uGg6eTU1aTyPOdRIKu1PZ1aK1H9H1Hn/wEiICeFeSKl73t8dK541Eu/M09FWOq/mrhGXeoiUAyXk/h+pf9xU2lbmsXpqG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=cyYxd4qc; arc=none smtp.client-ip=45.254.50.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=4TOJO 2TgucOnMCTJMIJIVkCaQ27EmlhBbO24n6BSyEY=; b=cyYxd4qczRY2DMXCTUuED DstPL1FZwcaLt35xBsPQC7/6FnUMjArlvGXj4TiXKOGPmuNmzO+g1nBVQWgxfUB0 RZOHQqoKb+srWepZys0lXKmAczGABdk9l/tdXec5nzpWpfyF9ASAKJLbRmNoTvHe q71ghjvKTSKLMUlvOligqs= Received: from yangzhang2020.localdomain (unknown [60.27.227.220]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wD3v+Nv4jpm+z+lDg--.23507S2; Wed, 08 May 2024 10:24:47 +0800 (CST) From: "yang.zhang" To: alexghiti@rivosinc.com Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, "yang.zhang" Subject: [PATCH V3] riscv: set trap vector earlier Date: Wed, 8 May 2024 10:24:45 +0800 Message-Id: <20240508022445.6131-1-gaoshanliukou@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3v+Nv4jpm+z+lDg--.23507S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Wr1DJFW3Kw1rWF4ktr4xZwb_yoW8Jr1kpr 4fKw18CryFkrWxWa43AFsY939xt3WDXa1fWa98Cay5GFWDXa4fJ3s2qw4DWw1a9r4UC395 tF12grySyw1UA37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jdHUDUUUUU= X-CM-SenderInfo: pjdr2x5dqox3xnrxqiywtou0bp/1tbiNwbX8mXAlHQD7QADs8 From: "yang.zhang" The exception vector of the booting hart is not set before enabling the mmu and then still points to the value of the previous firmware, typically _start. That makes it hard to debug setup_vm() when bad things happen. So fix that by setting the exception vector earlier. Reviewed-by: Alexandre Ghiti Signed-off-by: yang.zhang --- V2 -> v3: - Fix commit message v1 -> v2: - As Alex commented, remove the patch for supporting hugesize kernek image - Add the omissive logic of set trap vector earlier https://lore.kernel.org/lkml/20240506022239.6817-1-gaoshanliukou@163.com --- arch/riscv/kernel/head.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 4236a69c35cb..03dc440e643e 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -300,6 +300,9 @@ SYM_CODE_START(_start_kernel) #else mv a0, a1 #endif /* CONFIG_BUILTIN_DTB */ + /* Set trap vector to spin forever to help debug */ + la a3, .Lsecondary_park + csrw CSR_TVEC, a3 call setup_vm #ifdef CONFIG_MMU la a0, early_pg_dir -- 2.25.1