From nobody Sat Nov 30 16:25:11 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; dkim=fail; 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=1600970965; cv=none; d=zohomail.com; s=zohoarc; b=WnxbBR8pP1xQJyFI6n8e/MNajJB9+77J7BDrtM+gypCNH3/ABZjKXNDEcrcuQr+goGdY3/35e+StBqRH2ewQ8WkRfLHw1ssusSvFdd3kHCbI2khqhCpi0JMGin/twAOPi+UDaMSM0lrw1WW6bL5HaY+4T0c9TY4OlQEddqxbCwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600970965; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=YT9wfG1zTzhMDJc3uK98Zp+SbMv1kIlZ8IYxWgh16Mg=; b=Fn2h44x0Pmotm3xAeynadzCZTsULBx6MC24GbIworWfviZwBNY9BxSYKvcGbBL28CDPs9aIM2ADFHseLcGyrjRGVG5L4/S7JQn9w63EnbakhXDV/5NREs7PHBaBsHJ9yMNlhzwm5DODjMhk5gwB4UGK78uoMNQPNH6Jhii112qk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1600970965449290.9972661905647; Thu, 24 Sep 2020 11:09:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kLVfr-0000sM-7j; Thu, 24 Sep 2020 18:08:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kLVfp-0000sH-O7 for xen-devel@lists.xenproject.org; Thu, 24 Sep 2020 18:08:54 +0000 Received: from mo4-p00-ob.smtp.rzone.de (unknown [85.215.255.21]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f5775a3d-eacc-48c9-a2bb-e2a9d8c23263; Thu, 24 Sep 2020 18:08:52 +0000 (UTC) Received: from sender by smtp.strato.de (RZmta 46.10.7 DYNA|AUTH) with ESMTPSA id 60ad29w8OI8kPzI (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) (Client did not present a certificate); Thu, 24 Sep 2020 20:08:46 +0200 (CEST) X-Inumbo-ID: f5775a3d-eacc-48c9-a2bb-e2a9d8c23263 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1600970931; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=YT9wfG1zTzhMDJc3uK98Zp+SbMv1kIlZ8IYxWgh16Mg=; b=hpDZc7EybC7nujxrffzcH83K70evPstDP1UymbwI9kAVohSXl3qvMOPhzhoERnNHir BGBD/J464a+CZvA6WCQZz49mxaOzTTPRypiGK6tecflVwMbSnRY90ixCjC0P3bAME6Aw v9bOW3Mk0BDDukSrX4eE/AYGQxoKaRunvL5s5FRH2yytltExHrdXTNAcvKzBSMkiBft8 Hi/Eu502PSql39DtyvGagGpJgoc+b6IzLIW4zS+YRFRBX9qs2BfiEE9QBita5JsDmGUu f2Vwj1gNQuIOSvexN2Xn8rBNNA9RnEpLpnkSIWETPpknVRH8oRVgY3X+LjWTj34h9Rbs rrow== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzBW/OdlBZQ4AHSS3G5Jjw==" X-RZG-CLASS-ID: mo00 From: Olaf Hering To: xen-devel@lists.xenproject.org Cc: Olaf Hering , Ian Jackson , Wei Liu Subject: [PATCH v1] libxc/bitops: increase potential size of bitmaps Date: Thu, 24 Sep 2020 20:08:43 +0200 Message-Id: <20200924180843.30452-1-olaf@aepfle.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If the bitmap is used to represent domU pages, the amount of memory is limited to 8TB due to the 32bit value. Adjust the code to use 64bit values as input. All callers already use some form of 64bit as input, so no further adjustment is required. Signed-off-by: Olaf Hering Acked-by: Wei Liu --- tools/libs/ctrl/xc_bitops.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/libs/ctrl/xc_bitops.h b/tools/libs/ctrl/xc_bitops.h index 0951e8267d..3d3a09772a 100644 --- a/tools/libs/ctrl/xc_bitops.h +++ b/tools/libs/ctrl/xc_bitops.h @@ -14,52 +14,52 @@ #define BITMAP_SHIFT(_nr) ((_nr) % 8) =20 /* calculate required space for number of bytes needed to hold nr_bits */ -static inline int bitmap_size(int nr_bits) +static inline unsigned long bitmap_size(unsigned long nr_bits) { return (nr_bits + 7) / 8; } =20 -static inline void *bitmap_alloc(int nr_bits) +static inline void *bitmap_alloc(unsigned long nr_bits) { return calloc(1, bitmap_size(nr_bits)); } =20 -static inline void bitmap_set(void *addr, int nr_bits) +static inline void bitmap_set(void *addr, unsigned long nr_bits) { memset(addr, 0xff, bitmap_size(nr_bits)); } =20 -static inline void bitmap_clear(void *addr, int nr_bits) +static inline void bitmap_clear(void *addr, unsigned long nr_bits) { memset(addr, 0, bitmap_size(nr_bits)); } =20 -static inline int test_bit(int nr, const void *_addr) +static inline int test_bit(unsigned long nr, const void *_addr) { const char *addr =3D _addr; return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1; } =20 -static inline void clear_bit(int nr, void *_addr) +static inline void clear_bit(unsigned long nr, void *_addr) { char *addr =3D _addr; BITMAP_ENTRY(nr, addr) &=3D ~(1UL << BITMAP_SHIFT(nr)); } =20 -static inline void set_bit(int nr, void *_addr) +static inline void set_bit(unsigned long nr, void *_addr) { char *addr =3D _addr; BITMAP_ENTRY(nr, addr) |=3D (1UL << BITMAP_SHIFT(nr)); } =20 -static inline int test_and_clear_bit(int nr, void *addr) +static inline int test_and_clear_bit(unsigned long nr, void *addr) { int oldbit =3D test_bit(nr, addr); clear_bit(nr, addr); return oldbit; } =20 -static inline int test_and_set_bit(int nr, void *addr) +static inline int test_and_set_bit(unsigned long nr, void *addr) { int oldbit =3D test_bit(nr, addr); set_bit(nr, addr); @@ -67,11 +67,11 @@ static inline int test_and_set_bit(int nr, void *addr) } =20 static inline void bitmap_or(void *_dst, const void *_other, - int nr_bits) + unsigned long nr_bits) { char *dst =3D _dst; const char *other =3D _other; - int i; + unsigned long i; for ( i =3D 0; i < bitmap_size(nr_bits); ++i ) dst[i] |=3D other[i]; }