linux-csky.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* set_thread_area.2: csky architecture undocumented
@ 2020-11-23 21:31 Alejandro Colomar (man-pages)
  2020-11-23 21:48 ` Michael Kerrisk (man-pages)
  2020-11-24  9:51 ` Michael Kerrisk (man-pages)
  0 siblings, 2 replies; 8+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-11-23 21:31 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages)
  Cc: linux-man, linux-kernel, Guo Ren, linux-csky, Arnd Bergmann

Hi Michael,

SYNOPSIS
       #include <linux/unistd.h>

       #if defined __i386__ || defined __x86_64__
       # include <asm/ldt.h>

       int get_thread_area(struct user_desc *u_info);
       int set_thread_area(struct user_desc *u_info);

       #elif defined __m68k__

       int get_thread_area(void);
       int set_thread_area(unsigned long tp);

       #elif defined __mips__

       int set_thread_area(unsigned long addr);

       #endif

       Note: There are no glibc wrappers for these system  calls;  see
       NOTES.


$ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
arch/csky/kernel/syscall.c:6:
SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
arch/mips/kernel/syscall.c:86:
SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
arch/x86/kernel/tls.c:191:
SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
arch/x86/kernel/tls.c:243:
SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
arch/x86/um/tls_32.c:277:
SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
arch/x86/um/tls_32.c:325:
SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)


See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184


I'd change
-      #elif defined __mips__
+      #elif defined(__mips__ || __csky__)

and then change the rest of the text to add csky when appropriate.
Am I correct?

Thanks,

Alex

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-23 21:31 set_thread_area.2: csky architecture undocumented Alejandro Colomar (man-pages)
@ 2020-11-23 21:48 ` Michael Kerrisk (man-pages)
  2020-11-24  9:51 ` Michael Kerrisk (man-pages)
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-11-23 21:48 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages)
  Cc: linux-man, linux-kernel, Guo Ren, linux-csky, Arnd Bergmann

Hello Alex,

On Mon, 23 Nov 2020 at 22:31, Alejandro Colomar (man-pages)
<alx.manpages@gmail.com> wrote:
>
> Hi Michael,
>
> SYNOPSIS
>        #include <linux/unistd.h>
>
>        #if defined __i386__ || defined __x86_64__
>        # include <asm/ldt.h>
>
>        int get_thread_area(struct user_desc *u_info);
>        int set_thread_area(struct user_desc *u_info);
>
>        #elif defined __m68k__
>
>        int get_thread_area(void);
>        int set_thread_area(unsigned long tp);
>
>        #elif defined __mips__
>
>        int set_thread_area(unsigned long addr);
>
>        #endif
>
>        Note: There are no glibc wrappers for these system  calls;  see
>        NOTES.
>
>
> $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
> arch/csky/kernel/syscall.c:6:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> arch/mips/kernel/syscall.c:86:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> arch/x86/kernel/tls.c:191:
> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
> arch/x86/kernel/tls.c:243:
> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
> arch/x86/um/tls_32.c:277:
> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
> arch/x86/um/tls_32.c:325:
> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
>
>
> See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
>
>
> I'd change
> -      #elif defined __mips__
> +      #elif defined(__mips__ || __csky__)
>
> and then change the rest of the text to add csky when appropriate.
> Am I correct?

As far as I can tell, you are correct.

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-23 21:31 set_thread_area.2: csky architecture undocumented Alejandro Colomar (man-pages)
  2020-11-23 21:48 ` Michael Kerrisk (man-pages)
@ 2020-11-24  9:51 ` Michael Kerrisk (man-pages)
  2020-11-24 12:07   ` Guo Ren
  2020-11-26 12:14   ` Alejandro Colomar (mailing lists; readonly)
  1 sibling, 2 replies; 8+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-11-24  9:51 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages)
  Cc: mtk.manpages, linux-man, linux-kernel, Guo Ren, linux-csky,
	Arnd Bergmann

Hi Alex,

