From nobody Tue Sep 12 07:49:44 2023 X-Original-To: dev-commits-src-branches@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 4RlG2K12p3z4tggx; Tue, 12 Sep 2023 07:49:45 +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 4RlG2K0ZLDz3MFh; Tue, 12 Sep 2023 07:49:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694504985; 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=fATr2Zr6TlOKlGnOaGcqxhL87tIE8wT2dZpC4M1cJ/o=; b=M1omLLfpxLa0t3ql4WDFm7p628HE5yoaJiqyOlZOoeyuTmWjgKO2+GmYkocDVKF7g/nruq 9VOLybuCFoUR4ocP8iG2lyVdYILQwxfCRvtl49KOmZJa5rEuYclMOG2rqpvv0vNDUeLyJd euIcmF3Gr+LAplFB6C66DHHhfzp4ZOlcSqwlxircVLTopr8NswbWasEdIhoPyDM5s/dU6G Uv6rBG61X00cr4oHS4SFcKrnKvHAWf/hJsi/I1z4H330wGDtFavY4chtTl6VQJRQ3pjp46 G0TO5/iGikaBy9CiDzyxD+jjmeAHuot2dkcZ31u5RP08SKm2OPhUavGvL1WxaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694504985; a=rsa-sha256; cv=none; b=JwVuvkMpWGEpzUptJ6NjC5ZS7JvSFURFDjyNiIDVJt8ZiqDVCX+UTDWL5hzOmrmVcSWjcW 6FSVoOYjDnQU5UfXFtTuZuw/EdA6dmhXeQ2Bh/Jao9JO9yfQGQrid68C4unPzWwIak+Shf aU1KyR9FWh/RBBXxyX5XXuvC8ZZYVEmZZktZWjsh6voQB50GukVaJatqcHhNjkpI1E4g2v IDJvnUyuUKdgd/3laLa7wIoJ3006Kq75qiRS8aHwbiiC+QR9J1Ge6RUXjkN9Eh39lpw2vZ Jg2j2ZnqGCqzAt9m/rAO5ch79mW3UKGQjsINgOM1KkNtpOMnG2cuAV+BkWbSUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694504985; 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=fATr2Zr6TlOKlGnOaGcqxhL87tIE8wT2dZpC4M1cJ/o=; b=iSldzn/9EKYDe1nTPat1WlndeJ6TYuuVvJjCuuY+zWUsJk8nEqVs0yXhP0h3YWUTgio+/q KxXFE57WT+yQmXl/7hE55B0vywAq00tRkjfqqy9iLPNaHrcluH3KryjgIegTPGfHHUxAR9 UrEolG97CAUeFtHXysUMqouybZZ2k3vhSyQlUcY7S79AQAcMelKnWCGiUpDdXIclnvdop0 9udHSselR8+djx+PuK1puQzbVaV0tV5YmcCq8K6+8aJ+sL75DhHaTTY9o6YnapwgF5Cwef M6jkTSZiW/C2ajexnaxwysd6fdUi34CuWP2pB0Hd7DuIlfuOEQyng5dFMB/dUQ== 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 4RlG2J6nRqz7tn; Tue, 12 Sep 2023 07:49:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38C7nidr072279; Tue, 12 Sep 2023 07:49:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38C7nial072276; Tue, 12 Sep 2023 07:49:44 GMT (envelope-from git) Date: Tue, 12 Sep 2023 07:49:44 GMT Message-Id: <202309120749.38C7nial072276@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: a321b17b8e6d - stable/14 - linux(4): Deduplicate mmap2 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: a321b17b8e6deb83249b685357631dfd8fafc9e8 Auto-Submitted: auto-generated The branch stable/14 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=a321b17b8e6deb83249b685357631dfd8fafc9e8 commit a321b17b8e6deb83249b685357631dfd8fafc9e8 Author: Dmitry Chagin AuthorDate: 2023-09-05 18:16:39 +0000 Commit: Dmitry Chagin CommitDate: 2023-09-12 07:48:56 +0000 linux(4): Deduplicate mmap2 To help porting the Linux emulation layer to a new platforms start using Linux names for conditional builds instead of architecture-specific ifdefs. MFC after: 1 week (cherry picked from commit 2a1cf1b6b55c8326bbe85d0fdf17b0f2fb9b34ce) --- sys/amd64/linux/linux_machdep.c | 9 --------- sys/amd64/linux32/linux.h | 4 ++++ sys/amd64/linux32/linux32_machdep.c | 9 --------- sys/arm64/linux/linux_machdep.c | 18 ------------------ sys/compat/linux/linux_misc.c | 17 +++++++++++++++++ sys/i386/linux/linux.h | 2 ++ sys/i386/linux/linux_machdep.c | 9 --------- 7 files changed, 23 insertions(+), 45 deletions(-) diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c index 7da1dccd6b45..33ce902a45bd 100644 --- a/sys/amd64/linux/linux_machdep.c +++ b/sys/amd64/linux/linux_machdep.c @@ -69,7 +69,6 @@ #include #include #include -#include #include #define LINUX_ARCH_AMD64 0xc000003e @@ -89,14 +88,6 @@ linux_set_upcall(struct thread *td, register_t stack) return (0); } -int -linux_mmap2(struct thread *td, struct linux_mmap2_args *args) -{ - - return (linux_mmap_common(td, args->addr, args->len, args->prot, - args->flags, args->fd, args->pgoff)); -} - int linux_iopl(struct thread *td, struct linux_iopl_args *args) { diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 395548b3c93f..5542df1b3185 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -46,6 +46,10 @@ #define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */ #define LINUX32_MAXVMEM 0 /* Unlimited */ +#define LINUX_ARCHWANT_MMAP2PGOFF 1 /* 32-bit off_t want offset + * represented in multiples + * of page size. */ + /* * Provide a separate set of types for the Linux types. */ diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index fb088ae37b26..e10502f9bd80 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -320,15 +320,6 @@ linux_set_upcall(struct thread *td, register_t stack) return (0); } -int -linux_mmap2(struct thread *td, struct linux_mmap2_args *args) -{ - - return (linux_mmap_common(td, PTROUT(args->addr), args->len, args->prot, - args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff * - PAGE_SIZE)); -} - int linux_mmap(struct thread *td, struct linux_mmap_args *args) { diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c index b9548387315b..3ba5683941b5 100644 --- a/sys/arm64/linux/linux_machdep.c +++ b/sys/arm64/linux/linux_machdep.c @@ -32,25 +32,17 @@ #include #include #include -#include #include #include #include -#include #include #include -#include #include #define LINUX_ARCH_AARCH64 0xc00000b7 -/* DTrace init */ -LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE); - -/* DTrace probes */ -LIN_SDT_PROBE_DEFINE0(machdep, linux_mmap2, todo); int linux_set_upcall(struct thread *td, register_t stack) @@ -67,16 +59,6 @@ linux_set_upcall(struct thread *td, register_t stack) return (0); } -/* LINUXTODO: deduplicate arm64 linux_mmap2 */ -int -linux_mmap2(struct thread *td, struct linux_mmap2_args *uap) -{ - - LIN_SDT_PROBE0(machdep, linux_mmap2, todo); - return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot, - uap->flags, uap->fd, uap->pgoff)); -} - int linux_set_cloned_tls(struct thread *td, void *desc) { diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index b9c67d513cd3..cb781f3bad75 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -365,6 +365,23 @@ linux_madvise(struct thread *td, struct linux_madvise_args *uap) uap->behav)); } +int +linux_mmap2(struct thread *td, struct linux_mmap2_args *uap) +{ +#if defined(LINUX_ARCHWANT_MMAP2PGOFF) + /* + * For architectures with sizeof (off_t) < sizeof (loff_t) mmap is + * implemented with mmap2 syscall and the offset is represented in + * multiples of page size. + */ + return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot, + uap->flags, uap->fd, (uint64_t)(uint32_t)uap->pgoff * PAGE_SIZE)); +#else + return (linux_mmap_common(td, PTROUT(uap->addr), uap->len, uap->prot, + uap->flags, uap->fd, uap->pgoff)); +#endif +} + #ifdef LINUX_LEGACY_SYSCALLS int linux_time(struct thread *td, struct linux_time_args *args) diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index 643c240f8e37..914dc9c9ae84 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -38,6 +38,8 @@ #define LINUX_DTRACE linuxulator +#define LINUX_ARCHWANT_MMAP2PGOFF 1 + /* * Provide a separate set of types for the Linux types. */ diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index 7f1738cda845..b5d42dc22162 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -308,15 +308,6 @@ linux_set_upcall(struct thread *td, register_t stack) return (0); } -int -linux_mmap2(struct thread *td, struct linux_mmap2_args *args) -{ - - return (linux_mmap_common(td, args->addr, args->len, args->prot, - args->flags, args->fd, (uint64_t)(uint32_t)args->pgoff * - PAGE_SIZE)); -} - int linux_mmap(struct thread *td, struct linux_mmap_args *args) {