[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN v2] Xen: Ensure "xenheap_bits - PAGE_SHIFT" can be used to shift "unsigned long"
- To: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 2 Dec 2022 09:31:07 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AxbW+aRMrgEOz9y0LOeXrdsB5+rJ1bnEGX77qJbykfY=; b=h8bGZNuiehX3IPiThL9FqQ095sWh3LDIvqyiilPFJMKA9Vu8o9CLP32NUk1AVEEcOggFOcZnpquAEwDPONrrdNnzik0NmB1i4OJAcZKHp7usy+0Xd0ggk9+/CNX8e26k2BYOC8aNtSPOiu21FBD902pWl2Lyr6JjmT9Gi3jWcUMangD8o6xknPHAqNIKBeL2PmfWgLQoy/lwC22rXUjDzz4227yFyG1zb7z1lraFeKBUbS1Sg0jw3w3h/ioqRc6t3LL6pM/qwPoFEItBqRJ00eh6L03xo9mCf4KSHKxu//I5zrcD964quW3Bmneu5V/LoWRvneMSXKa+V0i2+LC3uQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lRqvwtSLuR8u4Zd2nK63V/QY8kwQqtxohkuUUkIkB3f7xPf+C+eCk4E+9HL0UNcYC52r8X4n1YTBKjcQ7Lio5v692Kqtl6+qTamSOWiElsMSg/rBOD/F45lnnfrNfvDkz6Lc4HGwefQkEZPBhWNlF3OHVW0o8dExXgeU4NIXa5DlJ3Zt0N3J6zsYQyWUNVnxB5Gfx1CquspgO/ltg/mTslMZF581SSIGt8B4HFYFhsDcDI5p3dusustShQmZxvmAw+4ra/lRzF/0JOHWGKlALgoPo6cZZNmuukZO7SfI+cMvOk28SyGnrlkmQK3oKlG3Zd7GztTGgsLxcxxu2tKC6w==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: sstabellini@xxxxxxxxxx, stefanos@xxxxxxxxxx, julien@xxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, wl@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 02 Dec 2022 08:31:14 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 01.12.2022 19:11, Ayan Kumar Halder wrote:
> Machine frame number (mfn) is used to represent the hardware page address.
> This is an unsigned long variable. We need to check if it can hold the
> complete
> range of hardware page addresses. To ensure this we check that the count of
> bits
> represented by 'unsigned long' added to the bit index of page size, should be
> less than the count of bits required to represent the maximum physical
> address.
I'm afraid I can't connect the description with ...
> --- a/xen/common/page_alloc.c
> +++ b/xen/common/page_alloc.c
> @@ -2245,7 +2245,7 @@ void __init xenheap_max_mfn(unsigned long mfn)
> {
> ASSERT(!first_node_initialised);
> ASSERT(!xenheap_bits);
> - BUILD_BUG_ON(PADDR_BITS >= BITS_PER_LONG);
> + BUILD_BUG_ON((PADDR_BITS - PAGE_SHIFT) >= BITS_PER_LONG);
... the actual change made. Julien, when replying to v1, already gave
a clear hint what is relevant: The use of (xenheap_bits - PAGE_SHIFT)
in right hand operands of shift operators. As relevant is of course
the absence of uses directly as shift counts, which otherwise could
still be UB (and which iirc is why the adjustment by PAGE_SHIFT was
left out in the original check).
Jan
|