[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/11] m25p80: Improve command handling for unsupported commands
From: |
Peter Maydell |
Subject: |
[PULL 09/11] m25p80: Improve command handling for unsupported commands |
Date: |
Tue, 17 Mar 2020 11:40:37 +0000 |
From: Guenter Roeck <address@hidden>
Whenever an unsupported command is encountered, the current code
interprets each transferred byte as new command. Most of the time, those
'commands' are interpreted as new unknown commands. However, in rare
cases, it may be that for example address or length information
passed with the original command is by itself a valid command.
If that happens, the state machine may get completely confused and,
worst case, start writing data into the flash or even erase it.
To avoid the problem, transition into STATE_READING_DATA and keep
sending a value of 0 until the chip is deselected after encountering
an unsupported command.
Signed-off-by: Guenter Roeck <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Cédric Le Goater <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/block/m25p80.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
index 53bf63856f5..82270884416 100644
--- a/hw/block/m25p80.c
+++ b/hw/block/m25p80.c
@@ -1161,6 +1161,11 @@ static void decode_new_cmd(Flash *s, uint32_t value)
s->quad_enable = false;
break;
default:
+ s->pos = 0;
+ s->len = 1;
+ s->state = STATE_READING_DATA;
+ s->data_read_loop = true;
+ s->data[0] = 0;
qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
break;
}
--
2.20.1
- [PULL 00/11] target-arm queue, Peter Maydell, 2020/03/17
- [PULL 02/11] hw/arm/fsl-imx6ul: Fix USB interrupt numbers, Peter Maydell, 2020/03/17
- [PULL 01/11] hw/usb: Add basic i.MX USB Phy support, Peter Maydell, 2020/03/17
- [PULL 03/11] hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices, Peter Maydell, 2020/03/17
- [PULL 04/11] hw/arm/fsl-imx6ul: Wire up USB controllers, Peter Maydell, 2020/03/17
- [PULL 05/11] hw/arm/fsl-imx6: Wire up USB controllers, Peter Maydell, 2020/03/17
- [PULL 06/11] hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write(), Peter Maydell, 2020/03/17
- [PULL 08/11] m25p80: Improve command handling for Jedec commands, Peter Maydell, 2020/03/17
- [PULL 07/11] m25p80: Convert to support tracing, Peter Maydell, 2020/03/17
- [PULL 09/11] m25p80: Improve command handling for unsupported commands,
Peter Maydell <=
- [PULL 11/11] hw/arm/pxa2xx: Do not wire up OHCI for PXA255, Peter Maydell, 2020/03/17
- [PULL 10/11] aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command, Peter Maydell, 2020/03/17
- Re: [PULL 00/11] target-arm queue, Peter Maydell, 2020/03/17