Received: by 10.223.176.46 with SMTP id f43csp58485wra; Tue, 23 Jan 2018 16:06:28 -0800 (PST) X-Google-Smtp-Source: AH8x227rSZQDn4yqId7/PlAeWPGLyRhyXfNrJV97wStNV/CRWnfEIGO6CjQLX1eHwO5bK+MW+RiT X-Received: by 10.101.65.205 with SMTP id b13mr9578344pgq.280.1516752388869; Tue, 23 Jan 2018 16:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516752388; cv=none; d=google.com; s=arc-20160816; b=SBwQnpwAOEc5pdPc8YlHH/14BjgVwbIQks2iEgE0kGytlupxK56WNd+W6rtlB1QNha LNQWgFygiFxE3ABdYDRkXUKS+cNpOqPpc2mSvFMBI0tWl4y0OJz0ov+hSPXqhKh6E+a4 ZVCHLDf7WFnK/ezRjDPNo4d7+zW/rB1smSuMatX3GO9b+tcByrgyoFmbZMCnVSFyGIlD l1TTqQltLMisDn6euoahTUeK3zbcboURkuY5NF2E+s/AiQhtw3a32YSvPkK0kXTDKoou H9r7sxAE3y0uOy40LGLwq8lnvAarsVBh5s+m19m93DMyolUb0AwWr5M38hfg56U7hTw+ 4khQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=6T/jdCEwviijiYR69GN/GH+ifxgl3Q0oZhgxpbHWAdg=; b=Uhr+w3iPvcxcL+xpl84UsF5SbTASsZH/j5EZxJHHVrhjNOA/a6yKzSeaWyDb7uIFaG vrA9JlcTVHONKFrnITv3OiyokCjw2l7tZrb4HJge2UpOAyIoqiK1zhQFe8xODG1oe/aN 35OeRFnpxuO4Y8m6mdBzTl9ascamzZiA8tj+XdVzDqNk/3MGgNm2PQyh1VzAs1UhA0T5 PhxVH7VWOBdHPxc4ASmzkIJDjgPUvdEQrsrhyALbczSntiqqDvrdYph+y20wcK7RTHu9 FarWsq4XkYWDG2jYD/t8MvHNLPVYu1iTmGpZg9f8uRtTYuxKS6ESSRf9sTt7LOJgxGn9 qVuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si1093190plz.239.2018.01.23.16.06.07; Tue, 23 Jan 2018 16:06:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbeAXAFe (ORCPT + 99 others); Tue, 23 Jan 2018 19:05:34 -0500 Received: from mga09.intel.com ([134.134.136.24]:37372 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752535AbeAXAFd (ORCPT ); Tue, 23 Jan 2018 19:05:33 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jan 2018 16:05:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,404,1511856000"; d="scan'208";a="28943638" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.35]) by orsmga002.jf.intel.com with ESMTP; 23 Jan 2018 16:05:32 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id 9B2D7300D79; Tue, 23 Jan 2018 16:05:23 -0800 (PST) From: Andi Kleen To: Ingo Molnar Cc: David Woodhouse , Linus Torvalds , KarimAllah Ahmed , Linux Kernel Mailing List , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott Subject: Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation References: <1516476182-5153-1-git-send-email-karahmed@amazon.de> <1516476182-5153-10-git-send-email-karahmed@amazon.de> <1516566497.9814.78.camel@infradead.org> <1516572013.9814.109.camel@infradead.org> <1516638426.9521.20.camel@infradead.org> <20180123072930.soz25cyky3u4hpgv@gmail.com> Date: Tue, 23 Jan 2018 16:05:23 -0800 In-Reply-To: <20180123072930.soz25cyky3u4hpgv@gmail.com> (Ingo Molnar's message of "Tue, 23 Jan 2018 08:29:30 +0100") Message-ID: <87o9lkjf3w.fsf@linux.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ingo Molnar writes: > > Is there any reason why this wouldn't work? To actually maintain the true call depth you would need to intercept the return of the function too, because the counter has to be decremented at the end of the function. Plain ftrace cannot do that because it only intercepts the function entry. The function graph tracer can do this, but only at the cost of overwriting the return address (and saving return in a special stack) This always causes a mispredict on every return, and other overhead, and is one of the reasons why function graph is so much slower than the plain function tracer. I suspect the overhead would be significant. To make your scheme work efficiently work likely we would need custom gcc instrumentation for the returns. FWIW our plan was to add enough manual stuffing at strategic points, until we're sure enough of good enough coverage. -Andi