From patchwork Wed Oct 4 21:19:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9985563 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 ABA3660586 for ; Wed, 4 Oct 2017 21:23:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C8B628C2C for ; Wed, 4 Oct 2017 21:23:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9086128C2F; Wed, 4 Oct 2017 21:23:32 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, 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 31FCC28C2C for ; Wed, 4 Oct 2017 21:23:32 +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 1dzr6I-0002oJ-CQ; Wed, 04 Oct 2017 21:21:06 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzr6H-0002na-US for xen-devel@lists.xenproject.org; Wed, 04 Oct 2017 21:21:06 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 6F/A8-03283-1C055D95; Wed, 04 Oct 2017 21:21:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMfTAWt0DAVc jDa79YrP4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOevV3OXLBUqGLnnu2sDYzb+LsYuTiEBGYw Suy9dJYdxGEReMUicWvZcmYQR0Kgn1XiZ1MLaxcjJ5CTJdGyvYsdwk6TODBxLVARB5BdKdG+y BUkLCSgJLF1w1JmCPsvo8SBK7wgNpuAlsSehvlMIDNFBGaJSNx63cMG4jALnGGSON53EmyBsI CDxKfbT1hBhrIIqEocu8wBEuYVsJRY9fkI1F4TiYdHroGVcwLFj5x4A7XMQqL1zH2mCYyCCxg ZVjFqFKcWlaUW6Rob6CUVZaZnlOQmZuboGhqY6eWmFhcnpqfmJCYV6yXn525iBIYcAxDsYPy7 NvAQoyQHk5Io7ybfq5FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgj/IFygkWp6akVaZk5wOCHS Utw8CiJ8IaBpHmLCxJzizPTIVKnGC05Lty59IeJ48CeW0Cy4+bdP0xCLHn5ealS4rymIA0CIA 0ZpXlw42AReolRVkqYlxHoQCGegtSi3MwSVPlXjOIcjErCvNogU3gy80rgtr4COogJ6KA5TVd ADipJREhJNTAWMPxUUeL4Y2Ng46Cz1dDiVbK5/OP1FhZtp936MvdaFB77/bbF0ULjjvXpe3Ut J17Ma/Z59EHgw/7Fyw482bOKW4Mz5OvW2VJdTge25QZnv3Z7c6r9/4qpDibnU96vU//47YLxc tvWX7we5R81i3tZQqZPaf7kJDglS29rhYhYyEKOtSvythsrsRRnJBpqMRcVJwIARYYGecsCAA A= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1507152062!88144577!1 X-Originating-IP: [209.85.192.173] 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 62574 invoked from network); 4 Oct 2017 21:21:03 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 Oct 2017 21:21:03 -0000 Received: by mail-pf0-f173.google.com with SMTP id m63so6894788pfk.7 for ; Wed, 04 Oct 2017 14:21:03 -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=XTy+FH1xboCqmxybmqkMnzKfei/xJTw5wQAXY/wFKt0=; b=Q+Jwg4MGtsnH/vU5OGYxP36UBchce2+7CK7qbI+oqzGlHaKwRlViWdz2NebdAvaw8u VO6TG/L644lmcV+xEd0bHRq/o7HknV8WP/Uh4g1wknIH1+x5BSkUlq2KL64dxyq9w5dk Bar+a/Wx3OheKsHo2QSOAna3cWFNWN/LohcOj6OAG4qUrHcFkYycgkgp1hYrgdLjuaon U1NeEh9Sqx1uUZdXrWJM0ZveO2P3y+1LCFI8SqT7mVICNjHdWLlaIEifeiCySHjb/APd weUtEfsjx+WasEO4Bqkcd+dm11zcTc9xsZQOWGym82gNJCN0MeZ0KhTpZR1TSuGQG5bB XVBA== 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=XTy+FH1xboCqmxybmqkMnzKfei/xJTw5wQAXY/wFKt0=; b=stX07s7odyEOlXN/v2Ogl9XAuUHQt3hZu5hALdEMjYmapztgzEeGRs7wHzVIfkhfCE seBu8aNsorCwETN2rFlshoip+NvIGYAfIswmA60SkKwSh4WPCjOXmIUrRBu4kKiCxuEB DRd6DaDeAKW7Xzp6NZHr1NQhb5KmSsPOug7aZd9/UgvcghWc1/2CDkzDlBczpl4QPvJq dLRcEvlI54VnvP9P1YxY+WEbPoIHXD6xF9m9YKsThv7wwKNOgnBSjqi9vLR0Jm+vUM/x CwwT3OxgjTk5SXM7Kn35zWnl448D7gz+cN7O0tgdhCuKEbhmkHexCmyicIdoD+g5lJ7L HcYg== X-Gm-Message-State: AMCzsaV908KGbllKtroLhMdRBR3rUnaDy5FYmw5/8RfKIIj4d1lYj5Pq T9yvA9DSbMdsNsaHpjv4PW3xdw== X-Google-Smtp-Source: AOwi7QBAnwuBpwKdfuoISZFa5KGh/vLo/qxzbf51gA0BHpcD3FDmtAiBUDQ7I/ChY3xQwLiVeZwrqg== X-Received: by 10.98.46.69 with SMTP id u66mr10246046pfu.288.1507152061709; Wed, 04 Oct 2017 14:21:01 -0700 (PDT) Received: from skynet.sea.corp.google.com ([172.31.92.33]) by smtp.gmail.com with ESMTPSA id s68sm30204019pfd.72.2017.10.04.14.20.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Oct 2017 14:21:00 -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 , Kees Cook , Matthias Kaehlcke , Tom Lendacky , Andy Lutomirski , "Kirill A . Shutemov" , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Chris Wright , Alok Kataria , Rusty Russell , Tejun Heo , Christoph Lameter , Boris Ostrovsky , Alexey Dobriyan , Andrew Morton , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Dou Liyang , "Rafael J . Wysocki" , Mika Westerberg , Lukas Wunner , Masahiro Yamada , Alexei Starovoitov , Daniel Borkmann , Markus Trippelsdorf , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Rik van Riel , David Howells , Ard Biesheuvel , Waiman Long , Kyle Huey , Andrey Ryabinin , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , Rob Landley , "H . J . Lu" , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay Date: Wed, 4 Oct 2017 14:19:45 -0700 Message-Id: <20171004212003.28296-10-thgarnie@google.com> X-Mailer: git-send-email 2.14.2.920.gcf0c67979c-goog In-Reply-To: <20171004212003.28296-1-thgarnie@google.com> References: <20171004212003.28296-1-thgarnie@google.com> Cc: linux-arch@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.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 v3 09/27] 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