From patchwork Wed May 23 19:54:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10422277 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 76CA860224 for ; Wed, 23 May 2018 19:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65C5A28A7A for ; Wed, 23 May 2018 19:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5985028BCC; Wed, 23 May 2018 19:58:36 +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=-12.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, USER_IN_DEF_DKIM_WL 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 52F7A28AAA for ; Wed, 23 May 2018 19:58:35 +0000 (UTC) Received: (qmail 23905 invoked by uid 550); 23 May 2018 19:55:47 -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 23755 invoked from network); 23 May 2018 19:55:42 -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=+ZKQyXofwMaCZF6J8MMxRKO5hhGGS5oaGWxkCkq5XY0=; b=LqqsTcxqxaAjgGses42drmOcIOkBP9ad6CpGlJ49hKtF9k+n562EPs8/arI3K7oOKU DNeRBcoLGquG50E6iC2yriMfx+y3VbcYyzb06gokVGt9XTwf1+G54ZrbplpJD8NTETqO X3HS+dCnQrK0oGEQcQ5M5XGfic1UZF806DtZwzWljMv+aR+Iri1/BEJFRvRnFCpx55PD xRcSHb8N2tLjj/1PZuGDlL+AcxU5NRxsIl4cktT9cHwA4AdN2JSoCzAqAo8gdmlewK+G ostnVueX5wPioVVmQjJopio7IT6W9UHGHETIdQWxUAPIbAzNqWBsOy5KEH1l8HRNe7aH /XKg== 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=+ZKQyXofwMaCZF6J8MMxRKO5hhGGS5oaGWxkCkq5XY0=; b=Z3qRld5Lkw0W6GxVcAazZAqxJmOFeDKVYrJfpNAQBwyl+XqlG3QI8/VS0MP0GXI/PI F339V6mDgfKIdUCPI9xqshqhHRckKv/VlNnkCnxA0LJUVaW8pLsJgrbx8iQ76TeBXMI1 cj7cJtVqvNVqTsMIQ1SW3KWIADMGNkmwbQc6ik6OysPl8PsX5a+UaOu4Q5TxMvXt0IsC Tho82jjCTJpW3/EspjMpsxzHGTbY3/dkf7uWDoelfvNSKmEWsOTavs8B/JZnMjXTi/tw i89JYdSo7FLKfnFMomUJbK/3LDeRFBWPTo/pixQSMBblQNGeLyU+rpwH7QPNCZgnGNVP jCQA== X-Gm-Message-State: ALKqPwfmeCQgnLWsthsvGUSJBjlnox509phIV/pWOV67dgDs+CX38bIB J8cXXVHfolWEfZaGEBNS3CmKqA== X-Google-Smtp-Source: AB8JxZpf47qqEbbrhp+vA2cSTtApY9z3RwkpX+BTOxdCO6euTPL1qzE5e+7eBFRcGztgcb56t7BEIg== X-Received: by 2002:a63:4281:: with SMTP id p123-v6mr2380238pga.144.1527105329056; Wed, 23 May 2018 12:55:29 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Greg Kroah-Hartman , Thomas Garnier , Philippe Ombredanne , Kate Stewart , Arnaldo Carvalho de Melo , Yonghong Song , Andrey Ryabinin , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Alok Kataria , Steven Rostedt , Jan Kiszka , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , Alexey Dobriyan , Masami Hiramatsu , Cao jin , Francis Deslauriers , "Paul E . McKenney" , Nicolas Pitre , Andrew Morton , Randy Dunlap , "Luis R . Rodriguez" , Arnd Bergmann , Christopher Li , Jason Baron , Mika Westerberg , Lukas Wunner , Dou Liyang , Sergey Senozhatsky , Petr Mladek , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , David Woodhouse , Dave Hansen , Rik van Riel , Jia Zhang , Ricardo Neri , Jonathan Corbet , Jan Beulich , Matthias Kaehlcke , 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 Subject: [PATCH v3 12/27] x86/paravirt: Adapt assembly for PIE support Date: Wed, 23 May 2018 12:54:06 -0700 Message-Id: <20180523195421.180248-13-thgarnie@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180523195421.180248-1-thgarnie@google.com> References: <20180523195421.180248-1-thgarnie@google.com> 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 180bc0bff0fb..140747a98d94 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -337,9 +337,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) @@ -395,7 +403,7 @@ int paravirt_disable_iospace(void); */ #define PARAVIRT_CALL \ ANNOTATE_RETPOLINE_SAFE \ - "call *%c[paravirt_opptr];" + "call *%" paravirt_opptr_call "[paravirt_opptr];" /* * These macros are intended to wrap calls through one of the paravirt