|
From: kosmirror <kos...@us...> - 2025-06-10 05:24:19
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 65b232b0fc206eb9dfd4705d460a9f29fc942839 (commit)
from f376087d912cab7891ae9f9941d871913664c2a6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 65b232b0fc206eb9dfd4705d460a9f29fc942839
Author: Falco Girgis <gyr...@gm...>
Date: Sun Jun 8 07:44:25 2025 -0500
Fixed race when getting/setting IRQ/TRAPA handlers
When accessing an IRQ or TRAPA handler, it's possible that the handler
could be swapped out from under you either fully or partially by another
thread or IRQ.
It's also possible an IRQ or TRAPA handler could be called from an IRQ
WHILE its still being set by a user, so both the callback function and
userdata pointers may not have both been set atomically before the IRQ,
causing them to get out-of-sync.
- Disabled IRQs around IRQ and TRAPA handler setter and getter
accessors to ensure they accessed atomically.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/kernel/irq.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index cb8b3d06..6201e93b 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -3,7 +3,7 @@
arch/dreamcast/kernel/irq.c
Copyright (C) 2000-2001 Megan Potter
Copyright (C) 2024 Paul Cercueil
- Copyright (C) 2024 Falco Girgis
+ Copyright (C) 2024, 2025 Falco Girgis
Copyright (C) 2024 Andy Barajas
*/
@@ -62,6 +62,8 @@ int irq_set_handler(irq_t code, irq_handler hnd, void *data) {
return -1;
code >>= 5;
+
+ irq_disable_scoped();
irq_handlers[code] = (struct irq_cb){ hnd, data };
return 0;
@@ -75,11 +77,14 @@ irq_cb_t irq_get_handler(irq_t code) {
code >>= 5;
+ irq_disable_scoped();
return irq_handlers[code];
}
/* Set a global handler */
int irq_set_global_handler(irq_handler hnd, void *data) {
+ irq_disable_scoped();
+
global_irq_handler.hdl = hnd;
global_irq_handler.data = data;
return 0;
@@ -87,17 +92,23 @@ int irq_set_global_handler(irq_handler hnd, void *data) {
/* Get the global exception handler */
irq_cb_t irq_get_global_handler(void) {
+ irq_disable_scoped();
+
return global_irq_handler;
}
/* Set or remove a trapa handler */
int trapa_set_handler(trapa_t code, trapa_handler hnd, void *data) {
+ irq_disable_scoped();
+
trapa_handlers[code] = (struct trapa_cb){ hnd, data };
return 0;
}
/* Get a particular trapa handler */
trapa_handler trapa_get_handler(trapa_t code, void **data) {
+ irq_disable_scoped();
+
if(data)
*data = trapa_handlers[code].data;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|