From nobody Fri Dec 27 18:06:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173321933021273.09099652701059; Tue, 3 Dec 2024 01:48:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.847710.1262773 (Exim 4.92) (envelope-from ) id 1tIPW6-0000cT-5N; Tue, 03 Dec 2024 09:48:26 +0000 Received: by outflank-mailman (output) from mailman id 847710.1262773; Tue, 03 Dec 2024 09:48:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tIPW6-0000bu-1Q; Tue, 03 Dec 2024 09:48:26 +0000 Received: by outflank-mailman (input) for mailman id 847710; Tue, 03 Dec 2024 09:48:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tIPW5-0000ZD-A3 for xen-devel@lists.xenproject.org; Tue, 03 Dec 2024 09:48:25 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id bc4a7fe0-b15b-11ef-a0d3-8be0dac302b0; Tue, 03 Dec 2024 10:48:23 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E247143D; Tue, 3 Dec 2024 01:48:51 -0800 (PST) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 337253F58B; Tue, 3 Dec 2024 01:48:22 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bc4a7fe0-b15b-11ef-a0d3-8be0dac302b0 From: Luca Fancellu To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v4 1/5] common/vmap: Fall back to simple allocator when !HAS_VMAP Date: Tue, 3 Dec 2024 09:48:06 +0000 Message-Id: <20241203094811.427076-2-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203094811.427076-1-luca.fancellu@arm.com> References: <20241203094811.427076-1-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1733219334263116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Jan Beulich --- Changes from v3: - use #define-s instead of static inline functions Changes from v2: - Don't protect declarations. Changes from v1: - put back static inline iounmap - changed commit message - hide not used declaration for system with !HAS_VMAP - correct function declared in xvmalloc.h to be static inline - prefer '#ifdef' instead of '#if defined' where possible --- --- xen/include/xen/vmap.h | 2 +- xen/include/xen/xvmalloc.h | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h index c1dd7ac22f30..26c831757a11 100644 --- a/xen/include/xen/vmap.h +++ b/xen/include/xen/vmap.h @@ -5,7 +5,7 @@ * purpose area (VMAP_DEFAULT) and a livepatch-specific area (VMAP_XEN). T= he * latter is used when loading livepatches and the former for everything e= lse. */ -#if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START) +#ifndef __XEN_VMAP_H__ #define __XEN_VMAP_H__ =20 #include diff --git a/xen/include/xen/xvmalloc.h b/xen/include/xen/xvmalloc.h index 440d85a284bb..7686d49f8154 100644 --- a/xen/include/xen/xvmalloc.h +++ b/xen/include/xen/xvmalloc.h @@ -40,20 +40,31 @@ ((typeof(ptr))_xvrealloc(ptr, offsetof(typeof(*(ptr)), field[nr]), \ __alignof__(typeof(*(ptr))))) =20 +#ifdef CONFIG_HAS_VMAP + /* Free any of the above. */ void xvfree(void *va); =20 +/* 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) =3D NULL; \ } while ( false ) =20 -/* 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) { --=20 2.34.1