On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> SYNOPSIS
>        #include <linux/unistd.h>
> 
>        #if defined __i386__ || defined __x86_64__
>        # include <asm/ldt.h>
> 
>        int get_thread_area(struct user_desc *u_info);
>        int set_thread_area(struct user_desc *u_info);
> 
>        #elif defined __m68k__
> 
>        int get_thread_area(void);
>        int set_thread_area(unsigned long tp);
> 
>        #elif defined __mips__
> 
>        int set_thread_area(unsigned long addr);
> 
>        #endif
> 
>        Note: There are no glibc wrappers for these system  calls;  see
>        NOTES.
> 
> 
> $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
> arch/csky/kernel/syscall.c:6:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> arch/mips/kernel/syscall.c:86:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> arch/x86/kernel/tls.c:191:
> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
> arch/x86/kernel/tls.c:243:
> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
> arch/x86/um/tls_32.c:277:
> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
> arch/x86/um/tls_32.c:325:
> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
> 
> 
> See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
> 
> 
> I'd change
> -      #elif defined __mips__
> +      #elif defined(__mips__ || __csky__)
> 
> and then change the rest of the text to add csky when appropriate.
> Am I correct?

AFAICT, you are correct. I think the reason that csky is missing is
that the architecture was added after this manual pages was added.

Thanks,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-24  9:51 ` Michael Kerrisk (man-pages)
@ 2020-11-24 12:07   ` Guo Ren
  2020-11-26 12:16     ` Alejandro Colomar (mailing lists; readonly)
  2023-10-14 23:20     ` Alejandro Colomar
  2020-11-26 12:14   ` Alejandro Colomar (mailing lists; readonly)
  1 sibling, 2 replies; 8+ messages in thread
From: Guo Ren @ 2020-11-24 12:07 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages)
  Cc: Alejandro Colomar (man-pages),
	linux-man, linux-kernel, linux-csky, Arnd Bergmann

Thx Michael & Alejandro,

Yes, the man page has no csky's.

C-SKY have abiv1 and abiv2
For abiv1: There is no register for tls saving, We use trap 3 to got
tls and use set_thread_area to init ti->tp_value.
For abiv2: The r31 is the tls register. We could directly read r31 to
got r31 and use set_thread_area to init reg->tls value.

In glibc:
# ifdef __CSKYABIV2__
/* Define r31 as thread pointer register.  */
#  define READ_THREAD_POINTER() \
        mov r0, r31;
# else
#  define READ_THREAD_POINTER() \
        trap 3;
# endif

/* Code to initially initialize the thread pointer.  This might need
   special attention since 'errno' is not yet available and if the
   operation can cause a failure 'errno' must not be touched.  */
# define TLS_INIT_TP(tcbp) \
  ({ INTERNAL_SYSCALL_DECL (err);                                       \
     long result_var;                                                   \
     result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,            \
                    (char *) (tcbp) + TLS_TCB_OFFSET);                  \
     INTERNAL_SYSCALL_ERROR_P (result_var, err)                         \
       ? "unknown error" : NULL; })

In kernel:
SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
{
        struct thread_info *ti = task_thread_info(current);
        struct pt_regs *reg = current_pt_regs();

        reg->tls = addr;
        ti->tp_value = addr;

        return 0;
}

Any comments are welcome :)


On Tue, Nov 24, 2020 at 5:51 PM Michael Kerrisk (man-pages)
<mtk.manpages@gmail.com> wrote:
>
> Hi Alex,
>
> On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
> > Hi Michael,
> >
> > SYNOPSIS
> >        #include <linux/unistd.h>
> >
> >        #if defined __i386__ || defined __x86_64__
> >        # include <asm/ldt.h>
> >
> >        int get_thread_area(struct user_desc *u_info);
> >        int set_thread_area(struct user_desc *u_info);
> >
> >        #elif defined __m68k__
> >
> >        int get_thread_area(void);
> >        int set_thread_area(unsigned long tp);
> >
> >        #elif defined __mips__
> >
> >        int set_thread_area(unsigned long addr);
> >
> >        #endif
> >
> >        Note: There are no glibc wrappers for these system  calls;  see
> >        NOTES.
> >
> >
> > $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
> > arch/csky/kernel/syscall.c:6:
> > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > arch/mips/kernel/syscall.c:86:
> > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > arch/x86/kernel/tls.c:191:
> > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
> > arch/x86/kernel/tls.c:243:
> > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
> > arch/x86/um/tls_32.c:277:
> > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
> > arch/x86/um/tls_32.c:325:
> > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
> >
> >
> > See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
> >
> >
> > I'd change
> > -      #elif defined __mips__
> > +      #elif defined(__mips__ || __csky__)
> >
> > and then change the rest of the text to add csky when appropriate.
> > Am I correct?
>
> AFAICT, you are correct. I think the reason that csky is missing is
> that the architecture was added after this manual pages was added.
>
> Thanks,
>
> Michael
>
>
> --
> Michael Kerrisk
> Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
> Linux/UNIX System Programming Training: http://man7.org/training/



--
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-24  9:51 ` Michael Kerrisk (man-pages)
  2020-11-24 12:07   ` Guo Ren
@ 2020-11-26 12:14   ` Alejandro Colomar (mailing lists; readonly)
  1 sibling, 0 replies; 8+ messages in thread
