From patchwork Tue Jul 18 22:33:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 12E2660392 for ; Tue, 18 Jul 2017 22:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F291F285B7 for ; Tue, 18 Jul 2017 22:37:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E689E285CD; Tue, 18 Jul 2017 22:37:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E5EA285B7 for ; Tue, 18 Jul 2017 22:37:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4N-0000PK-Le; Tue, 18 Jul 2017 22:34:19 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4M-0000Nw-C3 for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:18 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id D1/DF-03582-9EC8E695; Tue, 18 Jul 2017 22:34:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXiVRtsoPuyJy/ S4GeCxfctk5kcGD0Of7jCEsAYxZqZl5RfkcCasbizl6XgMkfFj4NHWBsYT7F3MXJxCAnMYJTo ePuKEcRhEXjFInHjwg9mEEdCoJ9V4ltbE2sXIyeQEyextGk+M4RdKbH98g+wuJCAksTWDUuZI Ub9Y5RYOHMdWBGbgJbEnob5TCAJEYHZHBKLu86wgDgCAh/ZJG5sOQzWwizQwiTx5N82JpAWYQ FPiTfHJoDNZRFQlXjZfY0RxOYVsJTYcaUDqIEDaLexxN8v+iAmp4CVxPL7PBBXWEr09jawTGA UXMDIsIpRozi1qCy1SNfQUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzDoGIBg B+OnZQGHGCU5mJREebcq50UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuA91A2UEyxKTU+tSMvMA YY/TFqCg0dJhNcHJM1bXJCYW5yZDpE6xWjMMenA9i9MHK8m/P/GJMSSl5+XKiXOuwCkVACkNK M0D24QLC4vMcpKCfMyAp0mxFOQWpSbWYIq/4pRnINRSZi3H2QKT2ZeCdy+V0CnMAGdIuybA3J KSSJCSqqBUVn+zFY1PxumcNPIg0oqLoL/30uZ3p4Y8yp6y/ENr3zmXiv+JfRSNPeb/ew1F65Z PGicbrk34CD/wTfTlly798Aou5Sz+JRv8B0TE+0VUp23rkxn5ZmZuL4rI1zy7wXjmfYTqj5vz 7+mN7H8wNPDWzv1FsWkWbdOO/fiqoX/keWznf3kL2cefq3EUpyRaKjFXFScCACA9KFixgIAAA == X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1500417255!95343489!1 X-Originating-IP: [74.125.83.48] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7907 invoked from network); 18 Jul 2017 22:34:16 -0000 Received: from mail-pg0-f48.google.com (HELO mail-pg0-f48.google.com) (74.125.83.48) by server-14.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:16 -0000 Received: by mail-pg0-f48.google.com with SMTP id k14so20084711pgr.0 for ; Tue, 18 Jul 2017 15:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pYvte0CEMI7S7pZS+4EhVQ2NmcyX9nSjsV1ZTU3E+8U=; b=BMeRn3DBXpZka+qCVcgzApdqysydHXksd9uWGDSzlFywB6y5v+63MriePzL+e0QpKS K2KAackxJw+Fd+m1RmUhLrtjQWiY7MHtbueLbQjYQsRPOpJ9Bk3cPmymgp5c+aDdXiWS YCYCA9q+WfXfbTioAcs31AhKZoMwPUSR2wKtp07arZGy7+KlJK7XB0KU5PnXpvbzCUH6 8uc2fNx9n5wzGgRf+kGBGFQcCWl33a2vsKJG8X1xywZ4Rc0r1aUyzMmp2QqjXg7f/S1p NPxfQsK+JGWtUioksbNWcIJ65Z0MFxEehRY8r+Y6JlcvLxCRvErP2GvxDAwGKIeLXQ48 B33Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pYvte0CEMI7S7pZS+4EhVQ2NmcyX9nSjsV1ZTU3E+8U=; b=UE4FoUZ98Kbl5sqiufkb3DvQLgSK1q0aIJifaW/4Ub1kl1uVt+rvPpAtcZSnFzgtMS 79jdzMNNbDBudIRw16MPi+YEBJlm8Y7sJoQrUaAdXQ7FrCVEfm+JWAInKvM/HctMa9NF rZgW0MARVie2xCf4cYZAaVfb09RibAbRkwsi75dl91F8Qs7EwtJGCaW2siqL5b5kvY1g Yf0Qey7qquXc3rCLqTLU/3QZb5owlT4MxfMpqvQQ7gHwa9GCXIevy4BE8kmHOZvkCdwz vVCnxD5C/3ajGKJI1gx+5ULP/bjvH27UP472rusbEu6vJddXvKhT5DVJNKuOq9bKYEmq cYvg== X-Gm-Message-State: AIVw110AZmzuRetG+KX3qBNYDPwqNye60A7ymQ2OLOCliBP4Pn1plyAa konyAmclP5RuRmsi X-Received: by 10.84.231.198 with SMTP id g6mr4128063pln.110.1500417254864; Tue, 18 Jul 2017 15:34:14 -0700 (PDT) Received: from skynet.sea.corp.google.com ([100.100.206.164]) by smtp.gmail.com with ESMTPSA id b6sm6444242pgn.67.2017.07.18.15.34.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:14 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Thomas Garnier , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Andy Lutomirski , Borislav Petkov , "Kirill A . Shutemov" , Brian Gerst , Borislav Petkov , Christian Borntraeger , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Kees Cook , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Andrew Morton , Christopher Li , Dou Liyang , Masahiro Yamada , Daniel Borkmann , Markus Trippelsdorf , Peter Foley , Steven Rostedt , Tim Chen , Ard Biesheuvel , Catalin Marinas , Matthew Wilcox , Michal Hocko , Rob Landley , Jiri Kosina , "H . J . Lu" , Paul Bolle , Baoquan He , Daniel Micay Date: Tue, 18 Jul 2017 15:33:15 -0700 Message-Id: <20170718223333.110371-5-thgarnie@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170718223333.110371-1-thgarnie@google.com> References: <20170718223333.110371-1-thgarnie@google.com> Cc: linux-arch@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-sparse@vger.kernel.org, linux-crypto@vger.kernel.org, kernel-hardening@lists.openwall.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC 04/22] x86: Add macro to get symbol address for PIE support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a new _ASM_GET_PTR macro to fetch a symbol address. It will be used to replace "_ASM_MOV $, %dst" code construct that are not compatible with PIE. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/asm.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index 7a9df3beb89b..bf2842cfb583 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -55,6 +55,19 @@ # define CC_OUT(c) [_cc_ ## c] "=qm" #endif +/* Macros to get a global variable address with PIE support on 64-bit */ +#ifdef CONFIG_X86_32 +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(movl $##_src) +#else +#ifdef __ASSEMBLY__ +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(leaq (_src)(%rip)) +#else +#define __ASM_GET_PTR_PRE(_src) __ASM_FORM_COMMA(leaq (_src)(%%rip)) +#endif +#endif +#define _ASM_GET_PTR(_src, _dst) \ + __ASM_GET_PTR_PRE(_src) __ASM_FORM(_dst) + /* Exception table entry */ #ifdef __ASSEMBLY__ # define _ASM_EXTABLE_HANDLE(from, to, handler) \