[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH] arm/gic: Optimize lr_mask type based on GIC version
- To: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Thu, 5 Mar 2026 23:12:10 +0000
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=G5pjx4bf+wJbVOTCBWJI7I9V55TuDqo6aQNSqfapI5E=; b=qBluRLUiqQRskuHo4pF/ev73Na+mSNpblZcujBwOoT9IHdMI6nYnTLQ5kQj7hRWFlCEsV8Ep0JTnx8o6il6mxssR0MwM408voywOgJjprvPrbKXBb1pYuj+iaFEtSxX3q7o0k3kN+fPfL8BiQApfU9VRt/a0XUgSic1/165TOsSZtwTtfwpAk9G63Lirov/CqiVuBhNoMLE4HU9p8sVXWBPuiE/mlD1zl93Fr+RTqWSHJI5olxJUkEbtjDm7lSoblLOG3471KVlGAA5/QhXhxWgvpIhPQOQdPGSjshIa40ljCXOKN/RsEe1OKaBoC/erHyRcYGw+1N9x1DpIiW0HRw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Jz8aPoOD9fw1Xwk4j0GLg8YyM2EcL/2Dz9F04eHcDA4rkT7hUz4a0FuBpt1VsqAaTDP2+UzEjBnJUTtKcS7jmDcoNw22RvpEmvxi5PNeH6XFVKFfRcsUnIkTulal0RGFCEMMvK9nfCVXyKJzZt+t4m6vpkqZAEjAVvYC8+ySDmJ6/y7t5iZ+vZa3oXbuuMj4FAQgwIW1IUNhsQTvsHfbHqXPzqUPmjt9zTZQBjHLSmO4tdC0JsyfPvuZblf0BbKEfe7PJW3UvRHrGKVq9n/Igb2RFkAzx5UOzauRlIcq9zc6T3V6AGjm1VTuRw8QBE9GVwd07iRHU2kFaJWtJVWQjw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Thu, 05 Mar 2026 23:12:30 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 05/03/2026 11:01 pm, Andrew Cooper wrote:
> On 05/03/2026 7:57 pm, Ayan Kumar Halder wrote:
>> The lr_mask bitmap tracks which List Registers (LRs) are in use for
>> virtual interrupt injection. Previously, lr_mask always used uint64_t
>> (8 bytes) to support the maximum number of LRs across both GIC versions.
>>
>> However, GICv2 and GICv3 have different hardware limits:
>> - GICv3: ICH_VTR_EL2[3:0] encodes LR count -> max 16 LRs (4 bits)
>> - GICv2: GICH_VTR[5:0] encodes LR count -> max 64 LRs (6 bits)
>>
>> This patch introduces conditional compilation to optimize lr_mask size:
>> - CONFIG_GICV3=y: Use uint16_t (2 bytes) - sufficient for 16 LRs
>> - CONFIG_GICV3=n: Use uint64_t (8 bytes) - required for 64 LRs
>>
>> With this, parameter 'lr' in gicv3_ich_read_lr(), gicv3_ich_write_lr()
>> cannot have a value > 15. Thus, it should not possible to hit the
>> BUG() in the default case.
>>
>> Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
> What does this actually get you?
>
> Because it doesn't actually eliminate the BUG()s you reference.
>
> If you really want to go ahead with this patch, then make a lr_mask_t
> or the right type and don't double-code everything.
Also, this creates an Out-of-Bounds read in vgic_sync_from_lrs() amongst
others.
~Andrew
|