]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
common/vmap: Fall back to simple allocator when !HAS_VMAP
authorLuca Fancellu <luca.fancellu@arm.com>
Tue, 3 Dec 2024 09:48:06 +0000 (09:48 +0000)
committerJulien Grall <jgrall@amazon.com>
Fri, 6 Dec 2024 19:24:25 +0000 (19:24 +0000)
When HAS_VMAP is disabled, the xv{malloc,zalloc,...} functions
should fall back to the simple x{malloc,zalloc,...} variant,
implement that because MPU systems won't have virtual memory.

Additionally remove VMAP_VIRT_START from vmap.h guards since
MPU systems won't have it defined.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/include/xen/vmap.h
xen/include/xen/xvmalloc.h

index c1dd7ac22f30f761d42fd78a6448bde7330aee7a..26c831757a1138a4466b41d0808978910a952756 100644 (file)
@@ -5,7 +5,7 @@
  * purpose area (VMAP_DEFAULT) and a livepatch-specific area (VMAP_XEN). The
  * latter is used when loading livepatches and the former for everything else.
  */
-#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START)
+#ifndef __XEN_VMAP_H__
 #define __XEN_VMAP_H__
 
 #include <xen/mm-frame.h>
index 440d85a284bbc4d98c02568b0fdaad459fa0a871..7686d49f8154c66f5cf5853dd0921f1b78d33719 100644 (file)
     ((typeof(ptr))_xvrealloc(ptr, offsetof(typeof(*(ptr)), field[nr]), \
                              __alignof__(typeof(*(ptr)))))
 
+#ifdef CONFIG_HAS_VMAP
+
 /* Free any of the above. */
 void xvfree(void *va);
 
+/* Underlying functions */
+void *_xvmalloc(size_t size, unsigned int align);
+void *_xvzalloc(size_t size, unsigned int align);
+void *_xvrealloc(void *va, size_t size, unsigned int align);
+
+#else /* !CONFIG_HAS_VMAP */
+
+#define xvfree      xfree
+#define _xvmalloc   _xmalloc
+#define _xvzalloc   _xzalloc
+#define _xvrealloc  _xrealloc
+
+#endif /* CONFIG_HAS_VMAP */
+
 /* Free an allocation, and zero the pointer to it. */
 #define XVFREE(p) do { \
     xvfree(p);         \
     (p) = NULL;        \
 } while ( false )
 
-/* Underlying functions */
-void *_xvmalloc(size_t size, unsigned int align);
-void *_xvzalloc(size_t size, unsigned int align);
-void *_xvrealloc(void *va, size_t size, unsigned int align);
-
 static inline void *_xvmalloc_array(
     size_t size, unsigned int align, unsigned long num)
 {