]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/char/pl011: Use correct masks for IBRD and FBRD
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 14 Oct 2024 16:05:53 +0000 (17:05 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 15 Oct 2024 17:33:06 +0000 (20:33 +0300)
commit10e3edd9b3b745ca7772a046c06a27ef539fba33
tree92b584f7f864d7a5cc22112ee9c3f894cb2c4b7e
parent460ddd62fa559ec6c53e6229a3f1b6ceea7f5390
hw/char/pl011: Use correct masks for IBRD and FBRD

In commit b88cfee90268cad we defined masks for the IBRD and FBRD
integer and fractional baud rate divider registers, to prevent the
guest from writing invalid values which could cause division-by-zero.
Unfortunately we got the mask values the wrong way around: the FBRD
register is six bits and the IBRD register is 16 bits, not
vice-versa.

You would only run into this bug if you programmed the UART to a baud
rate of less than 9600, because for 9600 baud and above the IBRD
value will fit into 6 bits, as per the table in
 https://developer.arm.com/documentation/ddi0183/g/programmers-model/register-descriptions/fractional-baud-rate-register--uartfbrd

The only visible effects would be that the value read back from
the register by the guest would be truncated, and we would
print an incorrect baud rate in the debug logs.

Cc: qemu-stable@nongnu.org
Fixes: b88cfee90268 ("hw/char/pl011: Avoid division-by-zero in pl011_get_baudrate()")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2610
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Message-id: 20241007144732.2491331-1-peter.maydell@linaro.org
(cherry picked from commit cd247eae16ab1b9ce97fd34c000c1b883feeda45)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/char/pl011.c