From: Thomas Garnier Subject: [PATCH v2 21/27] x86/ftrace: Adapt function tracing for PIE support Date: Tue, 13 Mar 2018 13:59:39 -0700 Message-ID: <20180313205945.245105-22-thgarnie@google.com> References: <20180313205945.245105-1-thgarnie@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Cc: linux-arch@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sparse@vger.kernel.org, linux-crypto@vger.kernel.org, kernel-hardening@lists.openwall.com, xen-devel@lists.xenproject.org To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Greg Kroah-Hartman , Kate Stewart , Thomas Garnier , Arnd Bergmann , Philippe Ombredanne , Arnaldo Carvalho de Melo , Andrey Ryabinin , Matthias Kaehlcke , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Raf Return-path: In-Reply-To: <20180313205945.245105-1-thgarnie@google.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" List-Id: linux-crypto.vger.kernel.org V2hlbiB1c2luZyAtZlBJRS9QSUMgd2l0aCBmdW5jdGlvbiB0cmFjaW5nLCB0aGUgY29tcGlsZXIg Z2VuZXJhdGVzIGEKY2FsbCB0aHJvdWdoIHRoZSBHT1QgKGNhbGwgKl9fZmVudHJ5X19AR09UUENS RUwpLiBUaGlzIGluc3RydWN0aW9uCnRha2VzIDYgYnl0ZXMgaW5zdGVhZCBvZiA1IG9uIHRoZSB1 c3VhbCByZWxhdGl2ZSBjYWxsLgoKSWYgUElFIGlzIGVuYWJsZWQsIHJlcGxhY2UgdGhlIDZ0aCBi eXRlIG9mIHRoZSBHT1QgY2FsbCBieS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