This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 0b20ac192befa49764bf6ec92bd107a244a73744 Author: hujun5 <[email protected]> AuthorDate: Wed Sep 2 18:12:06 2026 +0800 rptun/arm64: let the doorbell follow the core that waits for it rptun_bmp_notify() always targeted the mask given to rptun_bmp_init(), in practice Core0. When the peer OS lives in the other security state of the same physical cores, the doorbell belongs to the sending core: its peer-world context is the one waiting for it. Treat an empty remote_cpu as that case and raise the SGI on the current core; a non-empty mask still names a distinct processor and is used as is. The doorbell is an SGI and up_enable_irq() only writes the calling core's redistributor, so enable it on every core, not just Core0. up_trigger_irq() also dropped the cpuset when a secure SGI had to go through the monitor; pass it as the second SMC argument. Signed-off-by: hujun5 <[email protected]> --- arch/arm64/src/common/arm64_gicv3.c | 3 ++- drivers/rptun/rptun_bmp.c | 27 ++++++++++++++++++++------- include/nuttx/rptun/rptun_bmp.h | 4 +++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/arch/arm64/src/common/arm64_gicv3.c b/arch/arm64/src/common/arm64_gicv3.c index c8194903a2d..52da710ee68 100644 --- a/arch/arm64/src/common/arm64_gicv3.c +++ b/arch/arm64/src/common/arm64_gicv3.c @@ -852,7 +852,8 @@ void up_trigger_irq(int irq, cpu_set_t cpuset) struct arm_smccc_res res; arm_smccc_smc(ARM_SMCCC_NUTTX_SEND_SECURE_SGI, - irq, 0, 0, 0, 0, 0, 0, &res); + irq, cpuset, + 0, 0, 0, 0, 0, &res); } else #endif diff --git a/drivers/rptun/rptun_bmp.c b/drivers/rptun/rptun_bmp.c index c2334e8d94a..1b70f927e4c 100644 --- a/drivers/rptun/rptun_bmp.c +++ b/drivers/rptun/rptun_bmp.c @@ -141,7 +141,18 @@ static int rptun_bmp_notify(FAR struct rptun_dev_s *dev, uint32_t vqid) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev; - up_trigger_irq(priv->irq_trigger, priv->cpuset); + /* An empty remote_cpu means the peer OS lives in the other security state + * of the SAME physical cores (REE <-> TEE), so the doorbell belongs to the + * core we are running on: that is the core whose peer-world context waits + * for it. A fixed mask would always poke one core no matter where the + * sender runs, serialising every notification through that core. + * + * Otherwise the peer is a distinct processor with its own core numbering + * and the mask the board passed is the only valid target. + */ + + up_trigger_irq(priv->irq_trigger, + priv->cpuset != 0 ? priv->cpuset : 1 << this_cpu()); return 0; } @@ -166,19 +177,21 @@ static int rptun_bmp_register_callback(FAR struct rptun_dev_s *dev, FAR void *arg) { FAR struct rptun_bmp_dev_s *priv = (FAR struct rptun_bmp_dev_s *)dev; +#ifdef CONFIG_SMP + cpu_set_t cpuset = (1 << CPU_SETSIZE) - 1; +#endif priv->callback = callback; priv->arg = arg; #ifdef CONFIG_SMP - /* The doorbell IRQ (SGI/PPI) is routed to CPU0. On ARM GIC, - * up_enable_irq/up_disable_irq for per-CPU interrupts only - * affects the local core's enable bit. We must ensure the - * operation executes on CPU0; use nxsched_cpu_call_single() - * to dispatch it if we are running on another core. + /* The doorbell SGI is enabled per core: up_enable_irq() writes the + * calling core's GICR_ISENABLER0 and affects that core only. Enable it + * on every core so delivery does not depend on which core the sender + * targets, nor on which core happens to run this registration. */ - nxsched_cpu_call_single(0, rptun_bmp_set_irq, priv); + nxsched_cpu_call(cpuset, rptun_bmp_set_irq, priv); #else rptun_bmp_set_irq(priv); #endif diff --git a/include/nuttx/rptun/rptun_bmp.h b/include/nuttx/rptun/rptun_bmp.h index ff156c11099..50971082c56 100644 --- a/include/nuttx/rptun/rptun_bmp.h +++ b/include/nuttx/rptun/rptun_bmp.h @@ -52,7 +52,9 @@ extern "C" * rsc - The resource for shared memory * irq_event - Interrupt ID to attach * irq_trigger - Interrupt ID to trigger - * remote_cpu - Remote CPU ID + * remote_cpu - Set of cores the doorbell is raised on. Pass an empty set + * when the peer shares these physical cores (REE <-> TEE); the doorbell + * is then raised on whichever core sends it. * * Returned Value: * OK on success, negated errno on failure
