From patchwork Thu Aug 10 17:26:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894371 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 9F86160236 for ; Thu, 10 Aug 2017 17:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8735D28A93 for ; Thu, 10 Aug 2017 17:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A78228AE9; Thu, 10 Aug 2017 17:30: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 4CB0528A93 for ; Thu, 10 Aug 2017 17:30:39 +0000 (UTC) Received: (qmail 1670 invoked by uid 550); 10 Aug 2017 17:27: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 1381 invoked from network); 10 Aug 2017 17:27:15 -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=5cwMD/PqyndTnsdIb8rc1e28IqthEN9AJJlS0aHs4OM=; b=F8eS01QC3bvM3ngIPXN5tFskv5S1C3su7zHvep/BgKhu4gWjNTHaCU2gz7ZTXLbfGL XWrkn9TBP/aCRpj7o36FdiIgdu//wh+hxQgdhFtd6JuowSQ7Kmw1wcFtJcwkyRT8++gn S65WWa8zj81HXLLDPlAXWcvfPkT20QBAcOhdCsUB+t19CF3N6Xr2PApa/FGuJYNJXgRX fio2sici4xUGv5n/FGr9mWlU/vINEvXGNVClchClEop+MKYb3yE0XBh8rOAPC9LuV9/H jTeL6moYmaISX9tu0xC995LfYhewF0NyENaLO1edRtE8+vHfQyuyp4/mkUo/6bkVVOxx a3xA== 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=5cwMD/PqyndTnsdIb8rc1e28IqthEN9AJJlS0aHs4OM=; b=fTsLz9qFw626rZdE7ptpODOPn/RhyP96DQTVELsWOXHm8M44cajJKANrHA/8TEn0R7 ggbm7Bw/nlNXAyNQchXFdqxQCxQfVtuYG+NsWKczYRiOrgIygjzu7rd3ZXL8DRZ0+BH+ eaWsiBEooozetAnVh7Lt22dXBY1I58ylBk8BHAezRfpE0k9DEb2nDomv1RE7q/9azzfW 3TXgk5pDTfHkFD6p/Uc8BlXlCtSH7IQM6xWfJdCnorjIh6GUEQkz3ZrlOVWj1b1hoWIm 1cqsPnviZy6TNOKqQMBCNKQSGIrgxCY/i3qC2vi0cdA519Bwr1wb/ARfVfkNVq1UzE7X Ig8Q== X-Gm-Message-State: AHYfb5gpgxdTOn9NG62cL59atjJnfsJSh62obs/ZWyR+nQHr6+XLBnRy usrm0rwaOrtooJtD X-Received: by 10.99.53.12 with SMTP id c12mr12069515pga.15.1502386023229; Thu, 10 Aug 2017 10:27:03 -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 , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Paul Gortmaker , Chris Metcalf , Andrew Morton , "Paul E . McKenney" , Nicolas Pitre , Christopher Li , "Rafael J . Wysocki" , Lukas Wunner , Mika Westerberg , Dou Liyang , Daniel Borkmann , Alexei Starovoitov , Masahiro Yamada , Markus Trippelsdorf , Steven Rostedt , Kees Cook , Rik van Riel , David Howells , Waiman Long , Kyle Huey , Peter Foley , Tim Chen , Catalin Marinas , Ard Biesheuvel , Michal Hocko , Matthew Wilcox , "H . J . Lu" , Paul Bolle , Rob Landley , 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: Thu, 10 Aug 2017 10:26:06 -0700 Message-Id: <20170810172615.51965-15-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog In-Reply-To: <20170810172615.51965-1-thgarnie@google.com> References: <20170810172615.51965-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v2 14/23] 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