From nobody Thu Feb 09 07:56:46 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 4PC8Mf6sNJz3myBK; Thu, 9 Feb 2023 07:56:46 +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 4PC8Mf5vz4z44kX; Thu, 9 Feb 2023 07:56:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929406; 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=EfW3nLy4DAwQW4+uDo2dRS5vN1LFge8HkDEU3FwktJY=; b=nhGIZPD1t3B31sqjxVm697aw9SNW0yvUa4GlI6+ZkL6lQ+wWVH1L3lzKT+g3WWTUXMXCeP gv34YUqDaRZRGqvS57nr3nx0iOZrBhpk36GWYUuV7+rTt0ciIkce/3L1UCKlOznaBK22Ng kvhwOOAmgaCRseIwdRMyNZJcGIUQzYSL5euSsa0kIp7qwpRUQrlBk3JDy//EHUlN2e3xzG x/2HAq47LH1OoJKIw0H41Mi3nWMJlBZ1TE68lpy0xflSwdxjDBrmX93T82trbu8xtuu2Bs uGytbSfjuiV6I1gxkrNgWor1AFqiO4wYztBf6+IQKEocXWdT44eFBcxyEjeLiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675929406; 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=EfW3nLy4DAwQW4+uDo2dRS5vN1LFge8HkDEU3FwktJY=; b=u8S7KeLaZePn1LvQi2/HIkn+svl6Jrd1pjeITphhQekrSSI08XDj7XSEAzrOFN6e3h5hkz NnhjYqJIw5oBno3rrrqCszopcZFXcylly2JdTSDBcuHusnpZvrJU+5XFDyNQkZMj6IQtXK kp0RbJnqWKJ9x80uZMnRooxZmAcpUI2cuWq0hj/0PjVeTdYYVuqYhHEYmbPlYLmnuJt2Jp LLE5+3A+17AmpORMI5l3XuFvg5hMzRtjbY18M6LFibPfAWfq5bva6BIKO3fnFUXnODJbth /mCy+kocKI5lvQVGZLKGFTmQot31L7XlvK3daBoK800c687kphthSJ3DFJOHnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675929406; a=rsa-sha256; cv=none; b=tz5gW5yPSDTdcZLN8PU7bRv3kFs3rE/T43yxmd2Ichzm6JuWUvIDDjOsa9dHDIlgrqSGsV 2vgVsvzTdF/sv851mAaRDiqWpDFuJel5rk6PBHLQsNaCNSLNyN0TJq8fG/vfQCf4UY2U/w 43PZbmznmovE/LRI9kWX2hFEaHDyMm1FWWPJd6e98K01eMB1J4tIapkaaNxcdDxBfi4rMZ JLAfelmuOS3tXkhDvUlyyOjFNdIZW9Z/rpBC8d3iROGO+fMZ2dfq8/8ujesMtsPnjjJ9q2 k3F4oT18EsMo7zHKpfsv3C6hZxS91Gy1rjxO2C1bp5+ilO+yCs29snQjZ103FQ== 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 4PC8Mf50gZzVHh; Thu, 9 Feb 2023 07:56:46 +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 3197uk34092971; Thu, 9 Feb 2023 07:56:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3197ukiu092970; Thu, 9 Feb 2023 07:56:46 GMT (envelope-from git) Date: Thu, 9 Feb 2023 07:56:46 GMT Message-Id: <202302090756.3197ukiu092970@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 7125bd6e9f20 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 7125bd6e9f20473b1b161499e8235843fc62ae5e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=7125bd6e9f20473b1b161499e8235843fc62ae5e commit 7125bd6e9f20473b1b161499e8235843fc62ae5e Author: Dmitry Chagin AuthorDate: 2023-02-02 14:58:07 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-09 07:55:24 +0000 linux(4): Deduplicate linux_trans_osrel(). MFC after: 1 week (cherry picked from commit 95b8603427d5759c5d6090ffaacfaf7f3b8fb926) --- 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 45d940a42b51..4fe2bfb78f7f 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); @@ -736,37 +735,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 432ed51cbb7e..c2b54369552f 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); @@ -1015,39 +1014,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 7bf0dbca6eda..0bd8d60dcd93 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); @@ -569,27 +568,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 dc41b9595003..39249cb25320 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); @@ -839,32 +838,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 */