From nobody Wed Jul 27 09:36:44 2022 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 4Lt7vw4FwHz4WwFc; Wed, 27 Jul 2022 09:36:44 +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 4Lt7vw3krtz4NG6; Wed, 27 Jul 2022 09:36:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658914604; 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=r4UVvfKHJ3l/JW/0bGFebjt+hQQ6oic4rTcziKPTXMU=; b=GfJkWOaG0ITm4s9Z3GnWjTBxPuCzS0JZKlcpz3NiMio3o43ishgv0oZTNBNBbOb+j7a/Da ABAcpfpI4fqKsFftNM/ksqu6he6raEnMYlvlOU1eu1osHtYImPVOqo0tybmLZbCUiXFEha njBB9+a1vlnpbyWBa7DOqARLe4trGH19Gs5YUe7Mlbs8X+W8/Wf76iGhMed+1hG53Yut99 UvklU4iYeRhewNYzpQ8niIwvCwlLIbsyXnb5diWJhv9sVMv88TUrrbHCIbdAMk3egWBYd+ CLIqKXFt9jmdr2gb6PRahtxGfKbwGnT3bI0xVVMatT4PHPUlWzoBrJI8+Oq4+w== 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 4Lt7vw2Tspz1BW0; Wed, 27 Jul 2022 09:36:44 +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 26R9aiQT072570; Wed, 27 Jul 2022 09:36:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26R9aiFt072569; Wed, 27 Jul 2022 09:36:44 GMT (envelope-from git) Date: Wed, 27 Jul 2022 09:36:44 GMT Message-Id: <202207270936.26R9aiFt072569@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: cc876e9fa5d1 - stable/13 - cuse(3): Remove PAGE_SIZE from libcuse. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cc876e9fa5d15aa07271cdf609946bf7c8c7fb9f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658914604; 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=r4UVvfKHJ3l/JW/0bGFebjt+hQQ6oic4rTcziKPTXMU=; b=lhE/O0WMi/DAbsZApJ239poGAo0R9NXKBIGbA1e4qPuuGvj+Ez3ZhgO8DmYAoPp9Fg+Od7 NFmChaT2rJu+HdRWvxSld43qIe8X55HdmrVI9+6CVDxC1B4GdJJ/JpAwsboLVBsH8C6GKN D6NwzdVUcVwWUUk4pnHn3R6l3ssQ4v5KeNduiLZMfPb0ZX+p+eeHCNrZ/GJV8t4sXPGuGL CKc7JNP/kvzlawXPYrDwaL1i1/sc7PaHuWGZh+p1SV9chXHGYIw26O4O8Jj+agOZAZqkao evuz5+HdzO6y6juzb6zSb3kz3tfh5tfIW2E660+jxPxSTilaaXvM49mzGdjP7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658914604; a=rsa-sha256; cv=none; b=nv/KXPbb1H2e4CKZnSJ3dbhkrVuR/MCirCuDJBK3exEdJ651B8ectl6eUlTwgKYc/tMXDD 90iqOwS5c6WcbN57x4OEbXPqVAwPUKtv4uruExlxoYySaP/WQc9w6jWARY+IdrOEs6jV8Y BMtde59NcYV7AdCKA0Nz8PLWOJWkwkYrzptsqqgGdHkM0pVOQhCcS7OejsrFKffwXWGP1v gaKapTu+6HT6Wmt8n0xPhWpz/vkZXDXLrgm/gId9J7zg2DHXFeTK/dQsei20PdC6Jc+k/m 8rp6ZsS1D6mm5x19IGcCeoWWOYiIDXFgdtfAOtRz7g/L92yBX3MBSoAOTC74fg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=cc876e9fa5d15aa07271cdf609946bf7c8c7fb9f commit cc876e9fa5d15aa07271cdf609946bf7c8c7fb9f Author: Hans Petter Selasky AuthorDate: 2022-06-23 20:34:45 +0000 Commit: Hans Petter Selasky CommitDate: 2022-07-27 09:33:36 +0000 cuse(3): Remove PAGE_SIZE from libcuse. To allow for a dynamic page size on arm64 remove the static value from libcuse. Differential Revision: https://reviews.freebsd.org/D35585 Sponsored by: NVIDIA Networking (cherry picked from commit 2c28cd09d9f7ac266a8c7b283384712aba0af93a) --- lib/libcuse/cuse_lib.c | 20 +++++++++++--------- sys/fs/cuse/cuse.c | 9 ++++++++- sys/fs/cuse/cuse_ioctl.h | 6 +++--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/libcuse/cuse_lib.c b/lib/libcuse/cuse_lib.c index 436b5db728bd..fda0c96d0d70 100644 --- a/lib/libcuse/cuse_lib.c +++ b/lib/libcuse/cuse_lib.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2010-2012 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -142,7 +142,7 @@ cuse_vmoffset(void *_ptr) uint8_t *ptr_max; uint8_t *ptr = _ptr; unsigned long remainder; - int n; + unsigned long n; CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { @@ -158,9 +158,10 @@ cuse_vmoffset(void *_ptr) remainder = (ptr - ptr_min); - remainder -= remainder % PAGE_SIZE; + remainder -= remainder % + (unsigned long)getpagesize(); - return ((n * PAGE_SIZE * CUSE_ALLOC_PAGES_MAX) + remainder); + return ((n * CUSE_ALLOC_BYTES_MAX) + remainder); } } CUSE_UNLOCK(); @@ -172,9 +173,10 @@ void * cuse_vmalloc(int size) { struct cuse_alloc_info info; + unsigned long pgsize; + unsigned long n; void *ptr; int error; - int n; if (f_cuse < 0) return (NULL); @@ -184,7 +186,8 @@ cuse_vmalloc(int size) if (size < 1) return (NULL); - info.page_count = howmany(size, PAGE_SIZE); + pgsize = getpagesize(); + info.page_count = howmany(size, pgsize); CUSE_LOCK(); for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) { @@ -212,10 +215,9 @@ cuse_vmalloc(int size) else break; } - ptr = mmap(NULL, info.page_count * PAGE_SIZE, + ptr = mmap(NULL, info.page_count * pgsize, PROT_READ | PROT_WRITE, - MAP_SHARED, f_cuse, CUSE_ALLOC_PAGES_MAX * - PAGE_SIZE * n); + MAP_SHARED, f_cuse, CUSE_ALLOC_BYTES_MAX * n); if (ptr == MAP_FAILED) { diff --git a/sys/fs/cuse/cuse.c b/sys/fs/cuse/cuse.c index a893250043c4..7c7d8ec20493 100644 --- a/sys/fs/cuse/cuse.c +++ b/sys/fs/cuse/cuse.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2010-2020 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -64,6 +64,13 @@ #include #include +#define CUSE_ALLOC_PAGES_MAX \ + (CUSE_ALLOC_BYTES_MAX / PAGE_SIZE) + +#if (CUSE_ALLOC_PAGES_MAX == 0) +#error "PAGE_SIZE is too big!" +#endif + static int cuse_modevent(module_t mod, int type, void *data) { diff --git a/sys/fs/cuse/cuse_ioctl.h b/sys/fs/cuse/cuse_ioctl.h index 322ff28a4131..44e3c122979d 100644 --- a/sys/fs/cuse/cuse_ioctl.h +++ b/sys/fs/cuse/cuse_ioctl.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2014 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2014-2022 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,13 +30,13 @@ #include #include -#define CUSE_BUFFER_MAX PAGE_SIZE +#define CUSE_BUFFER_MAX (1 << 12) /* bytes */ #define CUSE_DEVICES_MAX 64 /* units */ #define CUSE_BUF_MIN_PTR 0x10000UL #define CUSE_BUF_MAX_PTR 0x20000UL #define CUSE_ALLOC_UNIT_MAX 128 /* units */ /* All memory allocations must be less than the following limit */ -#define CUSE_ALLOC_PAGES_MAX (((16UL * 1024UL * 1024UL) + PAGE_SIZE - 1) / PAGE_SIZE) +#define CUSE_ALLOC_BYTES_MAX (1UL << 24) /* bytes */ struct cuse_dev;