From patchwork Tue Jul 18 22:33:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850049 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 7A59460393 for ; Tue, 18 Jul 2017 22:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6605E285B7 for ; Tue, 18 Jul 2017 22:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59ABA285D8; Tue, 18 Jul 2017 22:37:02 +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 01A70285CB for ; Tue, 18 Jul 2017 22:37:02 +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 1dXb4P-0000Qw-Sm; Tue, 18 Jul 2017 22:34:21 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4O-0000PJ-3h for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:20 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id DE/A9-01729-BEC8E695; Tue, 18 Jul 2017 22:34:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVyMfTAVt1XPXm RBp1Nihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aF5Y3MBRt4K97POMjSwHiGu4uRi0NIYCaj xJrf/xlBHBaBVywSfXsXs4I4EgL9rBINfc1ADieQEyfxZOlCdgi7UuLQiTtgcSEBJYmtG5YyQ 4z6xyhxc/FyFpAEm4CWxJ6G+UwgCRGB2RwSi7vOsIA4AgIf2SRubDkM1sIs0MIk8eTfNqAyDg 5hAQuJ398MQLpZBFQlFp86xwZi8wpYSiy52McCUiIhYCzx94s+iMkpYCWx/D4PxBGWEr29DSw TGAUXMDKsYtQoTi0qSy3SNTTWSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDDoG INjB+G+b5yFGSQ4mJVHercp5kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeH27gXKCRanpqRVpm TnA8IdJS3DwKInw+oCkeYsLEnOLM9MhUqcYLTmuXFn3hYljyoHtQPLVhP/fmIRY8vLzUqXEeR eANAiANGSU5sGNg8XoJUZZKWFeRqADhXgKUotyM0tQ5V8xinMwKgnz9oNM4cnMK4Hb+groICa gg4R9c0AOKklESEk1MLZVhu/zMOvNatqUw3P877KTDTdERBpNOLdz6LEbL/te9e78ysw33yNb 3z6R2frK+HWXa4jB/7sNGQIST6qNV9zrP+t/2/Vlpe/KcxmJ+19vSvlx5uH06y+ZTl1ecbmlK tJg4wvFCPZN0uythlmCJW3Lu9QuieW63U04nhmj9fz/gzR3x05dESWW4oxEQy3mouJEAO9m8y DMAgAA X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1500417257!101849531!1 X-Originating-IP: [209.85.192.181] 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 59518 invoked from network); 18 Jul 2017 22:34:18 -0000 Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:18 -0000 Received: by mail-pf0-f181.google.com with SMTP id q85so17854488pfq.1 for ; Tue, 18 Jul 2017 15:34:18 -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=YlO/Sv2vA0Kdq7YbCCEu5A7iUDwAdXbeZIHfoPX7iNo=; b=oJizZnwf6UgkdswcXRUUwnrN1j14v2lFEnVRmkW4GkQTi9nqrI4GcOMzKArc77WPQV awd48HFv1BFZZRaAXnf52HsOpUAlgC/hCTGJWU4GJ8DSxoQ2kHoZzkjwba64vda96p7+ T6hTBnGYLQQGFHO2SFQCTCFOlWq4T4AUcC13jQEAQz+h2wJcUq0CLbwgYxINZMRcbgdL oS5dZ+wM1PlC4Wz6fd827sIj757NqXv5uO945B30Cwhtpx7/L+L1cR9FbkYqVy9QuxNj 0r558O68EzNyHzrAU0e1K+ze1y0CsYNkdOljlclO3GIZyKeJH8FexXfd7eWAADgFYqJT M2hQ== 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=YlO/Sv2vA0Kdq7YbCCEu5A7iUDwAdXbeZIHfoPX7iNo=; b=H8jX11GJbEhnIlpo0e9YzZ/+bRNse8qBg73clHmdQQqyS0szdjCe7Dqxc1p+YWoyl8 Eg16zVm7/A6i01sdUY3iGQOzeMPv19epZhLBCrW+SJjdtBw9+CnBOOuShCGTAdx3owue 3LvSeDX1t5dRd6pqaMoKEpK9H1ICa3dfuQJbGlyz1vv1Hfs7f2f/02YgB/TKfqQ/GEI/ Eo4RNYzOubAgZ2mT8DwKNAsm3G8+dYXHRkirjruxHCnWPRojOplcNwHcKKaIcUsePLFh /gjxsrF1Y65wiDVGOmwCWA/Cmr7gfFf7MQmHPasvrkDi20Vzxe/+ga+5bEywVzUq1dVX lwcg== X-Gm-Message-State: AIVw11123dAHvBSHIRy1xmwxDajv/La4yNF5IUOtylJaWBDIDfZljEIT waa3Djb8Hz/ZZnxb X-Received: by 10.84.177.195 with SMTP id x61mr4094956plb.44.1500417256501; Tue, 18 Jul 2017 15:34:16 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:15 -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:16 -0700 Message-Id: <20170718223333.110371-6-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 05/22] 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 72a8e6adebe6..ab2462396bd8 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