Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3888417imm; Tue, 29 May 2018 16:10:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKvLGq9xnUWLkFkrgPDEFspAVMmmAfOWl0GTaSero0LC7Zye19ml1bZRd94VCmQgmMm64u1 X-Received: by 2002:a62:3e11:: with SMTP id l17-v6mr377458pfa.18.1527635440896; Tue, 29 May 2018 16:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527635440; cv=none; d=google.com; s=arc-20160816; b=aoAhy4W4/o9IaV6IWFJmjWMg7QEE56K5lomc1rPdu+yBPxeggv6zC6FKmmIbqnfCuE 8TYWJ/OZAt+lYymzGpVBixcHfuluBd0lvtfULPewuPZspYS6VZvvJUJjXpIDYJFVv7GW hjA70pg1BEhwJpfi4BZYb99GP+NTq+hr8Q4JmdssUX6oWn98kw89yFuwcC3XgasBefDJ 741td2LFdfNUMzGf3kJ0zOrtd/xrcbAdDUIZGNGNtTRdmWOIqYkwTU4Ngvqzsu0xTIaB 27DOEG8CxhMfw98nvs1HhA5P1KN57YqUydkwoLOsnv7+QUCjtuHeq8h7nY6tToOSWtnS ocww== 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 :arc-authentication-results; bh=saTeGKtkFnxQZMvAVdSZ6l7OgGdNr4pllOk8EUxgLR4=; b=IFk51zu7QKplE4/dOFT5wimribI9/Bdq3yX7HK4Hav33q6AraMAbMcp4ECIf056VbI JyzMtHXU1WJ29cZtBIspLVjUsdYO85KbPCFHqhN69IWSNUQxoBNnToBAZdjQqY2dK3cw FrgPA5eS1Bkg8XPaqGiDo3M46e4BoYJDpfVAyiR7x3t70TUQSiakoXoIhgs5BUS6RNaL XAGUiH72MNVW4CbFge3SQGUDQIms53wMWJCI3zLk/gte3qGTQqXM1zOjOm7YC50eMf3E FRUUulgrvZyu7An/HfMfB6od87mpWRC+8AhUhNb0we4GrW+zOsBX1nlwLLp2mKBc+aVX xfoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ofVpigO/; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61-v6si32691288plb.560.2018.05.29.16.10.24; Tue, 29 May 2018 16:10:40 -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=@google.com header.s=20161025 header.b=ofVpigO/; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967868AbeE2XIj (ORCPT + 99 others); Tue, 29 May 2018 19:08:39 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:40620 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935846AbeE2XIg (ORCPT ); Tue, 29 May 2018 19:08:36 -0400 Received: by mail-it0-f67.google.com with SMTP id j186-v6so21028825ita.5 for ; Tue, 29 May 2018 16:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=saTeGKtkFnxQZMvAVdSZ6l7OgGdNr4pllOk8EUxgLR4=; b=ofVpigO/T0c2FXWcjmz4y80tI47tE4csGa4pyiFPaexN36+y+JiMtHycUeP0j1WRFi BIOc9gp5HnEuismtWv7geOpP7REzS4Rjj05jfIav/lYn8hNT43LN0vIc58hX7PHWagDU 4R7oK6lDm32UFNqYcon4c86YjEpmiMbNPYFBuoqb04CeSU4zOzzFyapAKQWH9R7Z2H+P cHtpI2fOAg9cWcWgNh4aaFlB7Hu+HWlVan355cWtOUzwKUn4LlUSLOhg8+CPFmRZmKWQ T9OhxfkOL6bzImxpi/pffQK/Qu467wCQm7L2vp8q9pPbP9+HvGhNiamU0WHBkQgkCxBM EM6g== 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=saTeGKtkFnxQZMvAVdSZ6l7OgGdNr4pllOk8EUxgLR4=; b=a2U+xSkJTm/MFBLF1A0tDbL075y/fPB2U5jWRScsTNF8M9LOKEeHl0Kv0aM8yVwW4h 7E5Q+0H5NgG1EWOsv9MJJTL3gI9s/DQeS1v9ZB21obca5C6QdhMrsVuCSy3J0OTHB8g1 /ZC6/FN25iLHabuyCRViCVwj/4pHFXA6xsJ/YWCEFqTviGjb+0Tu8SmWABy16w3icpmk Xgg3fGgl7pyQvPzERqKnKnhY3cX02MkTEkMclxqMpGphzRHWIaaFEKtt7pE0CgbRlWzS WjbcW+/nbkJFYkAEbd7eesYTncqPkhEbpmE4LQjkufjzKb2pbSMlQ4/98SIdfVRfYiiR xV9A== X-Gm-Message-State: APt69E3xmf5FNi3MdR9FaMHv+DE3D8lPysVOylMyUiFjeRk8/4fhAVkR XzMcvDnj78eB2ktH7tcWh95e7GAqP5/j/HqiUG375w== X-Received: by 2002:a24:7842:: with SMTP id p63-v6mr844614itc.97.1527635315913; Tue, 29 May 2018 16:08:35 -0700 (PDT) MIME-Version: 1.0 References: <20180529221625.33541-1-thgarnie@google.com> <20180529221625.33541-15-thgarnie@google.com> <01000163ae145cac-5ac07b51-8f08-4da5-bb93-0238d59756d3-000000@email.amazonses.com> In-Reply-To: <01000163ae145cac-5ac07b51-8f08-4da5-bb93-0238d59756d3-000000@email.amazonses.com> From: Thomas Garnier Date: Tue, 29 May 2018 16:08:24 -0700 Message-ID: Subject: Re: [PATCH v4 14/27] x86/percpu: Adapt percpu for PIE support To: Christoph Lameter Cc: Kernel Hardening , Dave Hansen , Vitaly Kuznetsov , Tom Lendacky , Skip Mathieu Desnoyers , Skip Frederic Weisbecker , Nicholas Piggin , Kees Cook , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "the arch/x86 maintainers" , Tejun Heo , Dennis Zhou , Boris Ostrovsky , Juergen Gross , Dominik Brodowski , Borislav Petkov , Josh Poimboeuf , Andy Lutomirski , Peter Zijlstra , "Kirill A. Shutemov" , Andrew Morton , Philippe Ombredanne , Greg KH , Alexey Dobriyan , Francis Deslauriers , Masahiro Yamada , Cao jin , Masami Hiramatsu , "Paul E . McKenney" , Nicolas Pitre , Randy Dunlap , LKML , xen-devel 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 Tue, May 29, 2018 at 3:46 PM Christopher Lameter wrote: > On Tue, 29 May 2018, Thomas Garnier wrote: > > Perpcu uses a clever design where the .percu ELF section has a virtual > > address of zero and the relocation code avoid relocating specific > > symbols. It makes the code simple and easily adaptable with or without > > SMP support. > > > > This design is incompatible with PIE because generated code always try to > > access the zero virtual address relative to the default mapping address. > We always access relative to the "segment register". > You can already change the segment register to relocate the per cpu > sections arbitrarily since all per cpu "addresses" are offsets relative to > the segment register. I am not sure what exactly you are trying to > accomplish here? When building with PIE, the compiler wants the code to be relocatable anywhere in the 64-bit VA space. Instead of taking the segment register as an immediate value, it takes it as VA that need to be relocated relative to where the kernel is mapped. The per-cpu section VA is zero to create the proper offset to the different variable. The kernel could be at the top of the 64-bit VA space. PIE will try to create the delta between any VA and zero and fail because segment register based operations do not have full 64-bit VA range. Does it make sense? For PIE only, this change will remove the per-cpu section VA of zero. Now the distance between the per-cpu symbol and the kernel base VA can fit in the generated instructions. > Maybe you need to explain it better? I will try do explain it better on the next patch set. -- Thomas