From patchwork Tue Jul 18 22:33:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850069 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 E4BC360392 for ; Tue, 18 Jul 2017 22:37:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0E4D285CB for ; Tue, 18 Jul 2017 22:37:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C53B3285E4; Tue, 18 Jul 2017 22:37:17 +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 6EE9B285CB for ; Tue, 18 Jul 2017 22:37:17 +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 1dXb4e-0000jV-Cz; Tue, 18 Jul 2017 22:34:36 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dXb4d-0000h1-3K for xen-devel@lists.xenproject.org; Tue, 18 Jul 2017 22:34:35 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 42/55-01731-AFC8E695; Tue, 18 Jul 2017 22:34:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVyMfTAKt2fPXm RBiueylp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmHPxxiLHjNU7G95S9jA+M07i5GLg4hgRmM Eu3njzCDOCwCr1gkvr1qZQVxJAT6WSWeXXvM1sXICeTESaxb0cQMYZdLLO+fxwhiCwkoSWzds JQZYtQ/RolVLafAEmwCWhJ7GuYzgSREBGZzSCzuOsMC4ggIfGSTuLHlMFgLs0ALk8STf9uYQF qEBRwl7r7eBlTFAXSJqsSDe2kgYV4BK4mXnbcYQcISAsYSf7/og5icQOHl93kgjrCU6O1tYJn AKLiAkWEVo3pxalFZapGusV5SUWZ6RkluYmaOrqGBqV5uanFxYnpqTmJSsV5yfu4mRmDIMQDB Dsa9/5wOMUpyMCmJ8m5VzosU4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7qBsoJ1iUmp5akZaZA wx+mLQEB4+SCK8NMAKEeIsLEnOLM9MhUqcYLTmuXFn3hYljyoHtQPLVhP/fmIRY8vLzUqXEeR eAzBMAacgozYMbB4vQS4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmZQdZy5OZVwK39RXQQUx ABwn75oAcVJKIkJJqYNwYycKgbmp4Zv0Mzr2m73aV7ixarn33b0/lvs/9PBtzWIKy9x774Lnn sxt7j/WRXgvZvKnR7jFbSvLOH5627IiEo1snb4SjakdXzIVrgYVGl/N79IQ9JixlDfx4XEWj4 b/u5trzbkfYzhj4/giTduvhNdXewRa+pyy2qFP0dlas6neV3bdylFiKMxINtZiLihMBaYi9aM sCAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1500417272!67193894!1 X-Originating-IP: [209.85.192.170] 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 42477 invoked from network); 18 Jul 2017 22:34:33 -0000 Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by server-12.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2017 22:34:33 -0000 Received: by mail-pf0-f170.google.com with SMTP id s70so8741582pfs.0 for ; Tue, 18 Jul 2017 15:34:33 -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=EXjizk2zRx8HtQ+ccTFkqfnqtRGlFwAz8yk4LTT9n1w=; b=Z6128shBQSDxKqHm6hvoEEutVSrafwh3KSSM83llJl6U/rk7mSdWYv9vEbRt77Fyqk TK0VfLUBByl+KaZe1qNShA+YQx92ubbwSP2MdCctQMCHJB1MVmDlVI1qJym5XJdYl0+U S9RQW2MQcaw8oq7yQvG5u1Qy5qzNTZu5PxhN9R6p+KLvZu22mBu48AQuqiVMetsqtVuu CSEQaRbrx7ZcqJJKsOUyQwBxLTXqhnXlPoooXDZS+QE7lGrtn/9obfKmKVnqnkSJgcvn ttG565zO7nNCYY5EQ1ps2xK659D+PU6hWJVchNPawr1NCMENmNvcbFoCm/3NX+/GD3uZ ou4A== 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=EXjizk2zRx8HtQ+ccTFkqfnqtRGlFwAz8yk4LTT9n1w=; b=adNk43yC+EY4cvWUZfiB73JDOSSdGDB8biY/sXQTqzj9XR+gPx8cWOGQs9iyg2is7U gvUaZikLhqt6sFrO46Iy9pmbs0ikkx4cDGYVZjrWvXREBUILiDXRcDCfixDiw1pFpNu1 RGcwgGii80+ZxQpYvG6ouWR/nZs/gwZ9mRfzNjavps6ijDj2xYytzgsj50YVuJHCi0nl jsTDWtx+NBf1lTKYmlPMvGWAdo6iq4YGvicOV513qn2yLW5gL9drup0/lTXyOSzCLpDz 9rVlDmpeShQweL+2FqC+pkfKosj+ShbGRW/e4XS6zOetGDyyH+EYMGkUzhAt30DMb9sm K1SA== X-Gm-Message-State: AIVw11178Q7gIP8tg7gipXuex1GGHJRmHzv7nYwV75EZ1CK2jqNk/fed OKJn9EJArHn6E+ZO X-Received: by 10.99.55.79 with SMTP id g15mr4156435pgn.28.1500417271592; Tue, 18 Jul 2017 15:34:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 15:34:30 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Thomas Garnier , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Andy Lutomirski , Borislav Petkov , "Kirill A . Shutemov" , Brian Gerst , Borislav Petkov , Christian Borntraeger , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Kees Cook , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Andrew Morton , Christopher Li , Dou Liyang , Masahiro Yamada , Daniel Borkmann , Markus Trippelsdorf , Peter Foley , Steven Rostedt , Tim Chen , Ard Biesheuvel , Catalin Marinas , Matthew Wilcox , Michal Hocko , Rob Landley , Jiri Kosina , "H . J . Lu" , Paul Bolle , Baoquan He , Daniel Micay Date: Tue, 18 Jul 2017 15:33:25 -0700 Message-Id: <20170718223333.110371-15-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 14/22] x86/paravirt: 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 if PIE is enabled, switch the paravirt assembly constraints to be compatible. The %c/i constrains generate smaller code so is kept by default. 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/include/asm/paravirt_types.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index 9ffc36bfe4cd..6f67c10672ec 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -347,9 +347,17 @@ extern struct pv_lock_ops pv_lock_ops; #define PARAVIRT_PATCH(x) \ (offsetof(struct paravirt_patch_template, x) / sizeof(void *)) +#ifdef CONFIG_X86_PIE +#define paravirt_opptr_call "a" +#define paravirt_opptr_type "p" +#else +#define paravirt_opptr_call "c" +#define paravirt_opptr_type "i" +#endif + #define paravirt_type(op) \ [paravirt_typenum] "i" (PARAVIRT_PATCH(op)), \ - [paravirt_opptr] "i" (&(op)) + [paravirt_opptr] paravirt_opptr_type (&(op)) #define paravirt_clobber(clobber) \ [paravirt_clobber] "i" (clobber) @@ -403,7 +411,7 @@ int paravirt_disable_iospace(void); * offset into the paravirt_patch_template structure, and can therefore be * freely converted back into a structure offset. */ -#define PARAVIRT_CALL "call *%c[paravirt_opptr];" +#define PARAVIRT_CALL "call *%" paravirt_opptr_call "[paravirt_opptr];" /* * These macros are intended to wrap calls through one of the paravirt