From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225r8BStUfY8124krykPe0i95wB6OwEnVAa7/PXXwdjr5eSKoy7XODbOmz0rNmnck8tEhA4n ARC-Seal: i=1; a=rsa-sha256; t=1516752333; cv=none; d=google.com; s=arc-20160816; b=qwPGr0wnmoVol5Ovee91GisKNzAjPNqv5u70LYurrgMqnAEEOW8zlHthWlzD1RfbPU EJujLcjNc2vcJdxYsA3D3h2sSTWd5qQNHr+O1l+A5XvfJq6e7b/oODTQ9lhX5v+FhAiQ h8fwn/XT2v32nqYVs47F5oxCwmnsXDak1trPrzVt0Ry+91I7IRcEhOkxC+o/VQnd03MG AdXOIAjcBLCcaigcxjvrYQ2PEnOzPgWTNtKYGZqxLAtp0Bpxc8p1Gi/qutHryM3+T491 qImMpU9cRuorAJ7VdTU4tqTpCs+i8WEACSGMUlwqmlAdH3lE7w1Z0YzKdpx8Rb2FN812 nk4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:arc-authentication-results; bh=6T/jdCEwviijiYR69GN/GH+ifxgl3Q0oZhgxpbHWAdg=; b=TlvJEj0FCDtawN6iBd8YaT7Qaxp3pGX1jJhT0WrKIDcDRESoRcXLX7l0pJfQITJxoo 1RApz4FCBS5e/oPzbGtON2sCYeKpEeB7Q9OPaH0DkGyLkUya1hrUu3ZndRvNt5lXbipV 19iLkTeWLyI+cciI9cv8F0BrSgRvHRJkZO7F7ukB4eASstf/LJjog1cJJNpsMi0p4x1P yn0/rwE1JXlGOGY9Ux5ic6eKFqhccAqHZ+isFU3sXm1P2fIQmb7/SW6uKOtuEbomeOH3 a/WmJjyz8ZEBpBsLfkVm0o1QW60UxMEgXnU8OkTHdYZ4n0bW2VoO4COz9AIxfELFgNPu jHPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of ak@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ak@linux.intel.com Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of ak@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=ak@linux.intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,404,1511856000"; d="scan'208";a="28943638" 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590140582166248265?= X-GMAIL-MSGID: =?utf-8?q?1590430095045889223?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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