linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] riscv: Setup exception vector for nommu platform
@ 2020-08-13  3:38 Qiu Wenbo
  2020-08-13  5:42 ` Atish Patra
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Qiu Wenbo @ 2020-08-13  3:38 UTC (permalink / raw)
  To: Palmer Dabbelt, Paul Walmsley, linux-riscv
  Cc: Qiu Wenbo, Anup Patel, Atish Patra, Albert Ou, Anup Patel,
	Atish Patra, Greentime Hu, Damien Le Moal, linux-kernel

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 <anup@brainfault.org>
Suggested-by: Atish Patra <atishp@atishpatra.org>
Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  3:38 [PATCH v2] riscv: Setup exception vector for nommu platform Qiu Wenbo
@ 2020-08-13  5:42 ` Atish Patra
  2020-08-13  5:44 ` Damien Le Moal
  2020-08-13  8:49 ` Anup Patel
  2 siblings, 0 replies; 7+ messages in thread
From: Atish Patra @ 2020-08-13  5:42 UTC (permalink / raw)
  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

On Wed, Aug 12, 2020 at 8:40 PM Qiu Wenbo <qiuwenbo@phytium.com.cn> 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 <anup@brainfault.org>
> Suggested-by: Atish Patra <atishp@atishpatra.org>
> Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
> ---
>  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 <atish.patra@wdc.com>
-- 
Regards,
Atish

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  3:38 [PATCH v2] riscv: Setup exception vector for nommu platform Qiu Wenbo
  2020-08-13  5:42 ` Atish Patra
@ 2020-08-13  5:44 ` Damien Le Moal
  2020-08-13  6:45   ` Atish Patra
  2020-08-13  8:49 ` Anup Patel
  2 siblings, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2020-08-13  5:44 UTC (permalink / raw)
  To: Qiu Wenbo, Palmer Dabbelt, Paul Walmsley, linux-riscv
  Cc: Anup Patel, Atish Patra, Albert Ou, Anup Patel, Atish Patra,
	Greentime Hu, linux-kernel

On 2020/08/13 12:40, 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 <anup@brainfault.org>
> Suggested-by: Atish Patra <atishp@atishpatra.org>
> Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>

Please add a cc stable #5.8 tag. Kendryte support is in 5.8 stable.

> ---
>  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)
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  5:44 ` Damien Le Moal
@ 2020-08-13  6:45   ` Atish Patra
  2020-08-13  7:03     ` Damien Le Moal
  0 siblings, 1 reply; 7+ messages in thread
From: Atish Patra @ 2020-08-13  6:45 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Qiu Wenbo, Palmer Dabbelt, Paul Walmsley, linux-riscv,
	Anup Patel, Albert Ou, Anup Patel, Atish Patra, Greentime Hu,
	linux-kernel

On Wed, Aug 12, 2020 at 10:44 PM Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
>
> On 2020/08/13 12:40, 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 <anup@brainfault.org>
> > Suggested-by: Atish Patra <atishp@atishpatra.org>
> > Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
>
> Please add a cc stable #5.8 tag. Kendryte support is in 5.8 stable.
>

That won't be necessary as the patch that broke nommu (79b1feba5455) was
part of the 1st PR sent towards 5.9-rc1.


> > ---
> >  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)
> >
>
>
> --
> Damien Le Moal
> Western Digital Research



--
Regards,
Atish

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  6:45   ` Atish Patra
@ 2020-08-13  7:03     ` Damien Le Moal
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2020-08-13  7:03 UTC (permalink / raw)
  To: Atish Patra
  Cc: Qiu Wenbo, Palmer Dabbelt, Paul Walmsley, linux-riscv,
	Anup Patel, Albert Ou, Anup Patel, Atish Patra, Greentime Hu,
	linux-kernel

On 2020/08/13 15:45, Atish Patra wrote:
> On Wed, Aug 12, 2020 at 10:44 PM Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
>>
>> On 2020/08/13 12:40, 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 <anup@brainfault.org>
>>> Suggested-by: Atish Patra <atishp@atishpatra.org>
>>> Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
>>
>> Please add a cc stable #5.8 tag. Kendryte support is in 5.8 stable.
>>
> 
> That won't be necessary as the patch that broke nommu (79b1feba5455) was
> part of the 1st PR sent towards 5.9-rc1.

Oops. Yes indeed. Thanks !



-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  3:38 [PATCH v2] riscv: Setup exception vector for nommu platform Qiu Wenbo
  2020-08-13  5:42 ` Atish Patra
  2020-08-13  5:44 ` Damien Le Moal
@ 2020-08-13  8:49 ` Anup Patel
  2020-08-14 22:46   ` Palmer Dabbelt
  2 siblings, 1 reply; 7+ messages in thread
From: Anup Patel @ 2020-08-13  8:49 UTC (permalink / raw)
  To: Qiu Wenbo
  Cc: Palmer Dabbelt, Paul Walmsley, linux-riscv, Atish Patra,
	Albert Ou, Anup Patel, Atish Patra, Greentime Hu, Damien Le Moal,
	linux-kernel@vger.kernel.org List

On Thu, Aug 13, 2020 at 9:10 AM Qiu Wenbo <qiuwenbo@phytium.com.cn> 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 <anup@brainfault.org>
> Suggested-by: Atish Patra <atishp@atishpatra.org>
> Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
> ---
>  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
>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Regards,
Anup

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] riscv: Setup exception vector for nommu platform
  2020-08-13  8:49 ` Anup Patel
@ 2020-08-14 22:46   ` Palmer Dabbelt
  0 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2020-08-14 22:46 UTC (permalink / raw)
  To: anup
  Cc: qiuwenbo, Paul Walmsley, linux-riscv, atishp, aou, Anup Patel,
	Atish Patra, greentime.hu, Damien Le Moal, linux-kernel

On Thu, 13 Aug 2020 01:49:44 PDT (-0700), anup@brainfault.org wrote:
> On Thu, Aug 13, 2020 at 9:10 AM Qiu Wenbo <qiuwenbo@phytium.com.cn> 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 <anup@brainfault.org>
>> Suggested-by: Atish Patra <atishp@atishpatra.org>
>> Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
>> ---
>>  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
>>
>
> Looks good to me.
>
> Reviewed-by: Anup Patel <anup@brainfault.org>
>
> Regards,
> Anup

Thanks, this is on fixes.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-14 22:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13  3:38 [PATCH v2] riscv: Setup exception vector for nommu platform Qiu Wenbo
2020-08-13  5:42 ` Atish Patra
2020-08-13  5:44 ` Damien Le Moal
2020-08-13  6:45   ` Atish Patra
2020-08-13  7:03     ` Damien Le Moal
2020-08-13  8:49 ` Anup Patel
2020-08-14 22:46   ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).