[TCPIP] Fix global synchronization on SMP

We cannot just raise IRQL! Instead use a global ERESOURCE, which allows to be acquired recursively, as required by LWIP.
This commit is contained in:
Timo Kreuzer 2025-07-18 12:47:42 +03:00
parent b4731b7f8f
commit 069fc049db
2 changed files with 10 additions and 4 deletions

View file

@ -15,7 +15,7 @@ typedef struct _sys_mbox_t
int Valid;
} sys_mbox_t;
typedef KIRQL sys_prot_t;
typedef u32_t sys_prot_t;
typedef u32_t sys_thread_t;

View file

@ -5,6 +5,8 @@
static LIST_ENTRY ThreadListHead;
static KSPIN_LOCK ThreadListLock;
static ERESOURCE GlobalLock;
static ULONG GlobalLockLevel = 0;
KEVENT TerminationEvent;
NPAGED_LOOKASIDE_LIST MessageLookasideList;
@ -32,14 +34,18 @@ u32_t sys_now(void)
void
sys_arch_protect(sys_prot_t *lev)
{
/* Preempt the dispatcher */
KeRaiseIrql(DISPATCH_LEVEL, lev);
/* Acquire the global resource to prevent other CPUs from running */
ExEnterCriticalRegionAndAcquireResourceExclusive(&GlobalLock);
*lev = ++GlobalLockLevel;
}
void
sys_arch_unprotect(sys_prot_t lev)
{
KeLowerIrql(lev);
/* Release the global resource */
ASSERT((GlobalLockLevel > 0) && (lev == GlobalLockLevel));
GlobalLockLevel--;
ExReleaseResourceAndLeaveCriticalRegion(&GlobalLock);
}
err_t