From patchwork Thu Aug 10 17:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894339 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 C84A160236 for ; Thu, 10 Aug 2017 17:29:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD3B01FF61 for ; Thu, 10 Aug 2017 17:29:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1A3C2867D; Thu, 10 Aug 2017 17:29:20 +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 39548285F0 for ; Thu, 10 Aug 2017 17:29:20 +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 1dfrEe-0007kj-2y; Thu, 10 Aug 2017 17:27:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfrEd-0007ip-6U for xen-devel@lists.xenproject.org; Thu, 10 Aug 2017 17:27:03 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 57/D0-09901-6679C895; Thu, 10 Aug 2017 17:27:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXiVRusp5s6vSf S4MsNBYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP2p1ksBUuFKj5MOcnawLiNv4uRi0NIYAaj RO+qO2wgDovAKxaJO3ebGEEcCYF+VokjHQ/Zuxg5gZw4iVkXbzBB2NUS95ZOYAWxhQSUJLZuW MoMMeofo8TRm03MIAk2AS2JPQ3zmUASIgJLBSVOtl4DG8ss0MIk8eTfNrBRwgIOEu0XN4OtYB FQlTgzdydQEQcHr4ClxMYvbhDbTCSetE5iBLE5gcLTls1khthsITH110qmCYwCCxgZVjFqFKc WlaUW6RqZ6CUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBIYXAxDsYNz3MfIQoyQH k5Iob/Gn7kghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKEryTp/ZECgkWpaanVqRl5gADHSYtwcGjJ MK7FSTNW1yQmFucmQ6ROsVozDHpwPYvTByvJvz/xiTEkpeflyolzrsTpFQApDSjNA9uECwCLz HKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUUmY13Ua0BSezLwSuH2vgE5hAjolwrcT5JSSRISUVAN jU+6mTx6iSX+3S5mHhp6/KrXaTThFZ0Izx3+rbfL3NkYKWF01M57V8O54ndXmJpWbK/OD/MNF 8qw3KlxOa5gcsTzx37MJU67IrbgsfKViUuqrRW9ydvbeSk8rbVxmu2JiUonZ94Dfd7Y3L8vre cYguNLa6Gtc+a8ZL8zu5zduFix82ffq8ZQWJZbijERDLeai4kQA/wZi57sCAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1502386020!74255615!1 X-Originating-IP: [74.125.83.46] 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 52940 invoked from network); 10 Aug 2017 17:27:01 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2017 17:27:01 -0000 Received: by mail-pg0-f46.google.com with SMTP id v189so5533372pgd.2 for ; Thu, 10 Aug 2017 10:27:01 -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=Ho03Xn1wy3x29ZpV4ZOYwKcM/kqG0Bsaho/BItcN9xk=; b=SfnMbssic8RbxuKdj0EA+moz9+yvGeq/jbYu5Kd0UYOq9vvqM4cOVbPVu8OMajzxqB +fG4sgsLnFZll4JdOa48GhHcSVg5bm4TXZYPRU8BQfa3CmHK8zADoZfjIOWLs2yfN2jA wpLyrI+KTEThulcrK97NByoMsvYxwqpue0tSJsEvFoi3AoAjZZB+78pLq/512UGw+cRE WRj2uh8UK1HqmPPZ5Jw/S1NSkSmKImZzBTqUALN4qGY57eB6auaMOSFrj2IADhN45qMk u3WyOFupG6bjMBFa825yQ5sCfGtWDDP0wzeTx47KsZ6U5hUNgsHDn+uPzoS3t+op1rVu ATlA== 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=Ho03Xn1wy3x29ZpV4ZOYwKcM/kqG0Bsaho/BItcN9xk=; b=VY5Qg6mHiknjrfjjv+BEziUyD5KCuk/MObyqv31hZpz5Y99CRv87vdWMOLLLDCNhNR JBqf7eI0YODG8SE3vylKdPsrsAhc1v3QmR9t8D7VqiuO4fX4f0c79FKMfby3Foe4VzwK oMHKQ7qDOSlOEawl9AU0QYpT7rFkYXxaKonZpdKahMgoYDXrPsD34ktXSvG6e4uS4D9P 1KqwDWbGpByTy21cQaCxYccsfhsWa5VrrBzgeggVVHcP4nUyfs77bA3vjhVa0QH/fK3M 7rpPLfENIsuY3CZP1cD3rfnbGW3wcyqB0HbOd0JVVJ9UDRzpdmFixynd5BhyB3pSKEkU yN5g== X-Gm-Message-State: AHYfb5illA7d36EvNG4siYprSvQzFnENhF/01aOXy8BckdamJFY/sZds iDb46OQrHXyJYJTr X-Received: by 10.84.224.207 with SMTP id k15mr14311650pln.108.1502386019250; Thu, 10 Aug 2017 10:26:59 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Aug 2017 10:26:58 -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:26:03 -0700 Message-Id: <20170810172615.51965-12-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 11/23] x86/acpi: 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/acpi/wakeup_64.S | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S index 50b8ed0317a3..472659c0f811 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -14,7 +14,7 @@ * Hooray, we are in Long 64-bit mode (but still running in low memory) */ ENTRY(wakeup_long64) - movq saved_magic, %rax + movq saved_magic(%rip), %rax movq $0x123456789abcdef0, %rdx cmpq %rdx, %rax jne bogus_64_magic @@ -25,14 +25,14 @@ ENTRY(wakeup_long64) movw %ax, %es movw %ax, %fs movw %ax, %gs - movq saved_rsp, %rsp + movq saved_rsp(%rip), %rsp - movq saved_rbx, %rbx - movq saved_rdi, %rdi - movq saved_rsi, %rsi - movq saved_rbp, %rbp + movq saved_rbx(%rip), %rbx + movq saved_rdi(%rip), %rdi + movq saved_rsi(%rip), %rsi + movq saved_rbp(%rip), %rbp - movq saved_rip, %rax + movq saved_rip(%rip), %rax jmp *%rax ENDPROC(wakeup_long64) @@ -45,7 +45,7 @@ ENTRY(do_suspend_lowlevel) xorl %eax, %eax call save_processor_state - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq %rsp, pt_regs_sp(%rax) movq %rbp, pt_regs_bp(%rax) movq %rsi, pt_regs_si(%rax) @@ -64,13 +64,14 @@ ENTRY(do_suspend_lowlevel) pushfq popq pt_regs_flags(%rax) - movq $.Lresume_point, saved_rip(%rip) + leaq .Lresume_point(%rip), %rax + movq %rax, saved_rip(%rip) - movq %rsp, saved_rsp - movq %rbp, saved_rbp - movq %rbx, saved_rbx - movq %rdi, saved_rdi - movq %rsi, saved_rsi + movq %rsp, saved_rsp(%rip) + movq %rbp, saved_rbp(%rip) + movq %rbx, saved_rbx(%rip) + movq %rdi, saved_rdi(%rip) + movq %rsi, saved_rsi(%rip) addq $8, %rsp movl $3, %edi @@ -82,7 +83,7 @@ ENTRY(do_suspend_lowlevel) .align 4 .Lresume_point: /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq saved_context_cr4(%rax), %rbx movq %rbx, %cr4 movq saved_context_cr3(%rax), %rbx