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

Re: [PATCH v9 02/13] xen/arm: gic-v2: Implement GIC suspend/resume functions


  • To: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Fri, 15 May 2026 09:52:11 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=gmail.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=H8/52lj4JqbrZVaAay0Dp2lTfajKd/OUEFnUGw095J8=; b=v5HS03L0gG2AGvjMuM7S1Nx0PwZdrT5IQi9oj1mHm910+5MEcEIuKW451xP6Tdez82tXJTQ1cpv7ezxRbwdsPIp4mf72gdG0fAsHY++ND5xOPAywKz9wFiOm+UdTeTfKfhnf55InQPTaXnavbUX/CYq/ZeNXQnEQWmfiep93CtdvbidLFkC0uV8XYA30p8moVsceo9f3XvvcQYw0flX/dXP7qQcOYuFq0nWYG7PJ4B/gFfymTdJzqG2KvYlWg9Ogd6CVZFVx6w8JbHdsUgXQxYjw2N76BghneEnRiP97Mw/80eGiOR8cbBMETiACkbpv09zlOKQ2ubtwU3zmb8pGGw==
  • 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=H8/52lj4JqbrZVaAay0Dp2lTfajKd/OUEFnUGw095J8=; b=QQEQBgcrOm2NFOUbo0ns8O9YaPSn5ZgXws4wzOAKd0Bomyhu1KnndBCs/IZ6vb0F4Ly/9yCVgvsxHxQYqsbSDbuMkt03SC75EIg/51+qxkRDY6aa3DK/bjRPQFUTlMR6iGeVobFIn8I03Vvf2In62/2vm9JTZOPxxlDZAUcNqcgiejx0ca/xPWMdtOigZqGyG9S9b1buk9SFXMYpuWQkwAGuyBkO1mAm3u0V68Z8XgYktYhE/QxFwXdv+ETp9lronffHbohP/zQ1mNR6z0GJbYNodfYfQ1KtiHKNV2vNlPYm19XeSTgnP9r5E7gkEFCAGOGBq/HufhTezyHCAQJtOQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=PlsCjB8czbVq04FTY8+1iBakKbDb9N4ZPq+E+Vx5Eh1yx6iVCmZovQvaPBVzTUUzffJOI2pI7ZwEWBY/sYt4fg8ulwtqURExVZcVKIrDvJicWuvGwxOxf4I9BJ6DUxFnwKHwR2iCZpQTKDA0xa29CQZ9MlfIvENFxl6lZpba1oevXAmHSSvThKH8WrVJCtxSSbspRaeO6S3WAJxNlbK/9P8smE8uiPm3yoXRqcdVeZ8rX6Jsy/ENgxeDaGPhS2XMOmCO0Xa28W7TGecP8TRDH/h0wZ++A2FzMgq13pnvd4GInqtXxipof+T1XDWjDh4fAxb2qm7RjJtf3NhH30MiKQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AIMmB6zKLKeQsaq/V1EawmR79mm3QR0hbDjE4GQDSjsTWh/3dKNpBSd8BbKXNFpcN8jLXPrgpDD97gGZt6VoOe+zyvVYt4WFjfU7qXwBmgUNqig6TTaKNMQJlvNJLIg1+GxrwfkA2JUC3GGYYlbE9n+T3W5Sbmpih42DxbzkV2qESiRAMvkCabERt61XydNPL593MDi3keVIoQAqkvw9Auk2kZUdooSH9LjwfNEGLKN9uruAPVYDz7AxO+IqbgYu8F5qKbfGi/mxIBb6Ldembl9AAhKm1mOAjnnzgUgPUW9WP5VcbRbzeeHgX8N8q88ikGdAZ/0uanmvB8xjnglfGQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Mykola Kvach <mykola_kvach@xxxxxxxx>, 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: Fri, 15 May 2026 09:53:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc4jIxK7EE6l+HQkWYC60FHhQX47YL/3OAgAK9pQCAAB9fgA==
  • Thread-topic: [PATCH v9 02/13] xen/arm: gic-v2: Implement GIC suspend/resume functions

Hi Mykola,

