Reviewed-by: Jordan Justen <[email protected]>

On 2015-07-24 16:00:07, Laszlo Ersek wrote:
> We have an old bug in BootModeInitialization(): firmware is supposed to
> clear the CMOS register 0xF after reading it for the last time. QEMU only
> sets this register to 0xFE in "hw/timer/mc146818rtc.c", function
> rtc_notify_suspend(), and never clears it. However, SeaBIOS does clear it
> in "src/post.c" and "src/resume.c", so let's follow suit.
> 
> We've never noticed this until now because the register gets mysteriously
> cleared on non-resume reboots when OVMF runs on qemu-system-x86_64. But on
> qemu-system-i386, this bug breaks a (suspend, resume, reboot) triplet:
> after the last step OVMF thinks it's resuming because when it actually
> resumed (in the middle step), it failed to clear the register.
> 
> BootModeInitialization() is the perfect function to clear the register,
> right after setting mBootMode: the function is executed on both normal
> boot and on S3 resume; it succeeds DebugDumpCmos() -- so the dump is not
> affected by this patch --; and everything that relies on S3 vs. normal
> boot after we clear the register uses mBootMode anyway.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <[email protected]>
> ---
>  OvmfPkg/PlatformPei/Platform.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index fc98fc3..d7b1d41 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -324,6 +324,7 @@ BootModeInitialization (
>    if (CmosRead8 (0xF) == 0xFE) {
>      mBootMode = BOOT_ON_S3_RESUME;
>    }
> +  CmosWrite8 (0xF, 0x00);
>  
>    Status = PeiServicesSetBootMode (mBootMode);
>    ASSERT_EFI_ERROR (Status);
> -- 
> 1.8.3.1
> 
> 
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to