From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 21 Feb 2019 11:04:52 -0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gwm9q-00005a-B2 for speck@linutronix.de; Thu, 21 Feb 2019 12:04:51 +0100 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwm9o-000894-UW for speck@linutronix.de; Thu, 21 Feb 2019 11:04:49 +0000 Date: Thu, 21 Feb 2019 12:04:44 +0100 From: Peter Zijlstra Subject: [MODERATED] Re: [patch V2 09/10] MDS basics+ 9 Message-ID: <20190221110444.GD32477@hirez.programming.kicks-ass.net> References: <20190220150753.665964899@linutronix.de> <20190220151400.787843957@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20190220151400.787843957@linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Wed, Feb 20, 2019 at 04:08:02PM +0100, speck for Thomas Gleixner wrote: > static inline void mds_user_clear_cpu_buffers(void) > { > + if (static_branch_likely(&mds_user_clear_cond)) { > + if (__this_cpu_read(mds_cond_clear)) { > + __this_cpu_write(mds_cond_clear, 0); > + mds_clear_cpu_buffers(); > + } > + } > if (static_branch_likely(&mds_user_clear_always)) > mds_clear_cpu_buffers(); > } Results in: 998: e9 0b 00 00 00 jmpq 9a8 99d: 65 8b 05 00 00 00 00 mov %gs:0x0(%rip),%eax # 9a4 9a0: R_X86_64_PC32 mds_cond_clear-0x4 9a4: 85 c0 test %eax,%eax 9a6: 75 0f jne 9b7 9a8: e9 07 00 00 00 jmpq 9b4 9ad: 0f 00 2d 00 00 00 00 verw 0x0(%rip) # 9b4 9b0: R_X86_64_PC32 .rodata-0x4 9b4: 5b pop %rbx 9b5: 5d pop %rbp 9b6: c3 retq 9b7: 65 c7 05 00 00 00 00 movl $0x0,%gs:0x0(%rip) # 9c2 9be: 00 00 00 00 9ba: R_X86_64_PC32 mds_cond_clear-0x8 9c2: 0f 00 2d 00 00 00 00 verw 0x0(%rip) # 9c9 9c5: R_X86_64_PC32 .rodata-0x4 9c9: eb dd jmp 9a8 static inline void mds_user_clear_cpu_buffers(void) { if (!static_branch_likely(&mds_user_clear_always)) return; if (static_branch_likely(&mds_user_clear_cond)) { if (!__this_cpu_read(mds_cond_clear)) return; __this_cpu_write(mds_cond_clear, 0); } mds_clear_cpu_buffers(); } results in: 998: e9 22 00 00 00 jmpq 9bf 99d: e9 16 00 00 00 jmpq 9b8 9a2: 65 8b 05 00 00 00 00 mov %gs:0x0(%rip),%eax # 9a9 9a5: R_X86_64_PC32 mds_cond_clear-0x4 9a9: 85 c0 test %eax,%eax 9ab: 74 12 je 9bf 9ad: 65 c7 05 00 00 00 00 movl $0x0,%gs:0x0(%rip) # 9b8 9b4: 00 00 00 00 9b0: R_X86_64_PC32 mds_cond_clear-0x8 9b8: 0f 00 2d 00 00 00 00 verw 0x0(%rip) # 9bf 9bb: R_X86_64_PC32 .rodata-0x4 9bf: The only 'downside' is that means @mds_user_clear_always is now a misnomer (and needs be enabled for cond too).