From: Peter Maydell <peter.maydell@linaro.org>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Alistair Francis <alistair23@gmail.com>,
Prasad J Pandit <pjp@fedoraproject.org>,
Huawei PSIRT <psirt@huawei.com>
Subject: Re: [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration
Date: Tue, 6 Dec 2016 09:31:02 +0000 [thread overview]
Message-ID: <CAFEAcA8k++Q9ByEj_yynGW+N6sry4wNCB-=ASXtWuLHEBUxSHw@mail.gmail.com> (raw)
In-Reply-To: <cb06a932a7c6b29bc6eb0d35f31766bfb0bba47f.1480962799.git.alistair.francis@xilinx.com>
On 5 December 2016 at 18:35, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> The Cadence UART device emulator calculates speed by dividing the
> baud rate by a 'baud rate generator' & 'baud rate divider' value.
> The device specification defines these register values to be
> non-zero and within certain limits. Checks were recently added when
> writing to these registers but not when restoring from migration.
>
> This patch adds checks when restoring from migration to avoid divide by
> zero errors.
>
> Reported-by: Huawei PSIRT <psirt@huawei.com>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> It would be nice to squeeze this into 2.8 if possible.
>
> V3:
> - Fix broken migration logic
> - Manually double checked and it passes migration.
> V2:
> - Abort the migration if the data is invalid
>
> hw/char/cadence_uart.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
> index 0215d65..ce9063b 100644
> --- a/hw/char/cadence_uart.c
> +++ b/hw/char/cadence_uart.c
> @@ -502,6 +502,13 @@ static int cadence_uart_post_load(void *opaque, int version_id)
> {
> CadenceUARTState *s = opaque;
>
> + /* Ensure these two aren't invalid numbers */
> + if (s->r[R_BRGR] <= 1 || s->r[R_BRGR] & ~0xFFFF ||
> + s->r[R_BDIV] <= 3 || s->r[R_BDIV] & ~0xFF) {
The uart_write() code says BRGR == 1 is valid, but
this code says it isn't. Which is correct?
thanks
-- PMM
next prev parent reply other threads:[~2016-12-06 9:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 18:35 [Qemu-devel] [PATCH for 2.8 v3 1/1] cadence_uart: Check baud rate generator and divider values on migration Alistair Francis
2016-12-06 1:56 ` Huawei PSIRT
2016-12-06 9:31 ` Peter Maydell [this message]
2016-12-07 17:23 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFEAcA8k++Q9ByEj_yynGW+N6sry4wNCB-=ASXtWuLHEBUxSHw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=alistair.francis@xilinx.com \
--cc=alistair23@gmail.com \
--cc=pjp@fedoraproject.org \
--cc=psirt@huawei.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).