From patchwork Tue Jul 18 22:33:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850059 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 AD68D60393 for ; Tue, 18 Jul 2017 22:37:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 992EA285CD for ; Tue, 18 Jul 2017 22:37:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D958285E4; Tue, 18 Jul 2017 22:37:07 +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 14929285D8 for ; Tue, 18 Jul 2017 22:37:07 +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 1dXb4T-0000UZ-HL; Tue, 18 Jul 2017 22:34:25 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4R-0000Sh-UM for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:24 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 20/4D-03612-FEC8E695; Tue, 18 Jul 2017 22:34:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsVyMfTAZt13PXm RBq+vqVh83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlvV51iK1jHVjFn9kmWBsZDrF2MXBxCAjMY Je7dOcsE4rAIvGKR2Pd0LnsXIyeHhEA/q8TnJv8uRg4gO07i+K56iHClxNsL51hBbCEBJYmtG 5YyQwz6xyjxY9oZRpAEm4CWxJ6G+WBDRQRmc0gs7jrDAuIICHxkk7ix5TBYC7NAC5PEk3/bmE BahAW8JPo+bmIGsVkEVCV+/GwCG8UrYCmxZP4XZogzjCX+ftEHMTkFrCSW3+eBuMJSore3gWU Co+ACRoZVjBrFqUVlqUW6hhZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBIccA BDsYb24MOMQoycGkJMq7VTkvUogvKT+lMiOxOCO+qDQntfgQowwHh5IEr283UE6wKDU9tSItM wcY/DBpCQ4eJRFeH5A0b3FBYm5xZjpE6hSjPceVK+u+MHE0fdgCJKcc2A4kX034/41JiCUvPy 9VSpxXBKRNAKQtozQPbigsWi8xykoJ8zICnSnEU5BalJtZgir/ilGcg1FJmPcYyBSezLwSuN2 vgM5iAjpL2DcH5KySRISUVAOjoZDYTm3zBs3Wngx3gcwZPqVBSje5ZNN+HDW6qdWp/UaQNej+ /vTlt957bhDd3D9H/OTt7z/qXly0fO78cMpd3eM+02O+9N78aPA2I83v3r8ardrlR1nPrc9PU XLuzfjCUlHB7GIpYXPPst+Ah3k/q7OMfM5e3hPTd2mfe8YfWZf8U84mvEqJpTgj0VCLuag4EQ CyDSIu0QIAAA== X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1500417261!75971868!1 X-Originating-IP: [209.85.192.179] 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 36155 invoked from network); 18 Jul 2017 22:34:22 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:22 -0000 Received: by mail-pf0-f179.google.com with SMTP id s70so8740128pfs.0 for ; Tue, 18 Jul 2017 15:34:22 -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=Ia/+UcPfZ5JrPnjOstPd62ub5trdLlvtCdxYFUk0+G8=; b=ToG1NsPe95LWg7nXxbp6TUifW8z9GT77PKlecGtIYRBozQ9P4F1cBijfXi27qJJSej xT/opHZNmjAO80azomeUcOHJc/O95vTgQs/vgxEj6siBYRTzHFCAlof6MbfoQA1luYoU Xu/pTjCizhRL6KXs5tazgCyKBOMHCITsRQmFjkewzrpZqsQM211pdzZDMj23UyPmruT3 5ooiRDlBGvtl3LMgSU0FAzmNNbwLNhzBxg8xCMGAZmFxjEGcZ+VKC62iIc23lj8OoNLB SDdGGQmDv8JfRu3GzD+5UYlTun7L0EVIwTWvUkChsKCG8wn4pIO5IszraVfdDIQ5Tbkq Gw8Q== 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=Ia/+UcPfZ5JrPnjOstPd62ub5trdLlvtCdxYFUk0+G8=; b=LINBt1TxRwW1qf4mv1WPt1ITWAgws/lIp6tU7zRR1bOj3L3JyHgGa/K05EgoXZiUsn d8YK/azS0h1h5ZDufE8pYCEJdfKso9Y0J0eelVx8N3xwJRk59dbLLiph80iw+XjKi1e/ 236b+hA3ynQnrotOUFIcLzY7oRc4gd5SMf+7qboLruHwdI3mmXIQhA2GCgUWYnTywbxR nkaY8dlOX3oqfgsAq9Wt7Xxr3iDBHtQHfF/B58DKwGBOcL+GRWvSE0cy8UD9NK0wrh+c A22u3Gvaan5GTpWMuwolrGABCS9rwSE4mtnc0/WTuJ6NMjTD5LVB4umy48KAIRnq0zfu l7Hw== X-Gm-Message-State: AIVw110E+1Lw4Fzjh3Pf2RaiCxX4WXOvracJzcxrZ8tbPnepL5aBdLS+ tp+EbcyUPQKS8CO3 X-Received: by 10.84.210.40 with SMTP id z37mr3948390plh.265.1500417260501; Tue, 18 Jul 2017 15:34:20 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:18 -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:18 -0700 Message-Id: <20170718223333.110371-8-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 07/22] x86: relocate_kernel - 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 only relative references of symbols for the kernel to be PIE compatible. 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/kernel/relocate_kernel_64.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S index 98111b38ebfd..da817d1628ac 100644 --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -186,7 +186,7 @@ identity_mapped: movq %rax, %cr3 lea PAGE_SIZE(%r8), %rsp call swap_pages - movq $virtual_mapped, %rax + leaq virtual_mapped(%rip), %rax pushq %rax ret