Re: [PATCH] irqchip/gic-v3: Fix priority comparison when non-secure priorities are used
From: Marc Zyngier <maz@kernel.org>
Date: 2021-08-12 13:09:27
Also in:
lkml
On Thu, 12 Aug 2021 12:51:34 +0100, Alexandru Elisei [off-list ref] 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:
<quote>
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);
</quote>
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