]> xenbits.xensource.com Git - xen.git/commit
xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in xmalloc()
authorHenry Wang <Henry.Wang@arm.com>
Sat, 7 May 2022 02:54:34 +0000 (10:54 +0800)
committerJulien Grall <jgrall@amazon.com>
Wed, 8 Jun 2022 09:40:08 +0000 (10:40 +0100)
commit5047cd1d5deaa734ce67b4d706ac59d9a258c3e1
tree3efb4c9303d379341aa01aaf2329bc77c34ed98e
parente890b685996cbde3ba5378e772e7bfd2dd304b59
xen/common: Use enhanced ASSERT_ALLOC_CONTEXT in xmalloc()

xmalloc() will use a pool for allocation smaller than a page.
The pool is extended only when there are no more space. At which
point, alloc_xenheap_pages() is called to add more memory.

xmalloc() must be protected by ASSERT_ALLOC_CONTEXT. It should not
rely on pool expanding to trigger the ASSERT_ALLOC_CONTEXT in
alloc_xenheap_pages(). Hence, this commit moves the definition of
ASSERT_ALLOC_CONTEXT to header and uses the ASSERT_ALLOC_CONTEXT
to replace the original assertion in xmalloc().

For consistency, the same assertion should be used in xfree(),
and the position of the assertion should be at the beginning of
the xfree().

Also take the opportunity to enhance the non-static functions
xmem_pool_{alloc,free}() with the same assertion so that future
callers of these two functions can be benefited.

Reported-by: Wei Chen <Wei.Chen@arm.com>
Suggested-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Henry Wang <Henry.Wang@arm.com>
Tested-by: Julien Grall <jgrall@amazon.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/common/page_alloc.c
xen/common/xmalloc_tlsf.c
xen/include/xen/irq.h