Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp73970imn; Wed, 3 Aug 2022 20:15:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR5gdw6F4UNQsM+eJxvNKlWYSxYAw/W4EZ8axbUfaQOE3cWzjs7KSPc5EKunwzvVBDW1k/lj X-Received: by 2002:a05:6a00:787:b0:52d:47ca:e9fb with SMTP id g7-20020a056a00078700b0052d47cae9fbmr19586052pfu.39.1659582927574; Wed, 03 Aug 2022 20:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659582927; cv=none; d=google.com; s=arc-20160816; b=YqXCFAMYSEYLuGEdpSrUKsICBKlykrUAnO/64KYIgVTfqJNJATQIG+CLlVA/JQKIkg h1NujoKmmewt8QrBXQohxupJ4x7RB6efW0BsCs36RcQT1yk2wVnCy+Y3xjVrrge88Kov RkEC4mA8LGsg1ZRIIFKMPvWIJBaJ5dLYRstLbdHYF0AyitqmMTIwLEZhpjDe2WOgSDgT CKn8ktRcsskYWM8GHW00HOmk5ac5YWWxDXYmWZCTGHIyZsPKitsBKHwZZRDlMTgPt3uo OAP6Bf+YF9bPxoug7KkAk4KYR8zMok1MaIPrI/kxtOVSYDOp4UOxYGhIYGZu9ENzwXnY 9/Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=7AamRdppKvDSQrc9DYTmow3W1DdARJPLLdADy2Ps/Tk=; b=H74DScV2IQLui1RCvuwJY5x0PYvnuh1VKqUrufbG5s1Xl0L46uE9DyqRQmhPeXDLZJ w5zT4eEn9JWxcbyl+l4kfT6TTPelZucHErnztZVoJAL/oIYI3zPdUwzuDM1MGzkWu+Rn zq5uPpRR5/wWScGrU+0RGmUvKSbNCItgWQqiZBHoVErMo3YHzcSDkynfn6HAD+LxlWw1 yM9b211Rwzs35WXlMWi5mSAz0656pDrDWAyNvbkO2Sfg9QO572mYIGRm1pS4I04VBBYf oETzDm8N+krvxc56t43Hk5mxWozcWRt6uVuVW0ohHb3wMoNln7R2IL52UvBY+tD9azoo DN2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aLRkbAjr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a656055000000b0041aaa83d200si19263226pgp.579.2022.08.03.20.15.10; Wed, 03 Aug 2022 20:15:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aLRkbAjr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236387AbiHDCqW (ORCPT + 99 others); Wed, 3 Aug 2022 22:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbiHDCqS (ORCPT ); Wed, 3 Aug 2022 22:46:18 -0400 Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD581EC48 for ; Wed, 3 Aug 2022 19:46:17 -0700 (PDT) Received: by mail-ua1-x92b.google.com with SMTP id t21so7755319uaq.3 for ; Wed, 03 Aug 2022 19:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc; bh=7AamRdppKvDSQrc9DYTmow3W1DdARJPLLdADy2Ps/Tk=; b=aLRkbAjrkTiOBwngiAXaGfPz9SlT8CVBeBLb3a8Oh0vFnpsY2UxyXdJKhBcO6J9+Hj a+r0mX0vqT/JtsYSki4zIvGzFh/tbvxKchIZDlxk/SQ+mHOEft011MDpqWjN8u4Q2urS lsQUIbA+K4Rueo7ipWyuJmcHN8AjN/v4mlOj3porzVa2zC5G9jJpYjrBWhnkOAKCFkVw /h1xGQFgTmUmh4mmV1mB9TAzdpZNkXTRoNQAEFI+exbyGilGp1kkWNNbJRQZyWR08XvS kJYsbS+bxol3Ifu0+SoJrFNLs5fjn+3CTF0xyd0uM56R5JbbzH1VTIlK8Dhdkj0Yo0O6 qTNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=7AamRdppKvDSQrc9DYTmow3W1DdARJPLLdADy2Ps/Tk=; b=j89NlsDa/D5Kf6KyqPpR7wl30e+rEDWauNw+l4u3rAcShS3xBBd7WKpjwhs0GvnWtR ZRjjqlSwr/JdZaVXFgKyZM1ls7znTeiNo9agBk5ygvTWJU5aQ6ZZAVSmryC+sEtLNSde Wh2NmCy8T0QPPcM80XS7zFB71Y3dfgYDIrjx7Qmah5Q7IHYM9A91s/vgu3tcPoV5O0CM GRIPqku+C0VJN3xcwtV95FMzaA0T/ccO/c6tdv0+R6yocoQ2ZvivTxbqR/L9Oar/KqoB e/XMI5iSG5+CQBj+QYZAn+9oGdA3b7ue8RyNSkZUYhQItgULij3f/s9NFw5RIxwR6QKw bkcQ== X-Gm-Message-State: ACgBeo3oYDDPYHgpoxaYiGAsL435+oANxfm8ts6aBwkFN0SAzSMJ7d5p pquHvW5Q4KwSv+xwCWgj4YNvmMsQlQFJ9qsNYq8= X-Received: by 2002:ab0:65d6:0:b0:385:f6e1:83ef with SMTP id n22-20020ab065d6000000b00385f6e183efmr11690820uaq.23.1659581175594; Wed, 03 Aug 2022 19:46:15 -0700 (PDT) MIME-Version: 1.0 References: <20220803042728.3230346-1-chenhuacai@loongson.cn> <87r11xbxox.wl-maz@kernel.org> <97d33f58-6a15-3a94-f9c0-42ebd48cf562@loongson.cn> In-Reply-To: <97d33f58-6a15-3a94-f9c0-42ebd48cf562@loongson.cn> From: Huacai Chen Date: Thu, 4 Aug 2022 10:46:00 +0800 Message-ID: Subject: Re: [PATCH 1/2] irqchip/loongson-eiointc: Check hwirq overflow To: Jianmin Lv Cc: Marc Zyngier , Huacai Chen , Thomas Gleixner , loongarch@lists.linux.dev, LKML , Xuefeng Li , Jiaxun Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 3, 2022 at 7:59 PM Jianmin Lv wrote: > > > > On 2022/8/3 =E4=B8=8B=E5=8D=883:33, Huacai Chen wrote: > > Hi, Jianmin, > > > > On Wed, Aug 3, 2022 at 3:20 PM Marc Zyngier wrote: > >> > >> On Wed, 03 Aug 2022 05:27:27 +0100, > >> Huacai Chen wrote: > >>> > >>> Check hwirq overflow when allocate irq in eiointc domain. > >>> > >>> Signed-off-by: Huacai Chen > >>> --- > >>> drivers/irqchip/irq-loongson-eiointc.c | 7 +++++-- > >>> 1 file changed, 5 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip= /irq-loongson-eiointc.c > >>> index 80d8ca6f2d46..f8060e58ee06 100644 > >>> --- a/drivers/irqchip/irq-loongson-eiointc.c > >>> +++ b/drivers/irqchip/irq-loongson-eiointc.c > >>> @@ -241,8 +241,11 @@ static int eiointc_domain_alloc(struct irq_domai= n *domain, unsigned int virq, > >>> struct eiointc *priv =3D domain->host_data; > >>> > >>> ret =3D irq_domain_translate_onecell(domain, arg, &hwirq, &typ= e); > >>> - if (ret) > >>> - return ret; > >>> + if (ret < 0) > >>> + return -EINVAL; > >>> + > >>> + if (hwirq >=3D IOCSR_EXTIOI_VECTOR_NUM) > >>> + return -EINVAL; > >> > >> How can this happen? Also, you're allocating a *range*. Surely the > >> upper boundary should matter too? > > Do you know the exact reason? Please give some information, thanks. > > > > In our internal repo, we don't have middle domain in pch-msi driver, so > no check for hwirq as in alloc of middle domain. When hwirq is assigned > failed(negtive value), the wrong hwirq will be passed to parent > domain(eio domain)'s alloc, so we add check in eio domain's alloc there. > > > But here, it seems that the check is unnecessary, because in pch-msi driv= er: > > static int pch_msi_middle_domain_alloc(struct irq_domain *domain, > unsigned int virq, > unsigned int nr_irqs, void > *args) > { > struct pch_msi_data *priv =3D domain->host_data; > int hwirq, err, i; > > > hwirq =3D pch_msi_allocate_hwirq(priv, nr_irqs); > if (hwirq < 0) > return hwirq; > > > for (i =3D 0; i < nr_irqs; i++) { > err =3D pch_msi_parent_domain_alloc(domain, virq + i, > hwirq + i); > [...] > > > If pch_msi_allocate_hwirq failed, pch_msi_middle_domain_alloc will > return, and pch_msi_parent_domain_alloc(will call eio domain's alloc) > will not be called. OK, then this patch can be removed and I only need to send the 2nd one. Tha= nks. Huacai > > > >> > >> And for the umpteenth time, please add a cover letter when sending > >> multiple patches. This is a hard requirement for me. > > OK, I will add a cover letter, even for simple fix patches. Sorry. > > > > Huacai > >> > >> Thanks, > >> > >> M. > >> > >> -- > >> Without deviation from the norm, progress is not possible. > >