Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions arch/m68k-all/kernel/kernel_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ void cpu_Switch(regs_t *regs)
/* Update tc_SPReg */
task->tc_SPReg = (APTR)regs->a[7];

/*
* core_Switch() Remove()s/Enqueue()s ThisTask on TaskReady/TaskWait.
* Only Wait() gets here with a Disable() held. The Schedule() path
* (Permit(), Enable(), Reschedule(), ExitIntr preemption) arrives
* with INTEN set and the CPU at IPL 0 (Supervisor() does not raise
* it) or at the level of the interrupt that is exiting, so a higher
* level interrupt calling Signal() could edit the same list half-way
* through the Enqueue() and lose a task from both lists. Mask
* interrupts from here on; cpu_Dispatch() does the same before
* core_Dispatch() and the RTE to the new task restores its SR.
*/
asm volatile ("ori.w #0x0700,%%sr\n" : : : "memory");

core_Switch();
}

Expand Down
11 changes: 9 additions & 2 deletions arch/m68k-amiga/kernel/amiga_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ static inline UWORD custom_r(ULONG reg)
UWORD intenar = custom_r(INTENAR); \
if (!(intenar & INTF_INTEN)) \
return TRUE; \
/* Interrupted context had a Disable() outstanding (see EXIT) */ \
const BOOL in_disable = (SysBase->IDNestCnt >= 0); \
UWORD mask = intenar & custom_r(INTREQR) & (irq_mask); \
do {

Expand All @@ -148,8 +150,13 @@ static inline UWORD custom_r(ULONG reg)
* re-enabled the hardware itself (demos do: Disable(), set INTENA, \
* AddIntServer(), spin on a VBL counter), and its Enable() then leaves \
* INTEN clear for good. Interrupt handling must be transparent to the \
* interrupted code, so put the bit back */ \
custom_w(INTENA, INTF_SETCLR | INTF_INTEN); \
* interrupted code, so put the bit back - but only in that case. \
* Doing it unconditionally also fires when the interrupt lands just \
* as the interrupted code enters Disable() (INTENA written, IDNestCnt \
* not yet raised), turning interrupts back on inside its critical \
* section. */ \
if (in_disable && !(custom_r(INTENAR) & INTF_INTEN)) \
custom_w(INTENA, INTF_SETCLR | INTF_INTEN); \
/* Call Exec/ExitIntr */ \
return TRUE;

Expand Down
Loading