qemu/include
Jamin Lin 05d501a1ea aspeed/smc: Fix write incorrect data into flash in user mode
According to the design of ASPEED SPI controllers user mode, users write the
data to flash, the SPI drivers set the Control Register(0x10) bit 0 and 1
enter user mode. Then, SPI drivers send flash commands for writing data.
Finally, SPI drivers set the Control Register (0x10) bit 2 to stop
active control and restore bit 0 and 1.

According to the design of ASPEED SMC model, firmware writes the
Control Register and the "aspeed_smc_flash_update_ctrl" function is called.
Then, this function verify Control Register(0x10) bit 0 and 1. If it set user
mode, the value of s->snoop_index is SNOOP_START else SNOOP_OFF.
If s->snoop_index is SNOOP_START, the "aspeed_smc_do_snoop" function verify
the first incomming data is a new flash command and writes the corresponding
dummy bytes if need.

However, it did not check the current unselect status. If current unselect
status is "false" and firmware set the IO MODE by Control Register bit 31:28,
the value of s->snoop_index will be changed to SNOOP_START again and
"aspeed_smc_do_snoop" misunderstand that the incomming data is the new flash
command and it causes writing unexpected data into flash.

Example:
1. Firmware set user mode by Control Register bit 0 and 1(0x03)
2. SMC model set s->snoop SNOOP_START
3. Firmware set Quad Page Program with 4-Byte Address command (0x34)
4. SMC model verify this flash command and it needs 4 dummy bytes.
5. Firmware send 4 bytes address.
6. SMC model receives 4 bytes address
7. Firmware set QPI IO MODE by Control Register bit 31. (0x80000003)
8. SMC model verify new user mode by Control Register bit 0 and 1.
   Then, set s->snoop SNOOP_START again. (It is the wrong behavior.)
9. Firmware send 0xebd8c134 data and it should be written into flash.
   However, SMC model misunderstand that the first incoming data, 0x34,
   is the new command because the value of s->snoop is changed to SNOOP_START.
   Finally, SMC sned the incorrect data to flash model.

Introduce a new unselect attribute in AspeedSMCState to save the current
unselect status for user mode and set it "true" by default.
Update "aspeed_smc_flash_update_ctrl" function to check the previous unselect
status. If both new unselect status and previous unselect status is different,
update s->snoop_index value and call "aspeed_smc_flash_do_select".

Increase VMStateDescription version.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
[ clg: - Replaced VMSTATE_BOOL -> VMSTATE_BOOL_V ]
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2024-10-24 07:57:47 +02:00
..
authz
block include: Move QemuLockCnt APIs to their own header 2024-10-15 15:16:17 +01:00
chardev chardev/mux: convert size members to unsigned int 2024-10-15 12:26:01 +04:00
crypto crypto: accumulative hashing API 2024-10-10 12:32:59 +01:00
disas disas: Remove CRIS disassembler 2024-10-07 11:33:20 +02:00
exec exec/memop: Remove unused memop_big_endian() helper 2024-10-15 11:55:09 -03:00
fpu
gdbstub gdbstub/helpers: Introduce ldtul_$endian_p() helpers 2024-10-15 11:55:09 -03:00
hw aspeed/smc: Fix write incorrect data into flash in user mode 2024-10-24 07:57:47 +02:00
io qio: add support for SO_PEERCRED for socket channel 2024-07-22 13:47:41 +02:00
libdecnumber
migration migration: Remove unused VMSTATE_ARRAY_TEST() macro 2024-06-21 14:37:58 -03:00
monitor monitor: Remove obsolete stubs 2024-06-30 19:51:44 +03:00
net net: Remove deadcode 2024-10-03 17:26:05 +03:00
qapi qerror: QERR_PROPERTY_VALUE_OUT_OF_RANGE is no longer used, drop 2024-10-18 15:03:35 +02:00
qemu Remove some target-specific endianness knowledge from target/. 2024-10-16 20:22:08 +01:00
qom qom: update object_resolve_path*() documentation 2024-10-03 22:04:24 +02:00
scsi
semihosting semihosting: Include missing 'gdbstub/syscalls.h' header 2024-07-22 09:38:01 +01:00
standard-headers linux-headers: update to 6.10-rc1 2024-07-01 17:16:04 -04:00
sysemu KVM: Rename KVMState->nr_slots to nr_slots_max 2024-10-17 19:41:30 +02:00
tcg include/exec/memop: Move get_alignment_bits from tcg.h 2024-10-13 11:27:03 -07:00
ui ui: refactor using a common qemu_pixman_shareable 2024-10-14 17:34:09 +04:00
user linux-user: Remove support for CRIS target 2024-09-13 20:10:50 +02:00
elf.h
glib-compat.h
qemu-io.h
qemu-main.h