[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; int Valid;
} sys_mbox_t; } sys_mbox_t;
typedef KIRQL sys_prot_t; typedef u32_t sys_prot_t;
typedef u32_t sys_thread_t; typedef u32_t sys_thread_t;

View file

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