From patchwork Wed May 23 19:54:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10422273 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 5B2A460224 for ; Wed, 23 May 2018 19:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4934128A7A for ; Wed, 23 May 2018 19:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B8A828AAA; Wed, 23 May 2018 19:58:24 +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=-12.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, USER_IN_DEF_DKIM_WL 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 69C6428A7A for ; Wed, 23 May 2018 19:58:23 +0000 (UTC) Received: (qmail 23814 invoked by uid 550); 23 May 2018 19:55:43 -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 23684 invoked from network); 23 May 2018 19:55:38 -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=m5qhlOIpCB/2tztLizJQ43YnzIgfAXBAhGELjfanNVQ=; b=P1IFcCNGe4G303CM7PN1N3sBrWte72hmMpFB9pWzXMadSJn61Mk7H4bNBvlMcoCwk3 2/5WjYZDcstaur/IoxpSiJCzVF3VdPaIjRFOOqgt+MRO3ErobtbSaUtSTEN54MnTcBc9 5uofJjJc8tl8N3CJzt9Nprqg3W5N25WkbticG2iWOXqHCLIvSrwu7ms3/j7JPNNuJsWE 96Nbdt9yZPJBVwsK962oO5lAVo6C6CBNDtn3CnrNBsvTaryH63gajiQwqTBbo9DBgrhp h3PMuMVahVNGe1IBSsFM1WVtRSerhlKvh9M7QhY2Hl+7tn0dDMD+8uIiZZITYN8pm4W/ CzxA== 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=m5qhlOIpCB/2tztLizJQ43YnzIgfAXBAhGELjfanNVQ=; b=VmZFDfz8oNjXAJsZzsSoetunfz5mtnFsn+wucWsiBAI3xOamkihYRFPJsZRTLhj5IM BY7/nt48sw5sMIPpEmURjYan3FtjYVon35SAHkndXRhoRFJoiSb4FPLzGMoLUF9+ssE8 21sUMUxxJxw10kPhBSBdAV7jCRK93VTR0SYQmwrsSYHzEIYcLwtlW086uAQSY9pU0Zz8 R3MIJlTAz9wDvUdEHTN3/LnLwrigSkAHFabYzazOfI1o5bOXUWdKnYyFLp/JRCQHWij1 nLjJkGvPy6xXrSOFrZiP4zUBpR0itedgC6raLTnbnL6TCoGJeGnJr2WhXH8doSGKEfDI M/8Q== X-Gm-Message-State: ALKqPwe0qs3yJZDhLhMCubOB3lqXLupsJLvrHVATzoMTbmkppjESfk8V 37NHeCLyAvzq15t6gG0et2kbNA== X-Google-Smtp-Source: AB8JxZobJNTwv/eVTeZ8dOJzLclp/1K+GPFnX1mJxZs5p9l22s/IreJgoUT0wZc6nTGh02m4omy0oQ== X-Received: by 2002:a65:578b:: with SMTP id b11-v6mr3441596pgr.57.1527105326471; Wed, 23 May 2018 12:55:26 -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 , Thomas Garnier , Philippe Ombredanne , Kate Stewart , Arnaldo Carvalho de Melo , Yonghong Song , Andrey Ryabinin , 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 , Jan Kiszka , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , Alexey Dobriyan , Masami Hiramatsu , Cao jin , Francis Deslauriers , "Paul E . McKenney" , Nicolas Pitre , Andrew Morton , Randy Dunlap , "Luis R . Rodriguez" , Arnd Bergmann , Christopher Li , Jason Baron , Mika Westerberg , Lukas Wunner , Dou Liyang , Sergey Senozhatsky , Petr Mladek , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , David Woodhouse , Dave Hansen , Rik van Riel , Jia Zhang , Ricardo Neri , Jonathan Corbet , Jan Beulich , Matthias Kaehlcke , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay 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 v3 11/27] x86/power/64: Adapt assembly for PIE support Date: Wed, 23 May 2018 12:54:05 -0700 Message-Id: <20180523195421.180248-12-thgarnie@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180523195421.180248-1-thgarnie@google.com> References: <20180523195421.180248-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 Acked-by: Pavel Machek --- 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