From nobody Sat Jun 25 10:05:36 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 4AD5C864128; Sat, 25 Jun 2022 10:05:37 +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 4LVV410x8Bz3LV0; Sat, 25 Jun 2022 10:05:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656151537; 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=0hzXnYjaLzQWNcyPKCTS5ikBQBo/ZBkG0N/XCOe5aoo=; b=RI8ADX5Zs8vwmuFhJynnLv3WFi6RPaVkSV2q0cWqaKSYzPLkZO1IE4rmpS8LvBBH7km07U l1ESTwULiQyalEDmLpYTy8ducuQN22pgDJC5RePmIHMJBz12g50qxFfOSA5kgSSSc2JY7y 7L4eyrBCWLpTWkPzpA3iJggQ0th/TpGgXvBH4hMdY6ZtjqoVz/W2tQqb6bUib1938bFoj3 53kJFSZseQ8Wxbc5iJKG+y0ZwsRLy3hZdkw+wBwCfoxMYyaXdPGrYgInxstCgdCO+jEmaj c0pqhbks2kYzZeWE1/V5zWKwm3TqW4YsMib4fHsllWUi7HE9Epb34ghR2tpRCQ== 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 F3D38222FB; Sat, 25 Jun 2022 10:05:36 +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 25PA5a9c068677; Sat, 25 Jun 2022 10:05:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25PA5ao3068676; Sat, 25 Jun 2022 10:05:36 GMT (envelope-from git) Date: Sat, 25 Jun 2022 10:05:36 GMT Message-Id: <202206251005.25PA5ao3068676@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 2c28cd09d9f7 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 2c28cd09d9f7ac266a8c7b283384712aba0af93a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656151537; 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=0hzXnYjaLzQWNcyPKCTS5ikBQBo/ZBkG0N/XCOe5aoo=; b=fvr9THYz3PyZslwkoyBdItk5Wh5t6i1ORmNjdHhGmpOQt4S43SoUM5bQSnPxmZHwXY3jfW kahK/jCBtBFyuJbq7ykvxBuvsSGZR5VonZRRDhnt5luPTfnxvguk2eNvPT/FFMPWKn9v+h 9EncF9x1H6s7RXHdMn1jBkOD8GZChQ/S1Qa7FZ0AZFdOigI0f6D3lv0BuTKupwH63Dg2Br A/Wiq1ckkw0sHmvuEPVQL+xx8VHrQvfpBcTY4ubVzueSiDl+Zsk3RM/Oil39M56tu456uh YIaQC8+V21KLLdtr0aInHLJFtbjw5YZMoBWFFuRySRBAuYqx0P3nH9dhklXLbA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656151537; a=rsa-sha256; cv=none; b=PfUK5uE3RAHrBvF1hxJucZxWsTJg2VTnD67484xGtpTvFtuxTkV9Luxn+7T5QQUlTzxv8+ VeJdSLLWXApJhHQa+ecnQZm4pJNWGnmhU4w6SdDmS7kccQIXZS0l5s+4faP4yFZS8As5yN L3JwOazDcBwG1Yi+M2Mcye+JvNl5enGO/UM4CHaR4Emfg59cuHWr/u37MbFXfdHGDrwzFo kB7jg9d8OCdezWofdQB/G8jcD4G5QL2cKmoDU/jtMyhYJGV2hRdfPkpD7MaVde9+r2K8V0 jtOWBMjPxaaUTNUIK0lu9fWx3aWGccD8Q28PzLXTo4Cie7PFn6TiflKXJc325Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=2c28cd09d9f7ac266a8c7b283384712aba0af93a commit 2c28cd09d9f7ac266a8c7b283384712aba0af93a Author: Hans Petter Selasky AuthorDate: 2022-06-23 20:34:45 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-25 10:01:59 +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 MFC after: 1 week Sponsored by: NVIDIA Networking --- 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;