Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2710710ybh; Fri, 24 Jul 2020 22:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLO5AIJOo7Mg+HuxNokyLKN9YA1URPvT8rsTAHjIl7MsmnUqKVaqDKznc86JekwLLeJH0R X-Received: by 2002:aa7:d744:: with SMTP id a4mr12005881eds.94.1595654876271; Fri, 24 Jul 2020 22:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595654876; cv=none; d=google.com; s=arc-20160816; b=L4UqShB7vgNM9NEWiKIAE2Dt0aHYLCYQ9w/0BImTzvcy7SJiHgyHusmPFzdq+Cbe4D o3V33VzRgu3f9J7MVu2NRzgHpLXXPIc+lICo/gN3w7PQo1N34mDCUGvvp6I9ZDW+40+R B1LVFMvg1fs/jYmmk7qawjy5suqntvHyZmRu8Q8gqC5BN2B6QW+Z3EtO42rn4RdYx6JA h+/MsZXHU9nAhH7RIcY0GAVLQ2BKTm8suseH2IC8NCQOaiPq0Wh6fWyl4C1tv/UrXWHA g1LOu/rATFbEuFIYKeREKr4z7uLmIOlmWJVL45bwD/Cey44APmgEMdgpq682WOOqmHPh YTxg== 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=a6p0lVxEnhHsvjplpbb7vWgmumCrMN6gGnNK6UWZILU=; b=pjX8MrDlAuvxn0lRTDI5buYrxzuILKRfSWNvUgtrDu02IZNR6SxidN+6qgOXnqsREk 4h2BwaYnDSDCLpS4wIzUdQHXYb5rTZEAjrfvM7M9pIZRXQaR42wv5Z/yHo9Y9OBhl7jE Mjf5j/1mHBh1gHSU4DKvM1hSYQf+Ft6yXXenrpqydLZlH2Gp6HsDM2t4SFaoETnJ49a0 ryhdz6afHjA9ZqflRBsJftvQcitK2TrdcG35xBGm764Tn+PwdZ+vCzvDd7C7gg0sPzqb g0wtmNe/q/JdZCzSGZmyyG6BXN/ci7GOkzLwS2ArAKPedDYp4Roeq3E4+NuWgfOBJBzV WEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=Q1vZe+rK; 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 l23si864951ejq.620.2020.07.24.22.27.33; Fri, 24 Jul 2020 22:27:56 -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=Q1vZe+rK; 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 S1726434AbgGYF0Y (ORCPT + 99 others); Sat, 25 Jul 2020 01:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGYF0Y (ORCPT ); Sat, 25 Jul 2020 01:26:24 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50DEC0619D3 for ; Fri, 24 Jul 2020 22:26:23 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id a5so20057wrm.6 for ; Fri, 24 Jul 2020 22:26:23 -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=a6p0lVxEnhHsvjplpbb7vWgmumCrMN6gGnNK6UWZILU=; b=Q1vZe+rKwyyYjIW6XXvjhhERm0kakS74BuxhRPpXajZcKpBSQrLf4lCSu0NiYL2LFy n5RFcUmb062jxXoc9P482sXmu4tvBwwyPReseQpg5qGh/X58CzCvXB/NzsCvuF4EVd8x /zgGwj9uZmSfxsS3AdLH+E+vyTeIZLdZ6uLJU= 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=a6p0lVxEnhHsvjplpbb7vWgmumCrMN6gGnNK6UWZILU=; b=YSvCp3/6qMt5raWOAmqnytbSTnFLkrC8zpywFV8QgHvuLiu6WswK4odO+2x5Qi4pzf LdbXsBDD1G+KdMNRDZo3c66RxsYQ8jV6iqP2TaLSzMKmBWGDSxwE5x/Lw065RxbtikpG QJfDUtq7Hyy99metlmvxroNNQUI5BCIVRNeEruUm5wXOuZix4LbKB+Urqd2AJZKYxdV9 VETZJEuL6LkckrgmWC1shIpkJHmEzwPWwuAZaKKTNNUyR7e1WEoUV/uCQgagMR3Lj2IW KugNyfW5NLQnhULFv/UFDUKn6wjydg8pyf3RSZodXenwwCiidUFav7Xe+FOWLTSp/Tbf 7pPg== X-Gm-Message-State: AOAM531VTOpQjH0ejNAvjdX2ojuuIjOcKC+V2Fc3U6xrsauMM9bWzXCp PW01c5TKwKwpqnrmwXksZNs9Yipgujj+PF8swO5S X-Received: by 2002:adf:d84f:: with SMTP id k15mr10836892wrl.176.1595654782356; Fri, 24 Jul 2020 22:26:22 -0700 (PDT) MIME-Version: 1.0 References: <20200715233009.27183-2-atish.patra@wdc.com> In-Reply-To: From: Atish Patra Date: Fri, 24 Jul 2020 22:26:10 -0700 Message-ID: Subject: Re: [PATCH 1/4] RISC-V: Setup exception vector early To: Palmer Dabbelt Cc: Atish Patra , Albert Ou , Vincent Chen , Anup Patel , "linux-kernel@vger.kernel.org List" , sudeep.holla@arm.com, Zong Li , Paul Walmsley , Greentime Hu , linux-riscv 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 Fri, Jul 24, 2020 at 10:12 PM Palmer Dabbelt wrote: > > On Wed, 15 Jul 2020 16:30:06 PDT (-0700), Atish Patra wrote: > > The trap vector is set only in trap_init which may be too late in some > > cases. Early ioremap/efi spits many warning messages which may be useful. > > > > Setup the trap vector early so that any warning/bug can be handled before > > generic code invokes trap_init. > > > > Signed-off-by: Atish Patra > > --- > > arch/riscv/kernel/head.S | 10 ++++++++-- > > arch/riscv/kernel/smpboot.c | 1 - > > arch/riscv/kernel/traps.c | 8 +------- > > 3 files changed, 9 insertions(+), 10 deletions(-) > > > > diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S > > index 7ed1b22950fd..d0c5c316e9bb 100644 > > --- a/arch/riscv/kernel/head.S > > +++ b/arch/riscv/kernel/head.S > > @@ -77,10 +77,16 @@ relocate: > > csrw CSR_SATP, a0 > > .align 2 > > 1: > > - /* Set trap vector to spin forever to help debug */ > > - la a0, .Lsecondary_park > > + /* 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 > > + > > /* Reload the global pointer */ > > .option push > > .option norelax > > diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c > > index 4e9922790f6e..5a9c127a380e 100644 > > --- a/arch/riscv/kernel/smpboot.c > > +++ b/arch/riscv/kernel/smpboot.c > > @@ -154,7 +154,6 @@ asmlinkage __visible void smp_callin(void) > > mmgrab(mm); > > current->active_mm = mm; > > > > - trap_init(); > > notify_cpu_starting(smp_processor_id()); > > update_siblings_masks(smp_processor_id()); > > set_cpu_online(smp_processor_id(), 1); > > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c > > index 7d95cce5e47c..ad14f4466d92 100644 > > --- a/arch/riscv/kernel/traps.c > > +++ b/arch/riscv/kernel/traps.c > > @@ -174,13 +174,7 @@ int is_valid_bugaddr(unsigned long pc) > > } > > #endif /* CONFIG_GENERIC_BUG */ > > > > +/* stvec & scratch is already set from head.S */ > > void trap_init(void) > > { > > - /* > > - * 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); > > } > > While I think these are all actual fixes, it's pretty late in the cycle here so > I'm going to a bit on the careful side and only take the patches that actually > manifest as bugs in the current port. Assuming this doesn't manifest until > early_ioremap is enabled (and we don't do that yet), I've put it on for-next. > Yeah. early_ioremap is part of the UEFI series. So this can go into for-next. Thanks. > LMK if I'm wrong about this, or the following ones. > > Thanks! > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv -- Regards, Atish