On 10/26/15 14:47, Jeff Fan wrote:
> Add CPU AP hlt-loop code into startup code structure which is located in ACPI
> NVS range and will be safe during OS booting.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jeff Fan <[email protected]>
> CC: Michael Kinney <[email protected]>
> CC: Laszlo Ersek <[email protected]>
> ---
> UefiCpuPkg/CpuDxe/ApStartup.c | 12 ++++++++++++
> UefiCpuPkg/CpuDxe/CpuMp.h | 8 ++++++++
> 2 files changed, 20 insertions(+)
I think the word "run" should be dropped from the patch subject.
Other than that it *appears* sane to me. I didn't verify the binary
opcodes in mCpuApRunHltLoopCodeTemplate. Also, it doesn't work (more
about that in the next patch), but I don't know if that's a problem with
this patch or the next one.
The general logic is of course sane here.
Thanks
Laszlo
>
> diff --git a/UefiCpuPkg/CpuDxe/ApStartup.c b/UefiCpuPkg/CpuDxe/ApStartup.c
> index 77476ae..7449889 100644
> --- a/UefiCpuPkg/CpuDxe/ApStartup.c
> +++ b/UefiCpuPkg/CpuDxe/ApStartup.c
> @@ -36,6 +36,12 @@ ENABLE_EXECUTE_DISABLE_CODE
> mEnableExecuteDisableCodeTemplate = {
> #endif
> };
>
> +CPU_AP_RUN_HLT_LOOP_CODE mCpuApRunHltLoopCodeTemplate = {
> + 0xFA, // cli (Clear Interrupts)
> + 0xF4, // hlt
> + {0xEB, 0xFA} // jmp $-2
> +};
> +
> /**
> This .asm code used for translating processor from 16 bit real mode into
> 64 bit long mode. which help to create the mStartupCodeTemplate value.
> @@ -317,6 +323,12 @@ PrepareAPStartupCode (
> StartupCode->EnableExecuteDisable.Cr3Value = (UINT32) AsmReadCr3 ();
> #endif
>
> + CopyMem (
> + (VOID*) &StartupCode->CpuApRunHltLoopCode,
> + &mCpuApRunHltLoopCodeTemplate,
> + sizeof (CPU_AP_RUN_HLT_LOOP_CODE)
> + );
> +
> return EFI_SUCCESS;
> }
>
> diff --git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h
> index feca3be..907e993 100644
> --- a/UefiCpuPkg/CpuDxe/CpuMp.h
> +++ b/UefiCpuPkg/CpuDxe/CpuMp.h
> @@ -46,6 +46,12 @@ typedef struct {
> } ENABLE_EXECUTE_DISABLE_CODE;
>
> typedef struct {
> + UINT8 Cli; // cli
> + UINT8 Hlt; // hlt
> + UINT8 JmpToHlt[2]; // jmp $-2
> +} CPU_AP_RUN_HLT_LOOP_CODE;
> +
> +typedef struct {
> UINT8 JmpToCli[2];
>
> UINT16 GdtLimit;
> @@ -117,6 +123,8 @@ typedef struct {
> #endif
> UINT8 JmpToCpuDxeEntry[2];
>
> + CPU_AP_RUN_HLT_LOOP_CODE CpuApRunHltLoopCode;
> +
> } STARTUP_CODE;
>
> #pragma pack()
>
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel