lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 16 Dec 2019 11:33:33 -0800
From:   Paul Burton <paulburton@...nel.org>
To:     Guoyun Sun <sunguoyun@...ngson.cn>
Cc:     Ralf Baechle <ralf@...ux-mips.org>,
        James Hogan <jhogan@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Christian Brauner <christian.brauner@...ntu.com>,
        Arnd Bergmann <arnd@...db.de>,
        Heiko Carstens <heiko.carstens@...ibm.com>,
        David Howells <dhowells@...hat.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Catalin Marinas <catalin.marinas@....com>,
        linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
        Tiezhu Yang <yangtiezhu@...ngson.cn>,
        Xuefeng Li <lixuefeng@...ngson.cn>
Subject: Re: [PATCH V3] MIPS: Add get_thread_area syscall

Hi Guoyun,

On Mon, Dec 16, 2019 at 10:17:51AM +0800, Guoyun Sun wrote:
> CRIU(https://criu.org/) tools will dump TLS(Thread Local Storage) by
> get_thread_area during checkpoint and restore TLS by set_thread_area during
> restore. without this syscall, criu restore will fail on MIPS platform
> because a variable with GCC __thread will be invalid.
> 
> The following function will be called when criu restore
> 
> static inline void restore_tls(tls_t *ptls) {
>         asm volatile(
>                      "move $4, %0                                   \n"
>                      "li $2,  "__stringify(__NR_set_thread_area)"  \n"
>                      "syscall                                       \n"
>                      :
>                      : "r"(*ptls)
>                      : "$4","$2","memory");
> 
> the *ptls can be obtained by get_thread_area on MIPS platform when criu
> checkpoint. just like this:
> 
> static inline void arch_get_tls(tls_t *ptls)
> {
> 	asm volatile(
> 		     "move $4, %0				    \n"
> 		     "li $2,  "__stringify(__NR_get_thread_area)"  \n"
> 		     "syscall					    \n"
> 		     :
> 		     : "r"(ptls)
> 		     : "$4","$2","memory");
> 
> }

Why would you need a syscall for this?

Why not retrieve the value using the rdhwr instruction just like every
other bit of code using thread-local storage does?

ie. something like:

static inline void arch_get_tls(tls_t *ptls)
{
	asm("rdhwr %0, $29" : "=r"(*ptls));
}

Thanks,
    Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