[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN v1] Xen: Enable compilation when PADDR_BITS == BITS_PER_LONG
- To: Julien Grall <julien@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Ayan Kumar Halder <ayankuma@xxxxxxx>
- Date: Thu, 1 Dec 2022 12:12:25 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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=JlJGf8/dwhVPeW3uIbz8qek1CDO1pQa04wEt2CH/S6Y=; b=QA2Ov3HCdVjUn1vkuCEdOma7qqxv+nLz6XFIRZvGDcBgQHLp+2JmXbN32TbkIHWLqFpu8HA8lAORronGBxsEZwY2g5S1htJzSHU5N4bFUR5PspOPnxwtwsAfR248DU0O7mdnNm0k5HcJ/5D+4JASC6s7tVXRSQhmiO8LTPgIsdFWFmVWWtU1Ef3ovj2AWLTbxipN03i781g0EwFC3t2iMfPzkBQn/twmMSANT7OCAw36T9EdEE1XPuxWFQbsQcdXh2sHoXAAXZV4zW7ZD9WxSWu7mhvyyayK0pkS8940liwLfsJ7HeV5YQWD5lMCa7s6h0nlJhpIv42/i/CoMtdTYA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N9B4nQC5ppu4fTWE5+qEts5jqijvxj30BL7ZlOm5rHR0puINEV9C0bIt00ujqiVpyz4xocyAEgBJdxg9h+5JDvaD487WVFLk3Mmgks2SQD/TMMrxO4suhwgDziC80OXQdd5glLKIRjrvA8YmiFaEZEnM2/pp4S96shK+RuB0En2WUDQYPJWgvSAuw6gvyQEOmVSkipbA1peGvNETxKwUjfFFAySRVf+lwahEbOsEykXghED+utqMm9aNjHw77R84s3rBPTXb6dre2fHY0eDKvh3/nAhro755hKQXQw1Gm2QpfSybOLUC3OBQvs+osVKrWnFeEdgVgRPwv4vBarQ33Q==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: sstabellini@xxxxxxxxxx, stefanos@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, jbeulich@xxxxxxxx, bobbyeshleman@xxxxxxxxx, alistair.francis@xxxxxxx, connojdavis@xxxxxxxxx, wl@xxxxxxx
- Delivery-date: Thu, 01 Dec 2022 12:12:42 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 01/12/2022 10:26, Julien Grall wrote:
Hi Ayan,
Hi Julien,
I have a question.
On 01/12/2022 10:03, Ayan Kumar Halder wrote:
It is possible for a pointer to represent physical memory of the same
size.
In other words, a 32 bit pointer can represent 32 bit addressable
physical
memory.
Thus, issue a compilation failure only when the count of physical
address bits
is greater than BITS_PER_LONG (ie count of bits in void*).
I am having difficult to understand how this description is related to
the BUILD_BUG_ON(). AFAIU, it is used to check that xenheap_bits can
be used in shift.
If the unsigned long is 32-bit, then a shift of 32 could be undefined.
Looking at the current use, the shift are used with "xenheap_bits -
PAGE_SHIFT". So as long as PAGE_SHIFT is not 0, you would be fine.
Ack
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
Currently this change will not have any impact on the existing
architectures.
The following table illustrates PADDR_BITS vs BITS_PER_LONG of
different archs
------------------------------------------------
| Arch | PADDR_BITS | BITS_PER_LONG |
------------------------------------------------
| Arm_64 | 48 | 64 |
| Arm_32 | 40 | 32 |
| RISCV_64 | Don't know | 64 |
| x86 | 52 | 64 |
-------------------------------------------------
The Arm_32 line is a bit confusing because one would wonder why we
haven't seen this issue yet. So I think you want to clarify that the
code path is not used by Arm32.
Do you want this clarification and the above/below explanation to be a
part of the commit message ?
I will then send out a v2 with the fix.
- Ayan
However, this will change when we introduce a platform (For eg
Cortex-R52) which
supports 32 bit physical address and BITS_PER_LONG.
Thus, I have introduced this change as I don't see it causing a
regression on
any of the supported platforms.
xen/common/page_alloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 62afb07bc6..cd390a0956 100644
--- 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 > BITS_PER_LONG);
Based on the above, I think this wants to be "(PADDR_BITS -
PAGE_SHIFT) >= BITS_PER_LONG)".
Ack
xenheap_bits = min(flsl(mfn + 1) - 1 + PAGE_SHIFT, PADDR_BITS);
printk(XENLOG_INFO "Xen heap: %u bits\n", xenheap_bits);
}
Cheers,
|