[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XEN PATCH v15 2/4] x86/irq: allow setting IRQ permissions from GSI instead of pIRQ
- To: Jan Beulich <jbeulich@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
- From: "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Date: Fri, 13 Sep 2024 02:38:16 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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=F9hfHVBibKImmSNngGistT4fDuSWJC4VUQv36EtXzIU=; b=Be7zzZmRvoWGBeKblgxLMFyPK2yH5sqIztLe0KGkDb2pBcKOeiEkll2e5UKBC+QRKviBn6EiRhXxE4MAGTt79hiVF8275sWBVX4CncXRUn53zfkv0eWJvyo7wI4ya2sVn6zbZdnDaGqw0GzpQbwbYvE15UwBGPMDM27NSxqDxgQcbupI+18Qrwhb4bR70wq0+pvoXPR39tUbg8E0TV/u7RdXr80HTdgLxQnjJxpIrAmdnsWD3B8eNshdBWE/piD//OOO24SKi0yuuHOgighX5XE3Gy59Kj49YorDpfbLW+GsBB5d05IM4NC8X1I39RbneeqAXvYkLjVcLmCNRaBqqA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S3qw85bvizLMxEN7mj0Pv4qMtVfexQmZT4b46By6wi747FSNQz4uswzOI1rQDAxUIjPZaYhFBvfNmwVy3Fg79pAANzALRNTuklT0X2DDX0HN78LMa8OFCxwp5Ob3+S7asiCkHZqtVehQ+iwBg97flPrqyysEvh09CY+mM/ONHA2uWYxyuSfG2k03xa44ZLIWx11fMkKYwWB+DI+qYfb5Z08r3rXiC38hsDSMVXDQ6bBcGD/wkMW07ifVqcIKI3Pfrlcc1TNPwmBtioqzZyh7IK5NMpBBs+I5cQmXctTo6BKa4sJBHiPXALerV+eGKbc8Jsd1SZOQeQVRKipmOkZtqg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Chen, Jiqian" <Jiqian.Chen@xxxxxxx>
- Delivery-date: Fri, 13 Sep 2024 02:38:31 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHbBBiuopssrGEkhk6CaPzsYxSpJrJT9mIAgAAE1QCAAY3jgA==
- Thread-topic: [XEN PATCH v15 2/4] x86/irq: allow setting IRQ permissions from GSI instead of pIRQ
On 2024/9/12 18:51, Jan Beulich wrote:
> On 12.09.2024 12:34, Daniel P. Smith wrote:
>> On 9/11/24 02:58, Jiqian Chen wrote:
>>> @@ -237,6 +238,34 @@ long arch_do_domctl(
>>> break;
>>> }
>>>
>>> + case XEN_DOMCTL_gsi_permission:
>>> + {
>>> + int irq;
>>> + unsigned int gsi = domctl->u.gsi_permission.gsi;
>>> + uint32_t flags = domctl->u.gsi_permission.flags;
>>> +
>>> + /* Check only valid bits are set */
>>> + ret = -EINVAL;
>>> + if ( flags & ~XEN_DOMCTL_GSI_ACTION_MASK )
>>> + break;
>>> +
>>> + ret = irq = gsi_2_irq(gsi);
>>
>> I was recently informed that a = b = c; form is not MISRA compliant.
>> Since you just overwrite ret after the check, why not drop the
>> assignment to ret and mae the next check against irq instead.
>
> The Misra concern is valid, yet the suggestion doesn't look to be quite
> matching what is needed. After all if we take ...
>
>>> + if ( ret <= 0 )
>>> + break;
>
> ... the "break" path, "ret" needs to be set. Plus there's the problem of
> "ret" being zero when exiting the function indicates success, yet this
> is an error path (requiring ret < 0). So overall perhaps
>
> irq = gsi_2_irq(gsi);
> if ( irq <= 0 )
> {
> ret = irq ?: -EACCES;
> break;
> }
>
> ?
Yes, ret needs to be set. And since gsi_2_irq doesn't return 0(if irq is 0,
gsi_2_irq returns -EINVAL).
Maybe below is enough?
irq = gsi_2_irq(gsi);
if ( irq < 0 )
{
ret = irq;
break;
}
>
> Jan
--
Best regards,
Jiqian Chen.
|