kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] device-assignment: don't truncate MSIX capabilities table size
@ 2010-05-25 23:08 Alex Williamson
  2010-05-25 23:09 ` Chris Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alex Williamson @ 2010-05-25 23:08 UTC (permalink / raw)
  To: kvm; +Cc: quintela, chrisw, alex.williamson

PCI_MSIX_TABSIZE is 0x07ff

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 Applies on top of:
 [PATCH qemu-kvm 1/2] device-assignment: use stdint types
 [PATCH qemu-kvm 2/2] device-assignment: Don't use libpci

 hw/device-assignment.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index d8e7cb4..e254203 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1073,7 +1073,7 @@ static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
     else
         pos = pci_dev->cap.start;
 
-    entries_max_nr = pci_dev->config[pos + 2];
+    entries_max_nr = *(uint16_t *)(pci_dev->config + pos + 2);
     entries_max_nr &= PCI_MSIX_TABSIZE;
     entries_max_nr += 1;
 
@@ -1255,8 +1255,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
         entry_nr = assigned_dev_pci_read_word(pci_dev, pos + 2) &
                                                              PCI_MSIX_TABSIZE;
         pci_dev->config[pci_dev->cap.start + pci_dev->cap.length] = 0x11;
-        pci_dev->config[pci_dev->cap.start +
-                        pci_dev->cap.length + 2] = entry_nr;
+        *(uint16_t *)(pci_dev->config + pci_dev->cap.start +
+                      pci_dev->cap.length + 2) = entry_nr;
         msix_table_entry = assigned_dev_pci_read_long(pci_dev,
                                                       pos + PCI_MSIX_TABLE);
         *(uint32_t *)(pci_dev->config + pci_dev->cap.start +


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-25 23:08 [PATCH] device-assignment: don't truncate MSIX capabilities table size Alex Williamson
@ 2010-05-25 23:09 ` Chris Wright
  2010-05-25 23:14   ` Alex Williamson
  2010-05-26  0:27 ` Juan Quintela
  2010-05-27 12:07 ` Avi Kivity
  2 siblings, 1 reply; 9+ messages in thread
From: Chris Wright @ 2010-05-25 23:09 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, quintela, chrisw

* Alex Williamson (alex.williamson@redhat.com) wrote:
> PCI_MSIX_TABSIZE is 0x07ff

while not an issue now, i think that only works for little endian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-25 23:09 ` Chris Wright
@ 2010-05-25 23:14   ` Alex Williamson
  2010-05-25 23:19     ` Chris Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Williamson @ 2010-05-25 23:14 UTC (permalink / raw)
  To: Chris Wright; +Cc: kvm, quintela

On Tue, 2010-05-25 at 16:09 -0700, Chris Wright wrote:
> * Alex Williamson (alex.williamson@redhat.com) wrote:
> > PCI_MSIX_TABSIZE is 0x07ff
> 
> while not an issue now, i think that only works for little endian

Yep.  This is consistent with rest of the device assignment code though,
so I suspect there are numerous issues if it needed to support big
endian.

Alex


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-25 23:14   ` Alex Williamson
@ 2010-05-25 23:19     ` Chris Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Wright @ 2010-05-25 23:19 UTC (permalink / raw)
  To: Alex Williamson; +Cc: Chris Wright, kvm, quintela

* Alex Williamson (alex.williamson@redhat.com) wrote:
> On Tue, 2010-05-25 at 16:09 -0700, Chris Wright wrote:
> > * Alex Williamson (alex.williamson@redhat.com) wrote:
> > > PCI_MSIX_TABSIZE is 0x07ff
> > 
> > while not an issue now, i think that only works for little endian
> 
> Yep.  This is consistent with rest of the device assignment code though,
> so I suspect there are numerous issues if it needed to support big
> endian.

Suppose it's worth fixing it all up, can be in follow-up though.

For this one...

Acked-by: Chris Wright <chrisw@redhat.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-25 23:08 [PATCH] device-assignment: don't truncate MSIX capabilities table size Alex Williamson
  2010-05-25 23:09 ` Chris Wright
@ 2010-05-26  0:27 ` Juan Quintela
  2010-05-26 12:48   ` Avi Kivity
  2010-05-27 12:07 ` Avi Kivity
  2 siblings, 1 reply; 9+ messages in thread
From: Juan Quintela @ 2010-05-26  0:27 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, chrisw

Alex Williamson <alex.williamson@redhat.com> wrote:
> PCI_MSIX_TABSIZE is 0x07ff
>
> Reported-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Acked-by: Juan Quintela <quintela@redhat.com>

