Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp737154ybm; Wed, 22 May 2019 10:38:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtfCxBsuGdtfcGu6I43En1JIGaA1b+NaZB5MthytcqEEAusn+2MhdAiWcDPjQgX5RcCqt+ X-Received: by 2002:a63:c106:: with SMTP id w6mr7337476pgf.422.1558546680306; Wed, 22 May 2019 10:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558546680; cv=none; d=google.com; s=arc-20160816; b=QMC7ESwkEk5Y7ylFhX3VzEcoLRQ1o/m+QTj46RivCmElu+DSURkFpQierbaaNmU6st xdPN1Rm5pp47aFUbAHseWOU3gdqUEpXSGkh02GrvGDUQhXMiGFx942URdX1Dv1VulsaU G2HOgjChkFvuy86VTf62MR07lj6veTUGsjPZxGNpDQXzn9v+EHU6X2ne+3+UX3z5Tci/ b9a4K6vQSbHc319x+jbhIlXTMhf7OKoRxbv5inp7LRwJDoUlHxjJEr/8m0vXJ7HjydVn xJf21ExVTPRM74pWKw/IrvJOjazw3mRvZd5Ap+wIEbVyNiYt6nFflf+xjgSA/olbqUtn EZ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=csIO6/r6boDgls5PxYVv4WnR4nG5C2hWLcsvu4wXyRE=; b=MCdJqPr5Ai2adx/YJSr0+Ujk6cEzgFEldboUEUbe6ybf50G2d4QYrAjRZS9JkhEa/O MuG/tF2hyvfjhAEE/p7TLv7AbBLT122fXLiCtqCw36OBlKSdLAOx9I2/V9WenX+EkC9A xiNsTOfGgm54SL0yhMF4fxzhnKkGKuU09d/UvZNeXnfersLHuHg8lQ/+O4Jsh+Waw/gX e10hni6rxlJJ40OGT8q8CU8k5s8N7D3RGmeIywZc9vswXMd8mVDoBEdX4X9yrCC8xoRm 26FKkvqvqw63l5hElvyiGRrpt/rK1ZhwPvVdZ+Mv1lEOleP08xNqT+LgaazeTg2JYzHj 3ITg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=I5c1PJ8Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u2si27856614pfn.4.2019.05.22.10.37.45; Wed, 22 May 2019 10:38:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=I5c1PJ8Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729897AbfEVP5r (ORCPT + 99 others); Wed, 22 May 2019 11:57:47 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:50349 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbfEVP5r (ORCPT ); Wed, 22 May 2019 11:57:47 -0400 Received: by mail-it1-f193.google.com with SMTP id i10so4421570ite.0 for ; Wed, 22 May 2019 08:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=csIO6/r6boDgls5PxYVv4WnR4nG5C2hWLcsvu4wXyRE=; b=I5c1PJ8QlNgcKHXLHGh8brj9dKeIc23jMxGlGishmc7jg0dw/3WNuuAICPR4vHase6 PXKRpc3p3PBlZCgxRTvLDlTyAmIMxmJ7uAylqP0Oum+ZxW7HPwc5ZhsSqR+PuIQLF2kn rmWAp7Sa8igzbVYZCptsBDsyBpbNGWwDEp1Gg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=csIO6/r6boDgls5PxYVv4WnR4nG5C2hWLcsvu4wXyRE=; b=FmDzewqRanIk3X92mubZpBx2v4+Ax+jbC3vfKrxemRvbeNX5d/7zG/9TioTDIoOm3t XoOteBBT/XpYYVb0BqzWjpmy5JTi1wT2bph65uXZGFP/+dx6witdD9V9Q+fLAyMOj7Qq StnkHF5J3l11z+G8t/6Px6MFItgxsVqRIHJZYyFxeLY/KRQbbvZ7CMHXkWr3BXWCsJ0o ScHWm+djS7UlDeBhTxVwRPhu0woF8yjLBsCmJl8ac2A71slky2X8SuTm15KErIc+iAa7 E3nhmMspeXxjx3KDCBWjCm+y3UIy7QYeB0v1A2UCCy3yk2ZeUKskEmYvQVPtlj6euOSB ox8g== X-Gm-Message-State: APjAAAVPPE0JZJuaghGN9hWMMS/6aUg0d8PGHg9j9OBvihtEY3TY3HHS AxO3s9PgXl1RyVGBjP/ySlV9APmg0PU= X-Received: by 2002:a24:d43:: with SMTP id 64mr2092582itx.114.1558540666497; Wed, 22 May 2019 08:57:46 -0700 (PDT) Received: from mail-it1-f179.google.com (mail-it1-f179.google.com. [209.85.166.179]) by smtp.gmail.com with ESMTPSA id i25sm7730903ioi.42.2019.05.22.08.57.44 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 08:57:45 -0700 (PDT) Received: by mail-it1-f179.google.com with SMTP id m141so4385352ita.3 for ; Wed, 22 May 2019 08:57:44 -0700 (PDT) X-Received: by 2002:a02:5143:: with SMTP id s64mr8139039jaa.54.1558540664324; Wed, 22 May 2019 08:57:44 -0700 (PDT) MIME-Version: 1.0 References: <20190520231948.49693-1-thgarnie@chromium.org> <20190520231948.49693-4-thgarnie@chromium.org> In-Reply-To: From: Thomas Garnier Date: Wed, 22 May 2019 08:57:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 03/12] x86: Add macro to get symbol address for PIE support To: "H . Peter Anvin" Cc: Kernel Hardening , Kristen Carlson Accardi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "the arch/x86 maintainers" , Peter Zijlstra , Nadav Amit , Jann Horn , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 20, 2019 at 8:13 PM wrote: > > On May 20, 2019 4:19:28 PM PDT, Thomas Garnier wrote: > >From: Thomas Garnier > > > >Add a new _ASM_MOVABS macro to fetch a symbol address. It will be used > >to replace "_ASM_MOV $, %dst" code construct that are not > >compatible with PIE. > > > >Signed-off-by: Thomas Garnier > >--- > > arch/x86/include/asm/asm.h | 1 + > > 1 file changed, 1 insertion(+) > > > >diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h > >index 3ff577c0b102..3a686057e882 100644 > >--- a/arch/x86/include/asm/asm.h > >+++ b/arch/x86/include/asm/asm.h > >@@ -30,6 +30,7 @@ > > #define _ASM_ALIGN __ASM_SEL(.balign 4, .balign 8) > > > > #define _ASM_MOV __ASM_SIZE(mov) > >+#define _ASM_MOVABS __ASM_SEL(movl, movabsq) > > #define _ASM_INC __ASM_SIZE(inc) > > #define _ASM_DEC __ASM_SIZE(dec) > > #define _ASM_ADD __ASM_SIZE(add) > > This is just about *always* wrong on x86-86. We should be using leaq sym(%rip),%reg. If it isn't reachable by leaq, then it is a non-PIE symbol like percpu. You do have to keep those distinct! Yes, I agree. This patch is just having a shortcut when it is a non-PIE symbol. The other patches try to separate the use cases where a leaq sym(%rip) would work versus the need for a movabsq. There are multiple cases where relative references are not possible because the memory layout is different (hibernation, early boot or others). > -- > Sent from my Android device with K-9 Mail. Please excuse my brevity.