From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Paul Durrant <paul.durrant@citrix.com>,
Keir Fraser <keir@xen.org>,
xen-devel@lists.xen.org
Subject: Re: [PATCH v3 for 4.5] ioreq-server: handle the lack of a default emulator properly
Date: Tue, 30 Sep 2014 10:52:04 +0100 [thread overview]
Message-ID: <542A7D44.8080404@citrix.com> (raw)
In-Reply-To: <542A987E020000780003AF6E@mail.emea.novell.com>
On 30/09/14 10:48, Jan Beulich wrote:
>>>> On 30.09.14 at 11:29, <andrew.cooper3@citrix.com> wrote:
>> On 30/09/14 10:18, Paul Durrant wrote:
>>> I started porting QEMU over to use the new ioreq server API and hit a
>>> problem with PCI bus enumeration. Because, with my patches, QEMU only
>>> registers to handle config space accesses for the PCI device it implements
>>> all other attempts by the guest to access 0xcfc go nowhere and this was
>>> causing the vcpu to wedge up because nothing was completing the I/O.
>>>
>>> This patch introduces an I/O completion handler into the hypervisor for the
>>> case where no ioreq server matches a particular request. Read requests are
>>> completed with 0xf's in the data buffer, writes and all other I/O req types
>>> are ignored.
>>>
>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>> Cc: Keir Fraser <keir@xen.org>
>>> Cc: Jan Beulich <jbeulich@suse.com>
>> One bug, couple of nits.
>>
>> It is probably worth having a sentence in the commit message concerning
>> the removal of list_is_singular().
>>
>>> ---
>>> v3: - Fix for backwards string instruction emulation
>>>
>>> v2: - First non-RFC submission
>>> - Removed warning on unemulated MMIO accesses
>>>
>>> xen/arch/x86/hvm/hvm.c | 35 ++++++++++++++++++++++++++++++++---
>>> 1 file changed, 32 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
>>> index 5c7e0a4..e6611ed 100644
>>> --- a/xen/arch/x86/hvm/hvm.c
>>> +++ b/xen/arch/x86/hvm/hvm.c
>>> @@ -2386,8 +2386,7 @@ static struct hvm_ioreq_server
>> *hvm_select_ioreq_server(struct domain *d,
>>> if ( list_empty(&d->arch.hvm_domain.ioreq_server.list) )
>>> return NULL;
>>>
>>> - if ( list_is_singular(&d->arch.hvm_domain.ioreq_server.list) ||
>>> - (p->type != IOREQ_TYPE_COPY && p->type != IOREQ_TYPE_PIO) )
>>> + if ( p->type != IOREQ_TYPE_COPY && p->type != IOREQ_TYPE_PIO )
>>> return d->arch.hvm_domain.default_ioreq_server;
>>>
>>> cf8 = d->arch.hvm_domain.pci_cf8;
>>> @@ -2618,12 +2617,42 @@ bool_t hvm_send_assist_req_to_ioreq_server(struct
>> hvm_ioreq_server *s,
>>> return 0;
>>> }
>>>
>>> +static bool_t hvm_complete_assist_req(ioreq_t *p)
>>> +{
>>> + switch (p->type)
>> Style: ( p-> type )
>>
>>> + {
>>> + case IOREQ_TYPE_COPY:
>>> + case IOREQ_TYPE_PIO:
>>> + if ( p->dir == IOREQ_READ )
>>> + {
>>> + if ( !p->data_is_ptr )
>>> + p->data = ~0ul;
>>> + else
>>> + {
>>> + int i, step = p->df ? -p->size : p->size;
>> 'i' must be unsigned or larger, given p->count being uint32_t.
> No (or else similar changes would be needed elsewhere) - the field
> being uint32_t doesn't imply the full value range to be used. This is
> an ioreq_t, which we fill ourselves. Remember the code I pointed
> you to yesterday? The correctness of the above follows from
> similar implications afaict.
>
> Jan
>
It is a matter of defensive coding. Just because we do not expect
p->size * p->count to be greater than a page doesn't mean that some bug
wont cause it to happen.
At this point, the different between a signed and unsigned i is a
bounded or unbounded loop.
~Andrew
next prev parent reply other threads:[~2014-09-30 9:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 9:18 [PATCH v3 for 4.5] ioreq-server: handle the lack of a default emulator properly Paul Durrant
2014-09-30 9:29 ` Andrew Cooper
2014-09-30 9:31 ` Andrew Cooper
2014-09-30 9:43 ` Paul Durrant
2014-09-30 9:45 ` Andrew Cooper
2014-09-30 9:49 ` Jan Beulich
2014-09-30 9:52 ` Paul Durrant
2014-10-02 9:54 ` Paul Durrant
2014-10-02 10:28 ` Jan Beulich
2014-10-02 10:37 ` Paul Durrant
2014-09-30 9:48 ` Jan Beulich
2014-09-30 9:52 ` Andrew Cooper [this message]
2014-09-30 10:42 ` Jan Beulich
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=542A7D44.8080404@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=paul.durrant@citrix.com \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.