From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web12.39966.1656688578175625874 for ; Fri, 01 Jul 2022 08:16:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C1Y/ZGBi; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3D8BB82F36 for ; Fri, 1 Jul 2022 15:16:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB5D4C385A2 for ; Fri, 1 Jul 2022 15:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656688574; bh=c/5Df/NC6EV+NJZr5i38431qj7weG8oV1pDy4sJXu8M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=C1Y/ZGBiA4fc45EMkEhZ4daYXlyZr36NrpeUvHbPxU0EKDFBu1thm+Ib4EL18bf6Y X3dKPVJ22wtUJPJsYJ6FQld6IM0YRZPLHwuFlde2jh545rL4Pi9TbXA/aio40Tl0ny GIppoF5nm4Ige02C0Va+4bKS8sfp24w+yxNEkpDavaDCqPSgfAnjpgqge9yluTWMkD ig6Hx7EaFQp8CsV2Dz/2qJx/giRoKDohUMV4p7lqAIVO7PF53M2Gn5syPPDF87SEsD Ed/T8fREbxxHY0cOhKtBO7xj3lxTfa0jTUMPha+4v/R5+BQJi4wD9CAVxhS51ZFukQ vgfsBRQhXcQYA== Received: by mail-lf1-f41.google.com with SMTP id x3so4431200lfd.2 for ; Fri, 01 Jul 2022 08:16:14 -0700 (PDT) X-Gm-Message-State: AJIora9dzxArPmKIXsaADU+DPOFx66ZR0tXwiRv87Y3ujwhw74J0Im5Z Xv4mcvktLilZxBkWmslQVNq5mZNreUJyeZ9sSkY= X-Google-Smtp-Source: AGRyM1sQoZNuNrSrYjVdi6jyLX8qjmhg4Wi5O2Vmltdh33/Wuo3C7O/fI4cC8eY+eM5ByQ/BgWck7WfSrZ0NfkUvshw= X-Received: by 2002:a05:6512:e83:b0:47f:635c:3369 with SMTP id bi3-20020a0565120e8300b0047f635c3369mr9070334lfb.659.1656688572677; Fri, 01 Jul 2022 08:16:12 -0700 (PDT) MIME-Version: 1.0 References: <20220701150617.61224-1-robbiek@xsightlabs.com> In-Reply-To: <20220701150617.61224-1-robbiek@xsightlabs.com> From: "Ard Biesheuvel" Date: Fri, 1 Jul 2022 17:16:00 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ArmPkg/Drivers: ArmGicIsInterruptEnabled returns incorrect value To: Robbie King Cc: edk2-devel-groups-io , Leif Lindholm , Sami Mujawar Content-Type: text/plain; charset="UTF-8" On Fri, 1 Jul 2022 at 17:07, Robbie King wrote: > > The issue appears to have been introduced by: > > 41fb5d46 : ArmPkg/ArmGic: Use the GIC Redistributor instead of GIC Distributor for GICv3 > > The changes to ArmGicIsInterruptEnabled() introduced the error where the Boolean > result is assigned to Interrupts, but then the bit position check is performed > again (against the computed Boolean result instead of the interrupt mask) during > the return statement. > > Fix removes erroneous test and relies on boolean test made at return. > > Cc: Leif Lindholm > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Signed-off-by: Robbie King Nice find! How did you spot this? Through inspection? Or due to an actual failure? Reviewed-by: Ard Biesheuvel I'll go and queue this up, thanks. > --- > ArmPkg/Drivers/ArmGic/ArmGicLib.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/ArmPkg/Drivers/ArmGic/ArmGicLib.c b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > index 58ab45f812..dd3670c7cc 100644 > --- a/ArmPkg/Drivers/ArmGic/ArmGicLib.c > +++ b/ArmPkg/Drivers/ArmGic/ArmGicLib.c > @@ -366,10 +366,9 @@ ArmGicIsInterruptEnabled ( > FeaturePcdGet (PcdArmGicV3WithV2Legacy) || > SourceIsSpi (Source)) > { > - Interrupts = ((MmioRead32 ( > - GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset) > - ) > - & (1 << RegShift)) != 0); > + Interrupts = MmioRead32 ( > + GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset) > + ); > } else { > GicCpuRedistributorBase = GicGetCpuRedistributorBase ( > GicRedistributorBase, > -- > 2.17.1 >