On 9/6/23 16:08, Niklas Cassel wrote:
From: Niklas Cassel <niklas.cas...@wdc.com>

When encountering an NCQ error, you should not write the NCQ tag to the
SError register. This is completely wrong.

The SError register has a clear definition, where each bit represents a
different error, see PxSERR definition in AHCI 1.3.1.

If we write a random value (like the NCQ tag) in SError, e.g. Linux will
read SError, and will trigger arbitrary error handling depending on the
NCQ tag that happened to be executing.

In case of success, ncq_cb() will call ncq_finish().
In case of error, ncq_cb() will call ncq_err() (which will clear
ncq_tfs->used), and then call ncq_finish(), thus using ncq_tfs->used is
sufficient to tell if finished should get set or not.


Cc: qemu-sta...@nongnu.org
Fixes: f6ad2e32f8 ("ahci: add ahci emulation")
Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>

Signed-off-by: Niklas Cassel <niklas.cas...@wdc.com>
---
  hw/ide/ahci.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)


Reply via email to