提交 05fcfada 编写于 作者: M Michael S. Tsirkin 提交者: Anthony Liguori

qemu/pci: clarify pci config load routine

PCI load routine has to be called with size equal to 256 (otherwise it
will crash in weird ways).  So assert this, making code clearer.
Also avoid dynamically sized array on stack - good for portability.
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 dc1c9fe8
...@@ -193,14 +193,15 @@ int pci_bus_num(PCIBus *s) ...@@ -193,14 +193,15 @@ int pci_bus_num(PCIBus *s)
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size) static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
{ {
PCIDevice *s = container_of(pv, PCIDevice, config); PCIDevice *s = container_of(pv, PCIDevice, config);
uint8_t config[size]; uint8_t config[PCI_CONFIG_SPACE_SIZE];
int i; int i;
qemu_get_buffer(f, config, size); assert(size == sizeof config);
for (i = 0; i < size; ++i) qemu_get_buffer(f, config, sizeof config);
for (i = 0; i < sizeof config; ++i)
if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i]) if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i])
return -EINVAL; return -EINVAL;
memcpy(s->config, config, size); memcpy(s->config, config, sizeof config);
pci_update_mappings(s); pci_update_mappings(s);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册