From nobody Fri Nov 29 22:32:51 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=1620635750; cv=none; d=zohomail.com; s=zohoarc; b=PHXIjr4DUVRqU8MkeEsVTwu7bS+67wkBAr7LKlPikHpFUnXR50IEnzIEK8N+EHkbUipeL70Pi2Jj3cuXAQ4Px+P1NMx6ey9szxmvzho6O1aXwq24M831tAydb+cLnp0alybmsStGE5mMfJsS/VAiW6V/pN9DalhL/kgPi+zgGfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620635750; 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=0GfgLNoSK23ElqIhOQsKyZTxWMphR1AiSLMleYL5sUs=; b=QtmSNRJ62zPV06c1JxdF4a7jukF+sfLaOU+MeJFNVphw8k7X0WQAMiJyFT6NniQTgnrPLerCdKeUY8v/ropYdYs32lY1i4VKzPONkIvWT2IYQq1miLmb+rOZHv+L+SaxYOd2WvQAQkJXy6RJWf9A79NEu/iAtBB2NxrQ+YTQBZg= 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 1620635750115914.596285674887; Mon, 10 May 2021 01:35:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.124910.235168 (Exim 4.92) (envelope-from ) id 1lg1O4-0003Ep-HI; Mon, 10 May 2021 08:35:36 +0000 Received: by outflank-mailman (output) from mailman id 124910.235168; Mon, 10 May 2021 08:35:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1O4-0003Ee-E8; Mon, 10 May 2021 08:35:36 +0000 Received: by outflank-mailman (input) for mailman id 124910; Mon, 10 May 2021 08:35:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1O3-0002e9-FW for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:35:35 +0000 Received: from mx.upb.ro (unknown [141.85.13.210]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a4c4f404-e686-4e6f-b88d-a6fdc9cc32f0; Mon, 10 May 2021 08:35:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 7186EB56007B; Mon, 10 May 2021 11:35:27 +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 s8ApT06jIE62; Mon, 10 May 2021 11:35:24 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id C15BEB560125; Mon, 10 May 2021 11:35:24 +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 wUFcqcURlskq; Mon, 10 May 2021 11:35:24 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 5A31DB56007B; Mon, 10 May 2021 11:35:24 +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: a4c4f404-e686-4e6f-b88d-a6fdc9cc32f0 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Tim Deegan , Ian Jackson , Wei Liu Subject: [PATCH v3 1/5] tools/debugger: Fix PAGE_SIZE redefinition error Date: Mon, 10 May 2021 11:35:15 +0300 Message-Id: <88d4d2deeca3259450dc9af2b97f2fc1453a5d7d.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 KDD_PAGE_* macros in order to av= oid confusion between control domain page granularity (PAGE_* definitions) and guest domain page granularity (which is what we are dealing with here). We chose to define the KDD_PAGE_* macros instead of using XC_PAGE_* macros because (1) the code in kdd.c should not include any Xen headers and (2) to= add consistency for code in both kdd.c and kdd-xen.c. Signed-off-by: Costin Lupu Reviewed-by: Tim Deegan --- tools/debugger/kdd/kdd-xen.c | 15 ++++++--------- tools/debugger/kdd/kdd.c | 19 ++++++++----------- tools/debugger/kdd/kdd.h | 7 +++++++ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/debugger/kdd/kdd-xen.c b/tools/debugger/kdd/kdd-xen.c index f3f9529f9f..e78c9311c4 100644 --- a/tools/debugger/kdd/kdd-xen.c +++ b/tools/debugger/kdd/kdd-xen.c @@ -48,9 +48,6 @@ =20 #define MAPSIZE 4093 /* Prime */ =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1U << PAGE_SHIFT) - struct kdd_guest { struct xentoollog_logger xc_log; /* Must be first for xc log callbacks= */ xc_interface *xc_handle; @@ -72,7 +69,7 @@ static void flush_maps(kdd_guest *g) int i; for (i =3D 0; i < MAPSIZE; i++) { if (g->maps[i] !=3D NULL) - munmap(g->maps[i], PAGE_SIZE); + munmap(g->maps[i], KDD_PAGE_SIZE); g->maps[i] =3D NULL; } } @@ -490,13 +487,13 @@ static uint32_t kdd_access_physical_page(kdd_guest *g= , uint64_t addr, uint32_t map_pfn, map_offset; uint8_t *map; =20 - map_pfn =3D (addr >> PAGE_SHIFT); - map_offset =3D addr & (PAGE_SIZE - 1); + map_pfn =3D (addr >> KDD_PAGE_SHIFT); + map_offset =3D addr & (KDD_PAGE_SIZE - 1); =20 /* Evict any mapping of the wrong frame from our slot */=20 if (g->pfns[map_pfn % MAPSIZE] !=3D map_pfn && g->maps[map_pfn % MAPSIZE] !=3D NULL) { - munmap(g->maps[map_pfn % MAPSIZE], PAGE_SIZE); + munmap(g->maps[map_pfn % MAPSIZE], KDD_PAGE_SIZE); g->maps[map_pfn % MAPSIZE] =3D NULL; } g->pfns[map_pfn % MAPSIZE] =3D map_pfn; @@ -507,7 +504,7 @@ static uint32_t kdd_access_physical_page(kdd_guest *g, = uint64_t addr, else { map =3D xc_map_foreign_range(g->xc_handle, g->domid, - PAGE_SIZE, + KDD_PAGE_SIZE, PROT_READ|PROT_WRITE, map_pfn); =20 @@ -533,7 +530,7 @@ uint32_t kdd_access_physical(kdd_guest *g, uint64_t add= r, { uint32_t chunk, rv, done =3D 0; while (len > 0) { - chunk =3D PAGE_SIZE - (addr & (PAGE_SIZE - 1)); + chunk =3D KDD_PAGE_SIZE - (addr & (KDD_PAGE_SIZE - 1)); if (chunk > len)=20 chunk =3D len; rv =3D kdd_access_physical_page(g, addr, chunk, buf, write); diff --git a/tools/debugger/kdd/kdd.c b/tools/debugger/kdd/kdd.c index 17513c2650..320c623eda 100644 --- a/tools/debugger/kdd/kdd.c +++ b/tools/debugger/kdd/kdd.c @@ -288,9 +288,6 @@ static void kdd_log_pkt(kdd_state *s, const char *name,= kdd_pkt *p) * Memory access: virtual addresses and syntactic sugar. */ =20 -#define PAGE_SHIFT (12) -#define PAGE_SIZE (1ULL << PAGE_SHIFT)=20 - static uint32_t kdd_read_physical(kdd_state *s, uint64_t addr,=20 uint32_t len, void *buf) { @@ -352,7 +349,7 @@ static uint64_t v2p(kdd_state *s, int cpuid, uint64_t v= a) =20 /* Walk the appropriate number of levels */ for (i =3D levels; i > 0; i--) { - shift =3D PAGE_SHIFT + bits * (i-1); + shift =3D KDD_PAGE_SHIFT + bits * (i-1); mask =3D ((1ULL << bits) - 1) << shift; offset =3D ((va & mask) >> shift) * width; KDD_DEBUG(s, "level %i: mask 0x%16.16"PRIx64" pa 0x%16.16"PRIx64 @@ -364,12 +361,12 @@ static uint64_t v2p(kdd_state *s, int cpuid, uint64_t= va) return -1ULL; // Not present pa =3D entry & 0x000ffffffffff000ULL; if (pse && (i =3D=3D 2) && (entry & 0x80)) { // Superpage - mask =3D ((1ULL << (PAGE_SHIFT + bits)) - 1); + mask =3D ((1ULL << (KDD_PAGE_SHIFT + bits)) - 1); return (pa & ~mask) + (va & mask); } } =20 - return pa + (va & (PAGE_SIZE - 1)); + return pa + (va & (KDD_PAGE_SIZE - 1)); } =20 static uint32_t kdd_access_virtual(kdd_state *s, int cpuid, uint64_t addr, @@ -380,7 +377,7 @@ static uint32_t kdd_access_virtual(kdd_state *s, int cp= uid, uint64_t addr, =20 /* Process one page at a time */ while (len > 0) { - chunk =3D PAGE_SIZE - (addr & (PAGE_SIZE - 1)); + chunk =3D KDD_PAGE_SIZE - (addr & (KDD_PAGE_SIZE - 1)); if (chunk > len)=20 chunk =3D len; pa =3D v2p(s, cpuid, addr); @@ -591,7 +588,7 @@ static void get_os_info_64(kdd_state *s) uint64_t dbgkd_addr; DBGKD_GET_VERSION64 dbgkd_get_version64; /* Maybe 1GB is too big for the limit to search? */ - uint32_t search_limit =3D (1024 * 1024 * 1024) / PAGE_SIZE; /*1GB/Page= Size*/ + uint32_t search_limit =3D (1024 * 1024 * 1024) / KDD_PAGE_SIZE; /*1GB/= PageSize*/ uint64_t efer; =20 /* if we are not in 64-bit mode, fail */ @@ -620,7 +617,7 @@ static void get_os_info_64(kdd_state *s) * in 1GB range above the current page base address */ =20 - base =3D idt0_addr & ~(PAGE_SIZE - 1); + base =3D idt0_addr & ~(KDD_PAGE_SIZE - 1); =20 while (search_limit) { uint16_t val; @@ -633,7 +630,7 @@ static void get_os_info_64(kdd_state *s) if (val =3D=3D MZ_HEADER) // MZ break; =20 - base -=3D PAGE_SIZE; + base -=3D KDD_PAGE_SIZE; search_limit -=3D 1; } =20 @@ -720,7 +717,7 @@ static void find_os(kdd_state *s) /* Try each page in the potential range of kernel load addresses */ for (limit =3D s->os.base + s->os.range; s->os.base <=3D limit; - s->os.base +=3D PAGE_SIZE) + s->os.base +=3D KDD_PAGE_SIZE) if (check_os(s)) return; } diff --git a/tools/debugger/kdd/kdd.h b/tools/debugger/kdd/kdd.h index b9a17440df..b476a76d93 100644 --- a/tools/debugger/kdd/kdd.h +++ b/tools/debugger/kdd/kdd.h @@ -39,6 +39,13 @@ =20 #define PACKED __attribute__((packed)) =20 +/* We define our page related constants here in order to specifically + * avoid using the Xen page macros (this is a restriction for the code + * in kdd.c which should not include any Xen headers) and to add + * consistency for code in both kdd.c and kdd-xen.c. */ +#define KDD_PAGE_SHIFT 12 +#define KDD_PAGE_SIZE (1U << KDD_PAGE_SHIFT) + /*************************************************************************= **** * Serial line protocol: Sender sends a 16-byte header with an optional * payload following it. Receiver responds to each packet with an --=20 2.20.1 From nobody Fri Nov 29 22:32:51 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=1620635750; cv=none; d=zohomail.com; s=zohoarc; b=W8hCuFTJxaPvgBT1fv8CvipY9wyePiy110430G12eVIRihWzxtL1Lxm2jn7RReFx1MIWAdnxt3p9c2qwr9JsTO/vg+QAb1+uf83PZ5cQ1sdOc+IlSBMSk+Zw3HFfAMIEY8orBVNYFdV5GlUaNbiRM2IJ2NVrtFS0+1UDTXgX8Tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620635750; 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=fHygASjvSRjFIB1H7AgjibCXITuuztQiig++c1gz138=; b=EwTEItPJU9QDYjob65RfH7C88svxAwUYaU3HD0+lOOpexSJLqDn5qaDLEM03oTMyP26PP2zNPa7mcsdrz+vRElPngisgF+NlXWLN95IdW+wQqD+RXwj3fb73oszR5fmEoHch2Eph0g4zypr5jbXJbB+2ntqLoxHzv5bslDSjPrs= 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 1620635750121382.61070440849926; Mon, 10 May 2021 01:35:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.124911.235180 (Exim 4.92) (envelope-from ) id 1lg1O6-0003X3-0I; Mon, 10 May 2021 08:35:38 +0000 Received: by outflank-mailman (output) from mailman id 124911.235180; Mon, 10 May 2021 08:35:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1O5-0003Ww-St; Mon, 10 May 2021 08:35:37 +0000 Received: by outflank-mailman (input) for mailman id 124911; Mon, 10 May 2021 08:35:35 +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 1lg1O3-0002eE-Mf for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:35:35 +0000 Received: from mx.upb.ro (unknown [141.85.13.200]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 735a8251-99c3-4a2c-a60a-16b009ac1d42; Mon, 10 May 2021 08:35:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 33A2AB560113; Mon, 10 May 2021 11:35:27 +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 PQJTuWJ9td-r; 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 3BA25B56007B; 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 IskPJ_eR65xH; 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 C0E1FB560122; Mon, 10 May 2021 11:35:24 +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: 735a8251-99c3-4a2c-a60a-16b009ac1d42 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu , Julien Grall Subject: [PATCH v3 2/5] tools/libfsimage: Fix PATH_MAX redefinition error Date: Mon, 10 May 2021 11:35:16 +0300 Message-Id: <25e3833a1335193dd98c7d2fbf80eebc17c3528e.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 PATH_MAX is already defined in the system (e.g. in /usr/include/limits.h header) then gcc will trigger a redefinition error because of -Werror. Signed-off-by: Costin Lupu Reviewed-by: Julien Grall --- tools/libfsimage/ext2fs/fsys_ext2fs.c | 2 ++ tools/libfsimage/reiserfs/fsys_reiserfs.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/libfsimage/ext2fs/fsys_ext2fs.c b/tools/libfsimage/ext2f= s/fsys_ext2fs.c index a4ed10419c..5ed8fce90e 100644 --- a/tools/libfsimage/ext2fs/fsys_ext2fs.c +++ b/tools/libfsimage/ext2fs/fsys_ext2fs.c @@ -278,7 +278,9 @@ struct ext4_extent_header { =20 #define EXT2_SUPER_MAGIC 0xEF53 /* include/linux/ext2_fs.h */ #define EXT2_ROOT_INO 2 /* include/linux/ext2_fs.h */ +#ifndef PATH_MAX #define PATH_MAX 1024 /* include/linux/limits.h */ +#endif #define MAX_LINK_COUNT 5 /* number of symbolic links to follow= */ =20 /* made up, these are pointers into FSYS_BUF */ diff --git a/tools/libfsimage/reiserfs/fsys_reiserfs.c b/tools/libfsimage/r= eiserfs/fsys_reiserfs.c index 916eb15292..10ca657476 100644 --- a/tools/libfsimage/reiserfs/fsys_reiserfs.c +++ b/tools/libfsimage/reiserfs/fsys_reiserfs.c @@ -284,7 +284,9 @@ struct reiserfs_de_head #define S_ISDIR(mode) (((mode) & 0170000) =3D=3D 0040000) #define S_ISLNK(mode) (((mode) & 0170000) =3D=3D 0120000) =20 +#ifndef PATH_MAX #define PATH_MAX 1024 /* include/linux/limits.h */ +#endif #define MAX_LINK_COUNT 5 /* number of symbolic links to follow */ =20 /* The size of the node cache */ --=20 2.20.1 From nobody Fri Nov 29 22:32:51 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 From nobody Fri Nov 29 22:32:51 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=1620635757; cv=none; d=zohomail.com; s=zohoarc; b=Qsw1yODuj3Vb4pWoQvl1fiYbpUfbyUgfOPWYrtaj8uwLAmAdzknHkqMj+uBZiLzI5hif+Pfs8nGzEWH3S8j52eTm9AGCgv0fAI+N4972KzlS7vmap/ZG9lLLlaQXhURbmYHHkkTMpFfEhCuB+qBpBfzVEqFU5xIGwhD7/PRgngo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620635757; 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=yN48WfrzvrTGy2WVmE1e0hnbzX/usxFd586vef3gAtM=; b=UEqz8R7PSmoKzkoKe0rI30JX/bkYUB9YS67YUOC15y/vLqsRSS+ytIhrcEQA3Ln49qZUp048NadRhbiMgsgDHhrt5QOZF28cWnA/vaq/PEFMCQgT+VDaWxNjmrnd407dZj8Cav3oIKquc2rqiYvSM21DPWrhQMHu16WwVXzFfk0= 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 1620635757824975.0550048236971; Mon, 10 May 2021 01:35:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.124912.235192 (Exim 4.92) (envelope-from ) id 1lg1OA-0003uM-AZ; Mon, 10 May 2021 08:35:42 +0000 Received: by outflank-mailman (output) from mailman id 124912.235192; Mon, 10 May 2021 08:35:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1OA-0003u9-6q; Mon, 10 May 2021 08:35:42 +0000 Received: by outflank-mailman (input) for mailman id 124912; Mon, 10 May 2021 08:35:40 +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 1lg1O8-0002eE-Mx for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:35:40 +0000 Received: from mx.upb.ro (unknown [141.85.13.210]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 76893116-5f30-4af4-b45e-129555ef27c2; Mon, 10 May 2021 08:35:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 0A56EB560122; Mon, 10 May 2021 11:35:30 +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 i0deq6r05gz0; Mon, 10 May 2021 11:35:26 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 032A8B56012B; Mon, 10 May 2021 11:35:26 +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 VLVtO8iOZMin; 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 9A686B56012A; 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: 76893116-5f30-4af4-b45e-129555ef27c2 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 4/5] tools/libs/gnttab: Fix PAGE_SIZE redefinition error Date: Mon, 10 May 2021 11:35:18 +0300 Message-Id: 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/gnttab/freebsd.c | 28 +++++++++++++--------------- tools/libs/gnttab/linux.c | 28 +++++++++++++--------------- tools/libs/gnttab/netbsd.c | 23 ++++++++++------------- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/tools/libs/gnttab/freebsd.c b/tools/libs/gnttab/freebsd.c index 768af701c6..e42ac3fbf3 100644 --- a/tools/libs/gnttab/freebsd.c +++ b/tools/libs/gnttab/freebsd.c @@ -30,14 +30,11 @@ =20 #include =20 +#include #include =20 #include "private.h" =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - #define DEVXEN "/dev/xen/gntdev" =20 int osdep_gnttab_open(xengnttab_handle *xgt) @@ -77,10 +74,11 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, int domids_stride; unsigned int refs_size =3D ROUNDUP(count * sizeof(struct ioctl_gntdev_grant_ref), - PAGE_SHIFT); + XC_PAGE_SHIFT); + int os_page_size =3D getpagesize(); =20 domids_stride =3D (flags & XENGNTTAB_GRANT_MAP_SINGLE_DOMAIN) ? 0 : 1; - if ( refs_size <=3D PAGE_SIZE ) + if ( refs_size <=3D os_page_size ) map.refs =3D malloc(refs_size); else { @@ -107,7 +105,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, goto out; } =20 - addr =3D mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, fd, + addr =3D mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd, map.index); if ( addr !=3D MAP_FAILED ) { @@ -116,7 +114,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, =20 notify.index =3D map.index; notify.action =3D 0; - if ( notify_offset < PAGE_SIZE * count ) + if ( notify_offset < XC_PAGE_SIZE * count ) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -131,7 +129,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, if ( rv ) { GTERROR(xgt->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(addr, count * PAGE_SIZE); + munmap(addr, count * XC_PAGE_SIZE); addr =3D MAP_FAILED; } } @@ -150,7 +148,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 out: - if ( refs_size > PAGE_SIZE ) + if ( refs_size > os_page_size ) munmap(map.refs, refs_size); else free(map.refs); @@ -189,7 +187,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - if ( (rc =3D munmap(start_address, count * PAGE_SIZE)) ) + if ( (rc =3D munmap(start_address, count * XC_PAGE_SIZE)) ) return rc; =20 /* Finally, unmap the driver slots used to store the grant information= . */ @@ -256,7 +254,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, goto out; } =20 - area =3D mmap(NULL, count * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHA= RED, + area =3D mmap(NULL, count * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_= SHARED, fd, gref_info.index); =20 if ( area =3D=3D MAP_FAILED ) @@ -268,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 < PAGE_SIZE * count ) + if ( notify_offset < XC_PAGE_SIZE * count ) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -283,7 +281,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, if ( err ) { GSERROR(xgs->logger, "ioctl SET_UNMAP_NOTIFY failed"); - munmap(area, count * PAGE_SIZE); + munmap(area, count * XC_PAGE_SIZE); area =3D NULL; } =20 @@ -306,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 * PAGE_SIZE); + return munmap(start_address, count * XC_PAGE_SIZE); } =20 /* diff --git a/tools/libs/gnttab/linux.c b/tools/libs/gnttab/linux.c index 74331a4c7b..9ce27bee6e 100644 --- a/tools/libs/gnttab/linux.c +++ b/tools/libs/gnttab/linux.c @@ -32,14 +32,11 @@ #include #include =20 +#include #include =20 #include "private.h" =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - #define DEVXEN "/dev/xen/" =20 #ifndef O_CLOEXEC @@ -92,6 +89,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, int fd =3D xgt->fd; struct ioctl_gntdev_map_grant_ref *map; unsigned int map_size =3D sizeof(*map) + (count - 1) * sizeof(map->ref= s[0]); + int os_page_size =3D getpagesize(); void *addr =3D NULL; int domids_stride =3D 1; int i; @@ -99,11 +97,11 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, if (flags & XENGNTTAB_GRANT_MAP_SINGLE_DOMAIN) domids_stride =3D 0; =20 - if ( map_size <=3D PAGE_SIZE ) + if ( map_size <=3D os_page_size ) map =3D alloca(map_size); else { - map_size =3D ROUNDUP(map_size, PAGE_SHIFT); + map_size =3D ROUNDUP(map_size, XC_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 ) @@ -127,7 +125,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 retry: - addr =3D mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, fd, + addr =3D mmap(NULL, XC_PAGE_SIZE * count, prot, MAP_SHARED, fd, map->index); =20 if (addr =3D=3D MAP_FAILED && errno =3D=3D EAGAIN) @@ -152,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 < PAGE_SIZE * count) { + if (notify_offset < XC_PAGE_SIZE * count) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; } @@ -164,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 * PAGE_SIZE); + munmap(addr, count * XC_PAGE_SIZE); addr =3D MAP_FAILED; } } @@ -184,7 +182,7 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 out: - if ( map_size > PAGE_SIZE ) + if ( map_size > os_page_size ) munmap(map, map_size); =20 return addr; @@ -220,7 +218,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - if ( (rc =3D munmap(start_address, count * PAGE_SIZE)) ) + if ( (rc =3D munmap(start_address, count * XC_PAGE_SIZE)) ) return rc; =20 /* Finally, unmap the driver slots used to store the grant information= . */ @@ -466,7 +464,7 @@ void *osdep_gntshr_share_pages(xengntshr_handle *xgs, goto out; } =20 - area =3D mmap(NULL, count * PAGE_SIZE, PROT_READ | PROT_WRITE, + area =3D mmap(NULL, count * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, gref_info->index); =20 if (area =3D=3D MAP_FAILED) { @@ -477,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 < PAGE_SIZE * count) { + if (notify_offset < XC_PAGE_SIZE * count) { notify.index +=3D notify_offset; notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; } @@ -489,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 * PAGE_SIZE); + munmap(area, count * XC_PAGE_SIZE); area =3D NULL; } =20 @@ -510,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 * PAGE_SIZE); + return munmap(start_address, count * XC_PAGE_SIZE); } =20 /* diff --git a/tools/libs/gnttab/netbsd.c b/tools/libs/gnttab/netbsd.c index f8d7c356eb..a4ad624b54 100644 --- a/tools/libs/gnttab/netbsd.c +++ b/tools/libs/gnttab/netbsd.c @@ -28,15 +28,12 @@ #include #include =20 +#include #include #include =20 #include "private.h" =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - #define DEVXEN "/kern/xen/privcmd" =20 int osdep_gnttab_open(xengnttab_handle *xgt) @@ -87,19 +84,19 @@ void *osdep_gnttab_grant_map(xengnttab_handle *xgt, } =20 map.count =3D count; - addr =3D mmap(NULL, count * PAGE_SIZE, + addr =3D mmap(NULL, count * XC_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 * PAGE_SIZE); + munmap((void *)map.va, count * XC_PAGE_SIZE); addr =3D MAP_FAILED; } map.va =3D addr; =20 map.notify.offset =3D 0; map.notify.action =3D 0; - if ( notify_offset < PAGE_SIZE * count ) + if ( notify_offset < XC_PAGE_SIZE * count ) { map.notify.offset =3D notify_offset; map.notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -115,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 * PAGE_SIZE); + munmap(addr, count * XC_PAGE_SIZE); addr =3D MAP_FAILED; } =20 @@ -136,7 +133,7 @@ int osdep_gnttab_unmap(xengnttab_handle *xgt, } =20 /* Next, unmap the memory. */ - rc =3D munmap(start_address, count * PAGE_SIZE); + rc =3D munmap(start_address, count * XC_PAGE_SIZE); =20 return rc; } @@ -187,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 * PAGE_SIZE, + area =3D mmap(NULL, count * XC_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); =20 if ( area =3D=3D MAP_FAILED ) @@ -200,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 < PAGE_SIZE * count ) + if ( notify_offset < XC_PAGE_SIZE * count ) { alloc.notify.offset =3D notify_offset; alloc.notify.action |=3D UNMAP_NOTIFY_CLEAR_BYTE; @@ -215,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 * PAGE_SIZE); + munmap(area, count * XC_PAGE_SIZE); area =3D MAP_FAILED; goto out; } @@ -230,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 * PAGE_SIZE); + return munmap(start_address, count * XC_PAGE_SIZE); } =20 /* --=20 2.20.1 From nobody Fri Nov 29 22:32:51 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=1620635762; cv=none; d=zohomail.com; s=zohoarc; b=IGpNE0SXLUR/zsDofTuMF6YknSAwIcIsM3qd+XPvDwGD6QYhOstYUz2dBG5HQMxS7NrDlkNohWdx8jW8DnM/imeSUjrR2qszkmMGinMXr/tB8FIqpeo5sdQdjTnEMBsbF0RVl/yGeI8Fjbd948eqi8+O+egCI/aEkjDgF3x+i9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620635762; 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=vUi651JqqZpLoLIATw7aElNITt+X8v8BMPo699ZnbJ8=; b=oF3c6SVFEYWHqStYpqBRcpMeNPWGjiCQG8PCmClXHO2/VqTLsfUsQO5RW/hzb+YvJY6yKl9raF1xdLVnnNiRhTNKo2vu9VpTW/+qdtRPnksgT1pBA/hiExaL73KIh+r5Ezf3pV3emfNkkAE3Sl9jIdCxThfbfhynPp2McO+ByRU= 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 1620635762288250.04686986672777; Mon, 10 May 2021 01:36:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.124913.235203 (Exim 4.92) (envelope-from ) id 1lg1OF-0004Ot-K5; Mon, 10 May 2021 08:35:47 +0000 Received: by outflank-mailman (output) from mailman id 124913.235203; Mon, 10 May 2021 08:35:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg1OF-0004Oe-Gd; Mon, 10 May 2021 08:35:47 +0000 Received: by outflank-mailman (input) for mailman id 124913; Mon, 10 May 2021 08:35:45 +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 1lg1OD-0002eE-N4 for xen-devel@lists.xenproject.org; Mon, 10 May 2021 08:35:45 +0000 Received: from mx.upb.ro (unknown [141.85.13.230]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f16acf60-e581-4f6d-ba49-8a6aa8bc49ef; Mon, 10 May 2021 08:35:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 81A88B560127; Mon, 10 May 2021 11:35:30 +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 QOR1lcOwAZK7; Mon, 10 May 2021 11:35:26 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 9C781B56012E; Mon, 10 May 2021 11:35:26 +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 qMgwYnPDJBH2; Mon, 10 May 2021 11:35:26 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 02A1BB560113; 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: f16acf60-e581-4f6d-ba49-8a6aa8bc49ef X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Christian Lindig , David Scott , Ian Jackson , Wei Liu Subject: [PATCH v3 5/5] tools/ocaml: Fix redefinition errors Date: Mon, 10 May 2021 11:35:19 +0300 Message-Id: <50763a92df0c58ed0d7749717b7ff5e2a039a4dd.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). Same issue applies for redefinitions of Val_none and Some_val macros which can be already define in the OCaml system headers (e.g. /usr/lib/ocaml/caml/mlvalues.h). Signed-off-by: Costin Lupu Reviewed-by: Julien Grall Tested-by: Dario Faggioli --- tools/ocaml/libs/xc/xenctrl_stubs.c | 10 ++++------ tools/ocaml/libs/xentoollog/xentoollog_stubs.c | 4 ++++ tools/ocaml/libs/xl/xenlight_stubs.c | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index d05d7bb30e..f9e33e599a 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -36,14 +36,12 @@ =20 #include "mmap_stubs.h" =20 -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) - #define _H(__h) ((xc_interface *)(__h)) #define _D(__d) ((uint32_t)Int_val(__d)) =20 +#ifndef Val_none #define Val_none (Val_int(0)) +#endif =20 #define string_of_option_array(array, index) \ ((Field(array, index) =3D=3D Val_none) ? NULL : String_val(Field(Field(ar= ray, index), 0))) @@ -818,7 +816,7 @@ CAMLprim value stub_xc_domain_memory_increase_reservati= on(value xch, CAMLparam3(xch, domid, mem_kb); int retval; =20 - unsigned long nr_extents =3D ((unsigned long)(Int64_val(mem_kb))) >> (PAG= E_SHIFT - 10); + unsigned long nr_extents =3D ((unsigned long)(Int64_val(mem_kb))) >> (XC_= PAGE_SHIFT - 10); =20 uint32_t c_domid =3D _D(domid); caml_enter_blocking_section(); @@ -924,7 +922,7 @@ CAMLprim value stub_pages_to_kib(value pages) { CAMLparam1(pages); =20 - CAMLreturn(caml_copy_int64(Int64_val(pages) << (PAGE_SHIFT - 10))); + CAMLreturn(caml_copy_int64(Int64_val(pages) << (XC_PAGE_SHIFT - 10))); } =20 =20 diff --git a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c b/tools/ocaml/l= ibs/xentoollog/xentoollog_stubs.c index bf64b211c2..e4306a0c2f 100644 --- a/tools/ocaml/libs/xentoollog/xentoollog_stubs.c +++ b/tools/ocaml/libs/xentoollog/xentoollog_stubs.c @@ -53,8 +53,12 @@ static char * dup_String_val(value s) #include "_xtl_levels.inc" =20 /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/= ocaml-wrapping-c.php */ +#ifndef Val_none #define Val_none Val_int(0) +#endif +#ifndef Some_val #define Some_val(v) Field(v,0) +#endif =20 static value Val_some(value v) { diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xen= light_stubs.c index 352a00134d..45b8af61c7 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -227,8 +227,12 @@ static value Val_string_list(libxl_string_list *c_val) } =20 /* Option type support as per http://www.linux-nantes.org/~fmonnier/ocaml/= ocaml-wrapping-c.php */ +#ifndef Val_none #define Val_none Val_int(0) +#endif +#ifndef Some_val #define Some_val(v) Field(v,0) +#endif =20 static value Val_some(value v) { --=20 2.20.1