Good catch. Thanks! Committed in r14996.

It looks like QemuFlashRead & QemuFlashWrite have some more issues
regarding verifying that the read/write is contained to a single
block. Plus, as you pointed out in a separate email, the 64k comment
in both of those routines is wrong.

On Mon, Dec 16, 2013 at 10:48 PM, Laszlo Ersek <[email protected]> wrote:
> When QemuFlashWrite() is asked to write a range that includes the last
> byte of the LBA, then the byte that the function uses to switch the flash
> device back to read mode (ROMD mode in KVM speak) actually falls out of
> the LBA.
>
> Normally this doesn't cause visible problems. However, if the variable
> store and the firmware code are backed by separate flash devices, as
> implemented by
>
>   [Qemu-devel] [PATCH v2] hw/i386/pc_sysfw: support two flash drives
>   http://thread.gmane.org/gmane.comp.emulators.qemu/243678
>
> plus
>
>   [edk2] [edk2 PATCH] OvmfPkg: split the variable store to a separate file
>   http://thread.gmane.org/gmane.comp.bios.tianocore.devel/5045/focus=5046
>
> then the READ_ARRAY_CMD not only reaches a different LBA, it reaches a
> different qemu device. This results in a guest reboot soon after.
>
> Fix this by ensuring that we always stay within the LBA just written when
> issuing READ_ARRAY_CMD.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <[email protected]>
> ---
>  OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c 
> b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> index a3fe7d8..f9c6f5c 100644
> --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c
> @@ -208,7 +208,7 @@ QemuFlashWrite (
>    // Restore flash to read mode
>    //
>    if (*NumBytes > 0) {
> -    *Ptr = READ_ARRAY_CMD;
> +    *(Ptr - 1) = READ_ARRAY_CMD;
>    }
>
>    return EFI_SUCCESS;
> --
> 1.8.3.1
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to