Re: [RFC 09/10] x86/enter: Create macros to restrict/unrestrict Indirect Branch Speculation
From: Andi Kleen
Date: Tue Jan 23 2018 - 19:05:37 EST
Ingo Molnar <mingo@xxxxxxxxxx> 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