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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 69692C4338F for ; Thu, 12 Aug 2021 13:11:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21B2A61059 for ; Thu, 12 Aug 2021 13:11:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 21B2A61059 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=husSMglyMaQi8/GoXXwFsQc7bYFH3in/6eBWgTFeXFs=; b=4NY/hsnbr1DY6a tDsZLfAbESHyluEbAFHrPfrfgcfPxgmmGKGi+ppvqmfclndw35KzZrD0jNzkZs4X0Dfq2mLG9J4mP IrXcs8qirmzR4r8Uwl11Umh2H5AA7S8BweM0K55Y1bnA4xLgCaZ2qJJ47HH3X5mOX1BrvCKn3askf JJbfBwTfTsd5nopR3rWNAjMir+bgeHKp/kN7OqP7HU5pqV6hvvt7/RHvc7wQCcXiM33EvjdohkWGV ypfkcmYAnmYkhQkGh/7Ac2lb8cAFz/7OTLrOmlaEgb8hzq1Mv1r2Dii0ABCm1VeWhyBh0kGaXZ3vc gsncjOjoOfqteUc+CjXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mEASs-00A749-0l; Thu, 12 Aug 2021 13:09:42 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mEASd-00A71z-PU for linux-arm-kernel@lists.infradead.org; Thu, 12 Aug 2021 13:09:32 +0000 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210812_060927_887513_4C1D5E11 X-CRM114-Status: GOOD ( 25.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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.