[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 01/10] xen/arm: gicv3: refactor obtaining GIC addresses for common operations


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Leonid Komarianskyi <Leonid_Komarianskyi@xxxxxxxx>
  • Date: Fri, 22 Aug 2025 09:09:07 +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=0WTz+QN61rsmkvkidLnVpAe5TYYAQkwIINgDu6Vw00Y=; b=wCM4ssN/pwV0K3OuftW/Cf9vCHSOVcki9y7pTivG7PYu9Q73rv06B4yo8QU5FzeBAMS6TIHW6NGUIdBZ2zkt5hkOm10ywDTZ8Gu1KQlwYooEhVHSKsH5sHwvNaUjkRfFzFO9L4OjV4W3rp5UxhzDX7HF8an5xiAFEQgzC5X7OIuXS4l7uCv3fNg4BUUPi1ynV38wTB01BFHRFcGaFIlgOH6KQff6tfXfpmcqHCKe98UomItuTY0vt8EDUWfpc7ekxWKXnH5uJvITMISe7431iwD5Q5oBmEMZa7FRK0G4lqIeNJTee8y8gLZ6JFCM5OWI/X7rxM4Gi1ivITtu+2yl7A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QShMiQIFdz24LIxAj36cT9YNmlPZkBR01sq8Z+hn125XbMMvRLXoY2asXoQ9Dzc+PIDImZSHD98RXAktOFZEDD50LiuZy3yp8CGExuU4TawUR3K+w5M2tdhFxnhyvHnhL1yv7XqPLOQzumTNUfogke8PC6Ljrm5zqPACmTLmUJ5lzBSMkOwN4LbOuJL4wsvDozX/GuNvUjn3BlatNRWLtfc0bwyMfj58j+lVHMmGdq/06UpCc5WAhBdIasDRtMwFJ+maQi5spKz91q4mG7hZc2HPKO8AcWb/x8ethtkBbgaFr1B/CXxvRzI7cS2azLQfwb0EgqJ/ChBDhkcLDB/4lw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 22 Aug 2025 09:09:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcB5d7cCAQRdJCgUKSzBGsZt4ytbRtXheAgAEbjYA=
  • Thread-topic: [PATCH v2 01/10] xen/arm: gicv3: refactor obtaining GIC addresses for common operations

Hi Julien,

Thank you for your close review.

On 21.08.25 19:14, Julien Grall wrote:
> Hi Leonid,
> 
> On 07/08/2025 13:33, Leonid Komarianskyi wrote:
>> Currently, many common functions perform the same operations to calculate
>> GIC register addresses. This patch consolidates the similar code into
>> a separate helper function to improve maintainability and reduce 
>> duplication.
>> This refactoring also simplifies the implementation of eSPI support in 
>> future
>> changes.
>>
>> Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>
>>
>> ---
>> Changes in V2:
>> - no changes
> 
> I am a bit surprised this is just saying no changes given the discussion 
> in v1. I feel you should have pinged on the v1 to close off the 
> discussion before sending v2.
> 

Sorry, my bad. I should have reached out to you and clarified the 
unfinished discussion in V1. I just wanted to publish the changes in V2 
that were agreed upon in V1. But yes, I understand - it was a bad idea 
to push V2 without completing the discussion in V1. I apologize for that.

> While I understand your point and could accept we consolidate the code...
> 
> 

Thank you for your understanding and acceptance :) It really simplifies 
the changes in the next patches.
>> ---
>>   xen/arch/arm/gic-v3.c          | 99 ++++++++++++++++++++++------------
>>   xen/arch/arm/include/asm/irq.h |  1 +
>>   2 files changed, 67 insertions(+), 33 deletions(-)
>>
>> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
>> index cd3e1acf79..8fd78aba44 100644
>> --- a/xen/arch/arm/gic-v3.c
>> +++ b/xen/arch/arm/gic-v3.c
>> @@ -445,17 +445,62 @@ static void gicv3_dump_state(const struct vcpu *v)
>>       }
>>   }
>> +static void __iomem *get_addr_by_offset(struct irq_desc *irqd, u32 
>> offset)
>> +{
>> +    switch ( irqd->irq )
>> +    {
>> +    case 0 ... (NR_GIC_LOCAL_IRQS - 1):
>> +        switch ( offset )
>> +        {
>> +        case GICD_ISENABLER:
>> +        case GICD_ICENABLER:
>> +        case GICD_ISPENDR:
>> +        case GICD_ICPENDR:
>> +        case GICD_ISACTIVER:
>> +        case GICD_ICACTIVER:
>> +            return (GICD_RDIST_SGI_BASE + offset);
>> +        case GICD_ICFGR:
>> +            return (GICD_RDIST_SGI_BASE + GICR_ICFGR1);
>> +        case GICD_IPRIORITYR:
>> +            return (GICD_RDIST_SGI_BASE + GICR_IPRIORITYR0 + irqd->irq);
>> +        default:
>> +            break;
>> +        }
>> +    case NR_GIC_LOCAL_IRQS ... SPI_MAX_INTID:
>> +        switch ( offset )
>> +        {
>> +        case GICD_ISENABLER:
>> +        case GICD_ICENABLER:
>> +        case GICD_ISPENDR:
>> +        case GICD_ICPENDR:
>> +        case GICD_ISACTIVER:
>> +        case GICD_ICACTIVER:
>> +            return (GICD + offset + (irqd->irq / 32) * 4);
>> +        case GICD_ICFGR:
>> +            return (GICD + GICD_ICFGR + (irqd->irq / 16) * 4);
>> +        case GICD_IROUTER:
>> +            return (GICD + GICD_IROUTER + irqd->irq * 8);
>> +        case GICD_IPRIORITYR:
>> +            return (GICD + GICD_IPRIORITYR + irqd->irq);
>> +        default:
>> +            break;
>> +        }
>> +    default:
>> +        break;
>> +    }
>> +
>> +    /* Something went wrong, we shouldn't be able to reach here */
>  > +    panic("Invalid offset 0x%x for IRQ#%d", offset, irqd->irq);
> 
> ... I still quite concerned about using panic here. We need to try to 
> handle the error more gracefully in production.
> 
> Cheers,
> 

I was thinking about this again, and maybe it would be better to change 
the panic into simply printing an error using printk(XENLOG_G_ERR ...) 
and adding proper checks to ensure the return value is not NULL in the 
callers.
Also, in the case of gicv3_peek_irq, which must return a boolean value 
(due to the generic API for gicv3_read_pending_state), we could return 
false with an additional warning message that we are unable to read the 
actual value due to incorrect parameters; therefore, we return false.
What do you think about this approach?

Best regards,
Leonid

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.