Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp11226pxb; Thu, 12 Aug 2021 09:38:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+YdWWzw0o4w3hCtru0hIFD+su9UZMV//a3a5WluuJiXhzG13eaAjtA9NTLrohsJpIASTL X-Received: by 2002:a5d:9688:: with SMTP id m8mr3716083ion.78.1628786329537; Thu, 12 Aug 2021 09:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628786329; cv=none; d=google.com; s=arc-20160816; b=xgkoliwJCLZHOKXUJu4ydl2mpq+P8f037/997tfAwGoDZ3ipGb9EIE7uNqy0zFyw8l ClbwDW8dj/RFpOkxb3AlL59+oLeEN+8M44k/Ta2JJr+86jLJtk/3D/eGcrNpt2QkZ21j tjpf9/Ov4xAu1nRIek88KoIoMbK7h0ZfRC2/DiQ3RArbKIQ3iYAodUGfmxISUHbhqYGF iVaEisGXvnCUv4gbZHN1fk+LNjp+hIlZlrlOY/CjyoQDi9cE6gmjCn0iQ1Iabsiy+VgQ fPM5krUTfByVRqOmKPeTfyNXkKawsOIib/diZen6aO47Uh7dxDOvt9nIUjmZS8jjqAM4 xkvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=pef6WmejvgAf+JE5vu/sWyuDSYKqNPXUP1v/E/1L2lg=; b=OZPXLpECq7kXh6H1+iJNOQ+/VmwMoMq6C5U9tkqxYtOmrbOyK3Md9SlZ/GUU8vUVMq KpirpJ0AN3e2jOegwaRl1aWIgMt21CxJ2E3H/v+IQgcJ9i5EOanJREykO4UaQU10HWPc qHkwm/GPk6mDq2YRSmvKA6Ev2RN3meGYqvDKguWF6QspVYIDeLrcTKOpynJuKiskE2ES 5Amt10B8QbV/vtox9ayBQo/HlQJvZE9rIkOtmdyutqZQ8MidJBFtv5H1/PIWHmTPiuO5 jfNU/Bhm3I4VYqIFWf+vmlQ4EadglLEMLbzpPNIxSSceNpsaDwC55OF0L6gPUH9FhRqq fvkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y26si3655875jan.75.2021.08.12.09.38.30; Thu, 12 Aug 2021 09:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237584AbhHLNJu (ORCPT + 99 others); Thu, 12 Aug 2021 09:09:50 -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.