BTW, I also noticed the lack of pci_set_long() and friend functions, but
arrived to the same conclusion that you: all the device assignment
assumes that the world is x86_64 :)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-26  0:27 ` Juan Quintela
@ 2010-05-26 12:48   ` Avi Kivity
  2010-05-26 12:54     ` Juan Quintela
  2010-05-27  7:56     ` Jes Sorensen
  0 siblings, 2 replies; 9+ messages in thread
From: Avi Kivity @ 2010-05-26 12:48 UTC (permalink / raw)
  To: Juan Quintela; +Cc: Alex Williamson, kvm, chrisw

On 05/26/2010 03:27 AM, Juan Quintela wrote:
> Alex Williamson<alex.williamson@redhat.com>  wrote:
>    
>> PCI_MSIX_TABSIZE is 0x07ff
>>
>> Reported-by: Juan Quintela<quintela@redhat.com>
>> Signed-off-by: Alex Williamson<alex.williamson@redhat.com>
>>      
> Acked-by: Juan Quintela<quintela@redhat.com>
>
> BTW, I also noticed the lack of pci_set_long() and friend functions, but
> arrived to the same conclusion that you: all the device assignment
> assumes that the world is x86_64 :)
>    

IIRC it used to work on ia64 as well.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-26 12:48   ` Avi Kivity
@ 2010-05-26 12:54     ` Juan Quintela
  2010-05-27  7:56     ` Jes Sorensen
  1 sibling, 0 replies; 9+ messages in thread
From: Juan Quintela @ 2010-05-26 12:54 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Alex Williamson, kvm, chrisw

Avi Kivity <avi@redhat.com> wrote:
> On 05/26/2010 03:27 AM, Juan Quintela wrote:
>> Alex Williamson<alex.williamson@redhat.com>  wrote:
>>    
>>> PCI_MSIX_TABSIZE is 0x07ff
>>>
>>> Reported-by: Juan Quintela<quintela@redhat.com>
>>> Signed-off-by: Alex Williamson<alex.williamson@redhat.com>
>>>      
>> Acked-by: Juan Quintela<quintela@redhat.com>
>>
>> BTW, I also noticed the lack of pci_set_long() and friend functions, but
>> arrived to the same conclusion that you: all the device assignment
>> assumes that the world is x86_64 :)
>>    
>
> IIRC it used to work on ia64 as well.

But ia64 is little endian :)

static inline void
pci_set_word(uint8_t *config, uint16_t val)
{
    cpu_to_le16wu((uint16_t *)config, val);
}

on little endian, this is always an assignment :)

Problem is if we have big endian somewhere in the middle.

Later, Juan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-26 12:48   ` Avi Kivity
  2010-05-26 12:54     ` Juan Quintela
@ 2010-05-27  7:56     ` Jes Sorensen
  1 sibling, 0 replies; 9+ messages in thread
From: Jes Sorensen @ 2010-05-27  7:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Juan Quintela, Alex Williamson, kvm, chrisw

On 05/26/10 14:48, Avi Kivity wrote:
> On 05/26/2010 03:27 AM, Juan Quintela wrote:
>> BTW, I also noticed the lack of pci_set_long() and friend functions, but
>> arrived to the same conclusion that you: all the device assignment
>> assumes that the world is x86_64 :)
>>    
> 
> IIRC it used to work on ia64 as well.
> 

Same endianess, unless you run HPUX on the CPU.

Jes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] device-assignment: don't truncate MSIX capabilities table size
  2010-05-25 23:08 [PATCH] device-assignment: don't truncate MSIX capabilities table size Alex Williamson
  2010-05-25 23:09 ` Chris Wright
  2010-05-26  0:27 ` Juan Quintela
@ 2010-05-27 12:07 ` Avi Kivity
  2 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2010-05-27 12:07 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, quintela, chrisw

On 05/26/2010 02:08 AM, Alex Williamson wrote:
> PCI_MSIX_TABSIZE is 0x07ff
>
>    

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-05-27 12:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 23:08 [PATCH] device-assignment: don't truncate MSIX capabilities table size Alex Williamson
2010-05-25 23:09 ` Chris Wright
2010-05-25 23:14   ` Alex Williamson
2010-05-25 23:19     ` Chris Wright
2010-05-26  0:27 ` Juan Quintela
2010-05-26 12:48   ` Avi Kivity
2010-05-26 12:54     ` Juan Quintela
2010-05-27  7:56     ` Jes Sorensen
2010-05-27 12:07 ` Avi Kivity

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).