From patchwork Tue Jul 18 22:33:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850065 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 DFE0560392 for ; Tue, 18 Jul 2017 22:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBB96285CB for ; Tue, 18 Jul 2017 22:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C01A1285D8; Tue, 18 Jul 2017 22:37:12 +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 694B6285CB for ; Tue, 18 Jul 2017 22:37:12 +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 1dXb4Z-0000cI-Ln; Tue, 18 Jul 2017 22:34:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4Y-0000Zq-FN for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:30 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 8B/0F-01736-5FC8E695; Tue, 18 Jul 2017 22:34:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsXiVRusr/ulJy/ SYOcDY4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPC23tMBUuEKlatuM7UwLiVv4uRi0NIYAaj xN0NB1hBHBaBVywS5xtOsIM4EgL9rBI/tu0BcjiBnDiJttmPmCDsaoneZVdZQGwhASWJrRuWM kPY/xgllp61BLHZBLQk9jTMZwIZJCIwm0NicdcZFhBHQOAjm8SNLYeZQRxmgRYmiSf/toGNFR awlfiwfQkriM0ioCrR/GYr2FheASuJpVN3M3YxcgCtNpb4+0UfxOQECi+/zwOx2FKit7eBZQK j4AJGhlWMGsWpRWWpRbqGpnpJRZnpGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIFBxwAE OxgbtnseYpTkYFIS5d2qnBcpxJeUn1KZkVicEV9UmpNafIhRhoNDSYL3UDdQTrAoNT21Ii0zB xj+MGkJDh4lEV4bYAwI8RYXJOYWZ6ZDpE4xGnNMOrD9CxPHqwn/vzEJseTl56VKifMuAJkkAF KaUZoHNwgWl5cYZaWEeRmBThPiKUgtys0sQZV/xSjOwagkzNsPMoUnM68Ebt8roFOYgE4R9s0 BOaUkESEl1cC42IWzOOpVddbT+9oxmrv8hTXfbL86k2PGm1UCF4zfG1m8lr7OvdnQZ92SrWKR QifaNs/kv/hXaU3quYYEQ/0yqSAfD+ezZ3JFRc5kdBQuylU+ViVuscfETF1dQ2pezM7TPfcXO z59ujKpT6HqU4LCiq0zOFJb32ctnbH+tmLOp4u84uoz5jYosRRnJBpqMRcVJwIASr7h8cYCAA A= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1500417267!103449133!1 X-Originating-IP: [74.125.83.47] 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 61586 invoked from network); 18 Jul 2017 22:34:28 -0000 Received: from mail-pg0-f47.google.com (HELO mail-pg0-f47.google.com) (74.125.83.47) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:28 -0000 Received: by mail-pg0-f47.google.com with SMTP id k14so20086967pgr.0 for ; Tue, 18 Jul 2017 15:34:28 -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=8ea0mww+7QyVzAU5nQkrnjAyKSm+vTkPkcrOA9C25w4=; b=OPFl2dqB7KLGMPf/EzkdN7YuLvYUHtOUwzkwiqo3oyIaSB/7S6Iu3GnOaKifbOgZdp /qJ2OyYJ5GKKHhX/dEFf4BURSZx//SfYxHj4V6L7P+hSDGrdc1+zw6EjxlVUbqz6P+Tn DNqCh9Vqcf+lasFRDCcXgMW49rgvZRXOQcBBtrDSRo4cjcMZkIRcznmdCslCTgyikgLm zjcv4hBzDcFDMXZnRDwtz6u343ZvrrdffoNe6DWBAKXDwN3uEvAbeRB6CVPgX2JGHIJE 3nTlJcC3wzoDcRC7w9Mpkw3vpBOpD8w51lQDQMTUzy/H7hnOTViZwvCKoHJOCK3nLaAW olBw== 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=8ea0mww+7QyVzAU5nQkrnjAyKSm+vTkPkcrOA9C25w4=; b=FUTEzxevZZi95264wvP7XVOVCHASrkLBLi0Ny0nvX+hgEpDN0p2bds2ZeaOhQQohpn +criv7gUDf6ijLSIDXi2hYWF6g1ryBrVt+y76NFI9+4s2cg7PqEU4sLv9Vq4Y4x9U6A3 IyENZXDxGT70BaeMUkZQQJFlEPHohlUSrZq504zFKbLne4J5Sm7DFViAJ80SNKXSshgf x8fXoG6tmlwlmmpthkBTJtIITY04g8M1l+547jQD2kdz9OEsYkC+VH4nddkO/tLPn1tL oWwK9NpOa34oEg9+Pg263gbHAgWZ/3Wik/hozMI9V/V9nU07Sr6rEhGCtv7SIkarQ5Ws Torg== X-Gm-Message-State: AIVw110simceg+w50s4yr3m8z8BK3bogrw77qq6FnOqlaf1pKipxCZQn H65khHmc8ZHIAmcB X-Received: by 10.98.104.133 with SMTP id d127mr3943435pfc.193.1500417266800; Tue, 18 Jul 2017 15:34:26 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:26 -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:22 -0700 Message-Id: <20170718223333.110371-12-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 11/22] 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