Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp781004pxp; Fri, 11 Mar 2022 15:00:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUb5UQJrziMByuK9MUAf9+qPlQtQ/J2PhuDREkPsok9zQfyx7dNB+Pzo6odUquL2gcP9Kb X-Received: by 2002:a65:4101:0:b0:372:1875:c19c with SMTP id w1-20020a654101000000b003721875c19cmr10174038pgp.435.1647039600632; Fri, 11 Mar 2022 15:00:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647039600; cv=none; d=google.com; s=arc-20160816; b=vCjdGQjbewwVkOhWkczZAKgcmqNpeYpEaU0Ga5ZrPFVvgie3AYOash91D/HGV6iI3D GN3qWaQzFwLm8N9rXO7AFYRzPebxLvB4sbKmtMFGaaPDHU+hrARyJtKdzJafxc2mc8Tw J73T+TQpO/3z8saW977WVNBLLjFgiqhxweIjN0R8SRH4YUY27xipTBRuFLj8P1MaVgr9 SsU4d1nj9IPKz7dC2poSk+ewoE3W98kozhBPKNW3xShfSaZtkMnAAe6dxhTpB27BZsky i2RtFw8rlhD4k3Zq2acszWYyji8UnB4rswrt1MgXXfnm2MsL1EqlMZDsPkKwJusFH37+ kWVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=V1/TnLPrornoIN/WK1P7jxHhGPmmerjcFisapQwZfNE=; b=KhFVFjp+vBA6BKT5ClORr3NDJgfCsIGy6lU6tlieefxV6KuY6Vwm+BzehSpiYusHND f5RhmVqH41Hd/7d1mYwVAJEAForyQRIGnhCjTlvaUIe+X3H7x6Ir9Xi4q9R6SR1tTF01 dkug/HVr080eeWh/t/e2SlyRZJWXTEUMvY7r6Zu5gxLHk0QZKWePTz1A+XE6JZJ3lRvB 5vf/sULY9LAhwxMDONXoO8GMuejJ49Uk5x33yVjPSNLWhcEd83aCLERB1/BfGom+rnYR JtcyyGFEscJd0WTgVq9GCthvheLRsnnWryRps0P9uzZce0N5MZhV6g6b4enfxaGtHcA7 Io9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ozlabs-ru.20210112.gappssmtp.com header.s=20210112 header.b=SPKGt49q; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k6-20020a170902ce0600b0014f63facf03si9275898plg.81.2022.03.11.15.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 15:00:00 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ozlabs-ru.20210112.gappssmtp.com header.s=20210112 header.b=SPKGt49q; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 A874A2EA86C; Fri, 11 Mar 2022 13:56:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346420AbiCKEhH (ORCPT + 99 others); Thu, 10 Mar 2022 23:37:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346384AbiCKEg5 (ORCPT ); Thu, 10 Mar 2022 23:36:57 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DBFD1A8068 for ; Thu, 10 Mar 2022 20:35:48 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id u17so4744874pfk.11 for ; Thu, 10 Mar 2022 20:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs-ru.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=V1/TnLPrornoIN/WK1P7jxHhGPmmerjcFisapQwZfNE=; b=SPKGt49qDswbf2PivcNvXaZJ62enQa2p8KpJzako40QAEEFJAF12UBaljhGOfFLz7h l4Ifv4wgpLYh/BE3pvqcuz5Xkb4K/E12DRJzkEak0tnMAMaQSR4kCUJ2igcKqf30Qjfn ojR5TJ2MKHni0RODfI65PdMT73Ksb44ff6kfNrY4vXSF07CB2qwnZcSjYww8HcGJMea9 k/q5jbxbVkExV+7GKBT5zfe7d/uCIFzf+p4IBkKanZx7A3gFMpKQM9t8gs3nDb+DHlad kqFDSelbAqaKZuoAwqc0QbTSgTzbvpzm+3ruG8dXMcGV1F/38N1YpxBMgAJHcTMV2mqR uPlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=V1/TnLPrornoIN/WK1P7jxHhGPmmerjcFisapQwZfNE=; b=dJ4NO+NjGoq1wtZAmcwZ0FCW1bKSdQRDyc3wpWVrgqFrXZRPoHDlTsSmv/QGrexe6+ jtDCXfBNHY7xXHb4Q2B6fUp0IMvjHTXgUQDNAmlFFz/D/ja28gNeILyRNbpfgXjyp4jx zx3TQcIkt2/OTIpHbtO8FOK9m4Ro5S1oF7cZBICoOM1nIxQlM7ElbvfYTMB6pNd9avTA Ts6zol9SSqkf9HMthYwuclBpswq+OWLV2YJ6lv51512w1ZYNDaYWSo1/M3keQmlH4sYm UCSVCtlGxM3qZSyN+h2nm2eAdNIUyeK2g3ThAsl1ekTuPKTiQaUYIYBraY4Hkr0lyAyJ CYCw== X-Gm-Message-State: AOAM532MDS7NQPAERc7aQIykk8wGkGe9SpszCGV5voVCiT/szBFh04Gr ck5IiAD8Pd2H2qcBKKmHuUU2Zw== X-Received: by 2002:a62:684:0:b0:4f7:803:d1b0 with SMTP id 126-20020a620684000000b004f70803d1b0mr8551366pfg.10.1646973348053; Thu, 10 Mar 2022 20:35:48 -0800 (PST) Received: from [10.61.2.177] (110-175-254-242.static.tpgi.com.au. [110.175.254.242]) by smtp.gmail.com with ESMTPSA id j7-20020a637a47000000b003803fbcc005sm6829615pgn.59.2022.03.10.20.35.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Mar 2022 20:35:47 -0800 (PST) Message-ID: <03683f2e-4153-4b4d-fdc2-063aa10c24ac@ozlabs.ru> Date: Fri, 11 Mar 2022 15:35:36 +1100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:98.0) Gecko/20100101 Thunderbird/98.0 Subject: Re: [PATCH] powerpc: Replace ppc64 DT_RELACOUNT usage with DT_RELASZ/24 Content-Language: en-US To: Michael Ellerman , =?UTF-8?B?RsSBbmctcnXDrCBTw7Ju?= =?UTF-8?Q?g?= Cc: Nick Desaulniers , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, Nathan Chancellor , linux-kernel@vger.kernel.org, llvm@lists.linux.dev References: <20220309055118.1551013-1-maskray@google.com> <87a6dxm8e8.fsf@mpe.ellerman.id.au> From: Alexey Kardashevskiy In-Reply-To: <87a6dxm8e8.fsf@mpe.ellerman.id.au> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 On 3/11/22 15:15, Michael Ellerman wrote: > Fāng-ruì Sòng 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>=14.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 the >>>> relocation type with R_PPC64_RELATIVE, replacing every occurrence of >>>> DT_RELACOUNT with DT_RELASZ/sizeof(Elf64_Rela)=DT_RELASZ/24 is a correct >>>> alternative. >>> >>> checking that sizeof(Elf64_Rela) == 24, yep: https://godbolt.org/z/bb4aKbo5T >>> >>>> >>>> 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-aik@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 :) I guess it is me as now I have to add that UARRD64 thing to crt0.S as well, don't I? And also we are giving up on the llvm ld having a bug with RELACOUNT?