From patchwork Wed Oct 4 21:19:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9985577 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 DD8EA60586 for ; Wed, 4 Oct 2017 21:23:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8A628C2E for ; Wed, 4 Oct 2017 21:23:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D6228C2F; Wed, 4 Oct 2017 21:23:44 +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 0171328C30 for ; Wed, 4 Oct 2017 21:23:42 +0000 (UTC) Received: (qmail 15797 invoked by uid 550); 4 Oct 2017 21:21:22 -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 15702 invoked from network); 4 Oct 2017 21:21:20 -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=5umbMOlyCePbbR9sdmAfkJ4s8+iLpUm9XYg0uxqOLT4=; b=OjsFFQ7rHut+PRzjGzufehHD8sERsudmgEbW6ZJAG1SMiKWjHiHpRL8RVhR/sdOGAT AiAUXS4QTnMM89nRSFRYVu5WKfR7PB5EaWNFmwNMSUIt2/Fc4dSJnYmPWFSpqs7FThMT v+ZlHnO3uC+4V3nS3aUOIeoB5JjG2FyLqSdUn/Z1NbmP3DS1zfsZFyGSctESbGVVCtPZ ydNty8/9Ie29Ty6ciep2W/SfLz7CQpBv0TWmOgrZhNgNHpQOte1WMq4qXXTREpMGgzM3 Ce0EGjBSlaUlk+jiaca29DlEIXzFshyTOevdeV5ciTKJSHK1R7n+Lp9CAx174nUEGkOS xvBg== 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=5umbMOlyCePbbR9sdmAfkJ4s8+iLpUm9XYg0uxqOLT4=; b=FaNnD7nZuAImDwFO8qPlvB2wpu3IT7+keT6zTj//EsErukjlTTB0rK3YSxO0lsDQ37 EFjhElW4yOtcwFQY8fj7xVAUk5jrl/dpu+z6sNwT4rkoGi6PLm53g7xrycLVJAIGM6sA 3HDPMR0QFiTQKXWdyeE2LqndW/UCI99iMFI3EDv9FepqWk59K8W3DjXZ6qpfFE1pBaRj sFp9EXLV6AS08JFxqatl1DPOfdyBSXx3VC2UJtOR9SnOafmXRdHebNTUTOhx5vVFd2fr F8vUwo4Gpchmjp/7u9mZc5hckiU7lRZv/tta3KtjaAjtGmLs83dcV5UKy2wephm25xYU GorQ== X-Gm-Message-State: AHPjjUjWs4wuGaULg9NxkMl0m/R81tK/4TYIwvoZVyoFpLHUBZnpPLjB cS7JhVu6gR7LehYNVAuos7IWtg== X-Google-Smtp-Source: AOwi7QBLF36ymEhhXWE59gX4j4MryDXcOTRLQTuP+U9xDezgzhkK+50LMNAYAdDbgbL5tR7fCMgSwQ== X-Received: by 10.84.254.70 with SMTP id a6mr20684658pln.71.1507152066893; Wed, 04 Oct 2017 14:21:06 -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 , Kees Cook , 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 , Alexey Dobriyan , Andrew Morton , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Dou Liyang , "Rafael J . Wysocki" , Mika Westerberg , 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 , Andrey Ryabinin , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , Rob Landley , "H . J . Lu" , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Wed, 4 Oct 2017 14:19:48 -0700 Message-Id: <20171004212003.28296-13-thgarnie@google.com> X-Mailer: git-send-email 2.14.2.920.gcf0c67979c-goog In-Reply-To: <20171004212003.28296-1-thgarnie@google.com> References: <20171004212003.28296-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v3 12/27] 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 280d94c36dad..e6961f8a74aa 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -335,9 +335,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) @@ -391,7 +399,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