From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65926C4338F for ; Thu, 12 Aug 2021 13:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4284F61058 for ; Thu, 12 Aug 2021 13:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237384AbhHLNJv (ORCPT ); Thu, 12 Aug 2021 09:09:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:55464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236326AbhHLNJt (ORCPT ); Thu, 12 Aug 2021 09:09:49 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B78536109F; Thu, 12 Aug 2021 13:09:22 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mEASW-004YZp-Sn; Thu, 12 Aug 2021 14:09:21 +0100 Date: Thu, 12 Aug 2021 14:09:20 +0100 Message-ID: <871r6yajy7.wl-maz@kernel.org> From: Marc Zyngier To: Alexandru Elisei Cc: Chen-Yu Tsai , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] irqchip/gic-v3: Fix priority comparison when non-secure priorities are used In-Reply-To: <79eabae1-e4a3-7a12-7aa0-3680569584e5@arm.com> References: <20210811171505.1502090-1-wenst@chromium.org> <87fsvfal4n.wl-maz@kernel.org> <79eabae1-e4a3-7a12-7aa0-3680569584e5@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: alexandru.elisei@arm.com, wenst@chromium.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 Aug 2021 12:51:34 +0100, Alexandru Elisei wrote: > > Hi, > > After re-familiarizing myself with the spec, it starting to look to > me like indeed there's something not quite right (read as: totally > broken) with my patch. > > Arm IHI 0069F, the pseudocode for reading ICC_RPR_EL1 (page 11-797), > says that the priority returned is unchanged if SCTLR_EL3.FIQ == > 0. Sure, but look at what ICC_RPR_EL1 does for FIQ==1: if HaveEL(EL3) && !IsSecure() && SCR_EL3.FIQ == '1' then // A Non-secure GIC access and Group 0 inaccessible to Non-secure. if pPriority<7> == '0' then // Priority is in Secure half and not visible to Non-secure Priority = Zeros(); elsif !IsOnes(pPriority) then // Non-secure access and not idle, so physical priority must be shifted pPriority<7:0> = (pPriority AND PRIMask())<6:0>:'0'; return ZeroExtend(pPriority); See how the the priority is shifted *left* (bits [6:0] end up in [7:1])? > This means that the ICC_RPR_EL1 read will return the secure view > (the value as it is stored by the GIC) of the priority, so for > pseudo-nmis it will return (GICD_INT_NMI_PRI >> 1) | 0x80, which > definitely != GICD_INT_NMI_PRI. That's not my reading of the pseudocode. > This is further confirmed by this statement on page 4-67: > > "When GICD_CTLR.DS == 0, [..] For Non-secure access to ICC_PMR_EL1 > and ICC_RPR_EL1 when SCR_EL3.FIQ == 0: The Secure, unshifted view > applies." > > I don't know how I missed that during testing. > > Did a quick test on the model with PMU NMIs (GICD_CTRL.DS = 0, > SCTLR_EL2.FIQ = 0), gic_handle_nmi() was not being called at all, 0? Really???? > but when I changed the comparison to gic_read_rpr() == > ((GICD_INT_NMI_PRI >> 1) | 0x80), NMIs were being correctly handled > again. You have completely lost me. This contradicts what you have written above. Thanks, M. -- Without deviation from the norm, progress is not possible.