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

Re: [PATCH v2] x86/i8259: do not assume interrupts always target CPU0


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 24 Oct 2023 14:06:19 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=8DDXaMqjlUPXfonVbETQvei9LFFZosBxH82U2W04kuY=; b=j431KPMd+pcnIwTmJJs8FG1I3L+n9f5C9MnHgw0AnUpgpqSRabT14+Xn+WKWHFox7qZZvkzst3QHeiAhKmOLYmexUbMkO/RPKqU8ApX3Afj1/eYsX9Qnyu//SFJK0zdkIcYCmdBxzjGRL/qH49EZqvHIxrDVFKX690K/DxtSc3ujjHnu6kZn4lOzeZewzYn9Ga/ORmO/n2keM2D0uKRqKHq0irGNPGmcfQA9umkmnhDI+d3PoD2IZDJ4jBVBSQUkSDn+UHhQl2jLBKgb8AKxdRtQYBNNrGRohzT2MqciaEt9GYXnSXBHd6OoQtHqFH44vZIL66IKxW0d5/sra+C7sg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O/2GuLTv6U6N7u9yJpT0ZPnJ8Oy/ghSf5v4NDei8EDHMdtJy2lvYH5b3V2OX43HMTmJIUx3l0B6khrWoHioM6Mf8PxLZuwuSFRdAeBP3KwIb8ZFffpe6uM7taVahNgXSZC6u4vnl69BVJ+E3IwMyPnSruF2Mr03FXjSfjSCehk1/rLaMi0PWuAdT20Djs6HcxH15KUa2c8jxsMgZj+EAkOCGQM9RLXsqlg6tzRbRP7GG/kUxy3DPIR2qlM+uxgJcwFuK7RGLQcsGJp7QJCCwN6zsPsO/6/VQbWc1L/Cu0U8d23loGw9xKxOvCTNsfdMMd6SMbzEVF8djLO4LEZTOEw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 24 Oct 2023 12:06:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.10.2023 13:36, Roger Pau Monné wrote:
> On Tue, Oct 24, 2023 at 12:51:08PM +0200, Jan Beulich wrote:
>> On 24.10.2023 12:14, Roger Pau Monné wrote:
>>> On Tue, Oct 24, 2023 at 11:33:21AM +0200, Jan Beulich wrote:
>>>> On 23.10.2023 14:46, Roger Pau Monne wrote:
>>>>> --- a/xen/arch/x86/i8259.c
>>>>> +++ b/xen/arch/x86/i8259.c
>>>>> @@ -37,6 +37,15 @@ static bool _mask_and_ack_8259A_irq(unsigned int irq);
>>>>>  
>>>>>  bool bogus_8259A_irq(unsigned int irq)
>>>>>  {
>>>>> +    if ( smp_processor_id() &&
>>>>> +         !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | 
>>>>> X86_VENDOR_HYGON)) )
>>>>> +        /*
>>>>> +         * For AMD/Hygon do spurious PIC interrupt detection on all 
>>>>> CPUs, as it
>>>>> +         * has been observed that during unknown circumstances spurious 
>>>>> PIC
>>>>> +         * interrupts have been delivered to CPUs different than the BSP.
>>>>> +         */
>>>>> +        return false;
>>>>> +
>>>>>      return !_mask_and_ack_8259A_irq(irq);
>>>>>  }
>>>>
>>>> I don't think this function should be changed; imo the adjustment belongs
>>>> at the call site.
>>>
>>> It makes the call site much more complex to follow, in fact I was
>>> considering pulling the PIC vector range checks into
>>> bogus_8259A_irq().  Would that convince you into placing the check here
>>> rather than in the caller context?
>>
>> Passing a vector and moving the range check into the function is something
>> that may make sense. But I'm afraid the same does not apply to the
>> smp_processor_id() check, unless the function was also renamed to
>> bogus_8259A_vector(). Which in turn doesn't make much sense, to me at
>> least, as the logic would better be in terms of IRQs (which is what the
>> chip deals with primarily), not vectors (which the chip deals with solely
>> during the INTA cycle with the CPU).
> 
> The alternative is to use:
> 
>             if ( !(vector >= FIRST_LEGACY_VECTOR &&
>                    vector <= LAST_LEGACY_VECTOR &&
>                    (!smp_processor_id() ||
>                     /*
>                      * For AMD/Hygon do spurious PIC interrupt
>                      * detection on all CPUs, as it has been observed
>                      * that during unknown circumstances spurious PIC
>                      * interrupts have been delivered to CPUs
>                      * different than the BSP.
>                      */
>                    (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD |
>                                                 X86_VENDOR_HYGON))) &&
>                    bogus_8259A_irq(vector - FIRST_LEGACY_VECTOR)) )
>             {
> 
> Which I find too complex to read, and prone to mistakes by future
> modifications.

>From my pov the main badness with this is pre-existing: The wrapping of
a complex expression in !(...). The replacement of the prior plain
smp_processor_id() isn't much of a problem imo.

> What is your reasoning for wanting the smp_processor_id() check in
> the caller rather than bogus_8259A_irq()?  It does seem fine to me to
> do such check in bogus_8259A_irq(), as whether the IRQ is bogus also
> depends on whether it fired on the BSP or any of the APs.

bogus_8259A_irq() shouldn't be concerned about the CPU it runs on; it
should solely deal with 8259A aspects.

Jan



 


Rackspace

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