Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1070019pxa; Wed, 12 Aug 2020 22:46:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ15LR51Ji+97w5tesOGGZiTGIoEMQKXvr+toGGO3y3tRD6iQuC6MPgt7JdwP0E5kUsBXe X-Received: by 2002:a17:906:b59:: with SMTP id v25mr3190331ejg.436.1597297582501; Wed, 12 Aug 2020 22:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597297582; cv=none; d=google.com; s=arc-20160816; b=ZVsKp/2Tgu0VBu3CSgKVcvqrFqvZvJJD54jUBaUgl7cVAtIMEy/iePaHmcEjHgNXgY 3vksCOVTcZDZ+6KDKLrBhlZU4h5vG7NsQQE7r2hgjQb1xFpPMAjY7cm0e0YtxYt58TZF c3KIz0MTHpA8T+/mY+LzCFWZZgK7tdwT0xzWS0rwK658tBhROmqrd0wML1B7quYqCdsd daNOTCEzMWhbd0eK+tRanjHLi1s3iSKmwnMb5NF1JR9gbzNiQ6dMDkjRTQwFuCinv8/h hXz42GtbMVtQTSC+dr2D9eC/EHEDfDJw9VqfXuoSHsWSvlrGB1ST3TtOlQTiHfCiQG54 KtGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pO83i01MAyD94ySqpQBUGi1TfGYRhwJn4iuYrQxpj8s=; b=g5A3LNZRZ1qLiFPvbaVfzhOWLw9N6tzkPgbh+sffgLRK2PgrhFUrUTFyA77G9oBs/5 kDBLu/hOBLWYxzaXBS7cmw6nbp0/Nd/hdId+W5kPYSBxV6iGzOW+kjFKlG0f19+GHP6Z aSoJKCpU9KGQPlg//HZuHeDkwzDnsc2DAGZouB/kvLP9uIcMRNjV9NmcYeHJYSxpSBuk 9UFn6v9VhQknIYi6DrIACIQgdtP3DuSv3ewMxOyDy7y5VfMQr6CB0xsmPOCHwD3sR23e NdgFVsiblJP4HALz/fA28xko1S1WwMw41ql7zp0ZMATUx36wXB9YFJi0XLjoq2hzgVdm mzmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=UvMOetG8; 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 ss19si2515991ejb.252.2020.08.12.22.46.00; Wed, 12 Aug 2020 22:46:22 -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; dkim=pass header.i=@atishpatra.org header.s=google header.b=UvMOetG8; 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 S1726609AbgHMFmu (ORCPT + 99 others); Thu, 13 Aug 2020 01:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgHMFmt (ORCPT ); Thu, 13 Aug 2020 01:42:49 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A23BC061757 for ; Wed, 12 Aug 2020 22:42:49 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id 184so3950891wmb.0 for ; Wed, 12 Aug 2020 22:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pO83i01MAyD94ySqpQBUGi1TfGYRhwJn4iuYrQxpj8s=; b=UvMOetG8xfT+hNTYbhURfXf/xX2xdzUfhZuAo8WFAxQaBFBFQ2j+CJqZ1sTU18QBeo ZjNnRLtZwsC8zZqohO/kBjQBYy/KL/a7eSzt3kC3NFACa87pWVcwXrKDu6fvBVDwzY35 jqzSL3LMijIrfIvVeCxAJJsm8rlpo182KHa/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pO83i01MAyD94ySqpQBUGi1TfGYRhwJn4iuYrQxpj8s=; b=iv6SksIXRDLjmla01YLAihzaPauFzFDDilb+DL3lZNhI1rzbCj/hL0t4N4qeGncpkF V77CIPImE7iaSCYlIR4cCIWRXJ9/iadJuprUacldBVT9o3Ab/Tf4qRg8gwo+GJ96Qzt0 sDKbnHk15NCluIDa+RGKBACAG5IJMeQALA6WfD/vB3KxDzzc/YVpwIuATjEcfQNWWLr6 jw+gs/9CBt/OBguyHGJ/vkHCkHeVuR+SklzuK1bLeOeswhELEljV5QeNB1f1Y6ScYJDH 2UUC3bL3t0r4cn0HG53v2MhCDTNshmatbCa45BRNjA+ANTBS3Vj1lND+UNQu/CYqBYyT 12iQ== X-Gm-Message-State: AOAM530pzHL4K4v5MQ6+Wlve18UwWbpTHBV58Yo3VHOPDa/TNKd+AfEw hqqkUC6NDyM8NhW40PO+AUDRrVQDfX2Ve9pqENLF X-Received: by 2002:a1c:4d12:: with SMTP id o18mr2653434wmh.55.1597297365586; Wed, 12 Aug 2020 22:42:45 -0700 (PDT) MIME-Version: 1.0 References: <20200813033807.19556-1-qiuwenbo@phytium.com.cn> In-Reply-To: <20200813033807.19556-1-qiuwenbo@phytium.com.cn> From: Atish Patra Date: Wed, 12 Aug 2020 22:42:34 -0700 Message-ID: Subject: Re: [PATCH v2] riscv: Setup exception vector for nommu platform To: Qiu Wenbo , Palmer Dabbelt Cc: Paul Walmsley , linux-riscv , Anup Patel , Albert Ou , Anup Patel , Atish Patra , Greentime Hu , Damien Le Moal , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 12, 2020 at 8:40 PM Qiu Wenbo wrote: > > 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 > @palmer: Can you queue this for the next part2 PR ? Reviewed-by: Atish Patra -- Regards, Atish