From patchwork Thu Aug 10 17:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894345 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 54B4560236 for ; Thu, 10 Aug 2017 17:29:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BB101FF61 for ; Thu, 10 Aug 2017 17:29:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FE53285F0; Thu, 10 Aug 2017 17:29: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=-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 CD4911FF61 for ; Thu, 10 Aug 2017 17:29:23 +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 1dfrEh-0007pc-Ij; Thu, 10 Aug 2017 17:27:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfrEf-0007nC-W1 for xen-devel@lists.xenproject.org; Thu, 10 Aug 2017 17:27:06 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 41/80-03582-9679C895; Thu, 10 Aug 2017 17:27:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsXiVRtsqpsxvSf SoPeciMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmrF66gvWgtccFTNWvWFpYDzN3sXIxSEkMJ1R 4szvuWwgDovAKxaJDZ93MoE4EgL9rBKvH/UDZTiBnDiJ9tP/GSHsSokTq/aD2UICShJbNyxlh hj1j1FiXdtrFpAEm4CWxJ6G+WCTRASWCkqcbL3GCOIwC7QwSTz5t40JpEpYwEXi29XpzCA2i4 CqxLoT24CKODh4BSwlJt0yhthmIvGkdRLYNk6g8LRlM5khNltITP21kmkCo8ACRoZVjBrFqUV lqUW6hmZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB4cUABDsY728MOMQoycGk JMpb/Kk7UogvKT+lMiOxOCO+qDQntfgQowwHh5IEL/+0nkghwaLU9NSKtMwcYKDDpCU4eJREe LdOBUrzFhck5hZnpkOkTjEac0w6sP0LE8erCf+/MQmx5OXnpUqJ8+4EKRUAKc0ozYMbBIvAS4 yyUsK8jECnCfEUpBblZpagyr9iFOdgVBLmZQe5hyczrwRu3yugU5iATonw7QQ5pSQRISXVwCi +vYRrX2TL35qWILfXtut6KgPbsh4lBn4oeSV8LcTA94vqmY9aaxrMLpqmzH87y3m+9MPA9V8P 876f2sMx8YjQm9ObdN9xd76o3J6dY+H+6/QuPieGpwvvv7Zzv2P1JkmIqXHNOV5pj2Vpb2KSl y33KJtmqHTwhn0sb1j+ZM/9R48dZ93hK63EUpyRaKjFXFScCACxKlEhuwIAAA== X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1502386023!73901734!1 X-Originating-IP: [74.125.83.53] 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 42525 invoked from network); 10 Aug 2017 17:27:04 -0000 Received: from mail-pg0-f53.google.com (HELO mail-pg0-f53.google.com) (74.125.83.53) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2017 17:27:04 -0000 Received: by mail-pg0-f53.google.com with SMTP id l64so5398797pge.5 for ; Thu, 10 Aug 2017 10:27:04 -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=b0fcYsbNXGzh+lAqdO+baN7EXWCsgWP+gawHCo4/DDk=; b=geQxQD7hWZpd9vUSMEohWCkI3qmasSo9kzniYnAve8VUoBA3q5yPMyczgCg78nHOWH ndQTx9U7Q7B8E9Ski0Wue7WgCYxAu+8S5Q/RcbLgwDkxziPqpEWjyz07TOIwMtbEZV3P YbbbBjWjz45Sorr4TFbxcdKJgUVxzKWNpD4NKnwCfNISxA1pZ0oDcMKIUzqlccgvojwv phZPrw0feMMLHgbONOhitG/C+KS4Km8kOITXvr/yFe7K/1htd3Vbs9cnI9JK7CLRl7Qz DgSYHFvlYFdhFiC/AIa2WLCB73XJ93EdMGCnqoRMiFTSxjpPvo+IL3tzT79EeTnVd2Fc Ylrw== 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=b0fcYsbNXGzh+lAqdO+baN7EXWCsgWP+gawHCo4/DDk=; b=C1FBuxeoWv1IvP6vvLEewuke4EOSBdmCVjCmiWJg07YHBS8rnnfmo29OaWuzpWZ1Ze F1HnfldJ1gNRW3fB+90o0NywP/7X6QcPcY/uJt+ajQdmIz67oNC76owzyjhT4MMJMoT7 COwczWot8Wqmt+ODXPLrBMqbCLiVwU98cCDURC2QAD91ZXqaXsVeK1m2P6i9Did4YtFu OlmEy8pTYRWDSWEJhvxxhbJ3Mecbc5jBp1zCRL2oisONuzXzlBUeTIh1EpjWBy/+vl0g tJTvoyfRQg8Nw4jWjhFPOnTwlKLE5oOtWUdAYOu7BlT8BQ6Fhs6EHdZXWEbzWLCRPf+W eBrQ== X-Gm-Message-State: AHYfb5gWVK85XTUiTSCK4OIZfg6X3+1jzky/5BZyt6XkQgWa/ysLMmcI Y1T17DeaPX8gaZFF X-Received: by 10.99.96.74 with SMTP id u71mr12138230pgb.129.1502386022014; Thu, 10 Aug 2017 10:27:02 -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.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Aug 2017 10:27:01 -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:05 -0700 Message-Id: <20170810172615.51965-14-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 13/23] x86/power/64: 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 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