All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Clément Léger" <cleger@rivosinc.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	Andrew Jones <ajones@ventanamicro.com>,
	Ved Shanbhogue <ved@rivosinc.com>
Subject: Re: [PATCH 2/3] lib/riscv: clear SDT when entering exception handling
Date: Tue, 3 Jun 2025 10:22:07 +0200	[thread overview]
Message-ID: <bcb3cffe-5fca-45fc-aa30-c167f6cf3c5c@rivosinc.com> (raw)
In-Reply-To: <20250603-8e4c2aa217e6be3b3ee43972@orel>



On 03/06/2025 10:16, Andrew Jones wrote:
> On Fri, May 23, 2025 at 09:53:09AM +0200, Clément Léger wrote:
>> In order to avoid taking double trap once we have entered a trap and
>> saved everything, clear SDT at the end of entry. This is not exactly
>> required when double trap is disabled (probably most of the time), but
>> that's not harmful.
> 
> Hmm... I wonder if this shouldn't be left to the handlers. Maybe
> we should just provide a couple helpers in processor.h, such as
> 
> local_dlbtrp_enable()
> local_dlbtrp_disable()

Hi Drew,

Yeah indeed, that makes sense, some of them might have to save more info
before re-enabling trap in a near future.

I'll drop this patch and use that proposal.

> 
> If we do need to manage this at save_context time, then I have
> a couple comments below
> 
>>
>> Signed-off-by: Clément Léger <cleger@rivosinc.com>
>> ---
>>  riscv/cstart.S | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/riscv/cstart.S b/riscv/cstart.S
>> index 575f929b..a86f97f0 100644
>> --- a/riscv/cstart.S
>> +++ b/riscv/cstart.S
>> @@ -212,14 +212,15 @@ secondary_entry:
>>  	REG_S	t6, PT_T6(a0)			// x31
>>  	csrr	a1, CSR_SEPC
>>  	REG_S	a1, PT_EPC(a0)
>> -	csrr	a1, CSR_SSTATUS
>> -	REG_S	a1, PT_STATUS(a0)
>>  	csrr	a1, CSR_STVAL
>>  	REG_S	a1, PT_BADADDR(a0)
>>  	csrr	a1, CSR_SCAUSE
>>  	REG_S	a1, PT_CAUSE(a0)
>>  	REG_L	a1, PT_ORIG_A0(a0)
>>  	REG_S	a1, PT_A0(a0)
>> +	li t0, 	SR_SDT
>           ^    ^ should not be a tab
>           ^ should be tabs
> 
> SR_SDT isn't defined until the next patch so this breaks compiling at this
> point, which could break bisection. You can do a quick check of a series
> for this with
> 
>  git rebase -i -x 'make' <base>

Missed that, sorry, I'll check next time.

Thanks,

Clément

> 
>> +	csrrc 	a1, CSR_SSTATUS, t0
>> +	REG_S	a1, PT_STATUS(a0)
>>  .endm
>>  
>>  /*
>> @@ -227,6 +228,8 @@ secondary_entry:
>>   * Also restores a0.
>>   */
>>  .macro restore_context
>> +	REG_L	a1, PT_STATUS(a0)
>> +	csrw	CSR_SSTATUS, a1
>>  	REG_L	ra, PT_RA(a0)			// x1
>>  	REG_L	sp, PT_SP(a0)			// x2
>>  	REG_L	gp, PT_GP(a0)			// x3
>> @@ -260,8 +263,6 @@ secondary_entry:
>>  	REG_L	t6, PT_T6(a0)			// x31
>>  	REG_L	a1, PT_EPC(a0)
>>  	csrw	CSR_SEPC, a1
>> -	REG_L	a1, PT_STATUS(a0)
>> -	csrw	CSR_SSTATUS, a1
>>  	REG_L	a1, PT_BADADDR(a0)
>>  	csrw	CSR_STVAL, a1
>>  	REG_L	a1, PT_CAUSE(a0)
>> -- 
>> 2.49.0
>>
> 
> Thanks,
> drew


-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

WARNING: multiple messages have this Message-ID (diff)
From: "Clément Léger" <cleger@rivosinc.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	Andrew Jones <ajones@ventanamicro.com>,
	Ved Shanbhogue <ved@rivosinc.com>
Subject: Re: [PATCH 2/3] lib/riscv: clear SDT when entering exception handling
Date: Tue, 3 Jun 2025 10:22:07 +0200	[thread overview]
Message-ID: <bcb3cffe-5fca-45fc-aa30-c167f6cf3c5c@rivosinc.com> (raw)
In-Reply-To: <20250603-8e4c2aa217e6be3b3ee43972@orel>



