From patchwork Tue Mar 13 20:59:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10280781 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 89429602C2 for ; Tue, 13 Mar 2018 21:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79875284C8 for ; Tue, 13 Mar 2018 21:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B71F284D1; Tue, 13 Mar 2018 21:04:24 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 6A936284C8 for ; Tue, 13 Mar 2018 21:04:23 +0000 (UTC) Received: (qmail 21611 invoked by uid 550); 13 Mar 2018 21:01:02 -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 20411 invoked from network); 13 Mar 2018 21:00:52 -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=DZsEq1zFEG7w9tiVZ8nBqBYJOHCVzWGdhc4pdAiMld8=; b=my7DXLCgQCW7IpsAEJ4O+0BkDa/JPSaQ928EfCJQnoAw4JY8Lr2QRrjvbb2fK0Ln7p dUfiLffh2KZFPsB5QffX86M0+a0SvevM2YZUYUuU1py55w68iB1J/ToRYAzwFDkAEldD nKKXUEDkQmF0urNebBs/A0XZkTIlS1gmeh8BJFSsOnPhY7b/XbL0sI63mOumIyxnsLvF 3wCJMw/iN4uKqlk6rtt5S06CkqXf70M0532YImWqYVXKNWk8kfPstqKCo1GTQ9mcD1Wd ti/F6ZiCLKbDBdxXCQK1PRP2ng5TYIt9ZqnbRFNgvBs+VscHHdkGeLNa67zj71v/XJoN ni2w== 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=DZsEq1zFEG7w9tiVZ8nBqBYJOHCVzWGdhc4pdAiMld8=; b=un1tF2ECmE4Nfs6Cey7ZOdcoo2VYaVc1qM9aiih8ZvjolsfzeNfNYhq1C7DscqKc/q yhHhO76asvhl0f0e+AEdMTAmFnXv4cGFo+MmJJ8PBir3ehfPZZbVIUeiASLeRSnYnk8i g4zeMbm8EjkYskeYK2OeWWmGdERd4xsW+VYDf1KOCOSHCCPjYoekz0gUkPCNQKbO1cyv VWNimhA+aezw5UUQpDmXzLgBDA3wJFcbbo2iaiu+cYUpCZEHH/eHayQF55hvNpOxVqqz GvvoME0Zm3sWHxo/nH5q4s82nGAcT/l+T8/uJmBnOz0qbdYhgiBPaGpvnDgniYxEBcc9 mAWQ== X-Gm-Message-State: AElRT7HqqmzC6l395jPSzW4eUX7oG9kgEO2+9Fal4ileRzECXAnbZsWH Gn0pmlK411eBgHJwyXHZDXEBEw== X-Google-Smtp-Source: AG47ELt4TdcVakLAqPXDdnHvEFhN0XdsVDyKDPPQLqvkFilmMxK+MwPG4q9vj6jNW7PpKic5ac+AIg== X-Received: by 10.101.76.71 with SMTP id l7mr1611040pgr.192.1520974838621; Tue, 13 Mar 2018 14:00:38 -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 , Kate Stewart , Thomas Garnier , Arnd Bergmann , Philippe Ombredanne , Arnaldo Carvalho de Melo , Andrey Ryabinin , Matthias Kaehlcke , 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 , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , David Woodhouse , Alexey Dobriyan , "Paul E . McKenney" , Andrew Morton , Nicolas Pitre , Randy Dunlap , "Luis R . Rodriguez" , Christopher Li , Jason Baron , Ashish Kalra , Kyle McMartin , Dou Liyang , Lukas Wunner , Petr Mladek , Sergey Senozhatsky , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , Cao jin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Dave Hansen , Rik van Riel , Jia Zhang , Jiri Slaby , Kyle Huey , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Rob Landley , Baoquan He , Daniel Micay , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= 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 v2 12/27] x86/paravirt: Adapt assembly for PIE support Date: Tue, 13 Mar 2018 13:59:30 -0700 Message-Id: <20180313205945.245105-13-thgarnie@google.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog In-Reply-To: <20180313205945.245105-1-thgarnie@google.com> References: <20180313205945.245105-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