From patchwork Wed Oct 11 20:30:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10000545 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 150BE6037F for ; Wed, 11 Oct 2017 20:33:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A1A128B66 for ; Wed, 11 Oct 2017 20:33:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F260528B6E; Wed, 11 Oct 2017 20:33:18 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 935C128B66 for ; Wed, 11 Oct 2017 20:33:18 +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 1e2Nf1-0000QC-0R; Wed, 11 Oct 2017 20:31:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2Nf0-0000P3-Hi for xen-devel@lists.xenproject.org; Wed, 11 Oct 2017 20:31:22 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id C5/44-13910-99F7ED95; Wed, 11 Oct 2017 20:31:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMfTABt0Z9fc iDdY+t7b4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOmbvjAWLBSqGLmysdsDYy7+LsYuTiEBGYy Shy9u4e5i5GTg0XgFYvE1YWhILaEQD+rxM0N2RB2lkRv4xxGCDtN4viGdUwQdqXEtbu/2UBsI QElia0bljJDDP3HKHGl9y4rSIJNQEtiT8N8JpCEiMAJYYlNH34zgjjMAmeYJI73nQSq4uAQFn CSaNkQAXGFqsSeydfAtvEKWEocmPaLHWKbhcSxY4dZQGxOoPj3jYeYITZbSKycdZ51AqPgAka GVYwaxalFZalFuobGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgSHHAAQ7GL8s CzjEKMnBpCTK+zDmXqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd67dUA5waLU9NSKtMwcYPDDp CU4eJREeJtA0rzFBYm5xZnpEKlTjJYcF+5c+sPEcWDPLSDZcfPuHyYhlrz8vFQpcd6HIA0CIA 0ZpXlw42AReolRVkqYlxHoQCGegtSi3MwSVPlXjOIcjErCvIdBpvBk5pXAbX0FdBAT0EGiaXd ADipJREhJNTDmt/3LumMROEtAammmpQ9jwdU5Z2KEVByMO90VlzSffrF/dfTPfeu+x6w0s7QM 93yVbyUbu3aS+nFV8beXo3O/hb3IcK1aI/Lk5Y+dO4sjhd3zfPwV33kG+0X80Xh+k9Gg2VD/w cNZLVEC+y5tsPOzi17aeVNPrejtrcX/y/juXFVI2XbINViJpTgj0VCLuag4EQBWEFaVywIAAA == X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1507753879!70885915!1 X-Originating-IP: [209.85.192.176] 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 31756 invoked from network); 11 Oct 2017 20:31:20 -0000 Received: from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com) (209.85.192.176) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Oct 2017 20:31:20 -0000 Received: by mail-pf0-f176.google.com with SMTP id l188so1948792pfc.6 for ; Wed, 11 Oct 2017 13:31:20 -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=HQN8mG7Zz7xAAOoJxklfi7Le82B9smdJkCNd8m1I/0c=; b=NYv9N3MJfTRfriPRIYnf7Dlu6VeH9sMAIHQUZZZFDvKiyOwCWSk/YgN9xCM+i07J4Z NiRds4KBw63eKU5GZluTFnco4FiWo3Kt53Bx8Dn+Ucie6/SiCBkMjRn5y2LYDxtj+m45 Y2MIyiMb8eiauI2W23rNKEgeRuIyC2vbYoYFXJW66hOcf8Kk6WASFjmvilFdoqEC8blm ykeKFewKpHgbLKtTTdU6WTcq08dhiaka+KmHIMfYgXUYGVzmJ1sdqYhTzMi6h1jJOepn 5l6+tD9C2Re0vXBgb6LtWjogtite6otyXYayUZszKNbHf/XUXhcG2BcmFUXL8TmFiCki /oLg== 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=HQN8mG7Zz7xAAOoJxklfi7Le82B9smdJkCNd8m1I/0c=; b=SB8Z2YiAobbq+nZGKoZwtpB3s5KZlJDWE/gOPPbd3AXJFpNWpYKvluJygkuvWSQa0b EedlgEIzd1BhgTIHi+AKaRyMmlTgRH1jaCxdFFHjpV0rxTvUjS1qQM0k7/Q2/OockyeP l3Vo/0NsiQdhhLHICUgbkQs++BxKCWrUX/L77P6Tv8crfYgDr2fbNcQJTcQNsQAAbX8+ 9Raf1UVftEbpi5/VwOBWLuUn6ZaccHk2Fn1Dem25pWOyf7W1V47JMlKw+wuqRwz98aKg zK1TAzQfHTmkghFDqfjGZYXyvEPtQAK2sP/7CdNqOOkpBF4qmfmKdxYnu2vb1BfJpVDX Q0ww== X-Gm-Message-State: AMCzsaW+SvMWc4zCVyUpBRup1bsCT3p9gGoc97bytN2vO4EJfcU0Ncsw patJeuVb9Y7NEmgcyi4CPMkhwQ== X-Google-Smtp-Source: AOwi7QC2wkR9g0tmdwyUEhQwCqXXZiMWaa03DIpixnJ46heWqdQMf24tMX5jam43OmWUu3xuqm2tKA== X-Received: by 10.98.150.221 with SMTP id s90mr191924pfk.282.1507753878149; Wed, 11 Oct 2017 13:31:18 -0700 (PDT) Received: from skynet.sea.corp.google.com ([172.31.92.33]) by smtp.gmail.com with ESMTPSA id n12sm20691913pfb.149.2017.10.11.13.31.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Oct 2017 13:31:17 -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 , Kees Cook , Andrey Ryabinin , 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 , Paul Gortmaker , Andrew Morton , Alexey Dobriyan , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Mika Westerberg , Dou Liyang , "Rafael J . Wysocki" , 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 , Jonathan Corbet , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , "H . J . Lu" , Rob Landley , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay Date: Wed, 11 Oct 2017 13:30:09 -0700 Message-Id: <20171011203027.11248-10-thgarnie@google.com> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog In-Reply-To: <20171011203027.11248-1-thgarnie@google.com> References: <20171011203027.11248-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] [PATCH v1 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