From patchwork Wed Oct 11 20:30:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10000595 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 2AF6C6037F for ; Wed, 11 Oct 2017 20:34:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F39128B6E for ; Wed, 11 Oct 2017 20:34:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12C1D28B74; Wed, 11 Oct 2017 20:34:07 +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 11E3F28B6E for ; Wed, 11 Oct 2017 20:34:05 +0000 (UTC) Received: (qmail 15449 invoked by uid 550); 11 Oct 2017 20:31:39 -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 14294 invoked from network); 11 Oct 2017 20:31:35 -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=4GE4rc7j4PMH+rm4kc3luySDpxmc4NT0ua/ZYOp8V9o=; b=QyYGkKgg0nzIMsuO5Fy4MYms/5nOLVQBbFSjFXt36v29R2qBUP7tNzbHPoyZdoJUyG KeKrxrDWIO9a9zWUCLJp47+vWeINB2W5E84bxa7rxBs8i2zNmzfdba5Xtr0E3RDmWkl5 zUErg2o8c3QWgrX2iq9VgpQuwCOEVX/0ANR6a/3PuNBGKrLu/F6JSdfL4z368cTfAbsC MFXj9oE5TnW4pPvPbihlYbZXnenHY7KwOEISGxlAzmVHe1FAYw4yLj5Ghf4eP53tVOWD Xv7rrCGKvl80pzsb5r+QyDD9Gbeyf7AwHJyKHiqAgW+5sRDg5Z/x4KvQSmKHE9YbzwGz ckNQ== 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=4GE4rc7j4PMH+rm4kc3luySDpxmc4NT0ua/ZYOp8V9o=; b=YTI6/QwaG+L5M62o8u+6Ia7MsSHl5BVWkQijDu0NSp8LH1Vz2Hhn4FNFHa1tkx8I6j O8I4bPbd+inYUmSLIcj97U24fOeJRSzC8750mVTPEQOAe/TKI+k0JyXeW/yxMeM4Y81R PYVV04gZRTqPMM966k/GIH/OUPFxSxK4jvvuieYyJ7IPYTpsgZlO9MoOguArctczmd41 gLQsFKDFdFCvu6y+ei/u5/Wmm/CJrN4T9gSYuu+cQPvhkpxQ04F5qhnZq+M+p6tqZxNY KWh/BXBynm/hqNyo5j/UOkdS4sYZFX/xlI4UxjfPuUCqq3sNweOR1qIJgylL7z5vVvcJ jh/w== X-Gm-Message-State: AMCzsaV2xRQb9k0oRdslE9x0VrgxrfUmPhBfawFnrDpW6AMn0rUa8KkK gbQ9Fw9BM4gFPsW8oYFnSQE9qw== X-Google-Smtp-Source: AOwi7QADw7zP/j49FwELljVcEFbs5iSs7n64Maz8Aa/83MhsL3ROjfi7f6Bm9h1SvG1Ai9tEBNaYug== X-Received: by 10.84.143.68 with SMTP id 62mr161308ply.315.1507753883023; Wed, 11 Oct 2017 13:31:23 -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 , Kees Cook , Andrey Ryabinin , 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 , Paul Gortmaker , Andrew Morton , Alexey Dobriyan , "Paul E . McKenney" , Nicolas Pitre , Borislav Petkov , "Luis R . Rodriguez" , Greg Kroah-Hartman , Christopher Li , Steven Rostedt , Jason Baron , Mika Westerberg , Dou Liyang , "Rafael J . Wysocki" , 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 , Jonathan Corbet , Michal Hocko , Peter Foley , Paul Bolle , Jiri Kosina , "H . J . Lu" , Rob Landley , 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, 11 Oct 2017 13:30:12 -0700 Message-Id: <20171011203027.11248-13-thgarnie@google.com> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog In-Reply-To: <20171011203027.11248-1-thgarnie@google.com> References: <20171011203027.11248-1-thgarnie@google.com> Subject: [kernel-hardening] [PATCH v1 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