From nobody Sat Nov 30 00:46:01 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 ARC-Seal: i=1; a=rsa-sha256; t=1620635747; cv=none; d=zohomail.com; s=zohoarc; b=EWGsEcXbuz8jYHcJsI3XKByWbNyFyOtYdmngDO9UzY11nriLpPAOvnkJpfcNU86pwKtg8eI7NvzOOiub2nqGN2Gm1xqcQopqyZOAWC4DOiNVD9CLHZOEoqfooAn5aTmvT8W70eIXJBrTN5fFq5ONUG236w1hVTI/6ip0zzgvocM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620635747; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xqufeqv5aGgAiK0RzE0BOImnf4SbXkQWoM0u/vQb4RE=; b=GAUMYTENYmE7RdJTdDqCYguRw+FkTs/DCmr4JPBg4NHvi96HEiCO0VZ4a7VMkcQw9mqpfSgNs7BAt2JlIXfUzy6neXK7jmbN6USTPCNrO6Cg3++UC9FrZLg+Oi7qiB0joUOSf+gZwTo1MmUXU1Zb7cEE7DPyusfKL2f+X/akG4E= ARC-Authentication-Results: i=1; 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 1620635746728818.9333887309125; Mon, 10 May 2021 01:35:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.124909.235149 (Exim 4.92) (envelope-from ) id 1lg1O0-0002i8-AB; Mon, 10 May 2021 08:35:32 +0000 Received: by outflank-mailman (output) from mailman id 124909.235149; Mon, 10 May 2021 08:35:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1O0-0002h4-57; Mon, 10 May 2021 08:35:32 +0000 Received: by outflank-mailman (input) for mailman id 124909; Mon, 10 May 2021 08:35:30 +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 1lg1Ny-0002eE-Nx for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:35:30 +0000 Received: from mx.upb.ro (unknown [141.85.13.200]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 241b6232-d9e7-4af3-824a-d845635745e5; Mon, 10 May 2021 08:35:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id A5B8FB560125; Mon, 10 May 2021 11:35:28 +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 il_eQ4xYdlLU; Mon, 10 May 2021 11:35:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 9983AB560122; Mon, 10 May 2021 11:35:25 +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 CD1RpKBsSRw4; Mon, 10 May 2021 11:35:25 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 3BC0AB560126; Mon, 10 May 2021 11:35:25 +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: 241b6232-d9e7-4af3-824a-d845635745e5 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu Subject: [PATCH v3 3/5] tools/libs/foreignmemory: Fix PAGE_SIZE redefinition error Date: Mon, 10 May 2021 11:35:17 +0300 Message-Id: <2040286fc39b7e1d46376a8e75ac59d8d3be5aff.1620633386.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 Content-Type: text/plain; charset="utf-8" If PAGE_SIZE is already defined in the system (e.g. in /usr/include/limits.h header) then gcc will trigger a redefinition error because of -Werror. This patch replaces usage of PAGE_* macros with XC_PAGE_* macros in order to avo= id confusion between control domain page granularity (PAGE_* definitions) and guest domain page granularity (which is what we are dealing with here). Signed-off-by: Costin Lupu --- tools/libs/foreignmemory/core.c | 2 +- tools/libs/foreignmemory/freebsd.c | 10 +++++----- tools/libs/foreignmemory/linux.c | 23 ++++++++++++----------- tools/libs/foreignmemory/minios.c | 2 +- tools/libs/foreignmemory/netbsd.c | 10 +++++----- tools/libs/foreignmemory/private.h | 9 +-------- 6 files changed, 25 insertions(+), 31 deletions(-) diff --git a/tools/libs/foreignmemory/core.c b/tools/libs/foreignmemory/cor= e.c index 28ec311af1..7edc6f0dbf 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 << PAGE_SHIFT; + *size =3D fres.nr_frames << XC_PAGE_SHIFT; return 0; } =20 diff --git a/tools/libs/foreignmemory/freebsd.c b/tools/libs/foreignmemory/= freebsd.c index d94ea07862..2cf0fa1c38 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 << PAGE_SHIFT, prot, flags | MAP_SHARED, fd, 0= ); + addr =3D mmap(addr, num << XC_PAGE_SHIFT, prot, flags | MAP_SHARED, fd= , 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 << PAGE_SHIFT); + (void)munmap(addr, num << XC_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 << PAGE_SHIFT); + return munmap(addr, num << XC_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 << PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XC_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 << PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_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 c1f35e2db7..a5f6d62567 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< PAGE_SIZE ) + if ( pfn_arr_size > os_page_size ) munmap(pfn, pfn_arr_size); =20 if ( rc =3D=3D -ENOENT && i =3D=3D num ) @@ -270,7 +271,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handl= e *fmem, { int saved_errno =3D errno; =20 - (void)munmap(addr, num << PAGE_SHIFT); + (void)munmap(addr, num << XC_PAGE_SHIFT); errno =3D saved_errno; return NULL; } @@ -281,7 +282,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 << PAGE_SHIFT); + return munmap(addr, num << XC_PAGE_SHIFT); } =20 int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem, @@ -293,7 +294,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 << PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XC_PAGE_SHIFT) : 0; } =20 int osdep_xenforeignmemory_map_resource( @@ -312,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 << PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_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 43341ca301..c5453736d5 100644 --- a/tools/libs/foreignmemory/minios.c +++ b/tools/libs/foreignmemory/minios.c @@ -55,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 << PAGE_SHIFT); + return munmap(addr, num << XC_PAGE_SHIFT); } =20 /* diff --git a/tools/libs/foreignmemory/netbsd.c b/tools/libs/foreignmemory/n= etbsd.c index c0b1b8f79d..597db775d7 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 * PAGE_SIZE, prot, + addr =3D mmap(addr, num * XC_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 * PAGE_SIZE); + munmap(addr, num * XC_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 * PAGE_SIZE); + return munmap(addr, num * XC_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 << PAGE_SHIFT) : 0; + return fres ? munmap(fres->addr, fres->nr_frames << XC_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 << PAGE_SHIFT, + fres->addr =3D mmap(fres->addr, fres->nr_frames << XC_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 1ee3626dd2..65fe77aa5b 100644 --- a/tools/libs/foreignmemory/private.h +++ b/tools/libs/foreignmemory/private.h @@ -1,6 +1,7 @@ #ifndef XENFOREIGNMEMORY_PRIVATE_H #define XENFOREIGNMEMORY_PRIVATE_H =20 +#include #include =20 #include @@ -10,14 +11,6 @@ #include #include =20 -#ifndef PAGE_SHIFT /* Mini-os, Yukk */ -#define PAGE_SHIFT 12 -#endif -#ifndef __MINIOS__ /* Yukk */ -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) -#endif - struct xenforeignmemory_handle { xentoollog_logger *logger, *logger_tofree; unsigned flags; --=20 2.20.1