git: nvmm: Port to DragonFly #18: kernel memory allocation
Aaron LI
aly at crater.dragonflybsd.org
Tue Jul 20 16:30:19 PDT 2021
commit 30d365ffd7dd3ed03eec9b68570e5323d50d169f
Author: Aaron LI <aly at aaronly.me>
Date: Sat May 22 12:03:06 2021 +0800
nvmm: Port to DragonFly #18: kernel memory allocation
Use kmem_alloc() and kmem_free() to implement uvm_km_alloc() and
uvm_km_free() as they're used in svm_vcpu_create() and vmx_vcpu_create().
However, our kmem_alloc() may return 0 (i.e., allocation failure), so
need an extra check in the caller functions.
Since we've defined 'kmem_alloc' and 'kmem_free' macros to adapt
NetBSD's functions to use our kmalloc() and kfree(). Therefore, extra
parentheses are added around 'kmem_alloc' and 'kmem_free' to avoid macro
expansion, so the original functions would be called.
In addition, change the 'kmem_free()' to 'uvm_km_free()' in
vmx_vcpu_create(), aligning with the invocation pattern as well as
the use case in svm_vcpu_create().
Summary of changes:
sys/dev/virtual/nvmm/nvmm_compat.h | 33 +++++++++++++++++++++++++++++++++
sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c | 3 +++
sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c | 7 +++++--
sys/vm/vm_map.h | 1 +
4 files changed, 42 insertions(+), 2 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/30d365ffd7dd3ed03eec9b68570e5323d50d169f
--
DragonFly BSD source repository
More information about the Commits
mailing list