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: 9894351 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 E2ED960236 for ; Thu, 10 Aug 2017 17:29:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA05128A39 for ; Thu, 10 Aug 2017 17:29:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE2ED28A93; Thu, 10 Aug 2017 17:29:27 +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 6D18228A39 for ; Thu, 10 Aug 2017 17:29:27 +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 1dfrEh-0007q3-Pz; Thu, 10 Aug 2017 17:27:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfrEg-0007nC-BR for xen-devel@lists.xenproject.org; Thu, 10 Aug 2017 17:27:06 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id E5/80-03582-9679C895; Thu, 10 Aug 2017 17:27:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRWlGSWpSXmKPExsXiVRuso5s5vSf SYH6Mxfctk5kcGD0Of7jCEsAYxZqZl5RfkcCa8eT5cZaCNzwVq9uWsjcwTufuYuTkEBKYzijx clp9FyMXB4vAKxaJe9NXs4M4EgL9rBK9d2azglRJCMRJzGxvZ4ewKyQ+TD/DDNGtJLF1w1Jmk AYhgX+MEgfWrAZLsAloSexpmM8EkhARWCoocbL1GiOIwyzQwiTx5N82JpAqYQEXiSv/3rGA2C wCqhITfx8CW8crYCnx/cQKJoh1JhJPWicxgticQPFpy2ZCrbaQmPprJdMERoEFjAyrGNWLU4v KUot0DfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQJDiwEIdjDufO50iFGSg0lJ lLf4U3ekEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQle/mk9kUKCRanpqRVpmTnAIIdJS3DwKInwb p0KlOYtLkjMLc5Mh0idYjTmmHRg+xcmjlcT/n9jEmLJy89LlRLntQaZJABSmlGaBzcIFn2XGG WlhHkZgU4T4ilILcrNLEGVf8UozsGoJMzrCjKFJzOvBG7fK6BTmIBOifDtBDmlJBEhJdXAyHb c8FVUOO+GP8VF55ZeqYoy933x1esSQ/SF2b2zX33RPG0d6LWF3e7mfLU5HdzbJi5sWb1RS1/Q 3sVm9cJVmXym0s48lZtzJHcs6dabPf/I5crrSe8nx68tcdbce8L6c85y9VTntTYJK1jCfWXLf u1IZZv9wOrejpiFDpc2+pXvtH5XN03orRJLcUaioRZzUXEiAPenQYe5AgAA X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1502386023!71511517!1 X-Originating-IP: [74.125.83.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47693 invoked from network); 10 Aug 2017 17:27:04 -0000 Received: from mail-pg0-f44.google.com (HELO mail-pg0-f44.google.com) (74.125.83.44) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Aug 2017 17:27:04 -0000 Received: by mail-pg0-f44.google.com with SMTP id l64so5398972pge.5 for ; Thu, 10 Aug 2017 10:27:04 -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=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=DrHkNTMW1D+JJihuIcrACGgAK3c3a5nocTjcyi+8Za0igHeB0DOFU8BOx1SK3043bv WIT0+UwjiUDil+oTTv26WiL5sosM7t2o+L0BZrzLNVQ19cxqxUJdopq/RaVzyHjFakE3 a5s02yWPAmeHeJGQ9jvFND5WoKmgTqABN4Rq2eEYHy53NrorGz4M+Tops7LOoU39JBSt BcXOXNOQN/YhmLjFC+ZduLJCNnsgITFc6pZ60HqpCPrtAX05oToM0QJrt+FormxvfVQh hSjB+qnI4DFuEAR5GUx7egXaL4iXpRVc9AZArXPMh57GIkvBzNoINNNuMO11nh6dJl11 WJNQ== X-Gm-Message-State: AHYfb5hct9Ki8LfFpbFGt3hSygNgQdus52zjyoVXd7qmv0kQy8EYpx74 qON2YUf5zihcK314 X-Received: by 10.99.53.12 with SMTP id c12mr12069515pga.15.1502386023229; Thu, 10 Aug 2017 10:27:03 -0700 (PDT) Received: from skynet.sea.corp.google.com ([172.31.92.33]) by smtp.gmail.com with ESMTPSA id p77sm11894925pfi.153.2017.08.10.10.27.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Aug 2017 10:27:02 -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 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> 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 v2 14/23] 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