From patchwork Thu Aug 10 17:25:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894327 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 EDA4D60236 for ; Thu, 10 Aug 2017 17:29:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D49B71FF61 for ; Thu, 10 Aug 2017 17:29:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C835E28635; Thu, 10 Aug 2017 17:29:13 +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 709DF1FF61 for ; Thu, 10 Aug 2017 17:29:13 +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 1dfrEW-0007ad-Fx; Thu, 10 Aug 2017 17:26:56 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfrEU-0007Z8-RZ for xen-devel@lists.xenproject.org; Thu, 10 Aug 2017 17:26:54 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 10/A0-09901-E579C895; Thu, 10 Aug 2017 17:26:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRWlGSWpSXmKPExsVyMfTABt3Y6T2 RBst/8Vl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmfpu1lLtjIW/HiygbWBsaz3F2MXBxCAjMY Ja5vaGIGcVgEXrFIzNo9Bcjh5JAQ6GeVuLDDDcKOk5iy+hNUvEri6IxZrCC2kICSxNYNS5khJ v1jlJhxfRELSIJNQEtiT8N8JpCEiMBSQYmTrdcYQRxmgRYmiSf/tjGBVAkLWEt0t3WAdbAIqE r0N/8AW8ErYCGx5/RpJoh1JhJPWicxgticApYS05bNZIZYbSEx9ddKpgmMAgsYGVYxahSnFpW lFukaGeglFWWmZ5TkJmbm6BoamOnlphYXJ6an5iQmFesl5+duYgSGFwMQ7GD8tSzgEKMkB5OS KG/xp+5IIb6k/JTKjMTijPii0pzU4kOMMhwcShK8FdN6IoUEi1LTUyvSMnOAgQ6TluDgURLh3 ToVKM1bXJCYW5yZDpE6xWjJceXKui9MHFMObAeSryb8/8YkxJKXn5cqJc5rDTJPAKQhozQPbh wsGi8xykoJ8zICHSjEU5BalJtZgir/ilGcg1FJmPciyFqezLwSuK2vgA5iAjoowrcT5KCSRIS UVANj/Sevx3HrmyOuyLFkPfc7Gsjwzlh5gs9sTc4iLtN3RwM1ta7vXOpuXXv5msREhppFV103 X3BZ1jP/gpThEcGNb/6af5NbzPLnUeH63Y27uuvr73R8t2Le82fNM61EGfXcp3yLekVcb9yIc nnIMzNUiLOte3p6zm1FHqULdzgdog/3RNnEOygqsRRnJBpqMRcVJwIAQqH/MMECAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1502386012!77419920!1 X-Originating-IP: [209.85.192.176] 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 52012 invoked from network); 10 Aug 2017 17:26:53 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2017 17:26:53 -0000 Received: by mail-pf0-f176.google.com with SMTP id c28so5618940pfe.3 for ; Thu, 10 Aug 2017 10:26:53 -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=hftptOQTc0gbEeEY99+vP2O7D2WGfRgk+0XqGGLB6Kk=; b=vOWa05npzu25sAoYupd9rD5+UUXpjUn3Z1rTs/iXycXDNcbsLSsL5CmZjNpX0dWyAv SOMEAHYcOHUZJ5yYe01sYHo/hf8EgDTVJPSqdDo1B0vwgBs4r+B9nF8KXe8+hNlPj21S wwAuVJiROxCpII64mquqmmX1vcYskFUdu+8w52FTqoOYtcOK0ceT0C2Kkzu8eHQoAJNA yf2u8SWjbIxuE/dWb3BJ66+SOhwpocNx1At8kb4lACr0aCLCPk3g5P8sgRdCUO8c0kJO GFhusnX4XtURdtv4pSZNgmijs1jLgVK+sysm49O+H4o8t9Vb5FT2WX5w3qB9kGwyYOU+ h4XA== 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=hftptOQTc0gbEeEY99+vP2O7D2WGfRgk+0XqGGLB6Kk=; b=FdK2XDIClMnZxwq+eUmMExRu6oMC9J9rQzMoaP1ox+Tfg172kk44ClDUYaEnlHsx2d iuIYzZ75RX9KeI6uBJOUMj7QwNk0hgGDyttSHmIofiT0Ak6999WldNrq1FC9WJ4zTbmL 93Mb3rxr14RjwhFTbtoUnloncD6CEXM6ejKAXVrUvBLcUAAggGL2vXG0+7xCcR9lJunG wqgpCVLbC4ThWPVhCOgE0wqdRlmwcdMT7G0LgoKpK/7Nm0Sgav+d/80wfDHqr3spcWA3 S/dOxOeOcOSvG369TeWdpz3kEGHG2VaiwSb9ygiejTovF5UAQZT2lvNKYjLHeHnsjJ79 O5Bg== X-Gm-Message-State: AHYfb5i25hp41sgihTZvKOquJZWirVVpEztp/L1k6I+oq5/LVC2JxrIA DyBKJajseIOQArUy X-Received: by 10.98.204.10 with SMTP id a10mr13351936pfg.332.1502386010781; Thu, 10 Aug 2017 10:26:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Aug 2017 10:26:50 -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:57 -0700 Message-Id: <20170810172615.51965-6-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 05/23] xen: Adapt assembly 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 Change the assembly code to use the new _ASM_GET_PTR macro which get a symbol reference while being PIE compatible. Modify the RELOC macro that was using an assignment generating a non-relative reference. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/xen/xen-asm.h | 3 ++- arch/x86/xen/xen-head.S | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/xen/xen-asm.h b/arch/x86/xen/xen-asm.h index 465276467a47..3b1c8a2e77d8 100644 --- a/arch/x86/xen/xen-asm.h +++ b/arch/x86/xen/xen-asm.h @@ -2,8 +2,9 @@ #define _XEN_XEN_ASM_H #include +#include -#define RELOC(x, v) .globl x##_reloc; x##_reloc=v +#define RELOC(x, v) .globl x##_reloc; x##_reloc: _ASM_PTR v #define ENDPATCH(x) .globl x##_end; x##_end=. /* Pseudo-flag used for virtual NMI, which we don't implement yet */ diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index a7525e95d53f..a98cd42b9832 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -23,14 +23,15 @@ ENTRY(startup_xen) /* Clear .bss */ xor %eax,%eax - mov $__bss_start, %_ASM_DI - mov $__bss_stop, %_ASM_CX + _ASM_GET_PTR(__bss_start, %_ASM_DI) + _ASM_GET_PTR(__bss_stop, %_ASM_CX) sub %_ASM_DI, %_ASM_CX shr $__ASM_SEL(2, 3), %_ASM_CX rep __ASM_SIZE(stos) - mov %_ASM_SI, xen_start_info - mov $init_thread_union+THREAD_SIZE, %_ASM_SP + _ASM_GET_PTR(xen_start_info, %_ASM_AX) + mov %_ASM_SI, (%_ASM_AX) + _ASM_GET_PTR(init_thread_union+THREAD_SIZE, %_ASM_SP) jmp xen_start_kernel