Skip to content

Commit

Permalink
Merged PR 5474: Add code to block on AP execution if a task is in pro…
Browse files Browse the repository at this point in the history
…gress.

## Description

This adds a blocking loop to AP status check to ensure all APs are completed with any non-blocking tasks before allowing dispatch of new tasks.

- Breaking change?
  No.

## How This Was Tested

Tested by dispatching a long-running non-blocking task, and then attempting to dispatch a second task. Prior to this change, second task would proceed with dispatch, interfering with the first task. With this change, the second task waits in CheckAndUpdateApsStatus() until the first task completes.

## Integration Instructions

N/A
  • Loading branch information
joschock authored and kenlautner committed May 9, 2023
1 parent 818ca9e commit 7d231a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
12 changes: 8 additions & 4 deletions UefiCpuPkg/CpuMpPei/CpuMpPei.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,14 @@ PeiStartupThisAP (
The execution is in non-blocking mode. The BSP continues executing immediately
after starting the AP.
Caller is responsible for ensuring that the scheduled AP task is complete (via
caller-specific logic) before dispatching further tasks on the AP using this
or other routines in the API.
If an attempt is made to dispatch a blocking or non-blcoking task on the AP
while it is running a non-blocking task, that dispatch will block until the
AP completes the current task.
No timeout is specified - failure of the AP to complete the task is fatal. If
the AP crashes or fails to return from Procedure, then the next attempt to
dispatch blocking or non-blocking tasks on the AP will hang waiting on the AP.
No attempt is made to reset or recover the AP in this state.
@param[in] PeiServices An indirect pointer to the PEI Services Table
published by the PEI Foundation.
Expand Down
15 changes: 11 additions & 4 deletions UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,18 @@ CheckAndUpdateApsStatus (
continue;
}

Status = CheckThisAP (ProcessorNumber);
//
// Block until all CPUs are ready. This ensures that we don't attempt to dispatch
// tasks on CPUs that are executing a non-blocking task. NOTE: this implies
// that only one non-blocking AP dispatch may be outstanding at a time.
//
do {
Status = CheckThisAP (ProcessorNumber);

if (Status != EFI_NOT_READY) {
CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL;
}
if (Status != EFI_NOT_READY) {
CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL;
}
} while (Status == EFI_NOT_READY);
}

// MU_CHANGE - End Add basic support for non-blocking AP dispatch in PEI.
Expand Down

0 comments on commit 7d231a6

Please sign in to comment.