From nobody Sun Jul 21 13:14:46 2024 X-Original-To: dev-commits-src-main@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 4WRkQt3R3Nz5RV2V; Sun, 21 Jul 2024 13:14: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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WRkQt1PhQz4Rp5; Sun, 21 Jul 2024 13:14:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567686; 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=NPid9u7HXeKI1tTP8D/wCqLoRwgSSvV4Q26f6jWpb4o=; b=jBdxBDsaaS7Jy+M0T4mz+ep7r3qJUOfWZVvCl/W60Inw0vxo+PCIVp5e+gV9YbFzFk4Tcx lWr8njU1Wl0wLuAyjG3bZwvdWK+A6bqeAxQVTYOti4p+N8RKD7Fd0q8bOZquERvFRSAsHw QkQovAAB2oryEgaHEmhzuyTo+RRfqGYH8nRwLNLTiSEpRDxmZu0umReTiC6u4lk63CHZDx lAbe7Z/Yuy5UkHsfX4FojfKVTiIX+Xa2TQzpnbO4NMXQW90U7T6TybSp4wuXSicuftY8JA GkC/35/IsL2uDgJ1Eln7zfsMljGjz4SEgXFnM/UEHZdFAj56/f3gANHpBs9rLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567686; a=rsa-sha256; cv=none; b=jYAzzFbTLngbEwbiHuwxD+vzOEXx08hmzN476ZXkMFYJ1Tu40XTnH9nc3eSHWPF1vzHvhN COjdq0GFCMgKV8mFt6h+rX/4tKkwvCtsrsZi+nDdtsFZD1gvuIOdZ/6A1oo7jYVGj+Sz8R 9AX4JTtlPk6/L6CW4CFLOoeG/4/PRwjFS5weMbDAZs2QdRrbakRnz/1NanX7TUNk4Y4G8H KptEsbuMpGNxhgAqJVbYsh6CEAl6ts6B+0dmFmnnGGvqRQY5gNoKqSoRVBLp2B4VfE/qBz NoOstyCqrgiqh2E1kTz6+nLTfQGLIFKFTxANicBa8pLn762f+ec4JqK7sZOxyA== 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=1721567686; 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=NPid9u7HXeKI1tTP8D/wCqLoRwgSSvV4Q26f6jWpb4o=; b=KeoDRYkwbrtXlPJHBi+wcaSzPhMWPbZbgoUeVLlIu14yIVX3+0gfn/zSrtwSgyRhtZ9puc ROHbVgeDk9o+aH7XxP3hRBQ51SPn0SXfaCyIb/RcAjzBR0u9aI4Lt7Wsm0aWfJi9y5YLOe uVQCk6TByyDP1dapUu5ddpLjTP1qaxiXcqNTVELFFqLxnZ4IAWpSEzTOefYUK6xBNxU1wh oy/y+ydrFtFXOC+JlXk1kX3ZIp1CgIM5iNhmQCX7MxVEloazJDh/Hmpt0XqvB3U9LKowxk volU5RkdOe4bOb5pQiOF0z+4rZDxD6H8EsX+1vsfGaFBc5wg17eTccT/f4i2Kg== 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 4WRkQt0wPJz12Bg; Sun, 21 Jul 2024 13:14:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46LDEk0P022946; Sun, 21 Jul 2024 13:14:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDEk5T022943; Sun, 21 Jul 2024 13:14:46 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:46 GMT Message-Id: <202407211314.46LDEk5T022943@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: ab6e1167909b - main - LinuxKPI: Add kvrealloc to linux/slab.h List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ab6e1167909bf1e2792a2ba33000e13d33aaf551 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=ab6e1167909bf1e2792a2ba33000e13d33aaf551 commit ab6e1167909bf1e2792a2ba33000e13d33aaf551 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:08:28 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:08:28 +0000 LinuxKPI: Add kvrealloc to linux/slab.h Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45616 --- sys/compat/linuxkpi/common/include/linux/slab.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h b/sys/compat/linuxkpi/common/include/linux/slab.h index 298306b6ea05..e2d17e0558c2 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -91,6 +91,8 @@ struct linux_kmem_cache; #define ZERO_SIZE_PTR ((void *)16) #define ZERO_OR_NULL_PTR(x) ((x) == NULL || (x) == ZERO_SIZE_PTR) +extern void *lkpi_kmalloc(size_t size, gfp_t flags); + static inline gfp_t linux_check_m_flags(gfp_t flags) { @@ -212,13 +214,29 @@ kfree_sensitive(const void *ptr) zfree(__DECONST(void *, ptr), M_KMALLOC); } +static inline void * +kvrealloc(const void *ptr, size_t oldsize, size_t newsize, gfp_t flags) +{ + void *newptr; + + if (newsize <= oldsize) + return (__DECONST(void *, ptr)); + + newptr = kvmalloc(newsize, flags); + if (newptr != NULL) { + memcpy(newptr, ptr, oldsize); + kvfree(ptr); + } + + return (newptr); +} + static inline size_t ksize(const void *ptr) { return (malloc_usable_size(ptr)); } -extern void *lkpi_kmalloc(size_t size, gfp_t flags); extern struct linux_kmem_cache *linux_kmem_cache_create(const char *name, size_t size, size_t align, unsigned flags, linux_kmem_ctor_t *ctor); extern void *lkpi_kmem_cache_alloc(struct linux_kmem_cache *, gfp_t);