> On 15 May 2026, at 08:59, Mykola Kvach <xakep.amatop@xxxxxxxxx> wrote:
> 
> Hi Luca,
> 
> Thank you for the detailed review.
> 
> On Wed, May 13, 2026 at 5:09 PM Luca Fancellu <Luca.Fancellu@xxxxxxx> wrote:
>> 
>> Hi Mykola,
>> 
>>> +
>>> +static void gicv2_resume(void)
>>> +{
>>> +    unsigned int i, blocks = DIV_ROUND_UP(gicv2_info.nr_lines, 32);
>>> +
>>> +    gicv2_cpu_disable();
>>> +    /* Disable distributor */
>>> +    writel_gicd(0, GICD_CTLR);
>>> +
>>> +    for ( i = 0; i < blocks; i++ )
>>> +    {
>>> +        struct irq_block *irqs = gic_ctx.dist.irqs + i;
>>> +        size_t j, off = i * sizeof(irqs->isenabler);
>>> +
>>> +        writel_gicd(GENMASK(31, 0), GICD_ICENABLER + off);
>>> +        writel_gicd(irqs->isenabler, GICD_ISENABLER + off);
>>> +
>>> +        writel_gicd(GENMASK(31, 0), GICD_ICACTIVER + off);
>>> +        writel_gicd(irqs->isactiver, GICD_ISACTIVER + off);
>>> +
>>> +        off = i * sizeof(irqs->ipriorityr);
>>> +        for ( j = 0; j < ARRAY_SIZE(irqs->ipriorityr); j++ )
>>> +            writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 
>>> 4);
>> 
>> apologies for spotting these only now, in case gicv2_info.nr_lines is 1020,
>> here and below for GICD_ITARGETSR we are going to save also IDs 1020-1023
>> which are reserved.
>> 
>> Could we assume irqs->ipriorityr and irqs->itargetsr have the same size and 
>> implement
>> some cap logic which might cap the last loop (eventually):
>> 
>>    for ( i = 0; i < blocks; i++ )
>>    {
>>        struct irq_block *irqs = gic_ctx.dist.irqs + i;
>>        size_t j, off = i * sizeof(irqs->isenabler);
>>        size_t nr_regs = ARRAY_SIZE(irqs->ipriorityr);
>> 
>>        if ( i == blocks - 1 )
>>            nr_regs = DIV_ROUND_UP(gicv2_info.nr_lines - i * 32, 4);
>> 
>>        […]
>> 
>>        off = i * sizeof(irqs->ipriorityr);
>>        for ( j = 0; j < nr_regs; j++ )
>>            writel_gicd(irqs->ipriorityr[j], GICD_IPRIORITYR + off + j * 4);
>> 
>>        /*
>>         * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
>>         * they are read-only on multiprocessor implementations and RAZ/WI
>>         * on uniprocessor implementations.
>>         */
>>        if ( i )
>>        {
>>            off = i * sizeof(irqs->itargetsr);
>>            for ( j = 0; j < nr_regs; j++ )
>>                writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j * 4);
>>        }
>> 
>>        […]
>>    }
> 
> This was intentional to keep the logic simpler.
> 
> For the 1020-interrupt case, the extra word would correspond to
> interrupt IDs 1020-1023. My reading of ARM IHI 0048B.b is that this
> is architecturally harmless: section 4.1.2 says that reserved
> Distributor register addresses are RAZ/WI, and Table 4-1 marks
> GICD_IPRIORITYR offset 0x7fc and GICD_ITARGETSR offset 0xbfc as
> Reserved.
> 
> Would you be OK with keeping this as-is, or would you prefer me to add
> the cap logic anyway?

I think this would be the only part in the driver that does that, also Linux is 
avoiding
to touch these reserved parts
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/irqchip/irq-gic.c?h=v7.1-rc3#n582)
My preference would be to be consistent.

> 
>> 
>>> +
>>> +        /*
>>> +         * GICD_ITARGETSR0..7 cover SGIs/PPIs and hold no state to save:
>>> +         * they are read-only on multiprocessor implementations and RAZ/WI
>>> +         * on uniprocessor implementations.
>>> +         */
>>> +        if ( i )
>>> +        {
>>> +            off = i * sizeof(irqs->itargetsr);
>>> +            for ( j = 0; j < ARRAY_SIZE(irqs->itargetsr); j++ )
>>> +                writel_gicd(irqs->itargetsr[j], GICD_ITARGETSR + off + j * 
>>> 4);
>>> +        }
>>> +
>>> +        off = i * sizeof(irqs->icfgr);
>>> +        for ( j = 0; j < ARRAY_SIZE(irqs->icfgr); j++ )
>>> +            writel_gicd(irqs->icfgr[j], GICD_ICFGR + off + j * 4);
>> 
>> in the GICv2 specs the usage constraints
>> of GICD_ICFGR says: “Before changing the value of a programmable Int_config 
>> field,
>> software must disable the corresponding interrupt, otherwise GIC behavior is
>> UNPREDICTABLE"
>> 
>> ARM IHI 0048B.b, 4.3.13.
>> 
>> I think we should move this restore just after GICD_ICENABLER write, before 
>> writing
>> GICD_ISENABLER.
> 
> Good catch, I agree.
> 
> I will move the GICD_ICFGR restore after the GICD_ICENABLER writes
> and before restoring GICD_ISENABLER, so that programmable Int_config
> fields are restored while the corresponding interrupts are disabled.
> 
> I will also check whether it makes sense to move the other
> configuration restores before GICD_ISENABLER as well. The spec does
> not seem to impose the same strict requirement there, but keeping all
> configuration restores before re-enabling the interrupts might make
> the ordering clearer.
> 
>> 
>> And also the section says that the GICD_ICFGR0 is read-only.
> 
> For GICD_ICFGR0, my intention was to keep the restore loop uniform.
> There should be no useful SGI state to restore here: section 4.3.13
> says that SGI Int_config[1] is not programmable and RAO/WI, while
> Int_config[0] is reserved. Also, the value written is the value
> previously read from the same register.
> 
> So I do not expect this write to affect the architected SGI
> configuration. However, if you prefer avoiding the write to
> GICD_ICFGR0 explicitly, I will skip it in the next version of
> this series.

I think also Linux “restores” it, so I’m ok to keep the code as it is, in fact 
it’s read-only
and not marked as reserved, my bad!

Cheers,
Luca


 


Rackspace

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