From: Avi Kivity <avi@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jan Kiszka <jan.kiszka@web.de>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org, Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [PATCH 12/13] pci-assign: Generic config space access management
Date: Tue, 28 Jun 2011 12:10:53 +0300 [thread overview]
Message-ID: <4E099A9D.6050803@redhat.com> (raw)
In-Reply-To: <20110628085108.GL10881@redhat.com>
On 06/28/2011 11:51 AM, Michael S. Tsirkin wrote:
> On Mon, Jun 27, 2011 at 08:19:55PM +0200, Jan Kiszka wrote:
> > -/* There can be multiple VNDR capabilities per device, we need to find the
> > - * one that starts closet to the given address without going over. */
> > -static uint8_t find_vndr_start(PCIDevice *pci_dev, uint32_t address)
> > +static uint32_t assigned_dev_pci_read_config(PCIDevice *pci_dev,
> > + uint32_t address, int len)
> > {
> > - uint8_t cap, pos;
> > + AssignedDevice *assigned_dev = DO_UPCAST(AssignedDevice, dev, pci_dev);
> > + uint32_t virt_val = pci_default_read_config(pci_dev, address, len);
> > + uint32_t real_val, direct_mask;
> >
> > - for (cap = pos = 0;
> > - (pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_VNDR, pos));
> > - pos += PCI_CAP_LIST_NEXT) {
> > - if (pos<= address) {
> > - cap = MAX(pos, cap);
> > - }
> > + switch (len) {
> > + case 4:
> > + direct_mask =
> > + pci_get_long(assigned_dev->direct_config_read + address);
> > + break;
> > + case 2:
> > + direct_mask =
> > + pci_get_word(assigned_dev->direct_config_read + address);
> > + break;
> > + case 1:
> > + direct_mask =
> > + pci_get_byte(assigned_dev->direct_config_read + address);
> > + break;
> > + default:
> > + abort();
> > }
>
> One small issue here is that I think read config is not guaranteed to
> get a length aligned address, while pci_get_XXX assume length
> alignment. Further, because of alignment you can get beyond
> the end of array.
>
> I don't think it ever happens in practice on the PC,
It cannot happen with CF8/CFC configuration (bits 1:0 of CF8 are
reserved), but it can happen with mmconfig.
> so we can
> add an assert, but it's might be easier to look at how
> pci_default_read_config handles all these issues:
>
> uint32_t val = 0;
> assert(len == 1 || len == 2 || len == 4);
> len = MIN(len, pci_config_size(d) - address);
> memcpy(&val, d->config + address, len);
> return le32_to_cpu(val);
>
> You can replace config with direct access, and check full access
> with:
>
> allones = ~0x0;
> memcmp(&allones,&val, len)
> and full emulation:
> zero = 0x0;
> memcmp(&zero,&val, len)
>
> This is not done correctly by current code btw, I think.
I think this should be done by the bus code.
On the original Pentium, a 4-byte write to address 7 would be issued as
a write to address 0 with #BE7 (byte enable 7) asserted, then a write to
address 0 with #BE0, #BE1, and #B2 asserted. That is, a one-byte write
followed by a 3-byte write.
The memory API has support for this (only at the device level at
present, but shouldn't be to difficult to implement at the bus level as
well).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-06-28 9:10 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 18:19 [PATCH 00/13] qemu-kvm: device assignment cleanups and upstream diff reductions Jan Kiszka
2011-06-27 18:19 ` [PATCH 01/13] qemu-kvm: Reduce configure and Makefile.target diff to upstream Jan Kiszka
2011-06-27 18:19 ` [PATCH 02/13] qemu-kvm: Drop some no longer needed #ifdefs Jan Kiszka
2011-06-27 18:19 ` [PATCH 03/13] qemu-kvm: Drop -enable-nesting command line switch Jan Kiszka
2011-06-28 10:48 ` Roedel, Joerg
2011-06-28 10:52 ` Jan Kiszka
2011-06-28 11:45 ` Avi Kivity
2011-06-27 18:19 ` [PATCH 04/13] qemu-kvm: Remove eventfd compat header Jan Kiszka
2011-06-28 11:09 ` Michael S. Tsirkin
2011-06-28 11:11 ` Jan Kiszka
2011-06-28 12:07 ` Michael S. Tsirkin
2011-06-28 12:11 ` Jan Kiszka
2011-06-28 12:17 ` Michael S. Tsirkin
2011-06-28 12:40 ` Jan Kiszka
2011-07-03 9:46 ` Bernhard Held
2011-07-03 9:54 ` Michael S. Tsirkin
2011-07-03 9:57 ` Michael S. Tsirkin
2011-07-03 18:31 ` Bernhard Held
2011-07-04 10:37 ` Michael S. Tsirkin
2011-07-04 12:13 ` Bernhard Held
2011-07-04 13:34 ` Michael S. Tsirkin
2011-06-27 18:19 ` [PATCH 05/13] qemu-kvm: Remove qemu_ram_unmap Jan Kiszka
2011-06-27 18:19 ` [PATCH 06/13] qemu-kvm: Drop or replace useless device-assignment.h inclusions Jan Kiszka
2011-06-27 18:19 ` [PATCH 07/13] pci-assign: Fix kvm_deassign_irq handling in assign_irq Jan Kiszka
2011-06-27 18:19 ` [PATCH 08/13] pci-assign: Update legacy interrupts only if used Jan Kiszka
2011-06-27 18:19 ` [PATCH 09/13] pci-assign: Drop libpci header dependency Jan Kiszka
2011-06-28 8:54 ` Michael S. Tsirkin
2011-06-27 18:19 ` [PATCH 10/13] pci-assign: Refactor calc_assigned_dev_id Jan Kiszka
2011-06-27 18:19 ` [PATCH 11/13] pci-assign: Track MSI/MSI-X capability position, clean up related code Jan Kiszka
2011-06-27 18:19 ` [PATCH 12/13] pci-assign: Generic config space access management Jan Kiszka
2011-06-27 20:54 ` Michael S. Tsirkin
2011-06-27 22:48 ` Alex Williamson
2011-06-28 7:08 ` Jan Kiszka
2011-06-28 8:07 ` Avi Kivity
2011-06-28 8:19 ` Jan Kiszka
2011-06-28 8:21 ` Avi Kivity
2011-06-28 8:10 ` Michael S. Tsirkin
2011-06-28 8:18 ` Jan Kiszka
2011-06-28 8:30 ` Michael S. Tsirkin
2011-06-28 9:20 ` Jan Kiszka
2011-06-28 8:51 ` Michael S. Tsirkin
2011-06-28 9:10 ` Avi Kivity [this message]
2011-06-27 18:19 ` [PATCH 13/13] qemu-kvm: Resolve PCI upstream diffs Jan Kiszka
2011-06-28 8:58 ` Michael S. Tsirkin
2011-06-28 9:12 ` Jan Kiszka
2011-06-28 9:22 ` Michael S. Tsirkin
2011-06-28 8:10 ` [PATCH 00/13] qemu-kvm: device assignment cleanups and upstream diff reductions Avi Kivity
2011-06-28 8:57 ` Michael S. Tsirkin
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=4E099A9D.6050803@redhat.com \
--to=avi@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=jan.kiszka@web.de \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--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.