From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751245AbdKETxs (ORCPT ); Sun, 5 Nov 2017 14:53:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48176 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbdKETxr (ORCPT ); Sun, 5 Nov 2017 14:53:47 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6BD14820E7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jpoimboe@redhat.com Date: Sun, 5 Nov 2017 13:53:46 -0600 From: Josh Poimboeuf To: Linus Torvalds Cc: Ingo Molnar , Linux Kernel Mailing List , Thomas Gleixner , Peter Zijlstra , Andrew Morton Subject: Re: [GIT PULL] core kernel fixes Message-ID: <20171105195346.ndwucxwfhq25gqtp@treble> References: <20171105143346.c6idowugfpvkhd2k@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 05 Nov 2017 19:53:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 05, 2017 at 10:09:59AM -0800, Linus Torvalds wrote: > On Sun, Nov 5, 2017 at 6:33 AM, Ingo Molnar wrote: > > > > Please note that this pull request is RFC due to the top commit: > > > > ec1e1b610917: objtool: Prevent GCC from merging annotate_unreachable(), take 2 > > > > ... which is admittedly somewhat of an ad-hoc workaround for something the > > compiler should have done - if there's another solution we can try that. > > So I'm certainly ok with that workaround since apparently "asm > volatile" doesn't do it. > > That said, I think that if that asm needs to not be merged, it should > _also_ be marked as "volatile" - since that's the documented bit for > "not moved significantly". Of course, then because apparently that > isn't enough, the __COUNTER__ games are ok, but might really mention > an explicit comment in the code as to why they exist. Because right > now they look just odd and nonsensical. The GCC manual says: "asm statements that have no output operands, including asm goto statements, are implicitly volatile." Since these macros have input operands, but no output operands, I assume they're already implicitly volatile. But we can certainly make it explicit. And yes, a comment would be good. Something like so? diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 3672353a0acd..188ed9f65517 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -88,17 +88,22 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, /* Unreachable code */ #ifdef CONFIG_STACK_VALIDATION +/* + * These macros help objtool understand GCC code flow for unreachable code. + * The __COUNTER__ based labels are a hack to make each instance of the macros + * unique, to convince GCC not to merge duplicate inline asm statements. + */ #define annotate_reachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.reachable\n\t" \ - ".long %c0b - .\n\t" \ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ + ".pushsection .discard.reachable\n\t" \ + ".long %c0b - .\n\t" \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define annotate_unreachable() ({ \ - asm("%c0:\n\t" \ - ".pushsection .discard.unreachable\n\t" \ - ".long %c0b - .\n\t" \ - ".popsection\n\t" : : "i" (__COUNTER__)); \ + asm volatile("%c0:\n\t" \ + ".pushsection .discard.unreachable\n\t" \ + ".long %c0b - .\n\t" \ + ".popsection\n\t" : : "i" (__COUNTER__)); \ }) #define ASM_UNREACHABLE \ "999:\n\t" \