Message ID | 20170718223333.110371-11-thgarnie@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <xen-devel-bounces@lists.xen.org> 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 1428D60392 for <patchwork-xen-devel@patchwork.kernel.org>; Tue, 18 Jul 2017 22:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00182285D8 for <patchwork-xen-devel@patchwork.kernel.org>; Tue, 18 Jul 2017 22:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7FB9285E7; Tue, 18 Jul 2017 22:37: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 977B1285D8 for <patchwork-xen-devel@patchwork.kernel.org>; Tue, 18 Jul 2017 22:37: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 <xen-devel-bounces@lists.xen.org>) id 1dXb4Z-0000bH-8n; 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 <thgarnie@google.com>) id 1dXb4X-0000Y9-3X for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:29 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 39/4E-02175-4FC8E695; Tue, 18 Jul 2017 22:34:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsXiVRusp/u5Jy/ S4MBJYYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPGiwNsBbO4K+befMTYwLics4uRi0NIYDqj RNPMHnYQh0XgFYvEjQXfwRwJgX5WibNH7jJ2MXICOXESN1oPsULYlRLTZk4EiwsJKEls3bCUG WLUP0aJX4eOM4Mk2AS0JPY0zGcCSYgIzOaQWNx1hgXEERD4yCZxY8thsBZmgRYmiSf/tjGBtA gL2Ehcbd3MAmKzCKhKzF6/F8zmFbCS2PhxF1ADB9BuY4m/X/RBTE6g8PL7PBBXWEr09jawTGA UXMDIsIpRozi1qCy1SNfQQC+pKDM9oyQ3MTMHyDPVy00tLk5MT81JTCrWS87P3cQIDDsGINjB uGaq8yFGSQ4mJVHercp5kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeA91A+UEi1LTUyvSMnOAE QCTluDgURLhtQFGgRBvcUFibnFmOkTqFKMxx6QD278wcbya8P8bkxBLXn5eqpQ47wKQSQIgpR mleXCDYJF5iVFWSpiXEeg0IZ6C1KLczBJU+VeM4hyMSsK8x0Cm8GTmlcDtewV0ChPQKcK+OSC nlCQipKQaGC11bDnW/vt4YMrzxl+lTbGctj3yi6IlXjQWH13DEZCVvHyOW3SpzMrk5jXzLilO nPL23FHPi3cvzf6vcNyIfY7Cz91899bxXQm3iE6/EcklxNwr+eRb/8TaOX9y+1oN2OeExaxhv xN+YvFj0a1sS4KyNuq91z92bWvclfhtFi8XJtccsdjOs0iJpTgj0VCLuag4EQBBDiKDxwIAAA == X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1500417265!103449130!1 X-Originating-IP: [74.125.83.46] 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 61486 invoked from network); 18 Jul 2017 22:34:27 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:27 -0000 Received: by mail-pg0-f46.google.com with SMTP id u5so19919475pgq.3 for <xen-devel@lists.xenproject.org>; Tue, 18 Jul 2017 15:34:27 -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=iVsPDOvE/4mnM/CtOnJOylcb3dK/g+Y8XTzVwzqYYyY=; b=rGqLw0Zu31U1Fi+jIq4EqjosMuK/swb2ORNY9mXFb4vZJL18DqHyjVvzf9LRCet7wY zEujxE+ktMIvqUWxN//5Z7IAb1MI3fBujPaH7GL2YdsPI2YciCJYWLtNBOxvcB0KS15s nYf3PN5srJcq4i3yTxC5WxrelAz7143ftNCw3cqdTDJT/Z/XkqCwdSi546g1jiqQxGas 2oSP15jQMWMOT/0EQ7K0xsg/iCcI3dy9PJJIv8pUiGOwY3J3WO4ibbKhV8j4/akTtFO4 5Tz3G5jErJjyLZ1lrNVS9vf8Jr+2YPpbJ41Yf47MV4qTkmEUjltGJ9hqMpsWKV7ZZZik O26w== 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=iVsPDOvE/4mnM/CtOnJOylcb3dK/g+Y8XTzVwzqYYyY=; b=PO2D9RaRKQmmdWx1Qvcqnyp1kE7T9djFoZFjWosrAJYVoKyL52OzI4JckdiKzI2NPF LQHzujtpmfErWg6pMDKJT5jj3f+lnt7Kfi6pKoiDMca+S2w4+BqhufSXClgzp9PpQx2H mLtLP458HAPK2iuFL4BrzfXl7nzz28Gq+tDucZxYrBQsCNvGumVpHoQkCdj8LsYHLFAp Rubm0zIU9ol5zPoUGC7bqasxCqJh5Tweb1r9u+azhY2YtpkpQhd9mkV3vMTNq2n/z0Qt IlTB5OhaI47jJ2npCMB+Oi3hj1aZQPbZupYNkHFF7rWPmxnviM8iGHyXBzmkJ1bPVRd+ fsCw== X-Gm-Message-State: AIVw113wF+66i6SG+SGLHQKAftPIZqUsIPavQym0mgJeFfQ38CniyM6X h6FR9wmZPQZZt9rU X-Received: by 10.84.193.129 with SMTP id f1mr4102715pld.158.1500417265151; Tue, 18 Jul 2017 15:34:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:24 -0700 (PDT) From: Thomas Garnier <thgarnie@google.com> To: Herbert Xu <herbert@gondor.apana.org.au>, "David S . Miller" <davem@davemloft.net>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>, Peter Zijlstra <peterz@infradead.org>, Josh Poimboeuf <jpoimboe@redhat.com>, Thomas Garnier <thgarnie@google.com>, Arnd Bergmann <arnd@arndb.de>, Matthias Kaehlcke <mka@chromium.org>, Boris Ostrovsky <boris.ostrovsky@oracle.com>, Juergen Gross <jgross@suse.com>, Paolo Bonzini <pbonzini@redhat.com>, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>, Joerg Roedel <joro@8bytes.org>, Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Brian Gerst <brgerst@gmail.com>, Borislav Petkov <bp@suse.de>, Christian Borntraeger <borntraeger@de.ibm.com>, "Rafael J . Wysocki" <rjw@rjwysocki.net>, Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>, Tejun Heo <tj@kernel.org>, Christoph Lameter <cl@linux.com>, Kees Cook <keescook@chromium.org>, Paul Gortmaker <paul.gortmaker@windriver.com>, Chris Metcalf <cmetcalf@mellanox.com>, "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>, Andrew Morton <akpm@linux-foundation.org>, Christopher Li <sparse@chrisli.org>, Dou Liyang <douly.fnst@cn.fujitsu.com>, Masahiro Yamada <yamada.masahiro@socionext.com>, Daniel Borkmann <daniel@iogearbox.net>, Markus Trippelsdorf <markus@trippelsdorf.de>, Peter Foley <pefoley2@pefoley.com>, Steven Rostedt <rostedt@goodmis.org>, Tim Chen <tim.c.chen@linux.intel.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Catalin Marinas <catalin.marinas@arm.com>, Matthew Wilcox <mawilcox@microsoft.com>, Michal Hocko <mhocko@suse.com>, Rob Landley <rob@landley.net>, Jiri Kosina <jkosina@suse.cz>, "H . J . Lu" <hjl.tools@gmail.com>, Paul Bolle <pebolle@tiscali.nl>, Baoquan He <bhe@redhat.com>, Daniel Micay <danielmicay@gmail.com> Date: Tue, 18 Jul 2017 15:33:21 -0700 Message-Id: <20170718223333.110371-11-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 10/22] x86/CPU: 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 <xen-devel.lists.xen.org> List-Unsubscribe: <https://lists.xen.org/cgi-bin/mailman/options/xen-devel>, <mailto:xen-devel-request@lists.xen.org?subject=unsubscribe> List-Post: <mailto:xen-devel@lists.xen.org> List-Help: <mailto:xen-devel-request@lists.xen.org?subject=help> List-Subscribe: <https://lists.xen.org/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xen.org?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" <xen-devel-bounces@lists.xen.org> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 028245e1c42b..1adea8c4436e 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -47,7 +47,7 @@ static inline void *current_text_addr(void) { void *pc; - asm volatile("mov $1f, %0; 1:":"=r" (pc)); + asm volatile(_ASM_GET_PTR(1f, %0) "; 1:":"=r" (pc)); return pc; } @@ -682,6 +682,7 @@ static inline void sync_core(void) : "+r" (__sp) : : "memory"); #else unsigned int tmp; + unsigned long tmp2; asm volatile ( "mov %%ss, %0\n\t" @@ -691,10 +692,11 @@ static inline void sync_core(void) "pushfq\n\t" "mov %%cs, %0\n\t" "pushq %q0\n\t" - "pushq $1f\n\t" + "leaq 1f(%%rip), %1\n\t" + "pushq %1\n\t" "iretq\n\t" "1:" - : "=&r" (tmp), "+r" (__sp) : : "cc", "memory"); + : "=&r" (tmp), "=&r" (tmp2), "+r" (__sp) : : "cc", "memory"); #endif }
Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Use the new _ASM_GET_PTR macro instead of the 'mov $symbol, %dst' construct to not have an absolute reference. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier <thgarnie@google.com> --- arch/x86/include/asm/processor.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)