From: Thomas Garnier Subject: [PATCH v3 21/27] x86/ftrace: Adapt function tracing for PIE support Date: Wed, 23 May 2018 12:54:15 -0700 Message-ID: <20180523195421.180248-22-thgarnie@google.com> References: <20180523195421.180248-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 , Thomas Garnier , Philippe Ombredanne , Kate Stewart , Arnaldo Carvalho de Melo , Yonghong Song , Andrey Ryabinin , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Rafael J . Wysocki" , Len Return-path: In-Reply-To: <20180523195421.180248-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 eXRlIG9mIHRoZSBHT1QgY2FsbCBieSBhID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