Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5484454pxb; Wed, 26 Jan 2022 13:08:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJw34dUJj4HrCoBLk5eJfxheAfcxIaV/fNQamuWS0PKsxkO2QdKZnPFwVW192Bq4a+PLxFFU X-Received: by 2002:a17:90b:b0d:: with SMTP id bf13mr10441770pjb.31.1643231290664; Wed, 26 Jan 2022 13:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643231290; cv=none; d=google.com; s=arc-20160816; b=guIIXqC9XO3xTHjFB62DOfUULab9RudtyWC0xrUjlcgisyO7GJjXa2tdIfHMDOXqRb UKMmEQfQzrBG8g7X+PbDKSt10qoxSSMKQ6+tMEMNYqnVMUQ0HfsmyEc3VsjTMylFhOgg YWJQQmplxym6hpwKW0GpLzDY8YbRCqQbOLq5iMHx45fazx2T6rYo0V0aWc+faz7Ehwo1 Z1v88ibfxs5gGSbFfjozM5kggsAGjY6ksRysBeBOzNMq/1QGldge6egwZ4XPWLM4WcX0 Yh/D/NzTFQZUsIJpR4ksvegr4HCb3+AeKT2b/vWrAOFVRbIETl89lLROJiMFLOMyH42T B6wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=JKFljMMHrSjJJS6S4fdrZOKdr35JH+G439ROiQOmWAY=; b=sUsqprQWZjvIrW97xhZ9dB4MYVp7pQKhJswD3kg353uK+wqvUMXV3LyGOfNNAYVn+O eYn7SDq7xB9AjzLq3fehK1okDE7oU2EhzLy03lEJ43aqLzIqQg/9ohIxTTaOQ/5tkaOx 5IgWyqFwbY98cbYhP4OK/7OR+DtgKAg072n4tChV9ObaWObg2/LezrvIwolIiowzQO5k Dc+OHmiwSruQDxncMDcfoVzNNWWG+J8oINj2aH7dS8olOnLKp16BwSExGG7OJfQOJuBY 1izptY4lr3Mst8aHO0RwCEpEMzOaJIyPlzGmpZN79UkHRM1PGWavBVDWe2z+pz2wIVyI CPkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q195si308540pgq.607.2022.01.26.13.07.57; Wed, 26 Jan 2022 13:08:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240619AbiAZLVj (ORCPT + 99 others); Wed, 26 Jan 2022 06:21:39 -0500 Received: from gate.crashing.org ([63.228.1.57]:60260 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbiAZLVh (ORCPT ); Wed, 26 Jan 2022 06:21:37 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 20QBDv5f023172; Wed, 26 Jan 2022 05:13:57 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 20QBDtdZ023171; Wed, 26 Jan 2022 05:13:55 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 26 Jan 2022 05:13:55 -0600 From: Segher Boessenkool To: Nick Desaulniers Cc: Josh Poimboeuf , Borislav Petkov , Vasily Gorbik , Linus Torvalds , Ingo Molnar , Dave Hansen , Thomas Gleixner , Peter Zijlstra , Luc Van Oostenryck , x86@kernel.org, llvm@lists.linux.dev, linux-sparse@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot , Nathan Chancellor , linux-toolchains@vger.kernel.org, apinski@marvell.com Subject: Re: [PATCH] objtool: prefer memory clobber & %= to volatile & __COUNTER__ Message-ID: <20220126111355.GU614@gate.crashing.org> References: <20220114010526.1776605-1-ndesaulniers@google.com> <20220118192256.jzk5dnceeusq7x7u@treble> <20220118230120.pivvson7qekfiqic@treble> <20220125233128.GT614@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Tue, Jan 25, 2022 at 06:12:20PM -0800, Nick Desaulniers wrote: > Andrew clarified (thanks Andrew!) that %= can't be used as I imagined > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104236#c4 > and that I think was alluded to in > commit 3d1e236022cc ("objtool: Prevent GCC from merging annotate_unreachable()") > which is fine, so I'll just need to keep usage of __COUNTER__. Aha. Yes, %= *outputs* a unique number. Before the assembler output is written %= is just a string (like any other piece of output template). The output template is used for three things: 1) Inline assembler statements with different output templates are not considered identical; 2) Newlines and assembler statement separators (semicolons for most assembler dialects) are used to estimate the size of the machine code generated. This is a pessimistic estimate, but within reason: for example you can write a million byte output with just a few characters of input, if you want to sabotage yourself; 3) The output template is used at output time. The mentioned commit's message says "unfortunately older versions of GCC don't support it" which is mistaken. If you want two identical inline asm statements to not be considered identical by the compiler, you have to make them not identical. Like by using __COUNTER__ for example, yes :-) Segher