From nobody Thu Feb 2 14:59:10 2023 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 4P724G6V55z3fjDt; Thu, 2 Feb 2023 14:59:10 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P724G4h73z3FLT; Thu, 2 Feb 2023 14:59:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349950; 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=vHWh9tQL/7/WBmfDo6UmKm2JOi5Xaz8gHFfU7Gu17f0=; b=pOM8NFCrplKqnF7i5HozQh/jKaA+9cPlXaZrE+HL+kP2zYRZBGQQqV+WqDGK/irYzpmd41 NZ1dGg3zzvJsPFi1c3DtryZS65f932fsNH2mmLUszSrUAd8IGFthGtEMW06xz6mwxwz8SL 994vvzkPCl2NukuRam5d6cRMnfQIkwdYDKDDdLBeaTsUokRlUjz4ijk+TSk4wo0oACbq7k u1VNxEWilD9itXId5Cp4030rlXRR9dNxgTWKokWznfbvS5a7VCOOgtndNqD0tivjh0Tb0/ /eZtDCMrFUUww/ywVdaePp6rsySkvqLPeOOmjb5oMdkKsZqpelG8HJJy/+BR5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349950; 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=vHWh9tQL/7/WBmfDo6UmKm2JOi5Xaz8gHFfU7Gu17f0=; b=CYrdjmABwLPntYLvuJCYM2LfGDsHV6yjyMNGjUHDh709CgTCU1SBiC66wnQY5E6ZkS6hjI KhjqRpyd23u7WfEfwMzd/tm1xm/voBwpSljtjh5qUvKR2wNKJ9PTHGtHyrl72ViKuPvgr1 R0+a82+hlb/hfMSSys/Xj1Am6wVGPJcBGxUoZ/xm1IHns0JxLqAt7URie3HI2w7L1TmjHM PJF2WgLCeaF9J25rBFvtYus9GeR/O3CNmH9eSY8V3i+e2XVHcINq1RfvJPS/7SGmCsTn+q 3/th9P21uPS2k+mnpvgUi0w9Coiuuz3a7LZ2GkVUYFF6VcEziTRpscJE8t+i4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675349950; a=rsa-sha256; cv=none; b=QVLJciRK/TeB+xpZ2ItM7dnZTVD4qn9RCSPhyFrKBZ0KeAovP2+WYdOLuHwa7RqkqIu5Pa LrO/ZGqzB7nBzOySuw1L7pI+RS8VN5MzBQO9mB8hN72sC10ltWoX3LZ1GsWLa3Z84wLyAE hgaB2g8Y6H6hOeNZAM2sbqxA6E57EEHpmvdZlGnJsmhXIjJ557dO8e5Cr2pCvqkV/L4Mqq Z8uSFMeJvByI3FYfD9A2QwfRy1l3fNihq7vK6q/hp2GZn6FWxAfRHrJV64n0ACAsZ7W6FT YDNcdsw/bpVSfzArcc/yV5RKckTW5CDqZTEkXTODex8w6TdzLvnqRr/joUr8WQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P724G3pFZzyYG; Thu, 2 Feb 2023 14:59:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 312ExApe092165; Thu, 2 Feb 2023 14:59:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312ExAQE092164; Thu, 2 Feb 2023 14:59:10 GMT (envelope-from git) Date: Thu, 2 Feb 2023 14:59:10 GMT Message-Id: <202302021459.312ExAQE092164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 95b8603427d5 - main - linux(4): Deduplicate linux_trans_osrel(). List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 95b8603427d5759c5d6090ffaacfaf7f3b8fb926 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=95b8603427d5759c5d6090ffaacfaf7f3b8fb926 commit 95b8603427d5759c5d6090ffaacfaf7f3b8fb926 Author: Dmitry Chagin AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-02 14:58:07 +0000 linux(4): Deduplicate linux_trans_osrel(). MFC after: 1 week --- sys/amd64/linux/linux_sysvec.c | 31 ++----------------------------- sys/amd64/linux32/linux32_sysvec.c | 29 +---------------------------- sys/arm64/linux/linux_sysvec.c | 22 ---------------------- sys/compat/linux/linux_elf.c | 23 +++++++++++++++++++++++ sys/compat/linux/linux_elf.h | 5 +++++ sys/i386/linux/linux_sysvec.c | 27 --------------------------- 6 files changed, 31 insertions(+), 106 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index b42c90abc07d..96cdf5e5c818 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -115,7 +115,6 @@ extern const char *linux_syscallnames[]; SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); -static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); static void linux_vdso_reloc(char *mapping, Elf_Addr offset); @@ -737,37 +736,11 @@ linux_vdso_reloc(char *mapping, Elf_Addr offset) } } -static char GNULINUX_ABI_VENDOR[] = "GNU"; -static int GNULINUX_ABI_DESC = 0; - -static bool -linux_trans_osrel(const Elf_Note *note, int32_t *osrel) -{ - const Elf32_Word *desc; - uintptr_t p; - - p = (uintptr_t)(note + 1); - p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); - - desc = (const Elf32_Word *)p; - if (desc[0] != GNULINUX_ABI_DESC) - return (false); - - /* - * For Linux we encode osrel using the Linux convention of - * (version << 16) | (major << 8) | (minor) - * See macro in linux_mib.h - */ - *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); - - return (true); -} - static Elf_Brandnote linux64_brandnote = { - .hdr.n_namesz = sizeof(GNULINUX_ABI_VENDOR), + .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), .hdr.n_descsz = 16, .hdr.n_type = 1, - .vendor = GNULINUX_ABI_VENDOR, + .vendor = GNU_ABI_VENDOR, .flags = BN_TRANSLATE_OSREL, .trans_osrel = linux_trans_osrel }; diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index c28f1c396d36..6e40a6a82a39 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -127,7 +127,6 @@ static void linux_exec_sysvec_init(void *param); static int linux_on_exec_vmspace(struct proc *p, struct image_params *imgp); static void linux32_fixlimit(struct rlimit *rl, int which); -static bool linux32_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); static void linux_vdso_reloc(char *mapping, Elf_Addr offset); @@ -1016,39 +1015,13 @@ linux_vdso_reloc(char *mapping, Elf_Addr offset) } } -static char GNU_ABI_VENDOR[] = "GNU"; -static int GNULINUX_ABI_DESC = 0; - -static bool -linux32_trans_osrel(const Elf_Note *note, int32_t *osrel) -{ - const Elf32_Word *desc; - uintptr_t p; - - p = (uintptr_t)(note + 1); - p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); - - desc = (const Elf32_Word *)p; - if (desc[0] != GNULINUX_ABI_DESC) - return (false); - - /* - * For Linux we encode osrel using the Linux convention of - * (version << 16) | (major << 8) | (minor) - * See macro in linux_mib.h - */ - *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); - - return (true); -} - static Elf_Brandnote linux32_brandnote = { .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), .hdr.n_descsz = 16, /* XXX at least 16 */ .hdr.n_type = 1, .vendor = GNU_ABI_VENDOR, .flags = BN_TRANSLATE_OSREL, - .trans_osrel = linux32_trans_osrel + .trans_osrel = linux_trans_osrel }; static Elf32_Brandinfo linux_brand = { diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 169dafe26ed2..48b4305c5fe4 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -105,7 +105,6 @@ extern const char *linux_syscallnames[]; SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler); -static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); static void linux_vdso_reloc(char *mapping, Elf_Addr offset); @@ -571,27 +570,6 @@ linux_vdso_reloc(char *mapping, Elf_Addr offset) } } -static char GNU_ABI_VENDOR[] = "GNU"; -static int GNU_ABI_LINUX = 0; - -/* LINUXTODO: deduplicate */ -static bool -linux_trans_osrel(const Elf_Note *note, int32_t *osrel) -{ - const Elf32_Word *desc; - uintptr_t p; - - p = (uintptr_t)(note + 1); - p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); - - desc = (const Elf32_Word *)p; - if (desc[0] != GNU_ABI_LINUX) - return (false); - - *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); - return (true); -} - static Elf_Brandnote linux64_brandnote = { .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), .hdr.n_descsz = 16, diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c index 3e0582e2b8c3..43df9508d470 100644 --- a/sys/compat/linux/linux_elf.c +++ b/sys/compat/linux/linux_elf.c @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include #include struct l_elf_siginfo { @@ -465,3 +466,25 @@ __linuxN(copyout_strings)(struct image_params *imgp, uintptr_t *stack_base) return (0); } + +bool +linux_trans_osrel(const Elf_Note *note, int32_t *osrel) +{ + const Elf32_Word *desc; + uintptr_t p; + + p = (uintptr_t)(note + 1); + p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); + + desc = (const Elf32_Word *)p; + if (desc[0] != GNU_ABI_LINUX) + return (false); + /* + * For Linux we encode osrel using the Linux convention of + * (version << 16) | (major << 8) | (minor) + * See macro in linux_mib.h + */ + *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); + + return (true); +} diff --git a/sys/compat/linux/linux_elf.h b/sys/compat/linux/linux_elf.h index e0905983070b..87b21c4a14b2 100644 --- a/sys/compat/linux/linux_elf.h +++ b/sys/compat/linux/linux_elf.h @@ -33,11 +33,16 @@ struct note_info_list; /* Linux core notes are labeled "CORE" */ #define LINUX_ABI_VENDOR "CORE" +/* Elf notes */ +#define GNU_ABI_VENDOR "GNU" +#define GNU_ABI_LINUX 0 + /* This adds "linux32_" and "linux64_" prefixes. */ #define __linuxN(x) __CONCAT(__CONCAT(__CONCAT(linux,__ELF_WORD_SIZE),_),x) void __linuxN(prepare_notes)(struct thread *, struct note_info_list *, size_t *); int __linuxN(copyout_strings)(struct image_params *, uintptr_t *); +bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); #endif diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index aaf52b873258..9e2939ee4213 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -112,7 +112,6 @@ static void linux_exec_sysvec_init(void *param); static int linux_on_exec_vmspace(struct proc *p, struct image_params *imgp); static void linux_set_fork_retval(struct thread *td); -static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel); static void linux_vdso_install(const void *param); static void linux_vdso_deinstall(const void *param); static void linux_vdso_reloc(char *mapping, Elf_Addr offset); @@ -840,32 +839,6 @@ linux_vdso_reloc(char *mapping, Elf_Addr offset) } } -static char GNU_ABI_VENDOR[] = "GNU"; -static int GNULINUX_ABI_DESC = 0; - -static bool -linux_trans_osrel(const Elf_Note *note, int32_t *osrel) -{ - const Elf32_Word *desc; - uintptr_t p; - - p = (uintptr_t)(note + 1); - p += roundup2(note->n_namesz, sizeof(Elf32_Addr)); - - desc = (const Elf32_Word *)p; - if (desc[0] != GNULINUX_ABI_DESC) - return (false); - - /* - * For Linux we encode osrel using the Linux convention of - * (version << 16) | (major << 8) | (minor) - * See macro in linux_mib.h - */ - *osrel = LINUX_KERNVER(desc[1], desc[2], desc[3]); - - return (true); -} - static Elf_Brandnote linux_brandnote = { .hdr.n_namesz = sizeof(GNU_ABI_VENDOR), .hdr.n_descsz = 16, /* XXX at least 16 */