From patchwork Thu Jan 31 19:24:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10791345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6328C1390 for ; Thu, 31 Jan 2019 19:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A2A93102E for ; Thu, 31 Jan 2019 19:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AF7931053; Thu, 31 Jan 2019 19:44:05 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 7825A3102E for ; Thu, 31 Jan 2019 19:44:04 +0000 (UTC) Received: (qmail 6131 invoked by uid 550); 31 Jan 2019 19:43:06 -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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 19719 invoked from network); 31 Jan 2019 19:28:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e3dk7ZZLbgfAGqbWuqUoL9HQGz8pGKWmGgQPHhRwhHc=; b=LSObIfuTa0xQZr+bKcohW5Q4cnEUGVS1uN0e+E+t5yGY3ixq2p0ylnhjahS+VsAoud dfQFfu/K65GhONSXV/9Ig0S2IkwVgCuC03FqMl483WxEI8aBASFGlOqsYI9nwZ+tkzYl 0j0jR+quzA89kEo+E3f8gJx+6sY+4pX2Wao2E= 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:mime-version:content-transfer-encoding; bh=e3dk7ZZLbgfAGqbWuqUoL9HQGz8pGKWmGgQPHhRwhHc=; b=TBxsrai7n+0CrjVxncbduyrban7oHwBxOdkSz992T4OEPO4/hkQKv5U9bxoJnZyRN6 VTisYeUq6k94quR/d4cbit4qqOz6GRkt2L4kcZYe0E0qjOFlwFHci4w0XUul2a6gsqTZ hU1lYgO76a2mZ+ALRaIEE51AhE6UHdikwa7SUFRUGiC4NP7etgtFp6tSyAy5fxWFoWMZ WbNvMPdD7LVv79rzzlYSv9nC7Q9ZY+Rsw1cng8qBSjWsmni9QZUyhNyUiCeXvdvwDoTI GB1iJ/qXVNExpC4HN+DJbKkbz6Ebfc04Icva+WLE0fWEc2R5gRWTRm0Gle7vh4kg6GFs twPQ== X-Gm-Message-State: AHQUAuaF/N5lDJgktiJqQfDUBNRQY+qi49OKYoJdEu3tNsyLnl8FUlI5 EwMe6XGjpfqxqU3MDm/YC8UPl68Gk5I= X-Google-Smtp-Source: AHgI3IayF4kHqDIM+q4+Y8uOrB6q1Ap2qB2KO55tlf08CInn20aam+1XuCmrMPxPHm2eZ8La9YoXPQ== X-Received: by 2002:a17:902:e01:: with SMTP id 1mr21126754plw.251.1548962911253; Thu, 31 Jan 2019 11:28:31 -0800 (PST) From: Thomas Garnier To: kernel-hardening@lists.openwall.com Cc: kristen@linux.intel.com, Thomas Garnier , Juergen Gross , Alok Kataria , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 11/27] x86/paravirt: Adapt assembly for PIE support Date: Thu, 31 Jan 2019 11:24:18 -0800 Message-Id: <20190131192533.34130-12-thgarnie@chromium.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190131192533.34130-1-thgarnie@chromium.org> References: <20190131192533.34130-1-thgarnie@chromium.org> MIME-Version: 1.0 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 extend the KASLR randomization range below 0xffffffff80000000. 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 488c59686a73..8cfcc1b463de 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -342,9 +342,17 @@ extern struct paravirt_patch_template pv_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" (&(pv_ops.op)) + [paravirt_opptr] paravirt_opptr_type (&(pv_ops.op)) #define paravirt_clobber(clobber) \ [paravirt_clobber] "i" (clobber) @@ -392,7 +400,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