Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp742866pxp; Fri, 11 Mar 2022 13:58:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXTIgI+J886h+nYcbaMOjGnQOCLcWlDer23g8sg0K8s2hoK8bFD79h79u8jjnCi5LwygJA X-Received: by 2002:a05:6a00:1a0a:b0:4f6:ecc6:1173 with SMTP id g10-20020a056a001a0a00b004f6ecc61173mr11745717pfv.74.1647035903161; Fri, 11 Mar 2022 13:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647035903; cv=none; d=google.com; s=arc-20160816; b=KHoj8T2y7SykFy7L+08oT+ZbyCdNpL0idm0ZyU12ouwxxVskK0nLp4+QZdpBGsvVcS YaqRjgjP0l2t0szvKActuA6wIvOjR3hyvC/LwwyP4edurIpOta6M42XyVMoZPuWhTmEz tj5jb9tcRw7yl7UxLP0vZGNgarjyUxVz8zuGzDKC3ThYmPfxYeEareuDl4Lrv8JtZKlE lb/ttuWWfQ4Mf7bQuB3d/oca5idsXuhIP3W3buVJTeCbAfyULGmVeeh6CtVjnlMVhqCs aVhGsrQ9YrCOkXsjB1DuB0IogRAmwScsn/AnG7uk1synWPGFv2o8CbdupPscTeqGqWXa xdFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=aWuv/cB2IRk/pSpG8sU4nbvCzp3/Ix7ZV08F5OtN0eU=; b=h+MqO0m4348/OCTrXQf/DnBMe7IO7fn3JLGfPX2/fLWHaGajmbf88cU1s/3QPCojtg 30abFbpIJMSLgRMJoq0HXyhkZmJ2DpjZzFgNuQwiOnva6owlr3uSCJoP8RFFAtMipyLb wfnLUx04ZslpkZSIanwGYeArqYVQ90vztFjkBlTQlxfWGvooLIBcBmKQhKymNe3KpIcQ i7QXqWqbub/jsb+qCFsG1Gpp+d6jKRla1p+feYDeILGHCMlE0rwCLneAKjxZfDrHf867 mMxCpB1mv1duGfwZtWDkPlZ3ir646L87oqmJvoC+wtsjydZl+OnySw3k81AKO9WF0MYJ jKig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=i9UqldKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y13-20020a17090a600d00b001bd14e01f77si9349074pji.101.2022.03.11.13.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:58:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=i9UqldKK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E997207C08; Fri, 11 Mar 2022 13:15:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346032AbiCKERP (ORCPT + 99 others); Thu, 10 Mar 2022 23:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346049AbiCKERL (ORCPT ); Thu, 10 Mar 2022 23:17:11 -0500 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E614D1A129A for ; Thu, 10 Mar 2022 20:16:06 -0800 (PST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4KFCKY3zHjz4xbG; Fri, 11 Mar 2022 15:16:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1646972162; bh=aWuv/cB2IRk/pSpG8sU4nbvCzp3/Ix7ZV08F5OtN0eU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=i9UqldKKsJpUVZvfHbkXYq6awpvN5Ap6TjGO/igs37yYKbQDoRTw0zBa0t6e+eBGZ Ti5RhXN0X6ngbJodkwVd5SsGfg9Sb0+mV7/WmO6G/fynhEodhGhicoDEKBF6Iar46j P+/7siGGDClvmmHt1sws/1v/Elg3dX8QTxXblz2JiBBoA4MxDUHEOFUYIS0BXFp44f 5DTkcPpGrnLeXxFJlq+i9n34MfHhlxyTbXO7LayrXuueToBq0L0mskeCNyQx7VDUP8 aR5stvRDHwRay7QN1XbZY/+CNs46DPlK8ES167w5A6FZgdL7R0vj+UTkEbPOsj12Wz F7jnEIf+6Hsug== From: Michael Ellerman To: =?utf-8?B?RsSBbmctcnXDrCBTw7JuZw==?= , Alexey Kardashevskiy Cc: Nick Desaulniers , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Nathan Chancellor , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] powerpc: Replace ppc64 DT_RELACOUNT usage with DT_RELASZ/24 In-Reply-To: References: <20220309055118.1551013-1-maskray@google.com> Date: Fri, 11 Mar 2022 15:15:59 +1100 Message-ID: <87a6dxm8e8.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org F=C4=81ng-ru=C3=AC S=C3=B2ng writes: > On Thu, Mar 10, 2022 at 11:48 AM Nick Desaulniers > wrote: >> >> On Tue, Mar 8, 2022 at 9:53 PM Fangrui Song wrote: >> > >> > DT_RELACOUNT is an ELF dynamic tag inherited from SunOS indicating the >> > number of R_*_RELATIVE relocations. It is optional but {ld.lld,ld.lld} >> > -z combreloc always creates it (if non-zero) to slightly speed up glibc >> > ld.so relocation resolving by avoiding R_*R_PPC64_RELATIVE type >> > comparison. The tag is otherwise nearly unused in the wild and I'd >> > recommend that software avoids using it. >> > >> > lld>=3D14.0.0 (since commit da0e5b885b25cf4ded0fa89b965dc6979ac02ca9) >> > underestimates DT_RELACOUNT for ppc64 when position-independent long >> > branch thunks are used. Correcting it needs non-trivial arch-specific >> > complexity which I'd prefer to avoid. Since our code always compares t= he >> > relocation type with R_PPC64_RELATIVE, replacing every occurrence of >> > DT_RELACOUNT with DT_RELASZ/sizeof(Elf64_Rela)=3DDT_RELASZ/24 is a cor= rect >> > alternative. >> >> checking that sizeof(Elf64_Rela) =3D=3D 24, yep: https://godbolt.org/z/b= b4aKbo5T >> >> > >> > DT_RELASZ is in practice bounded by an uint32_t. Dividing x by 24 can = be >> > implemented as (uint32_t)(x*0xaaaaaaab) >> 4. >> >> Yep: https://godbolt.org/z/x9445ePPv >> >> > >> > Link: https://github.com/ClangBuiltLinux/linux/issues/1581 >> > Reported-by: Nathan Chancellor >> > Signed-off-by: Fangrui Song >> > --- >> > arch/powerpc/boot/crt0.S | 28 +++++++++++++++++----------- >> > arch/powerpc/kernel/reloc_64.S | 15 +++++++++------ >> > 2 files changed, 26 insertions(+), 17 deletions(-) ... > I rebased the patch on > git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > master and got a conflict. > Seems that https://lore.kernel.org/linuxppc-dev/20220309061822.168173-1-a= ik@ozlabs.ru/T/#u > ("[PATCH kernel v4] powerpc/64: Add UADDR64 relocation support") fixed > the issue. > It just doesn't change arch/powerpc/boot/crt0.S Yeah sorry, I applied Alexey's v4 just before I saw your patch arrive on the list. If one of you can rework this so it applies on top that would be great :) cheers