From nobody Sun Apr 28 03:47:09 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 16285205213601000.6312701714197; Mon, 9 Aug 2021 07:48:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.165020.301569 (Exim 4.92) (envelope-from ) id 1mD6Zm-0006BL-Ga; Mon, 09 Aug 2021 14:48:26 +0000 Received: by outflank-mailman (output) from mailman id 165020.301569; Mon, 09 Aug 2021 14: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 1mD6Zm-0006BA-D7; Mon, 09 Aug 2021 14:48:26 +0000 Received: by outflank-mailman (input) for mailman id 165020; Mon, 09 Aug 2021 14:48:24 +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 1mD6Zk-0005Xf-Gr for xen-devel@lists.xenproject.org; Mon, 09 Aug 2021 14:48:24 +0000 Received: from mx.upb.ro (unknown [141.85.13.231]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d27da33e-f920-11eb-9f1d-12813bfff9fa; Mon, 09 Aug 2021 14:48:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 212E3B56008E; Mon, 9 Aug 2021 17:48:13 +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 5XriUPtlryBL; Mon, 9 Aug 2021 17:48:10 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 4CA23B5600A7; Mon, 9 Aug 2021 17:48:10 +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 R56SC_X4Ih3V; Mon, 9 Aug 2021 17:48:10 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 2DDA7B56008E; Mon, 9 Aug 2021 17:48:09 +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: d27da33e-f920-11eb-9f1d-12813bfff9fa 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 1/4] public: Add page related definitions for accessing guests memory Date: Mon, 9 Aug 2021 17:47:56 +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: 1628520523886100001 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. For this patch we set the same values for both x86 and ARM architectures. Signed-off-by: Costin Lupu --- xen/include/public/arch-arm/page.h | 34 ++++++++++++++++++++++++++ xen/include/public/arch-x86/page.h | 34 ++++++++++++++++++++++++++ xen/include/public/page.h | 38 ++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 xen/include/public/arch-arm/page.h create mode 100644 xen/include/public/arch-x86/page.h create mode 100644 xen/include/public/page.h diff --git a/xen/include/public/arch-arm/page.h b/xen/include/public/arch-a= rm/page.h new file mode 100644 index 0000000000..e970feb49c --- /dev/null +++ b/xen/include/public/arch-arm/page.h @@ -0,0 +1,34 @@ +/*************************************************************************= ***** + * page.h + * + * Page definitions for accessing guests memory on ARM + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation = the + * rights to use, copy, modify, merge, publish, distribute, sublicense, an= d/or + * sell copies of the Software, and to permit persons to whom the Software= is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL= THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2021, Costin Lupu + */ + +#ifndef __XEN_PUBLIC_ARCH_ARM_PAGE_H__ +#define __XEN_PUBLIC_ARCH_ARM_PAGE_H__ + +#define XEN_PAGE_SHIFT 12 +#define XEN_PAGE_SIZE (1UL << XEN_PAGE_SHIFT) +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) + +#endif /* __XEN_PUBLIC_ARCH_ARM_PAGE_H__ */ diff --git a/xen/include/public/arch-x86/page.h b/xen/include/public/arch-x= 86/page.h new file mode 100644 index 0000000000..b1924ea3cb --- /dev/null +++ b/xen/include/public/arch-x86/page.h @@ -0,0 +1,34 @@ +/*************************************************************************= ***** + * page.h + * + * Page definitions for accessing guests memory on x86 + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation = the + * rights to use, copy, modify, merge, publish, distribute, sublicense, an= d/or + * sell copies of the Software, and to permit persons to whom the Software= is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL= THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2021, Costin Lupu + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_PAGE_H__ +#define __XEN_PUBLIC_ARCH_X86_PAGE_H__ + +#define XEN_PAGE_SHIFT 12 +#define XEN_PAGE_SIZE (1UL << XEN_PAGE_SHIFT) +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) + +#endif /* __XEN_PUBLIC_ARCH_X86_PAGE_H__ */ diff --git a/xen/include/public/page.h b/xen/include/public/page.h new file mode 100644 index 0000000000..d3e95fdb4a --- /dev/null +++ b/xen/include/public/page.h @@ -0,0 +1,38 @@ +/*************************************************************************= ***** + * page.h + * + * Page definitions for accessing guests memory + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation = the + * rights to use, copy, modify, merge, publish, distribute, sublicense, an= d/or + * sell copies of the Software, and to permit persons to whom the Software= is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL= THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2021, Costin Lupu + */ + +#ifndef __XEN_PUBLIC_PAGE_H__ +#define __XEN_PUBLIC_PAGE_H__ + +#if defined(__i386__) || defined(__x86_64__) +#include "arch-x86/page.h" +#elif defined (__arm__) || defined (__aarch64__) +#include "arch-arm/page.h" +#else +#error "Unsupported architecture" +#endif + +#endif /* __XEN_PUBLIC_PAGE_H__ */ --=20 2.20.1 From nobody Sun Apr 28 03:47:09 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 1628520514016997.7442428454002; Mon, 9 Aug 2021 07:48:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.165019.301558 (Exim 4.92) (envelope-from ) id 1mD6Zh-0005qb-8b; Mon, 09 Aug 2021 14:48:21 +0000 Received: by outflank-mailman (output) from mailman id 165019.301558; Mon, 09 Aug 2021 14:48:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mD6Zh-0005qU-4S; Mon, 09 Aug 2021 14:48:21 +0000 Received: by outflank-mailman (input) for mailman id 165019; Mon, 09 Aug 2021 14:48:19 +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 1mD6Zf-0005Xf-Ge for xen-devel@lists.xenproject.org; Mon, 09 Aug 2021 14:48:19 +0000 Received: from mx.upb.ro (unknown [141.85.13.221]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d27da33c-f920-11eb-9f1d-12813bfff9fa; Mon, 09 Aug 2021 14:48:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id CE741B5600AA; Mon, 9 Aug 2021 17:48:12 +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 CAUH5v2Ckw_F; Mon, 9 Aug 2021 17:48:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 1CFBBB56008E; Mon, 9 Aug 2021 17:48:11 +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 hRHX9oMMHtlN; Mon, 9 Aug 2021 17:48:11 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 446D8B560068; Mon, 9 Aug 2021 17:48:10 +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: d27da33c-f920-11eb-9f1d-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 2/4] libs/ctrl: Use Xen values for XC_PAGE_* definitions Date: Mon, 9 Aug 2021 17:47:57 +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: 1628520515372100003 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 14adaa0c10..90bb969fa0 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -54,10 +54,11 @@ #include #include #endif +#include =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 Sun Apr 28 03:47:09 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 1628521640292884.8538157090525; Mon, 9 Aug 2021 08:07:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.165036.301591 (Exim 4.92) (envelope-from ) id 1mD6rk-0001KX-FW; Mon, 09 Aug 2021 15:07:00 +0000 Received: by outflank-mailman (output) from mailman id 165036.301591; Mon, 09 Aug 2021 15:07:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mD6rk-0001KQ-CI; Mon, 09 Aug 2021 15:07:00 +0000 Received: by outflank-mailman (input) for mailman id 165036; Mon, 09 Aug 2021 15:06:59 +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 1mD6rj-0001KE-Jk for xen-devel@lists.xenproject.org; Mon, 09 Aug 2021 15:06:59 +0000 Received: from mx.upb.ro (unknown [141.85.13.221]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 70d0b23e-f923-11eb-9f1f-12813bfff9fa; Mon, 09 Aug 2021 15:06:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id D266AB5600A7; Mon, 9 Aug 2021 17:48:14 +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 RX58a2PqFQni; Mon, 9 Aug 2021 17:48:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id B2EDDB560090; Mon, 9 Aug 2021 17:48:11 +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 XQQYJsvFPE4s; Mon, 9 Aug 2021 17:48:11 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id 1E081B5600A8; Mon, 9 Aug 2021 17:48:11 +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: 70d0b23e-f923-11eb-9f1f-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 3/4] libs/foreignmemory: Use XEN_PAGE_* definitions Date: Mon, 9 Aug 2021 17:47:58 +0300 Message-Id: <35028145d07cde5e53e4ab20dc492ec322c92c2f.1628519855.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: 1628521641990100003 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/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 | 2 +- tools/libs/foreignmemory/solaris.c | 6 +++--- 7 files changed, 25 insertions(+), 33 deletions(-) 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..1200f98067 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 @@ -9,6 +8,7 @@ #include =20 #include +#include #include =20 struct xenforeignmemory_handle { 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 Sun Apr 28 03:47:09 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 1628521639028353.92907942025; Mon, 9 Aug 2021 08:07:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.165037.301602 (Exim 4.92) (envelope-from ) id 1mD6rl-0001ab-OO; Mon, 09 Aug 2021 15:07:01 +0000 Received: by outflank-mailman (output) from mailman id 165037.301602; Mon, 09 Aug 2021 15:07:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mD6rl-0001aU-Jz; Mon, 09 Aug 2021 15:07:01 +0000 Received: by outflank-mailman (input) for mailman id 165037; Mon, 09 Aug 2021 15:07:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mD6rk-0001KK-1k for xen-devel@lists.xenproject.org; Mon, 09 Aug 2021 15:07:00 +0000 Received: from mx.upb.ro (unknown [141.85.13.241]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 953f0b97-ee21-47d4-8146-650a65c50865; Mon, 09 Aug 2021 15:06:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 5A993B560090; Mon, 9 Aug 2021 17:48:15 +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 9X2BcH-RbmhP; Mon, 9 Aug 2021 17:48:12 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 55FF4B5600A8; Mon, 9 Aug 2021 17:48:12 +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 aUEKkMcYF0mA; Mon, 9 Aug 2021 17:48:12 +0300 (EEST) Received: from localhost.localdomain (unknown [86.121.144.181]) by mx.upb.ro (Postfix) with ESMTPSA id BB964B5600AA; Mon, 9 Aug 2021 17:48:11 +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: 953f0b97-ee21-47d4-8146-650a65c50865 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 4/4] libs/gnttab: Use XEN_PAGE_* definitions Date: Mon, 9 Aug 2021 17:47:59 +0300 Message-Id: <6928b89e08bcade24cee4c874d489f02d48083af.1628519855.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: 1628521640186100001 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/freebsd.c | 20 ++++++++++---------- tools/libs/gnttab/linux.c | 20 ++++++++++---------- tools/libs/gnttab/netbsd.c | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tools/libs/gnttab/freebsd.c b/tools/libs/gnttab/freebsd.c index e42ac3fbf3..7ecb0e3b38 100644 --- a/tools/libs/gnttab/freebsd.c +++ b/tools/libs/gnttab/freebsd.c @@ -28,9 +28,9 @@ #include #include =20 +#include #include =20 -#include #include =20 #include "private.h" @@ -74,7 +74,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 +105,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 +114,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 +129,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 +187,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 +254,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 +266,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 +281,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 +304,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..11f1acb771 100644 --- a/tools/libs/gnttab/linux.c +++ b/tools/libs/gnttab/linux.c @@ -29,10 +29,10 @@ #include #include =20 +#include #include #include =20 -#include #include =20 #include "private.h" @@ -101,7 +101,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 +125,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 +150,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 +162,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 +218,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 +464,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 +475,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 +487,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 +508,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..beb94be468 100644 --- a/tools/libs/gnttab/netbsd.c +++ b/tools/libs/gnttab/netbsd.c @@ -28,8 +28,8 @@ #include #include =20 -#include #include +#include #include =20 #include "private.h" @@ -84,19 +84,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 +112,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 +133,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 +184,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 +197,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 +212,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 +227,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