diff mbox series

[RESEND] scripts/gdb: add lx_current support for riscv

Message ID 20230222093730.1826523-1-suagrfillet@gmail.com (mailing list archive)
State Superseded
Headers show
Series [RESEND] scripts/gdb: add lx_current support for riscv | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 13 and now 13
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 0 this patch: 0
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 0 this patch: 0
conchuod/alphanumeric_selects success Out of order selects before the patch: 729 and now 729
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 2 this patch: 2
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
conchuod/source_inline success Was 0 now: 0
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Song Shuai Feb. 22, 2023, 9:37 a.m. UTC
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(+)

Comments

Conor Dooley Feb. 22, 2023, 9:52 a.m. UTC | #1
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
> 
>
Song Shuai Feb. 22, 2023, 10:13 a.m. UTC | #2
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
> >
> >
diff mbox series

Patch

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