From patchwork Thu Aug 10 17:25:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894335 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 277DC60236 for ; Thu, 10 Aug 2017 17:29:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E8071FF61 for ; Thu, 10 Aug 2017 17:29:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0252D285F0; Thu, 10 Aug 2017 17:29:16 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 7ACCB27C05 for ; Thu, 10 Aug 2017 17:29:15 +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 1dfrEU-0007Yq-94; Thu, 10 Aug 2017 17:26:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfrET-0007Xm-50 for xen-devel@lists.xenproject.org; Thu, 10 Aug 2017 17:26:53 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id BF/E1-02176-C579C895; Thu, 10 Aug 2017 17:26:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsVyMfTASt3o6T2 RBldmyVl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnLLz1kKbjCUbFw9wTWBsbT7F2MXBxCAjMY Jfof/GEFcVgEXrFIHP2xDcyREOhnlfh9cDFbFyMnkBMncWTLJyi7QuLIzd2MILaQgJLE1g1Lm SHsf4wSJ/6AxdkEtCT2NMxnAhkkIrBUUOJk6zVGEIdZoIVJ4sm/bUwgVcICPhJHru4C62ARUJ W4PuEt2CReAQuJpisb2CG2mUg8aZ0EVsMpYCkxbdlMqG0WElN/rWSawCiwgJFhFaNGcWpRWWq RrpGlXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYHjVMzAw7mBs2ut3iFGSg0lJ lLf4U3ekEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQle/mk9kUKCRanpqRVpmTnAQIdJS3DwKInwb p0KlOYtLkjMLc5Mh0idYrTkuHJl3RcmjikHtgPJVxP+f2MSYsnLz0uVEue1BpknANKQUZoHNw 4WjZcYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfO6gkzhycwrgdv6CuggJqCDInw7QQ4qSUR ISTUw7kpfJ+Ihu2xeZW37/2D73PkXtLe8VZT4WXTvshvDnaR7HGq194XOTlr45oUm77W6Q1v6 Vupt3v8ua296kV4c77E2o+I5At+O+rH/CzRusEhVaLd0DZv3L/O+SD5fkvOOmIIvkSej2zbfF 5Ctm3DXn7/oeENirYrpm/e+FQbqRxim3O3kENdTYinOSDTUYi4qTgQAXtbi/sECAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1502386010!92685336!1 X-Originating-IP: [209.85.192.169] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55526 invoked from network); 10 Aug 2017 17:26:51 -0000 Received: from mail-pf0-f169.google.com (HELO mail-pf0-f169.google.com) (209.85.192.169) by server-12.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2017 17:26:51 -0000 Received: by mail-pf0-f169.google.com with SMTP id c28so5618618pfe.3 for ; Thu, 10 Aug 2017 10:26:51 -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=zShWk/QxB3u/M1CGcpB4xl1REyHU8cm3b50pMykwbu8=; b=Nq/LQQzt6OAHjlwwqAOtVS9ml0B2TXplt5aCSWAR/mDUkarININkPeM+aXCvj7sQs9 7Zf84huaZzrdq6Ft6dVaWJrmcY/AlAKOiLyuOfBzUcXzWVOQoTOXCNSR+RsopsApzE2T EzM7/09hsq0i/wGRns7Vv76w+7OPC8QrcyljNys6lQ4HL1ilRv6Zr0VYwTIWx6XrXQbo LwJmI74b+wAUSSa+taCkRawCfczWx1AcF6oI2T86+vF2DOs1jlHnol4+wAbD/JuCg6bE kmnaN3XE6+NdWKkJO9N8FgS4jQ66bVT3bZKzPFfSO4LOr0uHPWtUHl88dm/2BlL0GxNg JdFg== 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=zShWk/QxB3u/M1CGcpB4xl1REyHU8cm3b50pMykwbu8=; b=iNqUF22+kzIe0I6HQ4I12VNSmWs1/0gi2tlBpX+ex/UhRCV7BQX2aysozIfEdtApsn lhH4oLYDChBMxLh3OxhU54hXlOc2dNysy8KlAaIuRmNOI+oEkPS4KRV1atYMsXmwHfXb nh1QogHsKrZNiKWBJP6D2l0sq/BZIoPhu4jfK7g8QEGPvo8aDTpwyChupzRPk+nUvinP sOulG/lUCYd7C1+kKZWAhgqRhu6qlyuSHMl8mavf94lDJ0sKJcIxXdLhmjvkb5CVDJk/ HP/qWYGPVjP3LsRBTAIMpUsittvwF8H2Z5HPV845zVsRgC3vmf7DVTZDSQaiIr3ijRUX NRxw== X-Gm-Message-State: AHYfb5g7z9/AeBwGbqxUl6bZMZLv0TRVXQF9ZnVkHZsWBkRx6XJ7kxjY r0YvDkPxqX3D8KP/ X-Received: by 10.84.218.4 with SMTP id q4mr14140309pli.202.1502386009257; Thu, 10 Aug 2017 10:26:49 -0700 (PDT) Received: from skynet.sea.corp.google.com ([172.31.92.33]) by smtp.gmail.com with ESMTPSA id p77sm11894925pfi.153.2017.08.10.10.26.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Aug 2017 10:26:48 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Thomas Garnier , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Paul Gortmaker , Chris Metcalf , Andrew Morton , "Paul E . McKenney" , Nicolas Pitre , Christopher Li , "Rafael J . Wysocki" , Lukas Wunner , Mika Westerberg , Dou Liyang , Daniel Borkmann , Alexei Starovoitov , Masahiro Yamada , Markus Trippelsdorf , Steven Rostedt , Kees Cook , Rik van Riel , David Howells , Waiman Long , Kyle Huey , Peter Foley , Tim Chen , Catalin Marinas , Ard Biesheuvel , Michal Hocko , Matthew Wilcox , "H . J . Lu" , Paul Bolle , Rob Landley , Baoquan He , Daniel Micay Date: Thu, 10 Aug 2017 10:25:56 -0700 Message-Id: <20170810172615.51965-5-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog In-Reply-To: <20170810172615.51965-1-thgarnie@google.com> References: <20170810172615.51965-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 v2 04/23] 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) \