Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1447962pxb; Fri, 20 Aug 2021 05:59:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHSlZUCQ7ttmJU9s8HQEIlxfYwojVs6plzZ9eliNika9NqSeprBkC3BKeXcsYSFO5p3Id1 X-Received: by 2002:a6b:fc17:: with SMTP id r23mr15901001ioh.89.1629464392626; Fri, 20 Aug 2021 05:59:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629464392; cv=none; d=google.com; s=arc-20160816; b=Uzf2rUezjPP2IoYMeN4HvFrAg+V3blgD+B3jN9wFBNMRvGfWj/Cu7Qhw+NAnXwxYfz 7RnRBZaXLZEBIx/rEMlWoKkOQ9eOosbcJJAQoZlrT6+PscG7M5+GGmYeghhexH4drBmP 0rsUpeeQWo/28YPmb5/WgICE1ngx5OuVBMG3yB7tWcZoV4xy6KqxFAAf0o5YwHHjD8TY XC03zGKViIflSttFr9ZHghDRFvvRUwgN/IcpkESq1JvE1LSSzWYDGNy91hfBGnO93vyM T6NtDfobhKLhZUhGDrx5Op0mc0cOsvXez1jhbn5bKCXF2rFsztyQDvEdqr0nEd3Ahw+S 8zUQ== 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=NaO3zjKFxdETypwRn6iiyQegCbemqvpXl9VFMMFvIn8=; b=gyGQZf11mj/BBo0mk5JY3zgu8fTPeUKn4AVS2RTfTFcUzas4k3rruTQbXa9o1OZF4N bb+Jb7kEW+Y3UhrVbpGpDw4+mYZuN/RB8kmKEE4QnAkhAXseleU986dQwipdWqXZbcIM iYkvCV8AILaLRGCF2i8d0YLd0mRjI9e4bYGR1YuXXPHZWyXLhYqYiiPxS200grXEeU9B 4/h7KJqHgnIS/aybgu6tLh5A0QwAQEUwKVf89Yy+9cIMCP+B0lEgcF8zsCH1U7I7/IbJ sgeZHx1fju2SYUj8oYK/OwJcil7ZNSTtVEgxrW+qF1IayLV9NHWh5yYdQD8mSOVNwYGm DTyg== 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 a14si2107550iod.86.2021.08.20.05.59.41; Fri, 20 Aug 2021 05:59:52 -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 S240509AbhHTM7h (ORCPT + 99 others); Fri, 20 Aug 2021 08:59:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:41766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237886AbhHTM7g (ORCPT ); Fri, 20 Aug 2021 08:59:36 -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 DEE2A6101A; Fri, 20 Aug 2021 12:58:58 +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 1mH46q-006BtP-VK; Fri, 20 Aug 2021 13:58:57 +0100 Date: Fri, 20 Aug 2021 13:58:56 +0100 Message-ID: <87pmu8qnlb.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: <061bafb6-b0fe-bd7c-1567-a642d3ddd4a5@arm.com> References: <20210811171505.1502090-1-wenst@chromium.org> <87fsvfal4n.wl-maz@kernel.org> <79eabae1-e4a3-7a12-7aa0-3680569584e5@arm.com> <871r6yajy7.wl-maz@kernel.org> <061bafb6-b0fe-bd7c-1567-a642d3ddd4a5@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 Hi Alex, On Thu, 12 Aug 2021 15:24:03 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 8/12/21 2:09 PM, Marc Zyngier wrote: > > 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])? > > Yes, when SCR_EL3.FIQ=1, but gic_nonsecure_priorities is enabled > when SCR_EL3.FIQ=0 (gic_has_group0()). In that case ICC_RPR_EL1 > returns (what I assume to be) the highest priority interrupt from > ICC_AP0R_EL1, ICC_AP1R_EL1NS and ICC_AP1R_EL1S. Isn't that the > secure view (or Distributor value) of the priority? Yup. I guess I got confused with what "non-secure" priorities mean in this context. [...] > I don't see how that is the case - ICC_RPR_EL1 contains the priority > value as seen by the Distributor, and non-secure priorities get > right-shifted when SCR_EL3.FIQ=0, meaning that GICD_INT_NMI_PRI > becomes (GICD_INT_NMI_PRI >> 1) | 0x80 in the Distributor. Can you > elaborate where I'm contradicting myself? I think I know why I confused myself. When FIQ==0, G0 is NS. On the face of it, this should mean that no shift occurs. However, G1S is still in the picture, and we get the extra shift to preserve the ordering with G1S. This is a different configuration from that of a guest, where G0 is also NS, but there is no shift at all, as there is no G1S. The GIC strikes back. Again. I run some more tests with this patch, and merge it of nothing breaks. Thanks, M. -- Without deviation from the norm, progress is not possible.