From: Jan Kiszka <jan.kiszka@siemens.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH 3/5] pci-assign: Fix dword read at PCI_COMMAND
Date: Thu, 28 Apr 2011 17:36:16 +0200 [thread overview]
Message-ID: <4DB98970.5030303@siemens.com> (raw)
In-Reply-To: <1304002266.3125.9.camel@x201>
On 2011-04-28 16:51, Alex Williamson wrote:
> On Thu, 2011-04-28 at 10:59 +0200, Jan Kiszka wrote:
>> If we emulate the command register, we must only read its content from
>> the shadow config space. For dword read of both PCI_COMMAND and
>> PCI_STATUS, at least the latter must be read from the device.
>>
>> For simplicity reasons and as the code path is not considered
>> performance critical for the affected SRIOV devices, the fix performes
>> device access to the command word unconditionally, even if emulation is
>> enabled and only that word is read.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>> hw/device-assignment.c | 8 +++++---
>> 1 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
>> index f37f108..ee81434 100644
>> --- a/hw/device-assignment.c
>> +++ b/hw/device-assignment.c
>> @@ -482,14 +482,11 @@ static uint32_t assigned_dev_pci_read_config(PCIDevice *d, uint32_t address,
>> /*
>> * Catch access to
>> * - vendor & device ID
>> - * - command register (if emulation needed)
>> * - base address registers
>> * - ROM base address & capability pointer
>> * - interrupt line & pin
>> */
>> if (ranges_overlap(address, len, PCI_VENDOR_ID, 4) ||
>> - (pci_dev->need_emulate_cmd &&
>> - ranges_overlap(address, len, PCI_COMMAND, 2)) ||
>> ranges_overlap(address, len, PCI_BASE_ADDRESS_0, 24) ||
>> ranges_overlap(address, len, PCI_ROM_ADDRESS, 8) ||
>> ranges_overlap(address, len, PCI_INTERRUPT_LINE, 2)) {
>> @@ -521,6 +518,11 @@ do_log:
>> DEBUG("(%x.%x): address=%04x val=0x%08x len=%d\n",
>> (d->devfn >> 3) & 0x1F, (d->devfn & 0x7), address, val, len);
>>
>> + if (pci_dev->need_emulate_cmd) {
>> + val = merge_bits(val, pci_default_read_config(d, PCI_COMMAND, 2),
>> + address, len, PCI_COMMAND, 0xffff);
>
> Shouldn't this be pci_default_read_config(d, address, len)? I think
> what you have works since PCI_COMMAND is at the start of a dword, but it
> violates the merge_bits() assumption that val and mval are from the same
> address with the same length. Thanks,
This is actually a real issue, reading a byte from PCI_COMMAND+1 is broken.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2011-04-28 15:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-28 8:59 [PATCH 0/5] qemu-kvm: pci-assign: Some more cleanups Jan Kiszka
2011-04-28 8:59 ` [PATCH 1/5] pci-assign: Clean up assigned_dev_pci_read/write_config Jan Kiszka
2011-04-28 14:29 ` Alex Williamson
2011-04-28 14:46 ` Jan Kiszka
2011-04-28 14:54 ` Alex Williamson
2011-04-28 15:06 ` Jan Kiszka
2011-04-28 15:46 ` Jan Kiszka
2011-04-28 8:59 ` [PATCH 2/5] pci-assign: Move merge_bits Jan Kiszka
2011-04-28 8:59 ` [PATCH 3/5] pci-assign: Fix dword read at PCI_COMMAND Jan Kiszka
2011-04-28 14:51 ` Alex Williamson
2011-04-28 15:36 ` Jan Kiszka [this message]
2011-04-28 8:59 ` [PATCH 4/5] pci-assign: Remove suspicious hunk from assigned_dev_pci_read_config Jan Kiszka
2011-04-28 8:59 ` [PATCH 5/5] pci-assign: Convert need_emulate_cmd into a bitmask Jan Kiszka
2011-04-28 9:34 ` [PATCH 0/5] qemu-kvm: pci-assign: Some more cleanups Avi Kivity
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=4DB98970.5030303@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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.