Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2026765ybh; Tue, 14 Jul 2020 13:38:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwgGxp0P2Mx3tZsYwlZ74s7rPOX6jyJ4W/XsI6sWSjUz9Qg+/7fcKTlpzpw/PWQZjMY7kh X-Received: by 2002:a17:906:4a94:: with SMTP id x20mr6446348eju.539.1594759082128; Tue, 14 Jul 2020 13:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594759082; cv=none; d=google.com; s=arc-20160816; b=IkrsUyxjSqRTGvK/XkmKFX5y2Q6sDWopWrikxHYKAGcdCosVhU4CvK95EFnskCGgt7 sktW7akBAoUY13RJP+f0m8YWsfGxLZuIW4Y310zypVIUt2E8dWq103vWeq3GbYzvd666 h79rE1GQHWfPu+O97c9GAMuZ+NshhWYgqiktIDZM/7Z9Yvd0Xt9e5kakiKleU8g5yOC2 klkeWM6ot/4sKLle0r+EEI7xZ2WPHXIo+k/cB/v+10CQ5LDhjXE0SSLBGOvjoo70fmR/ UmNT8cC03rwnVyN5ESv+H3fukjwfrP3THJuku9560j1FEMgr9Qp9TgSqk7FhAvIcVRaq flGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=ontnMwPVk3JI+fxLYQf4YU002R2JgbxcsAm8SNBm6RA=; b=E0bP32zJhMy7iDoDfi6CM+M5jEfu9K7NNV1ChLNari3OdVCznfq/RvJAx9mFTsG+C4 W9DxolfO2VJBKkg1VkLRsaxjt63Iz/05vL53gcWrlCfCjPIxakuFxzrbKQn8E6kQc7lP Ye28zbx6m1rntOGR5GFiy1kJ/5vKa0VpX4zyOP4p2SqV9zuRUkJWKWl25akqBV7/LUue F7bFQ+QteBtsCuXolzaYM610uoj+DUA8usYSzTOWuv3xdSyJeqJ1mX47PcIjKhP5VOgX XDKJAvIwWvfbRXZ72h53pBEVee51lJ3tSxLgZySS9BCE63TSOHFyG9dDc8xExHByuROW AlCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=K9wTzPUi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si8963856ejl.751.2020.07.14.13.37.38; Tue, 14 Jul 2020 13:38:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=K9wTzPUi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726973AbgGNUfk (ORCPT + 99 others); Tue, 14 Jul 2020 16:35:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbgGNUfk (ORCPT ); Tue, 14 Jul 2020 16:35:40 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17FB6C061755 for ; Tue, 14 Jul 2020 13:35:40 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id w27so13918609qtb.7 for ; Tue, 14 Jul 2020 13:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ontnMwPVk3JI+fxLYQf4YU002R2JgbxcsAm8SNBm6RA=; b=K9wTzPUiJDG1KitvZfj6VluRApPRlU7Osz+5FJujkwRKxywnstFY6Qa8RF/WN34Jkn R/M8G8uBEQSOYJrdr/dfyEq1/u6/a4OHCPvkM3D9+a4MHV/HREVZGVLFVdt92iCUgYYg H6IzWJc98X/TsdloSVjyhTZzkLailEtvzHfFMFO0n/wQznictut6kHQqWSZFCgoSyX5M efrKGGF+fbWFAhkaHAwXBbuN/G4D4k/7R+sA+mQZBSt3/Eu3/vmxOUnKH1R0p9FPebdw pmLQQMcNfBL0R9VDGpLT8gEGswMcDQc/1miK9lLBrdfny5cCnfx+EtUJCd2If2i7fy1B 4Z0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=ontnMwPVk3JI+fxLYQf4YU002R2JgbxcsAm8SNBm6RA=; b=iQGonRDBorYlJNDZodBaCLGm01ew2OyQNPxV0CbggY6hWH4LFEgm4/h9vlGADyztYF TXmqTvb54s4yZNrc1eLeYClAEUI4zgrA+DH0ol9MLi5w5nWDrA2xz7bpD33eG/EylC2P P6E3HZ5ZJALHLja6Rtfwx5DsjCA2pD5Q7G0C1q4GhZztihewnk9fgqtZ5ZC6xW03hY+2 4EBu1NK9cN6d/TOWA+G6bDI7EqYlMudCpFsmf3piGZR7vjqL1k+qrltz63mOE30Kx3FT Xnkd8fTF6jflVVBFXyH5XFcnLc1MGE2jl83bxTxx2qj2Sb/PMrt9Lfz5kfd8Jnz4yACq v7DA== X-Gm-Message-State: AOAM533qOc4Yr55+UX1JXDSqWeILy+cGmPQrYLcS+eKX8s8TYadAkn6R OymnJzbnzMmyCzb/Ymtx2Dc= X-Received: by 2002:ac8:311d:: with SMTP id g29mr6673218qtb.54.1594758939296; Tue, 14 Jul 2020 13:35:39 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id j203sm23121710qke.13.2020.07.14.13.35.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2020 13:35:38 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Tue, 14 Jul 2020 16:35:37 -0400 To: Sedat Dilek Cc: Arvind Sankar , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Nick Desaulniers , Fangrui Song , Dmitry Golovin , Clang-Built-Linux ML , Ard Biesheuvel , Masahiro Yamada , Daniel Kiper , Kees Cook , Nathan Chancellor , Arnd Bergmann , "H . J . Lu" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 0/7] x86/boot: Remove runtime relocations from compressed kernel Message-ID: <20200714203537.GD902932@rani.riverdale.lan> References: <20200714141550.GA329060@rani.riverdale.lan> <20200714192956.GA689174@rani.riverdale.lan> <20200714202100.GB902932@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 14, 2020 at 10:27:25PM +0200, Sedat Dilek wrote: > On Tue, Jul 14, 2020 at 10:24 PM Sedat Dilek wrote: > > > > On Tue, Jul 14, 2020 at 10:21 PM Arvind Sankar wrote: > > > > > > On Tue, Jul 14, 2020 at 10:08:04PM +0200, Sedat Dilek wrote: > > > > > > > > > > > > In any case, I think the right fix here would be to add -pie and > > > > > > --no-dynamic-linker to LDFLAGS_vmlinux instead of KBUILD_LDFLAGS. > > > > > > > > > > Hmm, you might be right with moving to LDFLAGS_vmlinux. > > > > > > > > > > > > > We will need the "ifndef CONFIG_LD_IS_LLD" as -r and -pie cannot be > > > > used together. > > > > Is that the or not the fact when moving to LDFLAGS_vmlinux? > > > > > > LDFLAGS_vmlinux will only be used to link boot/compressed/vmlinux, > > > whereas KBUILD_LDFLAGS is used for all linker invocations, and in > > > particular the little link to do the modversions stuff ends up using it. > > > > > > So once we move -pie --no-dynamic-linker to the more correct > > > LDFLAGS_vmlinux and/or stop modversions running, we'll be fine. Being > > > able to use -pie with lld is one of the goals of this series. > > > > > > > OK, I am doing a new full kernel build with: > > > > $ git diff arch/x86/boot/compressed/Makefile > > diff --git a/arch/x86/boot/compressed/Makefile > > b/arch/x86/boot/compressed/Makefile > > index 789d5d14d8b0..056a738e47c6 100644 > > --- a/arch/x86/boot/compressed/Makefile > > +++ b/arch/x86/boot/compressed/Makefile > > @@ -51,7 +51,7 @@ UBSAN_SANITIZE :=n > > KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) > > # Compressed kernel should be built as PIE since it may be loaded at any > > # address by the bootloader. > > -KBUILD_LDFLAGS += -pie $(call ld-option, --no-dynamic-linker) > > +LDFLAGS_vmlinux += -pie $(call ld-option, --no-dynamic-linker) > > LDFLAGS_vmlinux := -T > > > > hostprogs := mkpiggy > > > > - Sedat - > > Not my day - today. > > $ git diff arch/x86/boot/compressed/Makefile > diff --git a/arch/x86/boot/compressed/Makefile > b/arch/x86/boot/compressed/Makefile > index 789d5d14d8b0..9784ed37a5d7 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -51,8 +51,8 @@ UBSAN_SANITIZE :=n > KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) > # Compressed kernel should be built as PIE since it may be loaded at any > # address by the bootloader. > -KBUILD_LDFLAGS += -pie $(call ld-option, --no-dynamic-linker) > LDFLAGS_vmlinux := -T > +LDFLAGS_vmlinux += -pie $(call ld-option, --no-dynamic-linker) > > hostprogs := mkpiggy > HOST_EXTRACFLAGS += -I$(srctree)/tools/include > > - Sedat - Nope -- -T needs to be last, since it's (trickily) put together with the first prerequisite $(obj)/vmlinux.lds.