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: 9850045 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 D1C5A60392 for ; Tue, 18 Jul 2017 22:36:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCF94285B7 for ; Tue, 18 Jul 2017 22:36:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFA06285CD; Tue, 18 Jul 2017 22:36:54 +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 mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id D9D30285B7 for ; Tue, 18 Jul 2017 22:36:53 +0000 (UTC) Received: (qmail 28011 invoked by uid 550); 18 Jul 2017 22:34:46 -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 27931 invoked from network); 18 Jul 2017 22:34:43 -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=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=FePyvLQxEKtB68nt54MbIXod/zlq3VDO0W7ThxPF61JsvvykbmGggw1wVn7A3ed+g/ N1otYT4NFJgGYVkXieBVIgNIi3UxfgTJcXZiK4H/KBXlyNo6+whknzrGfJUmEQtvzUWU 1/wEapwoaLhx2+Yb7MyvecbDybSQZ0NBERrsF5PjPo190fXkeYaf9Qr5KrVm5ypBv4wF 9gk4ZYBPpmbkIiIRu9E/41WuQhrlCzzzyxn4G03PZlf3MH/DS+LNyLe6bVxWtXFyfpcF fpJt1kkGh4te2xN2b8ZZZ7R8jxKVwqCmEBl4qGirujNCqsA7lKy4hv62LuDqNa3GVhxS VrBQ== X-Gm-Message-State: AIVw112HRxP4FY1gCE50swsVfaLkeWq+qmSaw2DmaW0qnbczbuZEERDY y89bEEd5elLmVYAc X-Received: by 10.99.55.79 with SMTP id g15mr4156435pgn.28.1500417271592; Tue, 18 Jul 2017 15:34:31 -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 Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kernel-hardening@lists.openwall.com 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> Subject: [kernel-hardening] [RFC 14/22] x86/paravirt: Adapt assembly for PIE support 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