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] [day] [month] [year] [list]
Message-ID: <11e30cd0.47dc.16f118a143d.Coremail.sunguoyun@loongson.cn>
Date:   Tue, 17 Dec 2019 09:47:39 +0800 (GMT+08:00)
From:   孙国云 <sunguoyun@...ngson.cn>
To:     "Paul Burton" <paulburton@...nel.org>
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: Re: [PATCH V3] MIPS: Add get_thread_area syscall

Dear Paul,

Thank you very much.
I didn`t know this way asm("rdhwr %0, $29" : "=r"(*ptls)) before.Now I have a test for it and it realy can work normally.
I just find get_thread_area syscall at path arch/x86.so I have a implement on MIPS platform. And I think set_thread_area and get_thread_area is matched in pairs.
Now it seems that the get_thread_area syscall is not necessary for criu.

Thanks,
    Guoyun Sun

&gt; -----原始邮件-----
&gt; 发件人: "Paul Burton" <paulburton@...nel.org>
&gt; 发送时间: 2019-12-17 03:33:33 (星期二)
&gt; 收件人: "Guoyun Sun" <sunguoyun@...ngson.cn>
&gt; 抄送: "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>
&gt; 主题: Re: [PATCH V3] MIPS: Add get_thread_area syscall
&gt; 
&gt; Hi Guoyun,
&gt; 
&gt; On Mon, Dec 16, 2019 at 10:17:51AM +0800, Guoyun Sun wrote:
&gt; &gt; CRIU(https://criu.org/) tools will dump TLS(Thread Local Storage) by
&gt; &gt; get_thread_area during checkpoint and restore TLS by set_thread_area during
&gt; &gt; restore. without this syscall, criu restore will fail on MIPS platform
&gt; &gt; because a variable with GCC __thread will be invalid.
&gt; &gt; 
&gt; &gt; The following function will be called when criu restore
&gt; &gt; 
&gt; &gt; static inline void restore_tls(tls_t *ptls) {
&gt; &gt;         asm volatile(
&gt; &gt;                      "move $4, %0                                   \n"
&gt; &gt;                      "li $2,  "__stringify(__NR_set_thread_area)"  \n"
&gt; &gt;                      "syscall                                       \n"
&gt; &gt;                      :
&gt; &gt;                      : "r"(*ptls)
&gt; &gt;                      : "$4","$2","memory");
&gt; &gt; 
&gt; &gt; the *ptls can be obtained by get_thread_area on MIPS platform when criu
&gt; &gt; checkpoint. just like this:
&gt; &gt; 
&gt; &gt; static inline void arch_get_tls(tls_t *ptls)
&gt; &gt; {
&gt; &gt; 	asm volatile(
&gt; &gt; 		     "move $4, %0				    \n"
&gt; &gt; 		     "li $2,  "__stringify(__NR_get_thread_area)"  \n"
&gt; &gt; 		     "syscall					    \n"
&gt; &gt; 		     :
&gt; &gt; 		     : "r"(ptls)
&gt; &gt; 		     : "$4","$2","memory");
&gt; &gt; 
&gt; &gt; }
&gt; 
&gt; Why would you need a syscall for this?
&gt; 
&gt; Why not retrieve the value using the rdhwr instruction just like every
&gt; other bit of code using thread-local storage does?
&gt; 
&gt; ie. something like:
&gt; 
&gt; static inline void arch_get_tls(tls_t *ptls)
&gt; {
&gt; 	asm("rdhwr %0, $29" : "=r"(*ptls));
&gt; }
&gt; 
&gt; Thanks,
&gt;     Paul
</lixuefeng@...ngson.cn></yangtiezhu@...ngson.cn></catalin.marinas@....com></geert@...ux-m68k.org></dhowells@...hat.com></heiko.carstens@...ibm.com></arnd@...db.de></christian.brauner@...ntu.com></peterz@...radead.org></jhogan@...nel.org></ralf@...ux-mips.org></sunguoyun@...ngson.cn></paulburton@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