On 03/06/2025 10:16, Andrew Jones wrote:
> On Fri, May 23, 2025 at 09:53:09AM +0200, Clément Léger wrote:
>> In order to avoid taking double trap once we have entered a trap and
>> saved everything, clear SDT at the end of entry. This is not exactly
>> required when double trap is disabled (probably most of the time), but
>> that's not harmful.
> 
> Hmm... I wonder if this shouldn't be left to the handlers. Maybe
> we should just provide a couple helpers in processor.h, such as
> 
> local_dlbtrp_enable()
> local_dlbtrp_disable()

Hi Drew,

Yeah indeed, that makes sense, some of them might have to save more info
before re-enabling trap in a near future.

I'll drop this patch and use that proposal.

> 
> If we do need to manage this at save_context time, then I have
> a couple comments below
> 
>>
>> Signed-off-by: Clément Léger <cleger@rivosinc.com>
>> ---
>>  riscv/cstart.S | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/riscv/cstart.S b/riscv/cstart.S
>> index 575f929b..a86f97f0 100644
>> --- a/riscv/cstart.S
>> +++ b/riscv/cstart.S
>> @@ -212,14 +212,15 @@ secondary_entry:
>>  	REG_S	t6, PT_T6(a0)			// x31
>>  	csrr	a1, CSR_SEPC
>>  	REG_S	a1, PT_EPC(a0)
>> -	csrr	a1, CSR_SSTATUS
>> -	REG_S	a1, PT_STATUS(a0)
>>  	csrr	a1, CSR_STVAL
>>  	REG_S	a1, PT_BADADDR(a0)
>>  	csrr	a1, CSR_SCAUSE
>>  	REG_S	a1, PT_CAUSE(a0)
>>  	REG_L	a1, PT_ORIG_A0(a0)
>>  	REG_S	a1, PT_A0(a0)
>> +	li t0, 	SR_SDT
>           ^    ^ should not be a tab
>           ^ should be tabs
> 
> SR_SDT isn't defined until the next patch so this breaks compiling at this
> point, which could break bisection. You can do a quick check of a series
> for this with
> 
>  git rebase -i -x 'make' <base>

Missed that, sorry, I'll check next time.

Thanks,

Clément

> 
>> +	csrrc 	a1, CSR_SSTATUS, t0
>> +	REG_S	a1, PT_STATUS(a0)
>>  .endm
>>  
>>  /*
>> @@ -227,6 +228,8 @@ secondary_entry:
>>   * Also restores a0.
>>   */
>>  .macro restore_context
>> +	REG_L	a1, PT_STATUS(a0)
>> +	csrw	CSR_SSTATUS, a1
>>  	REG_L	ra, PT_RA(a0)			// x1
>>  	REG_L	sp, PT_SP(a0)			// x2
>>  	REG_L	gp, PT_GP(a0)			// x3
>> @@ -260,8 +263,6 @@ secondary_entry:
>>  	REG_L	t6, PT_T6(a0)			// x31
>>  	REG_L	a1, PT_EPC(a0)
>>  	csrw	CSR_SEPC, a1
>> -	REG_L	a1, PT_STATUS(a0)
>> -	csrw	CSR_SSTATUS, a1
>>  	REG_L	a1, PT_BADADDR(a0)
>>  	csrw	CSR_STVAL, a1
>>  	REG_L	a1, PT_CAUSE(a0)
>> -- 
>> 2.49.0
>>
> 
> Thanks,
> drew


  reply	other threads:[~2025-06-03  8:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  7:53 [PATCH 0/3] riscv: Add double trap testing Clément Léger
2025-05-23  7:53 ` Clément Léger
2025-05-23  7:53 ` [PATCH 1/3] lib/riscv: export FWFT functions Clément Léger
2025-05-23  7:53   ` Clément Léger
2025-06-03  7:14   ` Andrew Jones
2025-06-03  7:14     ` Andrew Jones
2025-05-23  7:53 ` [PATCH 2/3] lib/riscv: clear SDT when entering exception handling Clément Léger
2025-05-23  7:53   ` Clément Léger
2025-06-03  8:16   ` Andrew Jones
2025-06-03  8:16     ` Andrew Jones
2025-06-03  8:22     ` Clément Léger [this message]
2025-06-03  8:22       ` Clément Léger
2025-05-23  7:53 ` [PATCH 3/3] riscv: Add ISA double trap extension testing Clément Léger
2025-05-23  7:53   ` Clément Léger
2025-06-03  9:09   ` Andrew Jones
2025-06-03  9:09     ` Andrew Jones
2025-06-03  9:39     ` Clément Léger
2025-06-03  9:39       ` Clément Léger
2025-06-03  7:10 ` [PATCH 0/3] riscv: Add double trap testing Andrew Jones
2025-06-03  7:10   ` Andrew Jones
2025-06-03  7:52   ` Clément Léger
2025-06-03  7:52     ` Clément Léger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bcb3cffe-5fca-45fc-aa30-c167f6cf3c5c@rivosinc.com \
    --to=cleger@rivosinc.com \
    --cc=ajones@ventanamicro.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=ved@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.