From: Alejandro Colomar (mailing lists; readonly) @ 2020-11-26 12:14 UTC (permalink / raw)
  To: Michael Kerrisk (man-pages), Alejandro Colomar (man-pages)
  Cc: linux-man, linux-kernel, Guo Ren, linux-csky, Arnd Bergmann

HI Michael,

On 11/24/20 10:51 AM, Michael Kerrisk (man-pages) wrote:
> Hi Alex,
> 
> On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
>> Hi Michael,
>>
>> SYNOPSIS
>>        #include <linux/unistd.h>
>>
>>        #if defined __i386__ || defined __x86_64__
>>        # include <asm/ldt.h>
>>
>>        int get_thread_area(struct user_desc *u_info);
>>        int set_thread_area(struct user_desc *u_info);
>>
>>        #elif defined __m68k__
>>
>>        int get_thread_area(void);
>>        int set_thread_area(unsigned long tp);
>>
>>        #elif defined __mips__
>>
>>        int set_thread_area(unsigned long addr);
>>
>>        #endif
>>
>>        Note: There are no glibc wrappers for these system  calls;  see
>>        NOTES.
>>
>>
>> $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
>> arch/csky/kernel/syscall.c:6:
>> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
>> arch/mips/kernel/syscall.c:86:
>> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
>> arch/x86/kernel/tls.c:191:
>> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
>> arch/x86/kernel/tls.c:243:
>> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
>> arch/x86/um/tls_32.c:277:
>> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
>> arch/x86/um/tls_32.c:325:
>> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
>>
>>
>> See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
>>
>>
>> I'd change
>> -      #elif defined __mips__
>> +      #elif defined(__mips__ || __csky__)
>>
>> and then change the rest of the text to add csky when appropriate.
>> Am I correct?
> 
> AFAICT, you are correct. I think the reason that csky is missing is
> that the architecture was added after this manual pages was added.

Yep, I guessed it was that :)

Thanks,

Alex

