|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 1/3] Capture Context->Request once per SyncWorker iteration
Context->Request is a shared variable and so we must capture it instead
of rereading every time. Otherwise, this sequence will be possible:
* A synchronized action (e.g. __SyncProcessorDisableInterrupts)
completes from the owner's viewpoint, but its worker has not finished
updating Request = Context->Request yet;
* The owner sets Context->Request to something else;
* Request = Context->Request executes and sets Request to the wrong
value.
Assisted-by: LLM
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
src/xenbus/sync.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/xenbus/sync.c b/src/xenbus/sync.c
index eefa2fe..b416dbb 100644
--- a/src/xenbus/sync.c
+++ b/src/xenbus/sync.c
@@ -284,21 +284,22 @@ SyncWorker(
Request = SYNC_REQUEST_NONE;
for (;;) {
- NTSTATUS status;
+ SYNC_REQUEST Next;
+ NTSTATUS status;
- KeMemoryBarrier();
+ Next = ReadAcquire((LONG *)&Context->Request);
- if (Context->Request == SYNC_REQUEST_EXIT)
+ if (Next == SYNC_REQUEST_EXIT)
break;
- if (Context->Request == Request) {
+ if (Next == Request) {
_mm_pause();
continue;
}
status = STATUS_SUCCESS;
- switch (Context->Request) {
+ switch (Next) {
case SYNC_REQUEST_DISABLE_INTERRUPTS:
status = __SyncProcessorDisableInterrupts(&Irql);
break;
@@ -321,7 +322,7 @@ SyncWorker(
}
if (NT_SUCCESS(status))
- Request = Context->Request;
+ Request = Next;
}
ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL);
--
2.55.0.windows.3
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |