On 10/28/15 23:26, Yao, Jiewen wrote:
> Right. It seems S3Resume2Pei does not consider X64 mode. I found at least 3 
> functions need enhancement on mode transition:
> 1) S3RestoreConfig2() - S3Resume <-> SmmCpu (DXE mode);
> 2) S3ResumeExecuteBootScript() - S3Resume <-> BootScriptExecutor (DXE mode)
> 3) S3ResumeBootOs() - S3Resume -> OS WakingVector (OS decide).

In practice at least, these problems appear specific to SMM / SMRAM
usage. When we use OVMF's custom (insecure) LockBoxLib instance, the X64
build of S3Resume2Pei (actually, a fully X64 build of OVMF) provides a
working S3 feature, including Windows 7 and later guests, and Linux
guests. Even a minimal boot script is executed correctly (it has just an
INFO opcode).

If I remember correctly, quite a few code paths are possible through
S3Resume2Pei. I don't exactly recall which one is taken in the above
case, but I thought I'd point out that it works very well in practice.
(The fact notwithstanding that the lockbox is not protected from the
runtime guest OS.)

The pure Ia32 case works well both with and without OVMF's SMM feature.

I don't recall ever testing S3 with the Ia32X64 build; I plan to do that
soonish.

Thanks,
Laszlo

> Thank you
> Yao Jiewen
> 
> -----Original Message-----
> From: Laszlo Ersek [mailto:[email protected]] 
> Sent: Thursday, October 29, 2015 1:34 AM
> To: Kinney, Michael D; Fan, Jeff; Yao, Jiewen
> Cc: edk2-devel-01
> Subject: Re: about the SMM_S3_RESUME_SMM_64 branch in S3Resume2Pei
> 
> On 10/28/15 17:54, Kinney, Michael D wrote:
>> Laszlo,
>>
>> I do not believe any X64 PEI testing has not been performed with this 
>> module.  We will investigate a fix.
> 
> Thank you.
> 
> In any case, in OVMF we might be able to use this module nonetheless, with 
> the OvmfPkgIa32X64.dsc build (== 32-bit PEI, 64-bit DXE).
> 
> Thanks!
> Laszlo
> 
>>
>> Thanks,
>>
>> Mike
>>
>>> -----Original Message-----
>>> From: Laszlo Ersek [mailto:[email protected]]
>>> Sent: Wednesday, October 28, 2015 8:57 AM
>>> To: Fan, Jeff; Yao, Jiewen
>>> Cc: edk2-devel-01; Kinney, Michael D
>>> Subject: about the SMM_S3_RESUME_SMM_64 branch in S3Resume2Pei
>>>
>>> Hi,
>>>
>>> I have a question about the following code in 
>>> "UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c", function
>>> S3RestoreConfig2():
>>>
>>>>     if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) {
>>>>       //
>>>>       // Switch to long mode to complete resume.
>>>>       //
>>>>
>>>>       InterruptStatus = SaveAndDisableInterrupts ();
>>>>       //
>>>>       // Need to make sure the GDT is loaded with values that 
>>>> support long
>>> mode and real mode.
>>>>       //
>>>>       AsmWriteGdtr (&mGdt);
>>>>       //
>>>>       // update segment selectors per the new GDT.
>>>>       //
>>>>       AsmSetDataSelectors (DATA_SEGEMENT_SELECTOR);
>>>>       //
>>>>       // Restore interrupt state.
>>>>       //
>>>>       SetInterruptState (InterruptStatus);
>>>>
>>>>       AsmWriteCr3 ((UINTN)SmmS3ResumeState->SmmS3Cr3);
>>>>
>>>>       //
>>>>       // Disable interrupt of Debug timer, since IDT table cannot 
>>>> work in long
>>> mode.
>>>>       // NOTE: On x64 platforms, because DisablePaging64() will 
>>>> disable
>>> interrupts,
>>>>       // the code in S3ResumeExecuteBootScript() cannot be halted by 
>>>> soft
>>> debugger.
>>>>       //
>>>>       SaveAndSetDebugTimerInterrupt (FALSE);
>>>>
>>>>       AsmEnablePaging64 (
>>>>         0x38,
>>>>         SmmS3ResumeState->SmmS3ResumeEntryPoint,
>>>>         (UINT64)(UINTN)AcpiS3Context,
>>>>         0,
>>>>         SmmS3ResumeState->SmmS3StackBase + SmmS3ResumeState- 
>>>> SmmS3StackSize
>>>>         );
>>>>     }
>>>
>>> At the end of this block, the AsmEnablePaging64() function is called. 
>>> That call results in the following call tree, *if* the module was built for 
>>> X64:
>>>
>>> AsmEnablePaging64()           [MdePkg/Library/BaseLib/X86EnablePaging64.c]
>>>  InternalX86EnablePaging64() [MdePkg/Library/BaseLib/X64/Non-existing.c]
>>>    ASSERT (FALSE)
>>>
>>> This is because the InternalX86EnablePaging64() functionality is 
>>> unavailable in BaseLib on X64.
>>>
>>> My question: how is this branch in S3RestoreConfig2() supposed to 
>>> work *at
>>> all* in an X64 PEI build?
>>>
>>> Thank you,
>>> Laszlo
> 

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to