Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933579AbbGUSua (ORCPT ); Tue, 21 Jul 2015 14:50:30 -0400 Received: from mail-qk0-f173.google.com ([209.85.220.173]:35285 "EHLO mail-qk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933295AbbGUSu2 (ORCPT ); Tue, 21 Jul 2015 14:50:28 -0400 Message-ID: <55AE9471.1000601@gmail.com> Date: Tue, 21 Jul 2015 14:50:25 -0400 From: Jason Baron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Borislav Petkov , Peter Zijlstra CC: Andy Lutomirski , Thomas Gleixner , Mikulas Patocka , Paul Mackerras , Arnaldo Carvalho de Melo , Kees Cook , Andrea Arcangeli , Vince Weaver , "hillf.zj" , Valdis Kletnieks , "linux-kernel@vger.kernel.org" , Steven Rostedt Subject: Re: Kernel broken on processors without performance counters References: <20150708160750.GQ19282@twins.programming.kicks-ass.net> <559D8250.8000707@gmail.com> <20150710141359.GJ19282@twins.programming.kicks-ass.net> <20150721082107.GE18673@twins.programming.kicks-ass.net> <20150721154959.GS19282@twins.programming.kicks-ass.net> <20150721161215.GU19282@twins.programming.kicks-ass.net> <20150721181553.GA3378@nazgul.tnic> In-Reply-To: <20150721181553.GA3378@nazgul.tnic> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2055 Lines: 76 On 07/21/2015 02:15 PM, Borislav Petkov wrote: > On Tue, Jul 21, 2015 at 06:12:15PM +0200, Peter Zijlstra wrote: >> Yes, if you start out false, you must be unlikely. If you start out >> true, you must be likely. >> >> We could maybe try and untangle that if there really is a good use case, >> but this is the current state. >> >> The whole reason this happened is because 'false' is like: >> >> >> ... >> >> 1: >> ... >> >> >> >> label: >> >> jmp 1b >> >> >> Where the code if out-of-line by default. The enable will rewrite the >> with a jmp label. > Btw, native_sched_clock() is kinda botched because of that, see below. > > I'd want that RDTSC to come first with a NOP preceding it which can > become a JMP in case some idiotic CPU can't do RDTSC and needs to use > jiffies. Instead, we *unconditionally* jump to RDTSC which is WTF?! We > can just as well do a normal unlikely() without the static_key: hmmm...so this is a case where need to the default the branch to the out-of-line branch at boot. That is, we can't just enable the out-of-line branch at boot time, b/c it might be too late at that point? IE native_sched_clock() gets called very early? Thanks, -Jason > > .globl native_sched_clock > .type native_sched_clock, @function > native_sched_clock: > pushq %rbp # > movq %rsp, %rbp #, > #APP > # 21 "./arch/x86/include/asm/jump_label.h" 1 > 1:.byte 0x0f,0x1f,0x44,0x00,0 > .pushsection __jump_table, "aw" > .balign 8 > .quad 1b, .L122, __use_tsc #, > .popsection > > # 0 "" 2 > #NO_APP > movabsq $-4294667296000000, %rax #, tmp118 > popq %rbp # > imulq $1000000, jiffies_64(%rip), %rdx #, jiffies_64, D.28443 > addq %rdx, %rax # D.28443, D.28443 > ret > .L122: > #APP > # 118 "./arch/x86/include/asm/msr.h" 1 > rdtsc > # 0 "" 2 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/