Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1015544pxa; Wed, 12 Aug 2020 20:42:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd4CvNtnVTIIPMzYncDWFJgRZ6iThiaCsxBc2bVN7V9+hmwKlRUxrSCbFhnLStAs3CzPY6 X-Received: by 2002:a17:906:ce39:: with SMTP id sd25mr3090190ejb.80.1597290122226; Wed, 12 Aug 2020 20:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597290122; cv=none; d=google.com; s=arc-20160816; b=RoWhizJReWTvQwIOtl5IYZU3JzJ1dD0OwSi0mbhGNtOGt4NLi/PmybK1XkcvMQ1BKF LdONahKVVpEMGAU6T8IWX6tFtpd7Hr0TUNC2rl3wTJNW8oWkuaTYhblysCWTzasH/FHL 9Mr5AdoOpntJricKeiAky1EiXuquSTD74k9Ui+wfrIVu26DIUTqkLQXtFvrDd7Sm8UFw JAxv2eCukqLaLZJcOdAttrQkydKiT81yJYw3SyYksSgF4HsD2z+z9myR7wywryfRmYts EMKzoymulSm+fF8XVnmo7gRibXM24Yfzq2IV4B/Z8wTFu5AeZni5UkoFgqS4RMdzrc0o 272Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ik0DC0KucKbcy0ezxQMmIpMZt7mfmZJiFLEnoINQjFk=; b=zGPsswrdV+s8DwaSvN012qHUFX9sxAfOvne6EJbTn9pYbV+JAFr+jxZ+U/vnEb4sfF Yv84c/BTx+aweveV/bbGq5RdvF9XaSSNg9JZbh+dBAkIiuhTRMzdjgYT3nUZaH7SzP+Z ddl/MQ0AoOajRKORv/rYQDTkYMTVZ1+Tz7B6M3Od1NFL/9ndqT7LNURZiJ3ZEfFaQQjU Et8UnGi/hQphjYTNPhLoPKGlv52ep1r9LJHIZORg1ipkVjaG58MXb1RuQuzdUly8XEM1 Kn3xGYomBzoDU6ZI9zzmdLoc6zvZLg1aJ3I2DcF3BFqxdfmpXkwGQoSeJcApLLXkqlQs C3HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si2469048ejb.4.2020.08.12.20.41.38; Wed, 12 Aug 2020 20:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726568AbgHMDki (ORCPT + 99 others); Wed, 12 Aug 2020 23:40:38 -0400 Received: from lonlinode-sdnproxy-1.icoremail.net ([139.162.193.133]:24264 "HELO lonlinode-sdnproxy-1.icoremail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726078AbgHMDkh (ORCPT ); Wed, 12 Aug 2020 23:40:37 -0400 Received: from localhost.localdomain (unknown [175.0.107.229]) by c1app11 (Coremail) with SMTP id CwINCgBHjHwUtjRffJ0gAw--.51036S2; Thu, 13 Aug 2020 11:40:06 +0800 (CST) From: Qiu Wenbo To: Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org Cc: Qiu Wenbo , Anup Patel , Atish Patra , Albert Ou , Anup Patel , Atish Patra , Greentime Hu , Damien Le Moal , linux-kernel@vger.kernel.org Subject: [PATCH v2] riscv: Setup exception vector for nommu platform Date: Thu, 13 Aug 2020 11:38:04 +0800 Message-Id: <20200813033807.19556-1-qiuwenbo@phytium.com.cn> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8b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0_Gr0_Gr1UYxBIda VFxhVjvjDU0xZFpf9x0JU-miiUUUUU= X-Originating-IP: [175.0.107.229] X-CM-SenderInfo: 5tlx4vhqerq15k1wx33pof0zgofq/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Exception vector is missing on nommu platform and that is an issue. This patch is tested in Sipeed Maix Bit Dev Board. Fixes: 79b1feba5455 ("RISC-V: Setup exception vector early") Suggested-by: Anup Patel Suggested-by: Atish Patra Signed-off-by: Qiu Wenbo --- arch/riscv/kernel/head.S | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index d0c5c316e9bb..0a4e81b8dc79 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -77,16 +77,10 @@ relocate: csrw CSR_SATP, a0 .align 2 1: - /* Set trap vector to exception handler */ - la a0, handle_exception + /* Set trap vector to spin forever to help debug */ + la a0, .Lsecondary_park csrw CSR_TVEC, a0 - /* - * Set sup0 scratch register to 0, indicating to exception vector that - * we are presently executing in kernel. - */ - csrw CSR_SCRATCH, zero - /* Reload the global pointer */ .option push .option norelax @@ -144,9 +138,23 @@ secondary_start_common: la a0, swapper_pg_dir call relocate #endif + call setup_trap_vector tail smp_callin #endif /* CONFIG_SMP */ +.align 2 +setup_trap_vector: + /* Set trap vector to exception handler */ + la a0, handle_exception + csrw CSR_TVEC, a0 + + /* + * Set sup0 scratch register to 0, indicating to exception vector that + * we are presently executing in kernel. + */ + csrw CSR_SCRATCH, zero + ret + .Lsecondary_park: /* We lack SMP support or have too many harts, so park this hart */ wfi @@ -240,6 +248,7 @@ clear_bss_done: call relocate #endif /* CONFIG_MMU */ + call setup_trap_vector /* Restore C environment */ la tp, init_task sw zero, TASK_TI_CPU(tp) -- 2.28.0