From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: ACJfBovkazHQO9q8fT3ki9EPTfOa6euoW8lMTQZGgRxVXPppa9GYy0b+WsxgcrwLo35xVHQPqt9N ARC-Seal: i=1; a=rsa-sha256; t=1516289501; cv=none; d=google.com; s=arc-20160816; b=N9SOm+wUyS1qh6IWdct4wE9i8xMKHd/WmYdkwM0ihWUN2M7jdhjeLhigGXa8PTdt42 JAN1WsLnaLShV+baU6s2ISGNJ0dq93och5vTuP73eBBu9sjHGhxlJAZ7Mx/+x7W0GkpE Es5IaXrcKefO8mwSRYp16N3pAhSvA1Vlf/Z7KfLj2ELGGrgU7Dx8VdCnJ+R57j0OxYYq KmJK+LQGvTL4JZ7cSCsCJvArUpA54ugnyGxC7xkqZXE1P1fBancLC6Gt+uvEHherGXXs pvKs9/O0N86FGYkU3m/ZV45EcJu8vWjQrXLMGzeol3DuP2zFc7hBlmuP9165gdBkmZqt ZMKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=RfkX8quQn2szYdok5iu/qsONYKy4db+V07eu9e4dQ7g=; b=GuwVQZTFtJq4mCAyRG2gaaMqwlU0uIKEMvPhbjam32J9yeMVnSp7nwvdm72hIZZn6F puAykED8pqs9lrUgPAPT0clwhqGNS8FU2hF/yoIc9rrkV+Z7KUpo3MgSOdwYv3R0AZxj 1ekr7Ii8MQhJRNdFLYgHPqKKI/gMFWpj5YnfqUx4+dAbCCmapXpk2VyqPjd8HS3okypr 8VUEVLyZStL3GdH0CUNt5VwtsvyeHm/qYScX1jyeVEog83foun2kKpAfOm95xD4RsQm9 EQY95HLAFK78EJuurMkRZkxx6s+KAs1t8pEFo5Q6x/tWF4mtFilrk5Cjook/Cy6WwXyY E7Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=VCagIpI8; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=VCagIpI8; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Date: Thu, 18 Jan 2018 16:31:31 +0100 From: Peter Zijlstra To: Borislav Petkov Cc: David Woodhouse , Josh Poimboeuf , linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Thomas Gleixner , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick Subject: Re: [PATCH v2 07/10] x86/jump_label: Implement arch_static_assert() Message-ID: <20180118153131.GG2249@hirez.programming.kicks-ass.net> References: <20180116142825.376986833@infradead.org> <20180116143241.293294318@infradead.org> <20180118133322.ep66qnyedjl6qeiv@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180118133322.ep66qnyedjl6qeiv@pd.tnic> User-Agent: Mutt/1.9.2 (2017-12-15) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1589760004576769543?= X-GMAIL-MSGID: =?utf-8?q?1589944781061330945?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, Jan 18, 2018 at 02:33:22PM +0100, Borislav Petkov wrote: > On Tue, Jan 16, 2018 at 03:28:32PM +0100, Peter Zijlstra wrote: > > Implement the static (branch) assertion. It simply emits the address > > of the next instruction into a special section which objtool will read > > and validate against either __jump_table or .altinstructions. > > > > Use like: > > > > if (static_branch_likely(_key)) { > > arch_static_assert(); > > /* do stuff */ > > } > > > > Or > > > > if (static_cpu_has(_feat)) { > > arch_static_assert(); > > It looks to me like the asserts can be moved into the macros and the > assertion checking can happen by default ...? Right until the point where someone writes: if (static_cpu_has(_feat) || ponies) at which point it, rightfully, unconditionally asserts. Not sure someone does that with static_cpu_has(), but there's static_branch*() users that do exactly that.