* [PATCH 1/3] PCI: define max devices number on PCIBus as PCIBUS_MAX_DEVICES in pci.h
@ 2010-08-24 6:33 ` Ken CC
0 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:33 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/pci.c | 2 +-
hw/pci.h | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 70dbace..02019a1 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -47,7 +47,7 @@ struct PCIBus {
pci_hotplug_fn hotplug;
DeviceState *hotplug_qdev;
void *irq_opaque;
- PCIDevice *devices[256];
+ PCIDevice *devices[PCIBUS_MAX_DEVICES];
PCIDevice *parent_dev;
target_phys_addr_t mem_base;
diff --git a/hw/pci.h b/hw/pci.h
index ccb99d0..f90840c 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -100,6 +100,7 @@ typedef struct PCIIORegion {
#define PCI_ROM_SLOT 6
#define PCI_NUM_REGIONS 7
+#define PCIBUS_MAX_DEVICES 256
#include "pci_regs.h"
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 1/3] PCI: define max devices number on PCIBus as PCIBUS_MAX_DEVICES in pci.h
@ 2010-08-24 6:33 ` Ken CC
0 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:33 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/pci.c | 2 +-
hw/pci.h | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 70dbace..02019a1 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -47,7 +47,7 @@ struct PCIBus {
pci_hotplug_fn hotplug;
DeviceState *hotplug_qdev;
void *irq_opaque;
- PCIDevice *devices[256];
+ PCIDevice *devices[PCIBUS_MAX_DEVICES];
PCIDevice *parent_dev;
target_phys_addr_t mem_base;
diff --git a/hw/pci.h b/hw/pci.h
index ccb99d0..f90840c 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -100,6 +100,7 @@ typedef struct PCIIORegion {
#define PCI_ROM_SLOT 6
#define PCI_NUM_REGIONS 7
+#define PCIBUS_MAX_DEVICES 256
#include "pci_regs.h"
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/3] pci init: fail qemu if devfn exceeding the max devices number supported on bus
2010-08-24 6:33 ` [Qemu-devel] " Ken CC
@ 2010-08-24 6:48 ` Ken CC
-1 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:48 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
assert(devfn < PCIBUS_MAX_DEVICES)
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/pci.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 02019a1..1e804da 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -747,6 +747,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
PCIConfigWriteFunc *config_write,
bool is_bridge)
{
+ assert(devfn < PCIBUS_MAX_DEVICES);
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 2/3] pci init: fail qemu if devfn exceeding the max devices number supported on bus
@ 2010-08-24 6:48 ` Ken CC
0 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:48 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
assert(devfn < PCIBUS_MAX_DEVICES)
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/pci.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 02019a1..1e804da 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -747,6 +747,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
PCIConfigWriteFunc *config_write,
bool is_bridge)
{
+ assert(devfn < PCIBUS_MAX_DEVICES);
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 6:33 ` [Qemu-devel] " Ken CC
@ 2010-08-24 6:49 ` Ken CC
-1 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:49 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line
is bigger than 0x1f, return error -EINVAL.
0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/qdev-properties.c | 2 ++
hw/qdev.h | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9219cd7..96d814c 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
return -EINVAL;
}
}
+ if (slot > MAX_PCI_SLOTS)
+ return -EINVAL;
if (str[n] != '\0')
return -EINVAL;
if (fn > 7)
diff --git a/hw/qdev.h b/hw/qdev.h
index 678f8b7..fcfe52e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -7,6 +7,9 @@
#include "qemu-char.h"
#include "qemu-option.h"
+
+#define MAX_PCI_SLOTS 0x1f
+
typedef struct Property Property;
typedef struct PropertyInfo PropertyInfo;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 6:49 ` Ken CC
0 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:49 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line
is bigger than 0x1f, return error -EINVAL.
0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/qdev-properties.c | 2 ++
hw/qdev.h | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9219cd7..96d814c 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
return -EINVAL;
}
}
+ if (slot > MAX_PCI_SLOTS)
+ return -EINVAL;
if (str[n] != '\0')
return -EINVAL;
if (fn > 7)
diff --git a/hw/qdev.h b/hw/qdev.h
index 678f8b7..fcfe52e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -7,6 +7,9 @@
#include "qemu-char.h"
#include "qemu-option.h"
+
+#define MAX_PCI_SLOTS 0x1f
+
typedef struct Property Property;
typedef struct PropertyInfo PropertyInfo;
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 6:49 ` [Qemu-devel] " Ken CC
@ 2010-08-24 11:35 ` Isaku Yamahata
-1 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 11:35 UTC (permalink / raw)
To: Ken CC; +Cc: kvm, qemu-devel, Michael S. Tsirkin
Add Cc: mst@redhat.com.
MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
And the name should be start with PCI_ prefix for consistency?
Except that, the patches look okay.
thanks,
On Tue, Aug 24, 2010 at 02:49:27PM +0800, Ken CC wrote:
> Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line
> is bigger than 0x1f, return error -EINVAL.
>
> 0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
>
> Signed-off-by: Ken CC <ken.ccao@gmail.com>
> ---
> hw/qdev-properties.c | 2 ++
> hw/qdev.h | 3 +++
> 2 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 9219cd7..96d814c 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> }
> }
> + if (slot > MAX_PCI_SLOTS)
> + return -EINVAL;
> if (str[n] != '\0')
> return -EINVAL;
> if (fn > 7)
> diff --git a/hw/qdev.h b/hw/qdev.h
> index 678f8b7..fcfe52e 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -7,6 +7,9 @@
> #include "qemu-char.h"
> #include "qemu-option.h"
>
> +
> +#define MAX_PCI_SLOTS 0x1f
> +
> typedef struct Property Property;
>
> typedef struct PropertyInfo PropertyInfo;
>
>
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 11:35 ` Isaku Yamahata
0 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 11:35 UTC (permalink / raw)
To: Ken CC; +Cc: qemu-devel, kvm, Michael S. Tsirkin
Add Cc: mst@redhat.com.
MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
And the name should be start with PCI_ prefix for consistency?
Except that, the patches look okay.
thanks,
On Tue, Aug 24, 2010 at 02:49:27PM +0800, Ken CC wrote:
> Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line
> is bigger than 0x1f, return error -EINVAL.
>
> 0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
>
> Signed-off-by: Ken CC <ken.ccao@gmail.com>
> ---
> hw/qdev-properties.c | 2 ++
> hw/qdev.h | 3 +++
> 2 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 9219cd7..96d814c 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
> @@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
> return -EINVAL;
> }
> }
> + if (slot > MAX_PCI_SLOTS)
> + return -EINVAL;
> if (str[n] != '\0')
> return -EINVAL;
> if (fn > 7)
> diff --git a/hw/qdev.h b/hw/qdev.h
> index 678f8b7..fcfe52e 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -7,6 +7,9 @@
> #include "qemu-char.h"
> #include "qemu-option.h"
>
> +
> +#define MAX_PCI_SLOTS 0x1f
> +
> typedef struct Property Property;
>
> typedef struct PropertyInfo PropertyInfo;
>
>
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 11:35 ` Isaku Yamahata
@ 2010-08-24 11:42 ` Avi Kivity
-1 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 11:42 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
> Add Cc: mst@redhat.com.
>
> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
> And the name should be start with PCI_ prefix for consistency?
>
> Except that, the patches look okay.
>
These aren't slots, are they? They are functions.
There's a lot of slot/function confusion in qemu.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 11:42 ` Avi Kivity
0 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 11:42 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
> Add Cc: mst@redhat.com.
>
> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
> And the name should be start with PCI_ prefix for consistency?
>
> Except that, the patches look okay.
>
These aren't slots, are they? They are functions.
There's a lot of slot/function confusion in qemu.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 12:07 ` Isaku Yamahata
@ 2010-08-24 12:04 ` Avi Kivity
-1 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:04 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>> Add Cc: mst@redhat.com.
>>>
>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>> And the name should be start with PCI_ prefix for consistency?
>>>
>>> Except that, the patches look okay.
>>>
>> These aren't slots, are they? They are functions.
> The function checks if given $slot.$fn (or $slot) is valid.
> So it's slots. max 32.
+ assert(devfn< PCIBUS_MAX_DEVICES);
Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:04 ` Avi Kivity
0 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:04 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>> Add Cc: mst@redhat.com.
>>>
>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>> And the name should be start with PCI_ prefix for consistency?
>>>
>>> Except that, the patches look okay.
>>>
>> These aren't slots, are they? They are functions.
> The function checks if given $slot.$fn (or $slot) is valid.
> So it's slots. max 32.
+ assert(devfn< PCIBUS_MAX_DEVICES);
Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 11:42 ` Avi Kivity
@ 2010-08-24 12:07 ` Isaku Yamahata
-1 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 12:07 UTC (permalink / raw)
To: Avi Kivity; +Cc: Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>> Add Cc: mst@redhat.com.
>>
>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>> And the name should be start with PCI_ prefix for consistency?
>>
>> Except that, the patches look okay.
>>
>
> These aren't slots, are they? They are functions.
The function checks if given $slot.$fn (or $slot) is valid.
So it's slots. max 32.
> There's a lot of slot/function confusion in qemu.
Agreed.
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:07 ` Isaku Yamahata
0 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 12:07 UTC (permalink / raw)
To: Avi Kivity; +Cc: Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>> Add Cc: mst@redhat.com.
>>
>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>> And the name should be start with PCI_ prefix for consistency?
>>
>> Except that, the patches look okay.
>>
>
> These aren't slots, are they? They are functions.
The function checks if given $slot.$fn (or $slot) is valid.
So it's slots. max 32.
> There's a lot of slot/function confusion in qemu.
Agreed.
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 12:24 ` Isaku Yamahata
@ 2010-08-24 12:16 ` Avi Kivity
-1 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:16 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On 08/24/2010 03:24 PM, Isaku Yamahata wrote:
> On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
>> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>>> Add Cc: mst@redhat.com.
>>>>>
>>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>>> And the name should be start with PCI_ prefix for consistency?
>>>>>
>>>>> Except that, the patches look okay.
>>>>>
>>>> These aren't slots, are they? They are functions.
>>> The function checks if given $slot.$fn (or $slot) is valid.
>>> So it's slots. max 32.
>> + assert(devfn< PCIBUS_MAX_DEVICES);
>>
>>
>> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
> Ah, you're talking about 2/3. I talked about 3/3.
> You're right. The name is misleading.
> PCIBUS_MAX_FUNCTIONS? Or suggestions?
Or assert(devfn / 8 < PCIBUS_MAX_DEVICES) (and change that to be 32).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:16 ` Avi Kivity
0 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:16 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On 08/24/2010 03:24 PM, Isaku Yamahata wrote:
> On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
>> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>>> Add Cc: mst@redhat.com.
>>>>>
>>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>>> And the name should be start with PCI_ prefix for consistency?
>>>>>
>>>>> Except that, the patches look okay.
>>>>>
>>>> These aren't slots, are they? They are functions.
>>> The function checks if given $slot.$fn (or $slot) is valid.
>>> So it's slots. max 32.
>> + assert(devfn< PCIBUS_MAX_DEVICES);
>>
>>
>> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
> Ah, you're talking about 2/3. I talked about 3/3.
> You're right. The name is misleading.
> PCIBUS_MAX_FUNCTIONS? Or suggestions?
Or assert(devfn / 8 < PCIBUS_MAX_DEVICES) (and change that to be 32).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 12:04 ` Avi Kivity
@ 2010-08-24 12:16 ` Chen Cao
-1 siblings, 0 replies; 23+ messages in thread
From: Chen Cao @ 2010-08-24 12:16 UTC (permalink / raw)
To: Avi Kivity; +Cc: Isaku Yamahata, Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
> >On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
> >> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
> >>>Add Cc: mst@redhat.com.
> >>>
> >>>MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
> >>>And the name should be start with PCI_ prefix for consistency?
> >>>
> >>>Except that, the patches look okay.
> >>>
> >>These aren't slots, are they? They are functions.
> >The function checks if given $slot.$fn (or $slot) is valid.
> >So it's slots. max 32.
>
> + assert(devfn< PCIBUS_MAX_DEVICES);
>
>
> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
>
PCIBUS_MAX_DEVICES is the size of PCIBus.devices[], I have added it in
the first patch at the defination of struct PCIBus, line 50 hw/pci.c.
so i think the better name of the macro should be PCIBUS_MAX_FN,
right?
Ken
> --
> error compiling committee.c: too many arguments to function
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:16 ` Chen Cao
0 siblings, 0 replies; 23+ messages in thread
From: Chen Cao @ 2010-08-24 12:16 UTC (permalink / raw)
To: Avi Kivity; +Cc: Isaku Yamahata, Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
> >On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
> >> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
> >>>Add Cc: mst@redhat.com.
> >>>
> >>>MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
> >>>And the name should be start with PCI_ prefix for consistency?
> >>>
> >>>Except that, the patches look okay.
> >>>
> >>These aren't slots, are they? They are functions.
> >The function checks if given $slot.$fn (or $slot) is valid.
> >So it's slots. max 32.
>
> + assert(devfn< PCIBUS_MAX_DEVICES);
>
>
> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
>
PCIBUS_MAX_DEVICES is the size of PCIBus.devices[], I have added it in
the first patch at the defination of struct PCIBus, line 50 hw/pci.c.
so i think the better name of the macro should be PCIBUS_MAX_FN,
right?
Ken
> --
> error compiling committee.c: too many arguments to function
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 12:16 ` Chen Cao
@ 2010-08-24 12:19 ` Avi Kivity
-1 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:19 UTC (permalink / raw)
To: Chen Cao; +Cc: Isaku Yamahata, Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On 08/24/2010 03:16 PM, Chen Cao wrote:
> On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
>> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>>> Add Cc: mst@redhat.com.
>>>>>
>>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>>> And the name should be start with PCI_ prefix for consistency?
>>>>>
>>>>> Except that, the patches look okay.
>>>>>
>>>> These aren't slots, are they? They are functions.
>>> The function checks if given $slot.$fn (or $slot) is valid.
>>> So it's slots. max 32.
>> + assert(devfn< PCIBUS_MAX_DEVICES);
>>
>>
>> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
>>
> PCIBUS_MAX_DEVICES is the size of PCIBus.devices[], I have added it in
> the first patch at the defination of struct PCIBus, line 50 hw/pci.c.
> so i think the better name of the macro should be PCIBUS_MAX_FN,
> right?
Or make it 32 and scale it by PCI_FUNCTIONS_PER_DEVICE.
PCIBus.devices[] should be renamed to functions[] (later).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:19 ` Avi Kivity
0 siblings, 0 replies; 23+ messages in thread
From: Avi Kivity @ 2010-08-24 12:19 UTC (permalink / raw)
To: Chen Cao; +Cc: Isaku Yamahata, Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On 08/24/2010 03:16 PM, Chen Cao wrote:
> On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
>> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>>> Add Cc: mst@redhat.com.
>>>>>
>>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>>> And the name should be start with PCI_ prefix for consistency?
>>>>>
>>>>> Except that, the patches look okay.
>>>>>
>>>> These aren't slots, are they? They are functions.
>>> The function checks if given $slot.$fn (or $slot) is valid.
>>> So it's slots. max 32.
>> + assert(devfn< PCIBUS_MAX_DEVICES);
>>
>>
>> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
>>
> PCIBUS_MAX_DEVICES is the size of PCIBus.devices[], I have added it in
> the first patch at the defination of struct PCIBus, line 50 hw/pci.c.
> so i think the better name of the macro should be PCIBUS_MAX_FN,
> right?
Or make it 32 and scale it by PCI_FUNCTIONS_PER_DEVICE.
PCIBus.devices[] should be renamed to functions[] (later).
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
2010-08-24 12:04 ` Avi Kivity
@ 2010-08-24 12:24 ` Isaku Yamahata
-1 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 12:24 UTC (permalink / raw)
To: Avi Kivity; +Cc: Ken CC, kvm, qemu-devel, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>> Add Cc: mst@redhat.com.
>>>>
>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>> And the name should be start with PCI_ prefix for consistency?
>>>>
>>>> Except that, the patches look okay.
>>>>
>>> These aren't slots, are they? They are functions.
>> The function checks if given $slot.$fn (or $slot) is valid.
>> So it's slots. max 32.
>
> + assert(devfn< PCIBUS_MAX_DEVICES);
>
>
> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
Ah, you're talking about 2/3. I talked about 3/3.
You're right. The name is misleading.
PCIBUS_MAX_FUNCTIONS? Or suggestions?
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
@ 2010-08-24 12:24 ` Isaku Yamahata
0 siblings, 0 replies; 23+ messages in thread
From: Isaku Yamahata @ 2010-08-24 12:24 UTC (permalink / raw)
To: Avi Kivity; +Cc: Ken CC, qemu-devel, kvm, Michael S. Tsirkin
On Tue, Aug 24, 2010 at 03:04:44PM +0300, Avi Kivity wrote:
> On 08/24/2010 03:07 PM, Isaku Yamahata wrote:
>> On Tue, Aug 24, 2010 at 02:42:18PM +0300, Avi Kivity wrote:
>>> On 08/24/2010 02:35 PM, Isaku Yamahata wrote:
>>>> Add Cc: mst@redhat.com.
>>>>
>>>> MAX_PCI_SLOTS should be in pci.h instead of qdev.h?
>>>> And the name should be start with PCI_ prefix for consistency?
>>>>
>>>> Except that, the patches look okay.
>>>>
>>> These aren't slots, are they? They are functions.
>> The function checks if given $slot.$fn (or $slot) is valid.
>> So it's slots. max 32.
>
> + assert(devfn< PCIBUS_MAX_DEVICES);
>
>
> Looks like we're comparing a function number to PCIBUS_MAX_DEVICES.
Ah, you're talking about 2/3. I talked about 3/3.
You're right. The name is misleading.
PCIBUS_MAX_FUNCTIONS? Or suggestions?
--
yamahata
^ permalink raw reply [flat|nested] 23+ messages in thread
* [Qemu-devel] [PATCH 3/3] Check pci slot number in parse_pci_devfn
[not found] <20100824062517.12408.45246.stgit@k1>
@ 2010-08-24 6:34 ` Ken CC
0 siblings, 0 replies; 23+ messages in thread
From: Ken CC @ 2010-08-24 6:34 UTC (permalink / raw)
To: kvm; +Cc: yamahata, qemu-devel
Define MAX_PCI_SLOTS as 0x1f, if pci addr provided from command line
is bigger than 0x1f, return error -EINVAL.
0x1f << 3 | 7 == 255 (PCIBUS_MAX_DEVICES - 1)
Signed-off-by: Ken CC <ken.ccao@gmail.com>
---
hw/qdev-properties.c | 2 ++
hw/qdev.h | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9219cd7..96d814c 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -514,6 +514,8 @@ static int parse_pci_devfn(DeviceState *dev, Property *prop, const char *str)
return -EINVAL;
}
}
+ if (slot > MAX_PCI_SLOTS)
+ return -EINVAL;
if (str[n] != '\0')
return -EINVAL;
if (fn > 7)
diff --git a/hw/qdev.h b/hw/qdev.h
index 678f8b7..fcfe52e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -7,6 +7,9 @@
#include "qemu-char.h"
#include "qemu-option.h"
+
+#define MAX_PCI_SLOTS 0x1f
+
typedef struct Property Property;
typedef struct PropertyInfo PropertyInfo;
^ permalink raw reply related [flat|nested] 23+ messages in thread
end of thread, other threads:[~2010-08-24 12:19 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 6:33 [PATCH 1/3] PCI: define max devices number on PCIBus as PCIBUS_MAX_DEVICES in pci.h Ken CC
2010-08-24 6:33 ` [Qemu-devel] " Ken CC
2010-08-24 6:48 ` [PATCH 2/3] pci init: fail qemu if devfn exceeding the max devices number supported on bus Ken CC
2010-08-24 6:48 ` [Qemu-devel] " Ken CC
2010-08-24 6:49 ` [PATCH 3/3] Check pci slot number in parse_pci_devfn Ken CC
2010-08-24 6:49 ` [Qemu-devel] " Ken CC
2010-08-24 11:35 ` Isaku Yamahata
2010-08-24 11:35 ` Isaku Yamahata
2010-08-24 11:42 ` Avi Kivity
2010-08-24 11:42 ` Avi Kivity
2010-08-24 12:07 ` Isaku Yamahata
2010-08-24 12:07 ` Isaku Yamahata
2010-08-24 12:04 ` Avi Kivity
2010-08-24 12:04 ` Avi Kivity
2010-08-24 12:16 ` Chen Cao
2010-08-24 12:16 ` Chen Cao
2010-08-24 12:19 ` Avi Kivity
2010-08-24 12:19 ` Avi Kivity
2010-08-24 12:24 ` Isaku Yamahata
2010-08-24 12:24 ` Isaku Yamahata
2010-08-24 12:16 ` Avi Kivity
2010-08-24 12:16 ` Avi Kivity
[not found] <20100824062517.12408.45246.stgit@k1>
2010-08-24 6:34 ` Ken CC
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.