Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp189299pxa; Mon, 10 Aug 2020 23:42:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznGJHdWHy8Vtc0Veg38T3IGGB9GLPNlUPjg0/xg8Ji+voLaLpfy1nkB/IyOSgGkGwWK5Yg X-Received: by 2002:a50:cdd8:: with SMTP id h24mr23752658edj.241.1597128126621; Mon, 10 Aug 2020 23:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597128126; cv=none; d=google.com; s=arc-20160816; b=IA1SuYR+Wzs3Q3CjSqSMnqX9vAKIFBqVLRZ38iM3EW9uKXTqN+zk2euLVDOUcLrt96 PT3eLoc5VX7wikJz2MGFXZYGrUa4iQwmH+wHsidr92neuwiMHI2K/lPIRumeMPlXabE8 o2q1maJiP53KBhztI8y3ocRIeHV26/QAuYiMUr7RTCNt8CV4hBSofhKgBcdvl2OKuauw OghbzLsCppPfEObOZXEEHgEKkMK15w/rF/W05k2jf4kahU5LRKKeYPjWQ6cAVx/EPGZg XmejMPJ5/oCLFyzgYLeP+swFon2tuoCCEcMrm2+Cg/NMOww6trHSmf7wF40Y2yO4sNNk m3Sg== 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=o2gpLAVmbmOCizSbXmaF86QmIc1vQ68M8DzPTL4s7A4=; b=Swsne6OzsAeZuOjZYLhqUgsexaCr+qbjcTUOcqSBoZP86ttjbjP1MizA+UKHYn2DPd d7GAHTUSqMt+BxVmB0MIi6KXk+Hi4g0/lpo4Jzkigsu9sHwQMVSEZkVPFiyDUBliF0pg StEQ5bmHtL968oRM4Fn1Mkru0ceYC6U1X1ypHcP73WlP6dl7nzOeCMmZCzaDHTNk+iG6 OOtZKMtDcUJ7CElTZ4FcYI9BNmPS+diEHHp/JWZNuOw4mgFXrvgjA3NwAF65ZyhTsU85 J/vaAAXniYbNB8mOoMxlL5A2SUckkWIXiNEk1v6X8vTfCjg2ghujTeg7SfFWqyyUoSHH ni4w== 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 e17si5771022ejx.78.2020.08.10.23.41.43; Mon, 10 Aug 2020 23:42:06 -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 S1728167AbgHKGh7 (ORCPT + 99 others); Tue, 11 Aug 2020 02:37:59 -0400 Received: from lonlinode-sdnproxy-1.icoremail.net ([139.162.193.133]:56458 "HELO lonlinode-sdnproxy-1.icoremail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726520AbgHKGh7 (ORCPT ); Tue, 11 Aug 2020 02:37:59 -0400 Received: from localhost.localdomain (unknown [106.19.114.17]) by c1app6 (Coremail) with SMTP id BgINCgAnL_+0PDJfrfP+Aw--.3669S2; Tue, 11 Aug 2020 14:37:42 +0800 (CST) From: Qiu Wenbo To: Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org Cc: Qiu Wenbo , Albert Ou , Atish Patra , Anup Patel , Guo Ren , Zong Li , Greentime Hu , Vincent Chen , Damien Le Moal , linux-kernel@vger.kernel.org Subject: [PATCH] riscv: Setup exception vector for K210 properly Date: Tue, 11 Aug 2020 14:36:56 +0800 Message-Id: <20200811063659.284088-1-qiuwenbo@phytium.com.cn> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Enco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r0_Gr1UYxBIda VFxhVjvjDU0xZFpf9x0JU-J5rUUUUU= 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 it is a big issue. This patch is tested in Sipeed MAIX Bit Dev Board. Fixes: 79b1feba5455 ("RISC-V: Setup exception vector early") Signed-off-by: Qiu Wenbo --- arch/riscv/kernel/smpboot.c | 1 + arch/riscv/kernel/traps.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 356825a57551..23cde0ceb39d 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -154,6 +154,7 @@ asmlinkage __visible void smp_callin(void) mmgrab(mm); current->active_mm = mm; + trap_init(); notify_cpu_starting(curr_cpuid); update_siblings_masks(curr_cpuid); set_cpu_online(curr_cpuid, 1); diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index ad14f4466d92..a390239818ae 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -174,7 +174,16 @@ int is_valid_bugaddr(unsigned long pc) } #endif /* CONFIG_GENERIC_BUG */ -/* stvec & scratch is already set from head.S */ +/* stvec & scratch is already set from head.S when mmu is enabled */ void trap_init(void) { +#ifndef CONFIG_MMU + /* + * Set sup0 scratch register to 0, indicating to exception vector + * that we are presently executing in the kernel + */ + csr_write(CSR_SCRATCH, 0); + /* Set the exception vector address */ + csr_write(CSR_TVEC, &handle_exception); +#endif } -- 2.28.0