From nobody Thu Apr 25 10:46:43 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=1619782129; cv=none; d=zohomail.com; s=zohoarc; b=aRmxlxUIdZckn7Ol1CwLPgJoxKu3UqifC8sb4M/fcpanq1Xt3jrecn4xsWynIZ1uPQWXEaMCTaHNN2EHs7feXeJbroxh+Bv0JFAWqNwVRmn9CyHQWJUEGTzUyhfyO5CtUotErVCAC3mLtmWrgBr6Dz8WyK5QonFVV7VxEuc+EDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619782129; 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=7EPNqEAiW+09SE2xcD2xzpR318dgk1/uUQZNFk8JBwA=; b=I/1shEw3nkbWWIywO38O1hbJ7NYh9f2KI8joNF6wYbUuD124wOh+v+UUn0HxXhyYraklMcwSzPFkuGzWoUfc9K7d+vYDN0NSfKzoKYDHsper7FqQl1s9dR+v53ZpDjGbOmmpFh0gzQ7ljWgAhAZFJZdMIMnJWM5mc5EWySIZZBA= 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 161978212881930.160142743387382; Fri, 30 Apr 2021 04:28:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120473.227850 (Exim 4.92) (envelope-from ) id 1lcRJu-00015K-9E; Fri, 30 Apr 2021 11:28:30 +0000 Received: by outflank-mailman (output) from mailman id 120473.227850; Fri, 30 Apr 2021 11:28:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRJu-00015C-5N; Fri, 30 Apr 2021 11:28:30 +0000 Received: by outflank-mailman (input) for mailman id 120473; Fri, 30 Apr 2021 11:28:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRJs-00011a-Eb for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 11:28:28 +0000 Received: from mx.upb.ro (unknown [141.85.13.220]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 98151aa8-f33c-439a-9db7-ab35e1e21fc7; Fri, 30 Apr 2021 11:28:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id DCDBAB560113; Fri, 30 Apr 2021 14:28:20 +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 jgHZByzHpTZ1; Fri, 30 Apr 2021 14:28:18 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 735A9B5600B0; Fri, 30 Apr 2021 14:28:18 +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 Bok4qv--nPKH; Fri, 30 Apr 2021 14:28:18 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id B1651B56010D; Fri, 30 Apr 2021 14:28:17 +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: 98151aa8-f33c-439a-9db7-ab35e1e21fc7 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 v2 1/5] tools/debugger: Fix PAGE_SIZE redefinition error Date: Fri, 30 Apr 2021 14:28:07 +0300 Message-Id: <26c90f29058c8f2cf36230eee4f4e3ebd097a04d.1619781564.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/debugger/kdd/kdd-xen.c | 15 ++++++--------- tools/debugger/kdd/kdd.c | 21 ++++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/tools/debugger/kdd/kdd-xen.c b/tools/debugger/kdd/kdd-xen.c index f3f9529f9f..d6308929e8 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], XC_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 >> XC_PAGE_SHIFT); + map_offset =3D addr & (XC_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], XC_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, + XC_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 XC_PAGE_SIZE - (addr & (XC_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..fa23948242 100644 --- a/tools/debugger/kdd/kdd.c +++ b/tools/debugger/kdd/kdd.c @@ -50,6 +50,8 @@ #include #include =20 +#include + #include "kdd.h" =20 /* @@ -288,9 +290,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 +351,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 XC_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 +363,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 << (XC_PAGE_SHIFT + bits)) - 1); return (pa & ~mask) + (va & mask); } } =20 - return pa + (va & (PAGE_SIZE - 1)); + return pa + (va & (XC_PAGE_SIZE - 1)); } =20 static uint32_t kdd_access_virtual(kdd_state *s, int cpuid, uint64_t addr, @@ -380,7 +379,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 XC_PAGE_SIZE - (addr & (XC_PAGE_SIZE - 1)); if (chunk > len)=20 chunk =3D len; pa =3D v2p(s, cpuid, addr); @@ -591,7 +590,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) / XC_PAGE_SIZE; /*1GB/P= ageSize*/ uint64_t efer; =20 /* if we are not in 64-bit mode, fail */ @@ -620,7 +619,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 & ~(XC_PAGE_SIZE - 1); =20 while (search_limit) { uint16_t val; @@ -633,7 +632,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 XC_PAGE_SIZE; search_limit -=3D 1; } =20 @@ -720,7 +719,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 XC_PAGE_SIZE) if (check_os(s)) return; } --=20 2.20.1 From nobody Thu Apr 25 10:46:43 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=1619782128; cv=none; d=zohomail.com; s=zohoarc; b=ecytfj16NgO+vZqEdW43MuZx1+Zc/JFpjAawfgDif3CQfRIHcAx6P3D2hLnI3lRoFOyxDsx8vN2ZepofNESpd3PKY0CZlTZfXYQmAZb/j+gu1/MUJd5eT17wK1bOT6S+EzVc6ojVeY8bpElybVgXVFApH31YbBhym65yB7U+sms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619782128; 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=dVgKolzngdWiBjFgTqi5zeSrixTfp7L47B25QugvfpQ+WU0MBlsD+4yc5HkGU4OkrQ0DmmGwfNCQpl6yOfYfaWreKr1qYm+VMQZ3FRBuuQ3T4uZaQP2jB/DY16LaA4vZMJdY9cWgyZVI8GW4QCNlTyKQz8GG+EMHokio51CxMmw= 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 1619782128938239.9364072076844; Fri, 30 Apr 2021 04:28:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120471.227826 (Exim 4.92) (envelope-from ) id 1lcRJo-00011m-Gi; Fri, 30 Apr 2021 11:28:24 +0000 Received: by outflank-mailman (output) from mailman id 120471.227826; Fri, 30 Apr 2021 11:28:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRJo-00011f-Br; Fri, 30 Apr 2021 11:28:24 +0000 Received: by outflank-mailman (input) for mailman id 120471; Fri, 30 Apr 2021 11:28:23 +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 1lcRJn-00011V-0F for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 11:28:23 +0000 Received: from mx.upb.ro (unknown [141.85.13.230]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d9af1916-ede5-4400-a992-9f5a966b63df; Fri, 30 Apr 2021 11:28:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 1EDC8B5600B0; Fri, 30 Apr 2021 14:28:21 +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 Jb2eNVNYsFP2; Fri, 30 Apr 2021 14:28:19 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 3A962B56010D; Fri, 30 Apr 2021 14:28:19 +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 rEdz3PHn6_Jl; Fri, 30 Apr 2021 14:28:19 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 75072B560118; Fri, 30 Apr 2021 14:28:18 +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: d9af1916-ede5-4400-a992-9f5a966b63df 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 v2 2/5] tools/libfsimage: Fix PATH_MAX redefinition error Date: Fri, 30 Apr 2021 14:28:08 +0300 Message-Id: <9e323285b89717cd4cd8de7fb642e447b0dcfc4e.1619781564.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 Thu Apr 25 10:46:43 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=1619782138; cv=none; d=zohomail.com; s=zohoarc; b=cOrsyi+jFuPStuxjhvKKv/VfCDogCVuY+FhEJxOmu1Onw0+qe5mkIwQdIcwnjsVbVU2XFKZazJRukeXukZ9sFVYTzJNl/oqs9aOC01NsnRbI2uje+R3OGRbby5N+15DigG1RY7izX1Tlp28sgTaccx9FvEmZDZxU8iQv4+dfhZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619782138; 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=T98RNOExuKwq3RoQa+XW7151Osgfz948TjZGU3QTByuszJgjKdCKwlcKwNdGFVeKWORN9JNwIV7QGvflHhnlecLG6mMUmO5rTie3dEIN1RSzzxiPFSN1V1+afw3RwmerBmUPEFJDOo8qFF5C4ZhN5crIH6XjPM6j90Y6xp547Eg= 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 161978213873249.20202200249116; Fri, 30 Apr 2021 04:28:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120478.227886 (Exim 4.92) (envelope-from ) id 1lcRK9-0001MI-7X; Fri, 30 Apr 2021 11:28:45 +0000 Received: by outflank-mailman (output) from mailman id 120478.227886; Fri, 30 Apr 2021 11:28:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRK9-0001M7-2Z; Fri, 30 Apr 2021 11:28:45 +0000 Received: by outflank-mailman (input) for mailman id 120478; Fri, 30 Apr 2021 11:28:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRK7-00011a-FG for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 11:28:43 +0000 Received: from mx.upb.ro (unknown [141.85.13.5]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8b8d5e40-4c31-4353-af4a-2dcad4b481f4; Fri, 30 Apr 2021 11:28:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 08F08B56010D; Fri, 30 Apr 2021 14:28:23 +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 mrlJ3fkq2pCv; Fri, 30 Apr 2021 14:28:19 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id B17A3B56011F; Fri, 30 Apr 2021 14:28:19 +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 tM1YPzA45zOA; Fri, 30 Apr 2021 14:28:19 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 3B6CBB56011C; Fri, 30 Apr 2021 14:28:19 +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: 8b8d5e40-4c31-4353-af4a-2dcad4b481f4 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 v2 3/5] tools/libs/foreignmemory: Fix PAGE_SIZE redefinition error Date: Fri, 30 Apr 2021 14:28:09 +0300 Message-Id: <3ddcf2cc440eba6869cb26455510e7d6a123a1c1.1619781564.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 Thu Apr 25 10:46:43 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=1619782129; cv=none; d=zohomail.com; s=zohoarc; b=VYpzpiz4XGY0xj1sauS5AUivhE4bLZncviZyAF6a+fctp/JRFW9SkBtYwTY61CvOC1ULHAnejdsa4ZAeFIGowgiwb4IvvTfMx+CTL7agACVP573CvNHY+hewO5r71jBdwmwAUsz/YH3upbB1ptNJcP20X4GJO/aFt/tyACqpu7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619782129; 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=bP28o9GZGCvEqGszKgsSY7i/zcubkFq5/6hH3RTuOIvuisD4HSmkF0XVCg9pwcd4r0/UiIt2dzMfMI7o+KC1ki3yKG5YRjTJjAlDNewsoiNp1zRW6jugImi/RTsR4cEcnebstproQuHIKTZYZMQqM2XwCxshI3VdUChKJoIDOQM= 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 16197821286689.480137244177286; Fri, 30 Apr 2021 04:28:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120474.227862 (Exim 4.92) (envelope-from ) id 1lcRJy-00019P-IB; Fri, 30 Apr 2021 11:28:34 +0000 Received: by outflank-mailman (output) from mailman id 120474.227862; Fri, 30 Apr 2021 11:28:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRJy-00019G-EQ; Fri, 30 Apr 2021 11:28:34 +0000 Received: by outflank-mailman (input) for mailman id 120474; Fri, 30 Apr 2021 11:28:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRJx-00011a-Ej for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 11:28:33 +0000 Received: from mx.upb.ro (unknown [141.85.13.200]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f6fa5441-43a5-4aa1-b4d8-23e7c2bdbad8; Fri, 30 Apr 2021 11:28:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 37635B560118; Fri, 30 Apr 2021 14:28:23 +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 ymGLmKXsAxR9; Fri, 30 Apr 2021 14:28:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 0FE78B560121; Fri, 30 Apr 2021 14:28:20 +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 U3G9nkr-6Er9; Fri, 30 Apr 2021 14:28:19 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id B121DB560118; Fri, 30 Apr 2021 14:28:19 +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: f6fa5441-43a5-4aa1-b4d8-23e7c2bdbad8 X-Virus-Scanned: amavisd-new at upb.ro From: Costin Lupu To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Wei Liu Subject: [PATCH v2 4/5] tools/libs/gnttab: Fix PAGE_SIZE redefinition error Date: Fri, 30 Apr 2021 14:28:10 +0300 Message-Id: <64508f42952d971a0213dfd3fff53b990a3c6ebe.1619781564.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/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 Thu Apr 25 10:46:43 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=1619782133; cv=none; d=zohomail.com; s=zohoarc; b=Aw3kY/JGblMSAWJvWhMSVCpRMt6EkhiL+lZP3ZtUYYmcg5LbK7jmKDnb4KX8iC8JWHIuxgJe8kSb6tCnDqVCb/ij/EEbYNnl9xBmkdq3wfpg022tZVCP/BMN+YtLse3tg9Rflm57bNbhnlJn0sY/V6HRcffguMNPP5JWjXdWrcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619782133; 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=lnp+WrQocOTIU8q2/M5aPO+s4BOrKUHmUgPO0Lzti4I=; b=TbSQpo8mkzJTav+fGLbK/eqpvwBGk/uXPfIQdqlLRs6O9y8E2RXPeUzVE0Z1+PlYnaQFmQanvPbsrC9omeWj8dehfe4iTAaQUkw+v6S3SVECKc31+ZclJk9iuZi2sccYrQKTbT9UvC4+RxcyTEdjR/uUsyIeNf2+eTj9N0EwKnM= 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 1619782133300939.6186886110376; Fri, 30 Apr 2021 04:28:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120476.227874 (Exim 4.92) (envelope-from ) id 1lcRK3-0001F4-Qo; Fri, 30 Apr 2021 11:28:39 +0000 Received: by outflank-mailman (output) from mailman id 120476.227874; Fri, 30 Apr 2021 11:28:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRK3-0001Eu-N1; Fri, 30 Apr 2021 11:28:39 +0000 Received: by outflank-mailman (input) for mailman id 120476; Fri, 30 Apr 2021 11:28:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcRK2-00011a-FB for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 11:28:38 +0000 Received: from mx.upb.ro (unknown [141.85.13.230]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bb8a72c0-9212-4ddc-9666-b8cc43055019; Fri, 30 Apr 2021 11:28:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 1E14DB56011F; Fri, 30 Apr 2021 14:28:23 +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 bSylNCdeoEZB; Fri, 30 Apr 2021 14:28:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mx.upb.ro (Postfix) with ESMTP id 8E727B560118; Fri, 30 Apr 2021 14:28:20 +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 9hLohrSlnp5b; Fri, 30 Apr 2021 14:28:20 +0300 (EEST) Received: from localhost.localdomain (unknown [188.25.174.245]) by mx.upb.ro (Postfix) with ESMTPSA id 0F0BAB560113; Fri, 30 Apr 2021 14:28:19 +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: bb8a72c0-9212-4ddc-9666-b8cc43055019 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 v2 5/5] tools/ocaml: Fix redefinition errors Date: Fri, 30 Apr 2021 14:28:11 +0300 Message-Id: <1a8ff6dcdd70fef83828dce47e79eb846860cbe8.1619781564.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 defined in the OCaml system headers (e.g. /usr/lib/ocaml/caml/mlvalues.h). Signed-off-by: Costin Lupu --- 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