From nobody Fri May 3 19:19:52 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629738215390851.8811729972512; Mon, 23 Aug 2021 10:03:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.170503.311296 (Exim 4.92) (envelope-from ) id 1mIDLq-0001K4-Hd; Mon, 23 Aug 2021 17:03:10 +0000 Received: by outflank-mailman (output) from mailman id 170503.311296; Mon, 23 Aug 2021 17:03:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDLq-0001J7-DD; Mon, 23 Aug 2021 17:03:10 +0000 Received: by outflank-mailman (input) for mailman id 170503; Mon, 23 Aug 2021 17:03:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDLp-0001H2-7b for xen-devel@lists.xenproject.org; Mon, 23 Aug 2021 17:03:09 +0000 Received: from mx.upb.ro (unknown [141.85.13.220]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 33d58277-c271-4081-ae4c-a0dbf4362b78; Mon, 23 Aug 2021 17:03:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 2E3B2B56008F; Mon, 23 Aug 2021 20:03:06 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ZXIII3mYf7jK; Mon, 23 Aug 2021 20:03:03 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 90F37B5600BF; Mon, 23 Aug 2021 20:03:03 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Wz-XGhTtxHKr; Mon, 23 Aug 2021 20:03:03 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 9185AB56008F; Mon, 23 Aug 2021 20:03:02 +0300 (EEST) 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: 33d58277-c271-4081-ae4c-a0dbf4362b78 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v3 1/4] public: Add page related definitions for accessing guests memory Date: Mon, 23 Aug 2021 20:02:53 +0300 Message-Id: <22031be8466bb18d1dd891481ccc67d8c2b2dd55.1629737453.git.costin.lupu@cs.pub.ro> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1629738218122100002 Content-Type: text/plain; charset="utf-8" These changes introduce the page related definitions needed for mapping and accessing guests memory. These values are intended to be used by any toolst= ack component that needs to map guests memory. Until now, the values were defin= ed by the xenctrl.h header, therefore whenever a component had to use them it = also had to add a dependency for the xenctrl library. This patch also introduces xen_mk_long() macrodefinition for defining long constants both for C and assembler code. Signed-off-by: Costin Lupu Acked-by: Jan Beulich Acked-by: Julien Grall --- xen/include/public/arch-arm.h | 8 ++++++++ xen/include/public/arch-x86/xen.h | 8 ++++++++ xen/include/public/xen.h | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 64a2ca30da..caf7825d95 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -471,6 +471,14 @@ typedef uint64_t xen_callback_t; typedef struct xen_pmu_arch { uint8_t dummy; } xen_pmu_arch_t; #endif =20 +#if defined(__XEN__) || defined(__XEN_TOOLS__) +/* + * Page definitions needed for accessing guests memory + */ +#define XEN_PAGE_SHIFT 12 + +#endif/* __XEN__ || __XEN_TOOLS__ */ + #endif /* __XEN_PUBLIC_ARCH_ARM_H__ */ =20 /* diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x8= 6/xen.h index 7acd94c8eb..f9939c742b 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -385,6 +385,14 @@ DEFINE_XEN_GUEST_HANDLE(xen_msr_entry_t); */ #define XEN_HVM_DEBUGCONS_IOPORT 0xe9 =20 +#if defined(__XEN__) || defined(__XEN_TOOLS__) +/* + * Page definitions needed for accessing guests memory + */ +#define XEN_PAGE_SHIFT 12 + +#endif /* __XEN__ || __XEN_TOOLS__ */ + #endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ =20 /* diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index e373592c33..c6486040b9 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -64,11 +64,13 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); =20 /* Turn a plain number into a C unsigned (long (long)) constant. */ #define __xen_mk_uint(x) x ## U +#define __xen_mk_long(x) x ## L #define __xen_mk_ulong(x) x ## UL #ifndef __xen_mk_ullong # define __xen_mk_ullong(x) x ## ULL #endif #define xen_mk_uint(x) __xen_mk_uint(x) +#define xen_mk_long(x) __xen_mk_long(x) #define xen_mk_ulong(x) __xen_mk_ulong(x) #define xen_mk_ullong(x) __xen_mk_ullong(x) =20 @@ -76,6 +78,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); =20 /* In assembly code we cannot use C numeric constant suffixes. */ #define xen_mk_uint(x) x +#define xen_mk_long(x) x #define xen_mk_ulong(x) x #define xen_mk_ullong(x) x =20 @@ -1034,6 +1037,12 @@ struct xenctl_bitmap { typedef struct xenctl_bitmap xenctl_bitmap_t; #endif =20 +/* + * Page definitions needed for accessing guests memory + */ +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) + #endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ =20 #endif /* __XEN_PUBLIC_XEN_H__ */ --=20 2.20.1 From nobody Fri May 3 19:19:52 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629738215987912.2172663317771; Mon, 23 Aug 2021 10:03:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.170502.311293 (Exim 4.92) (envelope-from ) id 1mIDLq-0001HG-8R; Mon, 23 Aug 2021 17:03:10 +0000 Received: by outflank-mailman (output) from mailman id 170502.311293; Mon, 23 Aug 2021 17:03:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDLq-0001H9-5M; Mon, 23 Aug 2021 17:03:10 +0000 Received: by outflank-mailman (input) for mailman id 170502; Mon, 23 Aug 2021 17:03:08 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDLo-0001Gx-R4 for xen-devel@lists.xenproject.org; Mon, 23 Aug 2021 17:03:08 +0000 Received: from mx.upb.ro (unknown [141.85.13.241]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id fc001ef7-0433-11ec-a879-12813bfff9fa; Mon, 23 Aug 2021 17:03:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 10526B5600B7; Mon, 23 Aug 2021 20:03:06 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4lcgr9anX_5F; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 39269B56008F; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0_98ZgINJCV6; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 9049AB56005B; Mon, 23 Aug 2021 20:03:03 +0300 (EEST) 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: fc001ef7-0433-11ec-a879-12813bfff9fa X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH v3 2/4] libs/ctrl: Use Xen values for XC_PAGE_* definitions Date: Mon, 23 Aug 2021 20:02:54 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1629738218101100001 Content-Type: text/plain; charset="utf-8" We use the values provided by the Xen public interface for defining the XC_PAGE_* macros. Signed-off-by: Costin Lupu --- tools/include/xenctrl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index b77726eab7..52a1768ee7 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -55,9 +55,9 @@ #include #endif =20 -#define XC_PAGE_SHIFT 12 -#define XC_PAGE_SIZE (1UL << XC_PAGE_SHIFT) -#define XC_PAGE_MASK (~(XC_PAGE_SIZE-1)) +#define XC_PAGE_SHIFT XEN_PAGE_SHIFT +#define XC_PAGE_SIZE XEN_PAGE_SIZE +#define XC_PAGE_MASK XEN_PAGE_MASK =20 #define INVALID_MFN (~0UL) =20 --=20 2.20.1 From nobody Fri May 3 19:19:52 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629740330217877.2806098441321; Mon, 23 Aug 2021 10:38:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.170539.311348 (Exim 4.92) (envelope-from ) id 1mIDty-0007Dq-3E; Mon, 23 Aug 2021 17:38:26 +0000 Received: by outflank-mailman (output) from mailman id 170539.311348; Mon, 23 Aug 2021 17:38: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 1mIDtx-0007Dj-W9; Mon, 23 Aug 2021 17:38:25 +0000 Received: by outflank-mailman (input) for mailman id 170539; Mon, 23 Aug 2021 17:38:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDtx-0007Dd-7p for xen-devel@lists.xenproject.org; Mon, 23 Aug 2021 17:38:25 +0000 Received: from mx.upb.ro (unknown [141.85.13.201]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ea2552e6-0438-11ec-a87a-12813bfff9fa; Mon, 23 Aug 2021 17:38:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 69B4CB5600B7; Mon, 23 Aug 2021 20:03:10 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id oGo02o3IyrQN; Mon, 23 Aug 2021 20:03:05 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id E8CB7B5600C2; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id p2yt0dO45zb1; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 3A15EB5600C0; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) 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: ea2552e6-0438-11ec-a87a-12813bfff9fa X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH v3 3/4] libs/foreignmemory: Use XEN_PAGE_* definitions Date: Mon, 23 Aug 2021 20:02:55 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1629740332444100001 Content-Type: text/plain; charset="utf-8" These changes refine the changes in 0dbb4be7 which added a dependency to xenctrl library. We use the XEN_PAGE_* definitions instead of the XC_PAGE_* definitions and therefore we get rid of the unnecessary dependency. Signed-off-by: Costin Lupu --- tools/libs/foreignmemory/Makefile | 2 ++ tools/libs/foreignmemory/core.c | 2 +- tools/libs/foreignmemory/freebsd.c | 10 +++++----- tools/libs/foreignmemory/linux.c | 18 +++++++++--------- tools/libs/foreignmemory/minios.c | 10 +--------- tools/libs/foreignmemory/netbsd.c | 10 +++++----- tools/libs/foreignmemory/private.h | 1 - tools/libs/foreignmemory/solaris.c | 6 +++--- 8 files changed, 26 insertions(+), 33 deletions(-) diff --git a/tools/libs/foreignmemory/Makefile b/tools/libs/foreignmemory/M= akefile index 0eb9a3a712..e3f417f5ca 100644 --- a/tools/libs/foreignmemory/Makefile +++ b/tools/libs/foreignmemory/Makefile @@ -11,4 +11,6 @@ SRCS-$(CONFIG_SunOS) +=3D compat.c solaris.c SRCS-$(CONFIG_NetBSD) +=3D netbsd.c SRCS-$(CONFIG_MiniOS) +=3D minios.c =20 +CFLAGS +=3D -D__XEN_TOOLS__ + include $(XEN_ROOT)/tools/libs/libs.mk diff --git a/tools/libs/foreignmemory/core.c b/tools/libs/foreignmemory/cor= e.c index 7edc6f0dbf..ad1ad9fc67 100644 --- a/tools/libs/foreignmemory/core.c +++ b/tools/libs/foreignmemory/core.c @@ -202,7 +202,7 @@ int xenforeignmemory_resource_size( if ( rc ) return rc; =20 - *size =3D fres.nr_frames << XC_PAGE_SHIFT; + *size =3D fres.nr_frames << XEN_PAGE_SHIFT; return 0; } =20 diff --git a/tools/libs/foreignmemory/freebsd.c b/tools/libs/foreignmemory/= freebsd.c index 2cf0fa1c38..9439c4ca6a 100644 --- a/tools/libs/foreignmemory/freebsd.c +++ b/tools/libs/foreignmemory/freebsd.c @@ -63,7 +63,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, privcmd_mmapbatch_t ioctlx; int rc; =20 - addr =3D mmap(addr, num << XC_PAGE_SHIFT, prot, flags | MAP_SHARED, fd= , 0); + addr =3D mmap(addr, num << XEN_PAGE_SHIFT, prot, flags | MAP_SHARED, f= d, 0); if ( addr =3D=3D MAP_FAILED ) return NULL; =20 @@ -78,7 +78,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, { int saved_errno =3D errno; =20 - (void)munmap(addr, num << XC_PAGE_SHIFT); + (void)munmap(addr, num << XEN_PAGE_SHIFT); errno =3D saved_errno; return NULL; } @@ -89,7 +89,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem, void *addr, size_t num) { - return munmap(addr, num << XC_PAGE_SHIFT); + return munmap(addr, num << XEN_PAGE_SHIFT); } =20 int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem, @@ -101,7 +101,7 @@ int osdep_xenforeignmemory_restrict(xenforeignmemory_ha= ndle *fmem, int osdep_xenforeignmemory_unmap_resource(xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *= fres) { - return fres ? munmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT) : = 0; } =20 int osdep_xenforeignmemory_map_resource(xenforeignmemory_handle *fmem, @@ -120,7 +120,7 @@ int osdep_xenforeignmemory_map_resource(xenforeignmemor= y_handle *fmem, /* Request for resource size. Skip mmap(). */ goto skip_mmap; =20 - fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT, fres->prot, fres->flags | MAP_SHARED, fmem->fd, 0); if ( fres->addr =3D=3D MAP_FAILED ) return -1; diff --git a/tools/libs/foreignmemory/linux.c b/tools/libs/foreignmemory/li= nux.c index 9062117407..9dabf28cae 100644 --- a/tools/libs/foreignmemory/linux.c +++ b/tools/libs/foreignmemory/linux.c @@ -134,7 +134,7 @@ static int retry_paged(int fd, uint32_t dom, void *addr, /* At least one gfn is still in paging state */ ioctlx.num =3D 1; ioctlx.dom =3D dom; - ioctlx.addr =3D (unsigned long)addr + (i<addr, fres->nr_frames << XC_PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT) : = 0; } =20 int osdep_xenforeignmemory_map_resource( @@ -313,7 +313,7 @@ int osdep_xenforeignmemory_map_resource( /* Request for resource size. Skip mmap(). */ goto skip_mmap; =20 - fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT, fres->prot, fres->flags | MAP_SHARED, fmem->fd, 0); if ( fres->addr =3D=3D MAP_FAILED ) return -1; diff --git a/tools/libs/foreignmemory/minios.c b/tools/libs/foreignmemory/m= inios.c index f2f4dfb2be..2454eb9af3 100644 --- a/tools/libs/foreignmemory/minios.c +++ b/tools/libs/foreignmemory/minios.c @@ -17,14 +17,6 @@ * Copyright 2007-2008 Samuel Thibault . */ =20 -/* - * xenctrl.h currently defines __XEN_TOOLS__ which affects what is - * exposed by Xen headers. As the define needs to be set consistently, - * we want to include xenctrl.h before the mini-os headers (they include - * public headers). - */ -#include - #include #include #include @@ -63,7 +55,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem, void *addr, size_t num) { - return munmap(addr, num << XC_PAGE_SHIFT); + return munmap(addr, num << XEN_PAGE_SHIFT); } =20 /* diff --git a/tools/libs/foreignmemory/netbsd.c b/tools/libs/foreignmemory/n= etbsd.c index 597db775d7..ba69b9c6bb 100644 --- a/tools/libs/foreignmemory/netbsd.c +++ b/tools/libs/foreignmemory/netbsd.c @@ -76,7 +76,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, { int fd =3D fmem->fd; privcmd_mmapbatch_v2_t ioctlx; - addr =3D mmap(addr, num * XC_PAGE_SIZE, prot, + addr =3D mmap(addr, num * XEN_PAGE_SIZE, prot, flags | MAP_ANON | MAP_SHARED, -1, 0); if ( addr =3D=3D MAP_FAILED ) { PERROR("osdep_xenforeignmemory_map: mmap failed"); @@ -93,7 +93,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle = *fmem, { int saved_errno =3D errno; PERROR("osdep_xenforeignmemory_map: ioctl failed"); - munmap(addr, num * XC_PAGE_SIZE); + munmap(addr, num * XEN_PAGE_SIZE); errno =3D saved_errno; return NULL; } @@ -104,7 +104,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handl= e *fmem, int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem, void *addr, size_t num) { - return munmap(addr, num * XC_PAGE_SIZE); + return munmap(addr, num * XEN_PAGE_SIZE); } =20 int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem, @@ -117,7 +117,7 @@ int osdep_xenforeignmemory_restrict(xenforeignmemory_ha= ndle *fmem, int osdep_xenforeignmemory_unmap_resource( xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres) { - return fres ? munmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT) : = 0; } =20 int osdep_xenforeignmemory_map_resource( @@ -136,7 +136,7 @@ int osdep_xenforeignmemory_map_resource( /* Request for resource size. Skip mmap(). */ goto skip_mmap; =20 - fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XEN_PAGE_SHIFT, fres->prot, fres->flags | MAP_ANON | MAP_SHARED, -1,= 0); if ( fres->addr =3D=3D MAP_FAILED ) return -1; diff --git a/tools/libs/foreignmemory/private.h b/tools/libs/foreignmemory/= private.h index 8540303adc..48df948f90 100644 --- a/tools/libs/foreignmemory/private.h +++ b/tools/libs/foreignmemory/private.h @@ -1,7 +1,6 @@ #ifndef XENFOREIGNMEMORY_PRIVATE_H #define XENFOREIGNMEMORY_PRIVATE_H =20 -#include #include =20 #include diff --git a/tools/libs/foreignmemory/solaris.c b/tools/libs/foreignmemory/= solaris.c index 958fb01f6d..4466780bd8 100644 --- a/tools/libs/foreignmemory/solaris.c +++ b/tools/libs/foreignmemory/solaris.c @@ -72,7 +72,7 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem,= uint32_t dom, { int fd =3D fmem->fd; privcmd_mmapbatch_t ioctlx; - addr =3D mmap(addr, num*XC_PAGE_SIZE, prot, flags | MAP_SHARED, fd, 0); + addr =3D mmap(addr, num*XEN_PAGE_SIZE, prot, flags | MAP_SHARED, fd, 0= ); if ( addr =3D=3D MAP_FAILED ) return NULL; =20 @@ -84,7 +84,7 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem,= uint32_t dom, { int saved_errno =3D errno; =20 - (void)munmap(addr, num*XC_PAGE_SIZE); + (void)munmap(addr, num*XEN_PAGE_SIZE); errno =3D saved_errno; return NULL; } @@ -94,7 +94,7 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem,= uint32_t dom, int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem, void *addr, size_t num) { - return munmap(addr, num*XC_PAGE_SIZE); + return munmap(addr, num*XEN_PAGE_SIZE); } =20 /* --=20 2.20.1 From nobody Fri May 3 19:19:52 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629738538193943.8378099070231; Mon, 23 Aug 2021 10:08:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.170519.311326 (Exim 4.92) (envelope-from ) id 1mIDQy-00038n-ER; Mon, 23 Aug 2021 17:08:28 +0000 Received: by outflank-mailman (output) from mailman id 170519.311326; Mon, 23 Aug 2021 17:08:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDQy-00038g-BM; Mon, 23 Aug 2021 17:08:28 +0000 Received: by outflank-mailman (input) for mailman id 170519; Mon, 23 Aug 2021 17:08:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mIDQw-00038a-Vl for xen-devel@lists.xenproject.org; Mon, 23 Aug 2021 17:08:27 +0000 Received: from mx.upb.ro (unknown [141.85.13.240]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 43ee8c6d-77ef-45ab-b80b-157880e9e468; Mon, 23 Aug 2021 17:08:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 7CFEEB5600BF; Mon, 23 Aug 2021 20:03:11 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id LGNDaAA5lvfU; Mon, 23 Aug 2021 20:03:05 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 86157B56005B; Mon, 23 Aug 2021 20:03:05 +0300 (EEST) Received: from mx.upb.ro ([127.0.0.1]) by localhost (mx.upb.ro [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id zRvSgQiabKf3; Mon, 23 Aug 2021 20:03:05 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id ED5EEB5600C7; Mon, 23 Aug 2021 20:03:04 +0300 (EEST) 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: 43ee8c6d-77ef-45ab-b80b-157880e9e468 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu , Juergen Gross , Julien Grall Subject: [PATCH v3 4/4] libs/gnttab: Use XEN_PAGE_* definitions Date: Mon, 23 Aug 2021 20:02:56 +0300 Message-Id: <532a25ce59efa583b6e8bb3e258bd65058ba46c4.1629737453.git.costin.lupu@cs.pub.ro> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1629738540081100001 Content-Type: text/plain; charset="utf-8" These changes refine the changes in d1b32abd which added a dependency to xenctrl library. We use the XEN_PAGE_* definitions instead of the XC_PAGE_* definitions and therefore we get rid of the unnecessary dependency. Signed-off-by: Costin Lupu --- tools/libs/gnttab/Makefile | 2 ++ tools/libs/gnttab/freebsd.c | 19 +++++++++---------- tools/libs/gnttab/linux.c | 19 +++++++++---------- tools/libs/gnttab/netbsd.c | 19 +++++++++---------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tools/libs/gnttab/Makefile b/tools/libs/gnttab/Makefile index ae390ce60f..a884860378 100644 --- a/tools/libs/gnttab/Makefile +++ b/tools/libs/gnttab/Makefile @@ -13,4 +13,6 @@ SRCS-$(CONFIG_FreeBSD) +=3D $(SRCS-GNTTAB) $(SRCS-GNTSHR)= freebsd.c SRCS-$(CONFIG_NetBSD) +=3D $(SRCS-GNTTAB) $(SRCS-GNTSHR) netbsd.c SRCS-$(CONFIG_SunOS) +=3D gnttab_unimp.c gntshr_unimp.c =20 +CFLAGS +=3D -D__XEN_TOOLS__ + include $(XEN_ROOT)/tools/libs/libs.mk diff --git a/tools/libs/gnttab/freebsd.c b/tools/libs/gnttab/freebsd.c index e42ac3fbf3..548e21361d 100644 --- a/tools/libs/gnttab/freebsd.c +++ b/tools/libs/gnttab/freebsd.c @@ -30,7 +30,6 @@ =20 #include =20 -#include #include =20 #include "private.h" @@ -74,7 +73,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, int domids_stride; unsigned int refs_size =3D ROUNDUP(count * sizeof(struct ioctl_gntdev_grant_ref), - XC_PAGE_SHIFT); + XEN_PAGE_SHIFT); int os_page_size =3D getpagesize(); =20 domids_stride =3D (flags & XENGNTTAB_GRANT_MAP_SINGLE_DOMAIN) ? 0 : 1; @@ -105,7 +104,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, goto out; } =20 - addr =3D mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd, + addr =3D mmap(NULL, XEN_PAGE_SIZE * count, prot, MAP_SHARED, fd, map.index); if ( addr !=3D MAP_FAILED ) { @@ -114,7 +113,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, =20 notify.index =3D map.index; notify.action =3D 0; - if ( notify_offset < XC_PAGE_SIZE * count ) + if ( notify_offset < XEN_PAGE_SIZE * count ) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -129,7 +128,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, if ( rv ) { GTERROR(xgt->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(addr, count * XC_PAGE_SIZE); + munmap(addr, count * XEN_PAGE_SIZE); addr =3D MAP_FAILED; } } @@ -187,7 +186,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - if ( (rc =3D munmap(start_address, count * XC_PAGE_SIZE)) ) + if ( (rc =3D munmap(start_address, count * XEN_PAGE_SIZE)) ) return rc; =20 /* Finally, unmap the driver slots used to store the grant information= . */ @@ -254,7 +253,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, goto out; } =20 - area =3D mmap(NULL, count * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_= SHARED, + area =3D mmap(NULL, count * XEN_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP= _SHARED, fd, gref_info.index); =20 if ( area =3D=3D MAP_FAILED ) @@ -266,7 +265,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, =20 notify.index =3D gref_info.index; notify.action =3D 0; - if ( notify_offset < XC_PAGE_SIZE * count ) + if ( notify_offset < XEN_PAGE_SIZE * count ) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -281,7 +280,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, if ( err ) { GSERROR(xgs->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(area, count * XC_PAGE_SIZE); + munmap(area, count * XEN_PAGE_SIZE); area =3D NULL; } =20 @@ -304,7 +303,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, int osdep_gntshr_unshare(xengntshr_handle *xgs, void *start_address, uint32_t count) { - return munmap(start_address, count * XC_PAGE_SIZE); + return munmap(start_address, count * XEN_PAGE_SIZE); } =20 /* diff --git a/tools/libs/gnttab/linux.c b/tools/libs/gnttab/linux.c index 5628fd5719..064aa3097f 100644 --- a/tools/libs/gnttab/linux.c +++ b/tools/libs/gnttab/linux.c @@ -32,7 +32,6 @@ #include #include =20 -#include #include =20 #include "private.h" @@ -101,7 +100,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, map =3D alloca(map_size); else { - map_size =3D ROUNDUP(map_size, XC_PAGE_SHIFT); + map_size =3D ROUNDUP(map_size, XEN_PAGE_SHIFT); map =3D mmap(NULL, map_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_POPULATE, -1, 0); if ( map =3D=3D MAP_FAILED ) @@ -125,7 +124,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 retry: - addr =3D mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd, + addr =3D mmap(NULL, XEN_PAGE_SIZE * count, prot, MAP_SHARED, fd, map->index); =20 if (addr =3D=3D MAP_FAILED && errno =3D=3D EAGAIN) @@ -150,7 +149,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, struct ioctl_gntdev_unmap_notify notify; notify.index =3D map->index; notify.action =3D 0; - if (notify_offset < XC_PAGE_SIZE * count) { + if (notify_offset < XEN_PAGE_SIZE * count) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; } @@ -162,7 +161,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, rv =3D ioctl(fd, IOCTL_GNTDEV_SET_UNMAP_NOTIFY, ¬ify); if (rv) { GTERROR(xgt->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(addr, count * XC_PAGE_SIZE); + munmap(addr, count * XEN_PAGE_SIZE); addr =3D MAP_FAILED; } } @@ -218,7 +217,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - if ( (rc =3D munmap(start_address, count * XC_PAGE_SIZE)) ) + if ( (rc =3D munmap(start_address, count * XEN_PAGE_SIZE)) ) return rc; =20 /* Finally, unmap the driver slots used to store the grant information= . */ @@ -464,7 +463,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, goto out; } =20 - area =3D mmap(NULL, count * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, + area =3D mmap(NULL, count * XEN_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, gref_info->index); =20 if (area =3D=3D MAP_FAILED) { @@ -475,7 +474,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, =20 notify.index =3D gref_info->index; notify.action =3D 0; - if (notify_offset < XC_PAGE_SIZE * count) { + if (notify_offset < XEN_PAGE_SIZE * count) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; } @@ -487,7 +486,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, err =3D ioctl(fd, IOCTL_GNTALLOC_SET_UNMAP_NOTIFY, ¬ify); if (err) { GSERROR(xgs->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(area, count * XC_PAGE_SIZE); + munmap(area, count * XEN_PAGE_SIZE); area =3D NULL; } =20 @@ -508,7 +507,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, int osdep_gntshr_unshare(xengntshr_handle *xgs, void *start_address, uint32_t count) { - return munmap(start_address, count * XC_PAGE_SIZE); + return munmap(start_address, count * XEN_PAGE_SIZE); } =20 /* diff --git a/tools/libs/gnttab/netbsd.c b/tools/libs/gnttab/netbsd.c index a4ad624b54..b88dbcb49b 100644 --- a/tools/libs/gnttab/netbsd.c +++ b/tools/libs/gnttab/netbsd.c @@ -28,7 +28,6 @@ #include #include =20 -#include #include #include =20 @@ -84,19 +83,19 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 map.count =3D count; - addr =3D mmap(NULL, count * XC_PAGE_SIZE, + addr =3D mmap(NULL, count * XEN_PAGE_SIZE, prot, flags | MAP_ANON | MAP_SHARED, -1, 0); if ( map.va =3D=3D MAP_FAILED ) { GTERROR(xgt->logger, "osdep_gnttab_grant_map: mmap failed"); - munmap((void *)map.va, count * XC_PAGE_SIZE); + munmap((void *)map.va, count * XEN_PAGE_SIZE); addr =3D MAP_FAILED; } map.va =3D addr; =20 map.notify.offset =3D 0; map.notify.action =3D 0; - if ( notify_offset < XC_PAGE_SIZE * count ) + if ( notify_offset < XEN_PAGE_SIZE * count ) { map.notify.offset =3D notify_offset; map.notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -112,7 +111,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, { GTERROR(xgt->logger, "ioctl IOCTL_GNTDEV_MMAP_GRANT_REF failed: %d", rv); - munmap(addr, count * XC_PAGE_SIZE); + munmap(addr, count * XEN_PAGE_SIZE); addr =3D MAP_FAILED; } =20 @@ -133,7 +132,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - rc =3D munmap(start_address, count * XC_PAGE_SIZE); + rc =3D munmap(start_address, count * XEN_PAGE_SIZE); =20 return rc; } @@ -184,7 +183,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, alloc.domid =3D domid; alloc.flags =3D writable ? GNTDEV_ALLOC_FLAG_WRITABLE : 0; alloc.count =3D count; - area =3D mmap(NULL, count * XC_PAGE_SIZE, + area =3D mmap(NULL, count * XEN_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); =20 if ( area =3D=3D MAP_FAILED ) @@ -197,7 +196,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, =20 alloc.notify.offset =3D 0; alloc.notify.action =3D 0; - if ( notify_offset < XC_PAGE_SIZE * count ) + if ( notify_offset < XEN_PAGE_SIZE * count ) { alloc.notify.offset =3D notify_offset; alloc.notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -212,7 +211,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, if ( err ) { GSERROR(xgs->logger, "IOCTL_GNTDEV_ALLOC_GRANT_REF failed"); - munmap(area, count * XC_PAGE_SIZE); + munmap(area, count * XEN_PAGE_SIZE); area =3D MAP_FAILED; goto out; } @@ -227,7 +226,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, int osdep_gntshr_unshare(xengntshr_handle *xgs, void *start_address, uint32_t count) { - return munmap(start_address, count * XC_PAGE_SIZE); + return munmap(start_address, count * XEN_PAGE_SIZE); } =20 /* --=20 2.20.1