mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 01:00:52 +07:00
irqchip/gic-v3: Fix priority comparison when non-secure priorities are used
[ Upstream commit 8d474deaba2c4dd33a5e2f5be82e6798ffa6b8a5 ]
When non-secure priorities are used, compared to the raw priority set,
the value read back from RPR is also right-shifted by one and the
highest bit set.
Add a macro to do the modifications to the raw priority when doing the
comparison against the RPR value. This corrects the pseudo-NMI behavior
when non-secure priorities in the GIC are used. Tested on 5.10 with
the "IPI as pseudo-NMI" series [1] applied on MT8195.
[1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/
Fixes: 3367805909
("irqchip/gic-v3: Support pseudo-NMIs when SCR_EL3.FIQ == 0")
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
[maz: Added comment contributed by Alex]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210811171505.1502090-1-wenst@chromium.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9d690b5e2d
commit
ffd709642b
@ -115,6 +115,27 @@ EXPORT_SYMBOL(gic_pmr_sync);
|
|||||||
DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities);
|
DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities);
|
||||||
EXPORT_SYMBOL(gic_nonsecure_priorities);
|
EXPORT_SYMBOL(gic_nonsecure_priorities);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When the Non-secure world has access to group 0 interrupts (as a
|
||||||
|
* consequence of SCR_EL3.FIQ == 0), reading the ICC_RPR_EL1 register will
|
||||||
|
* return the Distributor's view of the interrupt priority.
|
||||||
|
*
|
||||||
|
* When GIC security is enabled (GICD_CTLR.DS == 0), the interrupt priority
|
||||||
|
* written by software is moved to the Non-secure range by the Distributor.
|
||||||
|
*
|
||||||
|
* If both are true (which is when gic_nonsecure_priorities gets enabled),
|
||||||
|
* we need to shift down the priority programmed by software to match it
|
||||||
|
* against the value returned by ICC_RPR_EL1.
|
||||||
|
*/
|
||||||
|
#define GICD_INT_RPR_PRI(priority) \
|
||||||
|
({ \
|
||||||
|
u32 __priority = (priority); \
|
||||||
|
if (static_branch_unlikely(&gic_nonsecure_priorities)) \
|
||||||
|
__priority = 0x80 | (__priority >> 1); \
|
||||||
|
\
|
||||||
|
__priority; \
|
||||||
|
})
|
||||||
|
|
||||||
/* ppi_nmi_refs[n] == number of cpus having ppi[n + 16] set as NMI */
|
/* ppi_nmi_refs[n] == number of cpus having ppi[n + 16] set as NMI */
|
||||||
static refcount_t *ppi_nmi_refs;
|
static refcount_t *ppi_nmi_refs;
|
||||||
|
|
||||||
@ -719,7 +740,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (gic_supports_nmi() &&
|
if (gic_supports_nmi() &&
|
||||||
unlikely(gic_read_rpr() == GICD_INT_NMI_PRI)) {
|
unlikely(gic_read_rpr() == GICD_INT_RPR_PRI(GICD_INT_NMI_PRI))) {
|
||||||
gic_handle_nmi(irqnr, regs);
|
gic_handle_nmi(irqnr, regs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user