> 
> Thanks,
> 
> Michael
> 
> 

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-24 12:07   ` Guo Ren
@ 2020-11-26 12:16     ` Alejandro Colomar (mailing lists; readonly)
  2023-10-14 23:20     ` Alejandro Colomar
  1 sibling, 0 replies; 8+ messages in thread
From: Alejandro Colomar (mailing lists; readonly) @ 2020-11-26 12:16 UTC (permalink / raw)
  To: Guo Ren, Michael Kerrisk (man-pages)
  Cc: Alejandro Colomar (man-pages),
	linux-man, linux-kernel, linux-csky, Arnd Bergmann

Hi Guo,

Thanks for the details!
I'll try to add csky to the man page,
and if I have any doubts I'll ask you.
Anyway, I'll CC you in any change I propose.

Cheers,

Alex

On 11/24/20 1:07 PM, Guo Ren wrote:
> Thx Michael & Alejandro,
> 
> Yes, the man page has no csky's.
> 
> C-SKY have abiv1 and abiv2
> For abiv1: There is no register for tls saving, We use trap 3 to got
> tls and use set_thread_area to init ti->tp_value.
> For abiv2: The r31 is the tls register. We could directly read r31 to
> got r31 and use set_thread_area to init reg->tls value.
> 
> In glibc:
> # ifdef __CSKYABIV2__
> /* Define r31 as thread pointer register.  */
> #  define READ_THREAD_POINTER() \
>         mov r0, r31;
> # else
> #  define READ_THREAD_POINTER() \
>         trap 3;
> # endif
> 
> /* Code to initially initialize the thread pointer.  This might need
>    special attention since 'errno' is not yet available and if the
>    operation can cause a failure 'errno' must not be touched.  */
> # define TLS_INIT_TP(tcbp) \
>   ({ INTERNAL_SYSCALL_DECL (err);                                       \
>      long result_var;                                                   \
>      result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,            \
>                     (char *) (tcbp) + TLS_TCB_OFFSET);                  \
>      INTERNAL_SYSCALL_ERROR_P (result_var, err)                         \
>        ? "unknown error" : NULL; })
> 
> In kernel:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> {
>         struct thread_info *ti = task_thread_info(current);
>         struct pt_regs *reg = current_pt_regs();
> 
>         reg->tls = addr;
>         ti->tp_value = addr;
> 
>         return 0;
> }
> 
> Any comments are welcome :)
> 
> 
> On Tue, Nov 24, 2020 at 5:51 PM Michael Kerrisk (man-pages)
> <mtk.manpages@gmail.com> wrote:
>>
>> Hi Alex,
>>
>> On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
>>> Hi Michael,
>>>
>>> SYNOPSIS
>>>        #include <linux/unistd.h>
>>>
>>>        #if defined __i386__ || defined __x86_64__
>>>        # include <asm/ldt.h>
>>>
>>>        int get_thread_area(struct user_desc *u_info);
>>>        int set_thread_area(struct user_desc *u_info);
>>>
>>>        #elif defined __m68k__
>>>
>>>        int get_thread_area(void);
>>>        int set_thread_area(unsigned long tp);
>>>
>>>        #elif defined __mips__
>>>
>>>        int set_thread_area(unsigned long addr);
>>>
>>>        #endif
>>>
>>>        Note: There are no glibc wrappers for these system  calls;  see
>>>        NOTES.
>>>
>>>
>>> $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
>>> arch/csky/kernel/syscall.c:6:
>>> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
>>> arch/mips/kernel/syscall.c:86:
>>> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
>>> arch/x86/kernel/tls.c:191:
>>> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
>>> arch/x86/kernel/tls.c:243:
>>> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
>>> arch/x86/um/tls_32.c:277:
>>> SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
>>> arch/x86/um/tls_32.c:325:
>>> SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
>>>
>>>
>>> See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
>>>
>>>
>>> I'd change
>>> -      #elif defined __mips__
>>> +      #elif defined(__mips__ || __csky__)
>>>
>>> and then change the rest of the text to add csky when appropriate.
>>> Am I correct?
>>
>> AFAICT, you are correct. I think the reason that csky is missing is
>> that the architecture was added after this manual pages was added.
>>
>> Thanks,
>>
>> Michael
>>
>>
>> --
>> Michael Kerrisk
>> Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
>> Linux/UNIX System Programming Training: http://man7.org/training/
> 
> 
> 
> --
> Best Regards
>  Guo Ren
> 
> ML: https://lore.kernel.org/linux-csky/
> 

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

* Re: set_thread_area.2: csky architecture undocumented
  2020-11-24 12:07   ` Guo Ren
  2020-11-26 12:16     ` Alejandro Colomar (mailing lists; readonly)
@ 2023-10-14 23:20     ` Alejandro Colomar
  2023-10-15 15:09       ` Guo Ren
  1 sibling, 1 reply; 8+ messages in thread
From: Alejandro Colomar @ 2023-10-14 23:20 UTC (permalink / raw)
  To: Guo Ren; +Cc: linux-man, linux-kernel, linux-csky, Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 4554 bytes --]

Hi Guo,

On Tue, Nov 24, 2020 at 08:07:07PM +0800, Guo Ren wrote:

Huh, 3 years already!  I've had this in my head for all this time; just
didn't find the energy to act on it.

> Thx Michael & Alejandro,
> 
> Yes, the man page has no csky's.

I've applied a patch to add initial documentation for it:
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=a63979eb24aaf73f4be5799cc9579f84a3874b7d>

> 
> C-SKY have abiv1 and abiv2
> For abiv1: There is no register for tls saving, We use trap 3 to got
> tls and use set_thread_area to init ti->tp_value.
> For abiv2: The r31 is the tls register. We could directly read r31 to
> got r31 and use set_thread_area to init reg->tls value.
> 
> In glibc:
> # ifdef __CSKYABIV2__
> /* Define r31 as thread pointer register.  */
> #  define READ_THREAD_POINTER() \
>         mov r0, r31;
> # else
> #  define READ_THREAD_POINTER() \
>         trap 3;
> # endif
> 
> /* Code to initially initialize the thread pointer.  This might need
>    special attention since 'errno' is not yet available and if the
>    operation can cause a failure 'errno' must not be touched.  */
> # define TLS_INIT_TP(tcbp) \
>   ({ INTERNAL_SYSCALL_DECL (err);                                       \
>      long result_var;                                                   \
>      result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,            \
>                     (char *) (tcbp) + TLS_TCB_OFFSET);                  \
>      INTERNAL_SYSCALL_ERROR_P (result_var, err)                         \
>        ? "unknown error" : NULL; })
> 
> In kernel:
> SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> {
>         struct thread_info *ti = task_thread_info(current);
>         struct pt_regs *reg = current_pt_regs();
> 
>         reg->tls = addr;
>         ti->tp_value = addr;
> 
>         return 0;
> }
> 
> Any comments are welcome :)

I'm sorry, but I have little understanding of this syscall, and that
shounds like gibberish to me :)

Feel free to send a patch to improve the documentation for csky.

Cheers,
Alex

> 
> 
> On Tue, Nov 24, 2020 at 5:51 PM Michael Kerrisk (man-pages)
> <mtk.manpages@gmail.com> wrote:
> >
> > Hi Alex,
> >
> > On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
> > > Hi Michael,
> > >
> > > SYNOPSIS
> > >        #include <linux/unistd.h>
> > >
> > >        #if defined __i386__ || defined __x86_64__
> > >        # include <asm/ldt.h>
> > >
> > >        int get_thread_area(struct user_desc *u_info);
> > >        int set_thread_area(struct user_desc *u_info);
> > >
> > >        #elif defined __m68k__
> > >
> > >        int get_thread_area(void);
> > >        int set_thread_area(unsigned long tp);
> > >
> > >        #elif defined __mips__
> > >
> > >        int set_thread_area(unsigned long addr);
> > >
> > >        #endif
> > >
> > >        Note: There are no glibc wrappers for these system  calls;  see
> > >        NOTES.
> > >
> > >
> > > $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
> > > arch/csky/kernel/syscall.c:6:
> > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > > arch/mips/kernel/syscall.c:86:
> > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > > arch/x86/kernel/tls.c:191:
> > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
> > > arch/x86/kernel/tls.c:243:
> > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
> > > arch/x86/um/tls_32.c:277:
> > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
> > > arch/x86/um/tls_32.c:325:
> > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
> > >
> > >
> > > See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
> > >
> > >
> > > I'd change
> > > -      #elif defined __mips__
> > > +      #elif defined(__mips__ || __csky__)
> > >
> > > and then change the rest of the text to add csky when appropriate.
> > > Am I correct?
> >
> > AFAICT, you are correct. I think the reason that csky is missing is
> > that the architecture was added after this manual pages was added.
> >
> > Thanks,
> >
> > Michael
> >
> >
> > --
> > Michael Kerrisk
> > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
> > Linux/UNIX System Programming Training: http://man7.org/training/
> 
> 
> 
> --
> Best Regards
>  Guo Ren
> 
> ML: https://lore.kernel.org/linux-csky/

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: set_thread_area.2: csky architecture undocumented
  2023-10-14 23:20     ` Alejandro Colomar
