From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] [ide] Check that asynchronous (DMA) submission succeeds
Date: Thu, 28 Aug 2008 15:23:37 -0500 [thread overview]
Message-ID: <48B70949.5040906@codemonkey.ws> (raw)
In-Reply-To: <18614.55228.190438.575778@mariner.uk.xensource.com>
Ian Jackson wrote:
> Check that asynchronous (DMA) submission succeeds
>
> If it does not, abort the command immediately rather than dropping
> it on the floor.
>
It's generally dangerous to call callbacks from the code that is issuing
a bdrv_aio_ operation. A malicious guest could potentially force the
emulation into an infinite loop.
It would be better to use a bottom half to dispatch the callback.
Regards,
Anthony Liguori
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> hw/ide.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/hw/ide.c b/hw/ide.c
> index 1e60591..9b95c35 100644
> --- a/hw/ide.c
> +++ b/hw/ide.c
> @@ -737,6 +737,13 @@ static inline void ide_abort_command(IDEState *s)
> s->status = READY_STAT | ERR_STAT;
> s->error = ABRT_ERR;
> }
> +static inline void ide_dma_submit_check(IDEState *s,
> + BlockDriverCompletionFunc *dma_cb, BMDMAState *bm)
> +{
> + if (bm->aiocb)
> + return;
> + dma_cb(bm, -1);
> +}
>
> static inline void ide_set_irq(IDEState *s)
> {
> @@ -933,6 +940,7 @@ static void ide_read_dma_cb(void *opaque, int ret)
> #endif
> bm->aiocb = bdrv_aio_read(s->bs, sector_num, s->io_buffer, n,
> ide_read_dma_cb, bm);
> + ide_dma_submit_check(s, ide_read_dma_cb, bm);
> }
>
> static void ide_sector_read_dma(IDEState *s)
> @@ -1035,6 +1043,7 @@ static void ide_write_dma_cb(void *opaque, int ret)
> #endif
> bm->aiocb = bdrv_aio_write(s->bs, sector_num, s->io_buffer, n,
> ide_write_dma_cb, bm);
> + ide_dma_submit_check(s, ide_write_dma_cb, bm);
> }
>
> static void ide_sector_write_dma(IDEState *s)
>
next prev parent reply other threads:[~2008-08-28 20:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-28 16:52 [Qemu-devel] [PATCH] [ide] Check that asynchronous (DMA) submission succeeds Ian Jackson
2008-08-28 20:23 ` Anthony Liguori [this message]
2008-08-29 9:41 ` Ian Jackson
2008-09-07 2:48 ` Anthony Liguori
2008-09-07 4:16 ` Jamie Lokier
2008-08-31 6:42 ` Gleb Natapov
2008-09-01 11:31 ` Ian Jackson
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=48B70949.5040906@codemonkey.ws \
--to=anthony@codemonkey.ws \
--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).