[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0507b86c-fe5a-7d47-07d2-e37e4dd94d1e@gmail.com>
Date: Thu, 26 Nov 2020 13:16:35 +0100
From: "Alejandro Colomar (mailing lists; readonly)"
<alx.mailinglists@...il.com>
To: Guo Ren <guoren@...nel.org>,
"Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
Cc: "Alejandro Colomar (man-pages)" <alx.manpages@...il.com>,
linux-man <linux-man@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-csky@...r.kernel.org, Arnd Bergmann <arnd@...db.de>
Subject: Re: set_thread_area.2: csky architecture undocumented
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@...il.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/
>
Powered by blists - more mailing lists