* [PATCH RESEND] scripts/gdb: add lx_current support for riscv
@ 2023-02-22 9:37 Song Shuai
2023-02-22 9:52 ` Conor Dooley
0 siblings, 1 reply; 3+ messages in thread
From: Song Shuai @ 2023-02-22 9:37 UTC (permalink / raw)
To: jan.kiszka, kbingham, paul.walmsley, palmer, aou
Cc: linux-kernel, linux-riscv, Song Shuai
RISC-V uses the tp register to save the current task_struct address
as its current() defines. So lx_current() of riscv just returns the
dereference of the address cast via task_ptr_type.
Signed-off-by: Song Shuai <suagrfillet@gmail.com>
---
scripts/gdb/linux/cpus.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
index 15fc4626d236..6825a9834394 100644
--- a/scripts/gdb/linux/cpus.py
+++ b/scripts/gdb/linux/cpus.py
@@ -173,6 +173,9 @@ def get_current_task(cpu):
else:
raise gdb.GdbError("Sorry, obtaining the current task is not allowed "
"while running in userspace(EL0)")
+ elif utils.is_target_arch("riscv"):
+ current_task_addr = gdb.parse_and_eval("$tp")
+ return current_task_addr.cast(task_ptr_type).dereference()
else:
raise gdb.GdbError("Sorry, obtaining the current task is not yet "
"supported with this arch")
--
2.20.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RESEND] scripts/gdb: add lx_current support for riscv
2023-02-22 9:37 [PATCH RESEND] scripts/gdb: add lx_current support for riscv Song Shuai
@ 2023-02-22 9:52 ` Conor Dooley
2023-02-22 10:13 ` Song Shuai
0 siblings, 1 reply; 3+ messages in thread
From: Conor Dooley @ 2023-02-22 9:52 UTC (permalink / raw)
To: Song Shuai
Cc: jan.kiszka, kbingham, paul.walmsley, palmer, aou, linux-kernel,
linux-riscv, akpm
[-- Attachment #1.1: Type: text/plain, Size: 1679 bytes --]
Hey Song
On Wed, Feb 22, 2023 at 05:37:30PM +0800, Song Shuai wrote:
> RISC-V uses the tp register to save the current task_struct address
> as its current() defines. So lx_current() of riscv just returns the
> dereference of the address cast via task_ptr_type.
FYI, there's already been some patches posted for this:
https://lore.kernel.org/all/mhng-bdcd75a5-e6d6-4090-8292-a32eb46e4464@palmer-ri-x1c9a/
That version already has review and ack tags from Palmer and others.
It seems to me that Andrew is the usual applier of patches for this
script, so I'm gonna add him to CC here so he is aware - but as it is
the middle of the merge window the best course of action might just be
reposting that patch, CCing Andrew, after v6.3-rc1.
Cheers,
Conor.
>
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> ---
> scripts/gdb/linux/cpus.py | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
> index 15fc4626d236..6825a9834394 100644
> --- a/scripts/gdb/linux/cpus.py
> +++ b/scripts/gdb/linux/cpus.py
> @@ -173,6 +173,9 @@ def get_current_task(cpu):
> else:
> raise gdb.GdbError("Sorry, obtaining the current task is not allowed "
> "while running in userspace(EL0)")
> + elif utils.is_target_arch("riscv"):
> + current_task_addr = gdb.parse_and_eval("$tp")
> + return current_task_addr.cast(task_ptr_type).dereference()
> else:
> raise gdb.GdbError("Sorry, obtaining the current task is not yet "
> "supported with this arch")
> --
> 2.20.1
>
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH RESEND] scripts/gdb: add lx_current support for riscv
2023-02-22 9:52 ` Conor Dooley
@ 2023-02-22 10:13 ` Song Shuai
0 siblings, 0 replies; 3+ messages in thread
From: Song Shuai @ 2023-02-22 10:13 UTC (permalink / raw)
To: Conor Dooley
Cc: jan.kiszka, kbingham, paul.walmsley, palmer, aou, linux-kernel,
linux-riscv, akpm
Conor Dooley <conor.dooley@microchip.com> 于2023年2月22日周三 09:53写道:
>
> Hey Song
>
> On Wed, Feb 22, 2023 at 05:37:30PM +0800, Song Shuai wrote:
> > RISC-V uses the tp register to save the current task_struct address
> > as its current() defines. So lx_current() of riscv just returns the
> > dereference of the address cast via task_ptr_type.
>
> FYI, there's already been some patches posted for this:
> https://lore.kernel.org/all/mhng-bdcd75a5-e6d6-4090-8292-a32eb46e4464@palmer-ri-x1c9a/
>
Deepak's patch is much better than mine, which also takes the
userspace and trap handler into count.
So no need to care about this patch.
> That version already has review and ack tags from Palmer and others.
> It seems to me that Andrew is the usual applier of patches for this
> script, so I'm gonna add him to CC here so he is aware - but as it is
> the middle of the merge window the best course of action might just be
> reposting that patch, CCing Andrew, after v6.3-rc1.
>
> Cheers,
> Conor.
>
> >
> > Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> > ---
> > scripts/gdb/linux/cpus.py | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py
> > index 15fc4626d236..6825a9834394 100644
> > --- a/scripts/gdb/linux/cpus.py
> > +++ b/scripts/gdb/linux/cpus.py
> > @@ -173,6 +173,9 @@ def get_current_task(cpu):
> > else:
> > raise gdb.GdbError("Sorry, obtaining the current task is not allowed "
> > "while running in userspace(EL0)")
> > + elif utils.is_target_arch("riscv"):
> > + current_task_addr = gdb.parse_and_eval("$tp")
> > + return current_task_addr.cast(task_ptr_type).dereference()
> > else:
> > raise gdb.GdbError("Sorry, obtaining the current task is not yet "
> > "supported with this arch")
> > --
> > 2.20.1
> >
> >
--
Thanks,
Song
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-22 10:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-22 9:37 [PATCH RESEND] scripts/gdb: add lx_current support for riscv Song Shuai
2023-02-22 9:52 ` Conor Dooley
2023-02-22 10:13 ` Song Shuai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox