From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC3D0C433DF for ; Fri, 7 Aug 2020 20:23:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A2F22074D for ; Fri, 7 Aug 2020 20:23:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yWx4R63A"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M6Snqi+5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A2F22074D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alum.mit.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FiPN6Y0Y1SeTNmAReWG5k/xwv84e0+GmSKjqdmREIA8=; b=yWx4R63ALjA2E9il/MlEKoEiJ otnhKu2EDrMyY8JoWpaCPOukiMOrh1FLbLzGPerOiLaHwf09q/KtczS6qvGtOY6SfMKl29TzN3QQs uJCsdhv6kJNkAGG4Aa0T0uiT/bVc0r6BAzw4bxVWgsYqlL++8mRbCLdM8xja2qb7egwZQutWSBdLx AgUg/3df5VesOBM3ML52g7JIZT8ZhpPImsFixFPopt0/U+SsUumfeGl8Rrpln9bq+8HJdqikl/idD wkRrZSteOiAHGrSdF69O8W32il/cBi6P1fyt7iHsUH9layTmTO3mVmbT8BiW9SLAQlBEn0P00+T8V w1c/Z0wjA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k48rS-0008I3-8D; Fri, 07 Aug 2020 20:21:06 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k48rO-0008H6-Ir for linux-arm-kernel@lists.infradead.org; Fri, 07 Aug 2020 20:21:04 +0000 Received: by mail-qt1-x842.google.com with SMTP id e5so2257289qth.5 for ; Fri, 07 Aug 2020 13:21:01 -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=B7Fctmg3cVLvQt7Pqxb1gnXBcCgs6NDZ66tmQ5JI0zg=; b=M6Snqi+5vU8MfS8JcxyXJ40DbOeNxstioyDIQ7RipbYSbN7JQ3Zh8YKulYvpWIfWMG eUMR1fQ+G6brVpm3EcSR81uT1VEg6XoL0pSdXn7PToQ63fvzZRxpWr3J6buyDNMuckpG 4Z5Ya2CnVn4fwpk7BFvYU91TRFyq9H8Thqax+U+MjxCQvmHtoD/2PZSEZcgCzNmuIf4t NnYgkjSYnqyQdRf/hbeSE358rBIHUE5LW0OvBTxreq4sKC88qCa34IlIHFrdpswidJ5/ WKci7ur3XnSKEEqXlCjTetdOmz8QPZzvjlK8a/y87yuY09ekPaVnHTsgldHwqdiuyOqL PwrA== 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=B7Fctmg3cVLvQt7Pqxb1gnXBcCgs6NDZ66tmQ5JI0zg=; b=XJq/oilRwOiY4U1WTNhTZbI0XfVHES6LKZQFsNMCSd1UZw/GG6VfUiqhwCMULiGfRs YFL6v8KhIzvsyXTtTlY7CyWed+utbblrLub0icyMptai+y7I2UNxkbSfpRR//JUIr0fW YYK1MI3tR391Ru4bq7QBo+Quaz5RQddZWGCL0ADZIco3RSKSw5+0ftnjUk9PcIcc+0rh kJ2zpmV+Xd2vWtej4zDazpMiJnvj8bRwWXbb931lJobwu0c8yv/wNOXExA2oiADb6lfM hc+P3yBmvvZoPvhjbjeRxzaa3/EkC1K2qfRANHv35WTK+pHaVRAd87oDobzQuQNp1RyW AbAg== X-Gm-Message-State: AOAM533j2UPy3MYMGOUS1ggeZ2P0PDBymZCmN6qgLbczwpGLbA3EJXrG Bp2W42uVmvBRHqWz0nU/k1c= X-Google-Smtp-Source: ABdhPJz/CW6PITmuhsKbBKT0FOoGWxKkovtopmDyC0lleFL8M8TfAO19eUhslQAEOHtMAH1StV6FdA== X-Received: by 2002:ac8:7152:: with SMTP id h18mr15653535qtp.44.1596831659768; Fri, 07 Aug 2020 13:20:59 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id y26sm8158811qto.75.2020.08.07.13.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 13:20:59 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 7 Aug 2020 16:20:56 -0400 To: Nick Desaulniers Subject: Re: [PATCH v5 06/36] x86/boot: Remove run-time relocations from head_{32,64}.S Message-ID: <20200807202056.GA1454138@rani.riverdale.lan> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-7-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200807_162102_674822_A9BBF7E1 X-CRM114-Status: GOOD ( 28.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-efi , Catalin Marinas , Arvind Sankar , Will Deacon , Thomas Gleixner , linux-arch , Fangrui Song , Masahiro Yamada , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , Russell King , Ard Biesheuvel , clang-built-linux , Ingo Molnar , Borislav Petkov , Kees Cook , Arnd Bergmann , Sedat Dilek , Nathan Chancellor , Peter Collingbourne , Linux ARM , LKML , James Morse Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 07, 2020 at 11:12:29AM -0700, Nick Desaulniers wrote: > On Fri, Jul 31, 2020 at 4:08 PM Kees Cook wrote: > > > > From: Arvind Sankar > > > > The BFD linker generates run-time relocations for z_input_len and > > z_output_len, even though they are absolute symbols. > > > > This is fixed for binutils-2.35 [1]. Work around this for earlier > > versions by defining two variables input_len and output_len in addition > > to the symbols, and use them via position-independent references. > > > > This eliminates the last two run-time relocations in the head code and > > allows us to drop the -z noreloc-overflow flag to the linker. > > > > Move the -pie and --no-dynamic-linker LDFLAGS to LDFLAGS_vmlinux instead > > of KBUILD_LDFLAGS. There shouldn't be anything else getting linked, but > > this is the more logical location for these flags, and modversions might > > call the linker if an EXPORT_SYMBOL is left over accidentally in one of > > the decompressors. > > > > [1] https://sourceware.org/bugzilla/show_bug.cgi?id=25754 > > > > Tested-by: Nick Desaulniers > > Reviewed-by: Kees Cook > > Reviewed-by: Ard Biesheuvel > > Reviewed-by: Fangrui Song > > Tested-by: Sedat Dilek > > Signed-off-by: Arvind Sankar > > Signed-off-by: Kees Cook > > --- > > arch/x86/boot/compressed/Makefile | 12 ++---------- > > arch/x86/boot/compressed/head_32.S | 17 ++++++++--------- > > arch/x86/boot/compressed/head_64.S | 4 ++-- > > arch/x86/boot/compressed/mkpiggy.c | 6 ++++++ > > 4 files changed, 18 insertions(+), 21 deletions(-) > > > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > > index 489fea16bcfb..7db0102a573d 100644 > > --- a/arch/x86/boot/compressed/Makefile > > +++ b/arch/x86/boot/compressed/Makefile > > @@ -51,16 +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. > > -ifeq ($(CONFIG_X86_32),y) > > -KBUILD_LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker) > > -else > > -# To build 64-bit compressed kernel as PIE, we disable relocation > > -# overflow check to avoid relocation overflow error with a new linker > > -# command-line option, -z noreloc-overflow. > > -KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ > > - && echo "-z noreloc-overflow -pie --no-dynamic-linker") > > -endif > > -LDFLAGS_vmlinux := -T > > +LDFLAGS_vmlinux := $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker) > > Oh, do these still need ld-option? bfd and lld both support these > flags. (Though in their --help, they mention single hyphen and double > hyphen respectively. Also, if we don't build this as PIE because the > linker doesn't support the option, we probably want to fail the build? > The check for pie doesn't, it's dropped in the next patch and pie is used unconditionally. no-dynamic-linker still needs the check as it was only supported from binutils-2.26. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel