From: Jan Kiszka <jan.kiszka@web.de>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 12/13] pci-assign: Generic config space access management
Date: Tue, 28 Jun 2011 09:08:09 +0200 [thread overview]
Message-ID: <4E097DD9.2080607@web.de> (raw)
In-Reply-To: <1309214919.2535.73.camel@x201>
[-- Attachment #1: Type: text/plain, Size: 5165 bytes --]
On 2011-06-28 00:48, Alex Williamson wrote:
>> - case PCI_CAP_ID_VPD:
>> - case PCI_CAP_ID_VNDR:
>> - assigned_dev_pci_write(pci_dev, address, val, len);
>> + switch (len) {
>> + case 4:
>> + direct_mask =
>> + pci_get_long(assigned_dev->direct_config_write + address);
>> + full_access = 0xffffffff;
>> + break;
>> + case 2:
>> + direct_mask =
>> + pci_get_word(assigned_dev->direct_config_write + address);
>> + full_access = 0xffff;
>> break;
>> + case 1:
>> + direct_mask =
>> + pci_get_byte(assigned_dev->direct_config_write + address);
>> + full_access = 0xff;
>> + break;
>> + default:
>> + abort();
>> + }
>
> Shouldn't there be a if (!direct_mask) return; here?
Yep.
>
>> + if (direct_mask != full_access) {
>> + val &= direct_mask;
>> + val |= assigned_dev_pci_read(pci_dev, address, len) & ~direct_mask;
>> }
>> + assigned_dev_pci_write(pci_dev, address, val, len);
>> }
>>
>> static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> @@ -1404,6 +1247,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> return ret;
>> }
>>
>> + /* direct read except for next cap pointer */
>> + memset(dev->direct_config_read + pos, 0xff, PCI_PM_SIZEOF);
>> + dev->direct_config_read[pos + PCI_CAP_LIST_NEXT] = 0;
>> +
>> pmc = pci_get_word(pci_dev->config + pos + PCI_CAP_FLAGS);
>> pmc &= (PCI_PM_CAP_VER_MASK | PCI_PM_CAP_DSI);
>> pci_set_word(pci_dev->config + pos + PCI_CAP_FLAGS, pmc);
>> @@ -1438,6 +1285,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> return ret;
>> }
>>
>> + /* direct read except for next cap pointer */
>> + memset(dev->direct_config_read + pos, 0xff, size);
>> + dev->direct_config_read[pos + PCI_CAP_LIST_NEXT] = 0;
>> +
>> type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS);
>> type = (type & PCI_EXP_FLAGS_TYPE) >> 8;
>> if (type != PCI_EXP_TYPE_ENDPOINT &&
>> @@ -1513,6 +1364,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> return ret;
>> }
>>
>> + /* direct read except for next cap pointer */
>> + memset(dev->direct_config_read + pos, 0xff, 8);
>> + dev->direct_config_read[pos + PCI_CAP_LIST_NEXT] = 0;
>> +
>> /* Command register, clear upper bits, including extended modes */
>> cmd = pci_get_word(pci_dev->config + pos + PCI_X_CMD);
>> cmd &= (PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO | PCI_X_CMD_MAX_READ |
>> @@ -1534,6 +1389,13 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> if ((ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8)) < 0) {
>> return ret;
>> }
>> +
>> + /* direct read except for next cap pointer */
>> + memset(dev->direct_config_read + pos, 0xff, 8);
>> + dev->direct_config_read[pos + PCI_CAP_LIST_NEXT] = 0;
>> +
>> + /* direct write for cap content */
>> + memset(dev->direct_config_write + pos + 2, 0xff, 6);
>> }
>>
>> /* Devices can have multiple vendor capabilities, get them all */
>> @@ -1545,6 +1407,21 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>> pos, len)) < 0) {
>> return ret;
>> }
>> +
>> + /* direct read except for next cap pointer */
>> + memset(dev->direct_config_read + pos, 0xff, len);
>> + dev->direct_config_read[pos + PCI_CAP_LIST_NEXT] = 0;
>> +
>> + /* direct write for cap content */
>> + memset(dev->direct_config_write + pos + 2, 0xff, len - 2);
>> + }
>> +
>> + /* If real and virtual capability list status bits differ, virtualize the
>> + * access. */
>> + if ((pci_get_word(pci_dev->config + PCI_STATUS) & PCI_STATUS_CAP_LIST) !=
>> + (assigned_dev_pci_read_byte(pci_dev, PCI_STATUS) &
>> + PCI_STATUS_CAP_LIST)) {
>> + dev->direct_config_read[PCI_STATUS] &= ~PCI_STATUS_CAP_LIST;
>> }
>>
>> return 0;
>> @@ -1694,6 +1571,26 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
>> return -1;
>> }
>>
>> + /*
>> + * Set up basic config space access control. Will be further refined during
>> + * device initialization.
>> + *
>> + * Direct read/write access is grangted for:
>> + * - status & command registers, revision ID & class code, cacheline size,
>> + * latency timer, header type, BIST
>> + * - cardbus CIS pointer, subsystem vendor & ID
>> + * - reserved fields
>> + * - Min_Gnt & Max_Lat
>> + */
>> + memset(dev->direct_config_read + PCI_COMMAND, 0xff, 12);
>
> This is more efficient, but maybe we should memset each field for
> grep-ability.
Will play with that. May save some comments.
>
> Nice change overall. Thanks,
Thanks,
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2011-06-28 7:08 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 [this message]
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
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=4E097DD9.2080607@web.de \
--to=jan.kiszka@web.de \
--cc=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox