Re: [PATCH] hw/block/pflash_cfi01: Always set romd mode when clearing wcycle and cmd
Philippe Mathieu-Daudé <[email protected]>
| Newsgroups | gmane.comp.emulators.qemu,gmane.comp.emulators.qemu.block |
|---|---|
| Message-ID | <[email protected]> |
On 18/8/26 13:57, Peter Maydell wrote:
> The pflash_cfi01 code has an invariant that the MemoryRegion is in
> ROMD mode if and only if wcycle == 0 && cmd == 0. We rely on this
> for setting ROMD mode on an inbound migration.
>
> There is one corner case where the code clears wcycle and cmd without
> also setting ROMD mode on the MR: in the "should never happen" code
> path in pflash_read(). As the comment notes, that code really is
> unreachable (unless an inbound migration feeds us a bogus pfl->cmd
> value), so this isn't a problem in practice. But it does make the
> code a little trickier to analyse.
>
> Pull out a function which does the "clear wcycle and cmd and set mode
> to ROMD", and use it in the three places that need to do this. This
> makes it clearer that we are preserving our invariant, and tidies up
> the loose end noted in the commit message of 60d010f66f2ad7
> ("hw/block/pflash_cfi01: Restore ROMD mode after migration").
>
> Signed-off-by: Peter Maydell <[email protected]>
> ---
> hw/block/pflash_cfi01.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>