From nobody Mon Nov 16 12:34:40 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jSnPD291Lz70X8F for ; Mon, 16 Nov 2026 12:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jSnPD15kRz3Dhw for ; Mon, 16 Nov 2026 12:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794832480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7X0FG/o14D3hnw8ywBZUUU/WQcvcL/0qEMhX5z3omuc=; b=Ofi/8ZxZulZd7kLPvq+Vs5RFKGoTMt3+ZvKfPk7da9bsPOetsB6qGjChwgDo5K3lh2mPXh Ow07ggSGAUsR7+ul3jNZHPEjT6fWVmM0ZFvZF8oD6Mq6AhZnHqWPTYclk/izY/juWvm5O1 65gjPo+oWhFKVVx/9TltOFS8GusDpvURhwCR41iMuCFHIz+gsL2bC4x57kz95D400BG1FV hbm6M9eHG9PZ/5XZI77Hp0ju6fTvaDnUtZwJCDzv8dS737uO/ZE00TYvVflmMZ9fCKhUbM 8YoIJ8Xx6jz4nUVwuKUdYyp6vqZGd21T+jZZEQftE0Ul9P9zwGBhFr5wTjE9Dg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794832480; b=twTUJjGYOciH/gpxpDkWi7tLk6qkvDbaXOObdFtZjibhH9p0ec4iRrGo7C85Lxh2eIrnvo lvOsfJ6Ugx9h7qNjfcdnyqfUIu15IeU9q9z0BFCL0iaFjoe9gh8M1j/hhEX/lKYiLhzRHI KuSSjSn/1vZtOgX6a6EB8O1T2ds17ZtZnwtaDASUCGh4jMZF0QJIgNTaNUpSVPR76/pnhP 9Iz7j73X13KHYLPIuJ5GniBrZ4A01pDENUIculqIVKFbx/aWnGH0jzdrdfh0lkh6DSJSaq lLacYZrrtJIw4Z+bUqTpV73VZpuDo1iC++tN3C4BDI3DXJPT2e8eccmjUBSowA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794832480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7X0FG/o14D3hnw8ywBZUUU/WQcvcL/0qEMhX5z3omuc=; b=tWjVmbvPUgS/xeA0+QVgcfRj/lWu+paUbM7OvQW+CWqZOzIPugULdC/7lJhxrXvopn+FbT Qf98ysA4iyUR/TOq7qIKhJHFU/60Wm8bmzfywYUYVPjE0kVswWHZeSDmdC/tbjoVmJ0CO1 GL2PSTyPqpRsfoRx3ttWq0wVZ6iIyAFmFqEgMLqGu6RXURpcj5md9irRinxL6MzV88pTrf cPLSza0PSG4wPRKQKlFA4AdlBPcC6XgWdUA8txR+5ju3JzYejKj/n/DDcX9dN/n+4zFvcZ lbpY6mHxTk9FQ0dHOVI1bFopbNIZ+aRovag9mAol32ZfcIELE/Dzi55X6z9RUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jSnPD0mXfzv82 for ; Mon, 16 Nov 2026 12:34:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1ac17 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 12:34:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: 46ce9acd6d15 - main - elfctl: add la52 for powerpc64 List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 46ce9acd6d157d3a63ca351a522d45a35ae83499 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 12:34:40 +0000 Message-Id: <6afaf860.1ac17.4e977351@gitrepo.freebsd.org> The branch main has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=46ce9acd6d157d3a63ca351a522d45a35ae83499 commit 46ce9acd6d157d3a63ca351a522d45a35ae83499 Author: Piotr Kubaj AuthorDate: 2026-11-15 20:57:46 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-16 12:34:20 +0000 elfctl: add la52 for powerpc64 The 0x40 feature bit is la57 on amd64 and la52 on powerpc64. Tag each feature with the machine it belongs to and only accept and show the names that match the file's e_machine, so la57 is only known for amd64 files and la52 only for powerpc64 ones. Reviewed by: kib MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D61331 --- usr.bin/elfctl/elfctl.1 | 13 ++++++++++++- usr.bin/elfctl/elfctl.c | 46 +++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/usr.bin/elfctl/elfctl.1 b/usr.bin/elfctl/elfctl.1 index c9e168234554..1029b0c4bc24 100644 --- a/usr.bin/elfctl/elfctl.1 +++ b/usr.bin/elfctl/elfctl.1 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 5, 2023 +.Dd November 15, 2026 .Dt ELFCTL 1 .Os .Sh NAME @@ -109,6 +109,17 @@ The .Va vm.pmap.prefer_uva_la48 sysctl MIB defines the default user address space size for binaries which do not set either of these flags. +.Pp +On powerpc64, +.Va la52 +names the same note bit and requests the full 52-bit address space of the +radix MMU instead of the default 48 bits; +.Va la48 +and +.Va vm.pmap.prefer_uva_la48 +work as on amd64. +Only the name that belongs to the file's architecture is recognised and +displayed for this bit. .Sh SEE ALSO .Xr mitigations 7 .Sh HISTORY diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index cacd30b44b2d..3b95e3de4791 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -48,29 +48,35 @@ #include #include "_elftc.h" -static bool convert_to_feature_val(const char *, uint32_t *); -static bool edit_file_features(Elf *, int, int, char *, bool); +static bool convert_to_feature_val(const char *, uint32_t *, unsigned int); +static bool edit_file_features(Elf *, int, int, char *, bool, unsigned int); static bool get_file_features(Elf *, int, int, uint32_t *, uint64_t *, bool); static void print_features(void); -static bool print_file_features(Elf *, int, int, char *, bool); +static bool print_file_features(Elf *, int, int, char *, bool, unsigned int); static void usage(void) __dead2; struct ControlFeatures { const char *alias; unsigned long value; const char *desc; + unsigned int machine; /* EM_* the name belongs to, EM_NONE for all */ }; static struct ControlFeatures featurelist[] = { - { "noaslr", NT_FREEBSD_FCTL_ASLR_DISABLE, "Disable ASLR" }, + { "noaslr", NT_FREEBSD_FCTL_ASLR_DISABLE, "Disable ASLR", EM_NONE }, { "noprotmax", NT_FREEBSD_FCTL_PROTMAX_DISABLE, - "Disable implicit PROT_MAX" }, - { "nostackgap", NT_FREEBSD_FCTL_STKGAP_DISABLE, "Disable stack gap" }, - { "wxneeded", NT_FREEBSD_FCTL_WXNEEDED, "Requires W+X mappings" }, + "Disable implicit PROT_MAX", EM_NONE }, + { "nostackgap", NT_FREEBSD_FCTL_STKGAP_DISABLE, "Disable stack gap", + EM_NONE }, + { "wxneeded", NT_FREEBSD_FCTL_WXNEEDED, "Requires W+X mappings", + EM_NONE }, { "la48", NT_FREEBSD_FCTL_LA48, - "amd64: Limit user virtual addresses to 48 bits" }, + "amd64, powerpc64: Limit user virtual addresses to 48 bits", EM_NONE }, { "la57", NT_FREEBSD_FCTL_LA57, - "amd64: Allow the use of 57-bit virtual addresses when available" }, + "amd64: Allow the use of 57-bit virtual addresses when available", + EM_X86_64 }, + { "la52", NT_FREEBSD_FCTL_LA52, + "powerpc64: Allow the use of 52-bit virtual addresses", EM_PPC64 }, }; static struct option long_opts[] = { @@ -180,12 +186,12 @@ main(int argc, char **argv) if (!editfeatures) { if (!print_file_features(elf, ehdr.e_phnum, fd, - argv[0], endian_swap)) { + argv[0], endian_swap, ehdr.e_machine)) { retval = 1; goto fail; } } else if (!edit_file_features(elf, ehdr.e_phnum, fd, - features, endian_swap)) { + features, endian_swap, ehdr.e_machine)) { retval = 1; goto fail; } @@ -222,7 +228,8 @@ usage(void) } static bool -convert_to_feature_val(const char *feature_str, uint32_t *feature_val) +convert_to_feature_val(const char *feature_str, uint32_t *feature_val, + unsigned int machine) { char *feature, *feature_tmp; int i, len; @@ -241,6 +248,10 @@ convert_to_feature_val(const char *feature_str, uint32_t *feature_val) len = nitems(featurelist); while ((feature = strsep(&feature_tmp, ",")) != NULL) { for (i = 0; i < len; ++i) { + /* Names that belong to another architecture are unknown. */ + if (featurelist[i].machine != EM_NONE && + featurelist[i].machine != machine) + continue; if (strcmp(featurelist[i].alias, feature) == 0) { input |= featurelist[i].value; break; @@ -295,7 +306,8 @@ convert_to_feature_val(const char *feature_str, uint32_t *feature_val) } static bool -edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap) +edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap, + unsigned int machine) { uint32_t features, prev_features; uint64_t off; @@ -307,7 +319,7 @@ edit_file_features(Elf *elf, int phcount, int fd, char *val, bool endian_swap) } prev_features = features; - if (!convert_to_feature_val(val, &features)) + if (!convert_to_feature_val(val, &features, machine)) return (false); /* Avoid touching file if no change. */ if (features == prev_features) @@ -338,7 +350,7 @@ print_features(void) static bool print_file_features(Elf *elf, int phcount, int fd, char *filename, - bool endian_swap) + bool endian_swap, unsigned int machine) { uint32_t features; unsigned long i; @@ -350,6 +362,10 @@ print_file_features(Elf *elf, int phcount, int fd, char *filename, printf("File '%s' features:\n", filename); for (i = 0; i < nitems(featurelist); ++i) { + /* The same bit has a different name on some architectures. */ + if (featurelist[i].machine != EM_NONE && + featurelist[i].machine != machine) + continue; printf("%-16s'%s' is ", featurelist[i].alias, featurelist[i].desc);