From patchwork Tue Mar 13 20:59:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10280779 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 72FC56038F for ; Tue, 13 Mar 2018 21:04:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61ED0284C8 for ; Tue, 13 Mar 2018 21:04:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54610284D1; Tue, 13 Mar 2018 21:04:16 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 2903C284C8 for ; Tue, 13 Mar 2018 21:04:14 +0000 (UTC) Received: (qmail 21584 invoked by uid 550); 13 Mar 2018 21:01:01 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20389 invoked from network); 13 Mar 2018 21:00:49 -0000 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=p1dT/bzscdZuc8cFz+1XZ1AKc5yvTh+Ysm8sQadR/rg=; b=AoGyG8CtM7OsetW++Vl8MMyetA1zmgboNdxmndYIGbMCFBm5/FW80ZLysaBtTKNhrf HmGh6Qp+XfgFf9AA2PCcceKgt0xCZiyg1cG2NkNC3y5LlSeZPqz9Tlq5UgO+VY4jlGDy gqtzA/0BcEBOz++La4O5aIF8I6VvOPfltCjSAfv6iixQthHKm+afo3+OyddEC7huYaMQ ZarmBnDXIEqZamD4cqMSiayUZxftCy6intaAnsvFrioqdX9F66Rw8k55wQRKk/DlAhS8 PGnKdIeGfm/KLTqVNW7XGw5XNI+bgIuFFNNdVvaw+ivvOMsdZiJP6VNzvspyIY1l4JmN rmjQ== 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=p1dT/bzscdZuc8cFz+1XZ1AKc5yvTh+Ysm8sQadR/rg=; b=rdIhgzrIisQkNNiI1MXwJlBEgBA02V5lM7n6FXIUbSlEVx7hvvFs9Zs7/8ty6DWsXB AYcUrAfOn95KRGgSbboa2D5trLkl1JfYckypIvnN9XA5pyoHGFwj5NeMkfC86RCiK2/Q M4JlUetuUg1Uyf821FIn9aZVWcuCgKEtjhc0eNC/7EwjD+KxHiJRX4J3wFHmLNhHy/4b IGzuApYHiXNVRUd9INNCbPdkV30swWMGJONh8a4Ekf9QRI732wsaVS1Gmol9z2B/vRw1 e+KCSXnzuBaHRoDnpPajYMqo9ktKMz8CT8ScJvaPmDyRHHV+JFfhxXLz7SsDXPNlKsi1 acjA== X-Gm-Message-State: AElRT7EIl/7q3ulSrLItvQ9ZVaod1ivQtYDP8dYaR0Xa/FKU2cQ/wfFC /QtnLGJ53MjVntvG/HcwfKREgA== X-Google-Smtp-Source: AG47ELtZYVW1WxSD+KZXpGD5xD2RMVULM9KT/XC4AIX9AomTwtEg1EVLAztxAnHaK1hQ3BBeHtzNgw== X-Received: by 10.98.204.69 with SMTP id a66mr1901489pfg.33.1520974836979; Tue, 13 Mar 2018 14:00:36 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Greg Kroah-Hartman , Kate Stewart , Thomas Garnier , Arnd Bergmann , Philippe Ombredanne , Arnaldo Carvalho de Melo , Andrey Ryabinin , Matthias Kaehlcke , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Alok Kataria , Steven Rostedt , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , David Woodhouse , Alexey Dobriyan , "Paul E . McKenney" , Andrew Morton , Nicolas Pitre , Randy Dunlap , "Luis R . Rodriguez" , Christopher Li , Jason Baron , Ashish Kalra , Kyle McMartin , Dou Liyang , Lukas Wunner , Petr Mladek , Sergey Senozhatsky , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , Cao jin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Dave Hansen , Rik van Riel , Jia Zhang , Jiri Slaby , Kyle Huey , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Rob Landley , Baoquan He , Daniel Micay , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 11/27] x86/power/64: Adapt assembly for PIE support Date: Tue, 13 Mar 2018 13:59:29 -0700 Message-Id: <20180313205945.245105-12-thgarnie@google.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog In-Reply-To: <20180313205945.245105-1-thgarnie@google.com> References: <20180313205945.245105-1-thgarnie@google.com> 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/power/hibernate_asm_64.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S index ce8da3a0412c..6fdd7bbc3c33 100644 --- a/arch/x86/power/hibernate_asm_64.S +++ b/arch/x86/power/hibernate_asm_64.S @@ -24,7 +24,7 @@ #include ENTRY(swsusp_arch_suspend) - 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) @@ -115,7 +115,7 @@ ENTRY(restore_registers) movq %rax, %cr4; # turn PGE back on /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq pt_regs_sp(%rax), %rsp movq pt_regs_bp(%rax), %rbp movq pt_regs_si(%rax), %rsi