@ 2023-10-15 15:09       ` Guo Ren
  0 siblings, 0 replies; 8+ messages in thread
From: Guo Ren @ 2023-10-15 15:09 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man, linux-kernel, linux-csky, Arnd Bergmann

On Sun, Oct 15, 2023 at 01:20:42AM +0200, Alejandro Colomar wrote:
> Hi Guo,
> 
> On Tue, Nov 24, 2020 at 08:07:07PM +0800, Guo Ren wrote:
> 
> Huh, 3 years already!  I've had this in my head for all this time; just
> didn't find the energy to act on it.
> 
> > Thx Michael & Alejandro,
> > 
> > Yes, the man page has no csky's.
> 
> I've applied a patch to add initial documentation for it:
> <https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=a63979eb24aaf73f4be5799cc9579f84a3874b7d>
> 
> > 
> > C-SKY have abiv1 and abiv2
> > For abiv1: There is no register for tls saving, We use trap 3 to got
> > tls and use set_thread_area to init ti->tp_value.
> > For abiv2: The r31 is the tls register. We could directly read r31 to
> > got r31 and use set_thread_area to init reg->tls value.
> > 
> > In glibc:
> > # ifdef __CSKYABIV2__
> > /* Define r31 as thread pointer register.  */
> > #  define READ_THREAD_POINTER() \
> >         mov r0, r31;
> > # else
> > #  define READ_THREAD_POINTER() \
> >         trap 3;
> > # endif
> > 
> > /* Code to initially initialize the thread pointer.  This might need
> >    special attention since 'errno' is not yet available and if the
> >    operation can cause a failure 'errno' must not be touched.  */
> > # define TLS_INIT_TP(tcbp) \
> >   ({ INTERNAL_SYSCALL_DECL (err);                                       \
> >      long result_var;                                                   \
> >      result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,            \
> >                     (char *) (tcbp) + TLS_TCB_OFFSET);                  \
> >      INTERNAL_SYSCALL_ERROR_P (result_var, err)                         \
> >        ? "unknown error" : NULL; })
> > 
> > In kernel:
> > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > {
> >         struct thread_info *ti = task_thread_info(current);
> >         struct pt_regs *reg = current_pt_regs();
> > 
> >         reg->tls = addr;
> >         ti->tp_value = addr;
> > 
> >         return 0;
> > }
> > 
> > Any comments are welcome :)
> 
> I'm sorry, but I have little understanding of this syscall, and that
> shounds like gibberish to me :)
> 
> Feel free to send a patch to improve the documentation for csky.
Yeah, I've sent a patch for it; please review:
https://lore.kernel.org/linux-csky/20231015150732.1991997-1-guoren@kernel.org/

> 
> Cheers,
> Alex
> 
> > 
> > 
> > On Tue, Nov 24, 2020 at 5:51 PM Michael Kerrisk (man-pages)
> > <mtk.manpages@gmail.com> wrote:
> > >
> > > Hi Alex,
> > >
> > > On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote:
> > > > Hi Michael,
> > > >
> > > > SYNOPSIS
> > > >        #include <linux/unistd.h>
> > > >
> > > >        #if defined __i386__ || defined __x86_64__
> > > >        # include <asm/ldt.h>
> > > >
> > > >        int get_thread_area(struct user_desc *u_info);
> > > >        int set_thread_area(struct user_desc *u_info);
> > > >
> > > >        #elif defined __m68k__
> > > >
> > > >        int get_thread_area(void);
> > > >        int set_thread_area(unsigned long tp);
> > > >
> > > >        #elif defined __mips__
> > > >
> > > >        int set_thread_area(unsigned long addr);
> > > >
> > > >        #endif
> > > >
> > > >        Note: There are no glibc wrappers for these system  calls;  see
> > > >        NOTES.
> > > >
> > > >
> > > > $ grep -rn 'SYSCALL_DEFINE.*et_thread_area'
> > > > arch/csky/kernel/syscall.c:6:
> > > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > > > arch/mips/kernel/syscall.c:86:
> > > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
> > > > arch/x86/kernel/tls.c:191:
> > > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
> > > > arch/x86/kernel/tls.c:243:
> > > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info)
> > > > arch/x86/um/tls_32.c:277:
> > > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc)
> > > > arch/x86/um/tls_32.c:325:
> > > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc)
> > > >
> > > >
> > > > See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184
> > > >
> > > >
> > > > I'd change
> > > > -      #elif defined __mips__
> > > > +      #elif defined(__mips__ || __csky__)
> > > >
> > > > and then change the rest of the text to add csky when appropriate.
> > > > Am I correct?
> > >
> > > AFAICT, you are correct. I think the reason that csky is missing is
> > > that the architecture was added after this manual pages was added.
> > >
> > > Thanks,
> > >
> > > Michael
> > >
> > >
> > > --
> > > Michael Kerrisk
> > > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
> > > Linux/UNIX System Programming Training: http://man7.org/training/
> > 
> > 
> > 
> > --
> > Best Regards
> >  Guo Ren
> > 
> > ML: https://lore.kernel.org/linux-csky/
> 
> -- 
> <https://www.alejandro-colomar.es/>



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

end of thread, other threads:[~2023-10-15 15:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-23 21:31 set_thread_area.2: csky architecture undocumented Alejandro Colomar (man-pages)
2020-11-23 21:48 ` Michael Kerrisk (man-pages)
2020-11-24  9:51 ` Michael Kerrisk (man-pages)
2020-11-24 12:07   ` Guo Ren
2020-11-26 12:16     ` Alejandro Colomar (mailing lists; readonly)
2023-10-14 23:20     ` Alejandro Colomar
2023-10-15 15:09       ` Guo Ren
2020-11-26 12:14   ` Alejandro Colomar (mailing lists; readonly)

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