From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by sourceware.org (Postfix) with ESMTPS id 279433857C54 for ; Mon, 21 Sep 2020 11:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 279433857C54 Received: by mail-il1-x144.google.com with SMTP id h2so13299921ilo.12 for ; Mon, 21 Sep 2020 04:32:00 -0700 (PDT) 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=KXsG/Di0ond9rHWcEF5ObfIJ5Lw6AJeGiSN2zkgBMh8=; b=h8Cz72Jm95nh+dEGJzqZmWY7xnuGO0/1i2R/0sNG+JRD+6Kq5O68NB/v6bRf2HJy66 BGTTQX5wSVfnfApz1v4T0wBykimJq+DsBXGo5FHbcQMnXZ6G5gSA35xKnvEQmdm0AOFj oha7SaTKdkmN6u39DShYSQWkts1SSZl6PywP0aZXQnK+jYp7iBb0D0jgb16helJxm5BS WLUeBz669WtTtUI1t3nVcIegm2VnwImo4DM91QqB+d8z4sKN5ov0QFaaiKmMAEz93lm0 jifNmEGCzZ9T7LgznaxF/n/tbws6/WwkZeu/dnh69wCd9nyCOAp52P+9/X/UsmCTvKcW Q/OQ== X-Gm-Message-State: AOAM533sK/4sXeTqtbsF+evtk+gAXkQtnP7klWmdUm22WXy/9Bu7kmQB t9SkMjXiQB9JjZr6OpfmqjCa+rwxFEEUG8z6jaw= X-Google-Smtp-Source: ABdhPJz5DNw0MHTxHVAJOkj+rXWRhqyNUFesIQO6ZBopMFZcZ7rCy/8LQXD6koZmJPUVU+Qqmf7G0xTQzewgmVSjik4= X-Received: by 2002:a92:6a0c:: with SMTP id f12mr37427751ilc.213.1600687919585; Mon, 21 Sep 2020 04:31:59 -0700 (PDT) MIME-Version: 1.0 References: <20200912134441.2407884-1-hjl.tools@gmail.com> <20200912134441.2407884-2-hjl.tools@gmail.com> <874knva4r6.fsf@oldenburg2.str.redhat.com> <87a6xn6v8u.fsf@oldenburg2.str.redhat.com> <87y2l75fls.fsf@oldenburg2.str.redhat.com> <87imc78rqt.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87imc78rqt.fsf@oldenburg2.str.redhat.com> From: "H.J. Lu" Date: Mon, 21 Sep 2020 04:31:23 -0700 Message-ID: Subject: Re: [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] To: Florian Weimer Cc: "H.J. Lu via Libc-alpha" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2020 11:32:01 -0000 On Mon, Sep 21, 2020 at 1:21 AM Florian Weimer wrote: > > * H. J. Lu: > > >> Putting this data into _rtld_global_ro is not correct if it is required > >> after static dlopen. The current static dlopen approach simply does not > >> support that. You can only assume that libc.so has been initialized > >> after static dlopen. > > > Unless it is removed, _rtld_global_ro is the right place. _rtld_global_ro > > is initialized by dynamic relocation. My patch does it. > > It initializes only part of it. I find this rather confusing. > > Why is this data in ld.so in the first place? I put it in ld.so with commit e2e4f56056adddc3c1efe676b40a4b4f2453103b Author: H.J. Lu Date: Thu Aug 13 03:37:47 2015 -0700 Add _dl_x86_cpu_features to rtld_global This patch adds _dl_x86_cpu_features to rtld_global in x86 ld.so and initializes it early before __libc_start_main is called so that cpu_features is always available when it is used and we can avoid calling __init_cpu_features in IFUNC selectors. which made many things possible, including CET support and commit bea3f92405f705684275bffee954cafe84ffb09d Author: H.J. Lu Date: Sun Oct 22 08:24:00 2017 -0700 x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265] In _dl_runtime_resolve, use fxsave/xsave/xsavec to preserve all vector, mask and bound registers. It simplifies _dl_runtime_resolve and supports different calling conventions. ld.so code size is reduced by more than 1 KB. However, use fxsave/xsave/xsavec takes a little bit more cycles than saving and restoring vector and bound registers individually. -- H.J.