[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 10/12] xen/arm: vgic-v3: add emulation of GICv3.1 eSPI registers
- To: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>
- From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Date: Wed, 3 Sep 2025 21:37:46 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=QTWA/4owJ7JAQakxcsrR5jbfywMTVZmx00kFDWsEWks=; b=NBnrEy+U1EaalaHBjspsNxN7GZ9ylUQv+HB6ZTUqpOYJDK5lt6oI8Ccx9AZbonkXQItOBv/gDy6uTJsjyVQP3wPdddMHGD02o0NrVCsRvikcSQqo7GNu16ZeeRYPCA+VNnepUtuI4j+/TS2WHhtA1S4vDrR9T6hp1VzwnNcEr8vjI6Eju7nHzFgAc4gAZnplwk8BcDJmG+MxKZT7tWPY4oKNkx8Z4W0BIL/AoLjo/idrTFJPPAyK4BCKVmT8/NU5wEw8FDmLSB04Xqf05qAZZpmKSiY4DIe7BF74HDyUuFnyKj1PzX9sriNuxR481Iur2aD2+5CSEwqzg40GZxlRrA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kpz4GyBlIDU/mHc+oHdF4jEanNFGelUce+KDupWNHOZyxE/JEnT50n+Olcal4e2Z7TRjkB9D9ZYFXlRXZwRuyiPWABBsISD6M4bCCiRCHZGE6e/Ax3ZTWufuLEBaYkfmd8OT2XL5fD1I4KAmmt5A2pTEDLsIJ3hwH2Vwpk6/us99VGHjZ5GHrA7ww+FQe83sA140hVTkA1udU+E2iAtrTqpFsGdV62djvdmx6EJ1fwqJq8OVsDfurCjewroR+MYDyBybqqDsdGsJy5CvDLY/dm03pDf+0+6QhHZs8VGxeruKtPRkmplOSfG1SEjFYfCm7u3AR9AKSskneyt0kp775w==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Leonid Komarianskyi <Leonid_Komarianskyi@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
- Delivery-date: Wed, 03 Sep 2025 21:37:58 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcHN9Gwo4As6udbUuFAitPPh/bLA==
- Thread-topic: [PATCH v6 10/12] xen/arm: vgic-v3: add emulation of GICv3.1 eSPI registers
Hi Oleksandr,
Oleksandr Tyshchenko <olekstysh@xxxxxxxxx> writes:
[...]
>> +static inline uint32_t vgic_get_reg_offset(uint32_t reg, uint32_t spi_base,
>> + uint32_t espi_base)
>> +{
>> + if ( reg < espi_base )
>> + return reg - spi_base;
>> + else
>> + return reg - espi_base;
>> +}
>
> I am wondering (I do not request a change) whether
> vgic_get_reg_offset() is really helpfull,
> e.g. is
> offset = vgic_get_reg_offset(reg, GICD_IPRIORITYR, GICD_IPRIORITYRnE);
> much better than:
> offset = reg < GICD_IPRIORITYRnE ? reg - GICD_IPRIORITYR : reg -
> GICD_IPRIORITYRnE;
>
IMO, it is easy to make a mistake, because you need to write register
name 3 times. Can cause errors during copy-pasting. But I saw clever
trick by Mykola Kvach, something like this:
#define vgic_get_reg_offset(addr, reg_name) ( addr < reg_name##nE ? \
addr - reg_name : addr - reg_name##nE )
And then you can just use this as
offset = vgic_get_reg_offset(reg, GICD_IPRIORITYR)
I don't know what maintainers think about this type of preprocessor
trickery, but in my opinion it is justified in this case, because it
leaves less room for a mistake.
--
WBR, Volodymyr
|