Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp246826pxa; Tue, 11 Aug 2020 01:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAoYfNihTQSe0QDYz6Y2rxBPD54H1szZLX0PY7M1rQrySzOUDK0rTyl2v40Lwh48isqE/J X-Received: by 2002:a50:e719:: with SMTP id a25mr23766836edn.15.1597135439173; Tue, 11 Aug 2020 01:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597135439; cv=none; d=google.com; s=arc-20160816; b=OHFUX0mT1vR0wFuVs48/gKpzjw9H5PQNa8up1RaUre91vce/j6ufa2nUTpGJb2R/b8 w0nSpf3x+/N1KWfc37GVlM37IHxs2fkQvJ86mxeALxS+cSwCdwNSHe77AwvmEdJaxiR3 0LVTOIsGhWtjJ8amVzgntL4KMbLHNyJSf36tZT0j1tBK1xgNviQvEDJC8Gf8Ad55Bxex 48yQWYz9JhVoVZwoCu56gaAHyXt733978eYb9fF3Q5rre3Uwtm10DUFA7ibhp3yHSuBA mRlcY+Rw6SAvzx3M+bh4aSte0amdotD55xYCBFOtCISacIGei8k3fVgWQNDErVuDh8ur aqMw== 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=btI/X9SDKoElUv2/KbWFVuLp06+/u9czm/CWpC6NJgM=; b=owzjJQ9IJAEJ6t4LIhKiRdUlurlpAd8THK1itxddagCaJt8abJY77+TMDtYJaZn7Th JM9arUjrvfO42/IVSb2Smb0W5/3teGoCwqNhJpqBaoaU2Ph6b0EFGiyi3+CoFg5dIWuA mIOuWOeDsh5mm46QLQO3vS8PtN+hpdRTYDvEqcnr2+QTcdr5emn23DXIms+WRIcTXUfp U155aWfmI5hh8kA0828KjGrWP2ZGvWIoHlVt/ecPIZAoqlwQqSjNn3yshUvEAAgLkP0N u15zMc1MfL+EnLITBJokmlCQwxculRJtRgHyvuzkNPL9DEL2D3J/boBLwswTQ3uCgIiT YKdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=DfUNFMfp; 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 x60si13968494ede.582.2020.08.11.01.43.35; Tue, 11 Aug 2020 01:43:59 -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=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=DfUNFMfp; 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 S1728335AbgHKIkz (ORCPT + 99 others); Tue, 11 Aug 2020 04:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbgHKIkz (ORCPT ); Tue, 11 Aug 2020 04:40:55 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA476C06174A for ; Tue, 11 Aug 2020 01:40:54 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id 184so2042916wmb.0 for ; Tue, 11 Aug 2020 01:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=btI/X9SDKoElUv2/KbWFVuLp06+/u9czm/CWpC6NJgM=; b=DfUNFMfpPON2NYu/waf/PF+SlGLX8CkQ+mMAndAEpNpx87wEnHfnN27eF7Z/uUP9g3 yyhUUT27Nr3k/s69a26aPTv+/Z/2/XIOtF9AbKAv8xf6Mypww73jtjjUPINjcrZr00gU OLx9q4Oh13ugyvCQbM0jh/RExazmLEbxEbQWwpVfSSnlCKgIxX1xWsk1Eq+JDbjyY5p0 8kjY9rydu4Fa2yGMvdELdhT7S81m/LyP/BAkCw7CtYuetWlVtiPRCb5U3x1yS+KXQkJO 9i4OVKk6eUhhiTbAnJhggCiQ41kfcaYmY1+PNoOlLkRUaFZBTODv3iK/YYybBc0jC4oC v5ew== 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=btI/X9SDKoElUv2/KbWFVuLp06+/u9czm/CWpC6NJgM=; b=H5OprcPfkoHMgHqnmQ2V0UOJ9JtRviuYdYYnhRrlgmRFKOSv8uHzo4MKeLXkuS/Qr6 RDz5rX0hquBtMHfMENaF5RrZnLAQEYPNK65EMUlrA3Qb33KnOIAN9eZW4lFczNvgGko+ hVmSPJbEwPOEaCOmod8GH0Xes8LMlX2PEr8XWmJ19/jVzK/2g4YSlreFXCT5grcGqJkc Mnl4KN9WrQQwmAetLzol5KN45eZHImueBNXVRZXcGGlZ7xa9dokMwTcdXtiecmihLrfS ZLFb48prVDsEHm2w66BxI2YH89wIUVK1PTBPSvsUIvCdhy7T53Cp+GQ06Vvr/adlPq2H +0Sg== X-Gm-Message-State: AOAM531Y2yZ+seg+zWtpaccin9luZr3Qj/6CmBlgayN6TxouxoDvWuli tz2dEh0oFdSEkcMB6AMgHaBJ3/kbJSoSbObwL0TfhQ== X-Received: by 2002:a1c:720e:: with SMTP id n14mr2964859wmc.152.1597135252525; Tue, 11 Aug 2020 01:40:52 -0700 (PDT) MIME-Version: 1.0 References: <20200811063659.284088-1-qiuwenbo@phytium.com.cn> In-Reply-To: <20200811063659.284088-1-qiuwenbo@phytium.com.cn> From: Anup Patel Date: Tue, 11 Aug 2020 14:10:40 +0530 Message-ID: Subject: Re: [PATCH] riscv: Setup exception vector for K210 properly To: Qiu Wenbo Cc: Palmer Dabbelt , Paul Walmsley , linux-riscv , Albert Ou , Atish Patra , Guo Ren , Zong Li , Greentime Hu , Vincent Chen , 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 Tue, Aug 11, 2020 at 12:07 PM Qiu Wenbo wrote: > > 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 > This issue seems to be only on the latest master branch of Linux stable tree so this fix need not be a stable fix. For MMU kernel, the CSR_TVEC is setup in relocate() function called from secondary_start_common() function of head.S For NoMMU kernel, we should set CSR_TVEC directly in secondary_start_common() function as "#else" case of the "#ifdef CONFIG_MMU". Regards, Anup