From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A95153858433 for ; Thu, 9 Feb 2023 14:35:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A95153858433 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675953341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PE8MvmoxIBkoiB3xW1VxZcHaK3FceJyi5VTlEuevzgo=; b=fwS9qRzSvwO5iTT0iYQKzEOjmbhNDt7a5XsZLy4PDmlIJLvVw23w8gXvbHVhkMAV3vi93j 3zR0Kq8n9BM05mweuHhz9tQju6aNQ+xsprQkvJUM6KHn5B7xZuUo+88y/b9JADNL6URTjR 7w4gI0KVjrAxnD0kXHnRX/tAnh9vFF8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-393-eOT1RXB7OxqvyeezhhE1MQ-1; Thu, 09 Feb 2023 09:35:38 -0500 X-MC-Unique: eOT1RXB7OxqvyeezhhE1MQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E45683813F27; Thu, 9 Feb 2023 14:35:37 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5766540B3FE1; Thu, 9 Feb 2023 14:35:37 +0000 (UTC) From: Florian Weimer To: "H.J. Lu via Libc-alpha" Cc: "H.J. Lu" , Carlos O'Donell Subject: Re: [PATCH] x86-64: Restore LD_PREFER_MAP_32BIT_EXEC support [BZ #28656] References: <20230126172256.829709-1-hjl.tools@gmail.com> Date: Thu, 09 Feb 2023 15:35:36 +0100 In-Reply-To: <20230126172256.829709-1-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Thu, 26 Jan 2023 09:22:56 -0800") Message-ID: <87k00qkitj.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * H. J. Lu via Libc-alpha: > Crossing 2GB boundaries with indirect calls and jumps can use more > branch prediction resources on Intel Golden Cove CPU (see the > "Misprediction for Branches >2GB" section in Intel 64 and IA-32 > Architectures Optimization Reference Manual.) There is visible > performance improvement on workloads with many PLT calls when executable > and shared libraries are mmapped below 2GB. Add the Prefer_MAP_32BIT_EXEC > bit so that mmap will try to map executable or denywrite pages in shared > libraries with MAP_32BIT first. > > NB: Prefer_MAP_32BIT_EXEC reduces bits available for address space > layout randomization (ASLR), which is always disabled for SUID programs > and can only be enabled by setting environment variable, > LD_PREFER_MAP_32BIT_EXEC. LD_PREFER_MAP_32BIT_EXEC works only between > shared libraries or between shared libraries and executables with > addresses below 2GB. PIEs are usually mapped above 4GB by the kernel. I still think we should fix this in the kernel, using MAP_DENYWRITE as a hint for placement. This way, it's easier to turn it on unconditionally for the whole system because the lower 4 GiB will not be polluted by code mappings. Thanks, Florian