debuggers.hg

view xen/drivers/pci/pci.c @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 69f670979660
children
line source
1 /******************************************************************************
2 * pci.c
3 *
4 * Architecture-independent PCI access functions.
5 */
7 #include <xen/pci.h>
8 #include <xen/pci_regs.h>
10 int pci_find_cap_offset(u8 bus, u8 dev, u8 func, u8 cap)
11 {
12 u8 id;
13 int max_cap = 48;
14 u8 pos = PCI_CAPABILITY_LIST;
15 u16 status;
17 status = pci_conf_read16(bus, dev, func, PCI_STATUS);
18 if ( (status & PCI_STATUS_CAP_LIST) == 0 )
19 return 0;
21 while ( max_cap-- )
22 {
23 pos = pci_conf_read8(bus, dev, func, pos);
24 if ( pos < 0x40 )
25 break;
27 pos &= ~3;
28 id = pci_conf_read8(bus, dev, func, pos + PCI_CAP_LIST_ID);
30 if ( id == 0xff )
31 break;
32 else if ( id == cap )
33 return pos;
35 pos += PCI_CAP_LIST_NEXT;
36 }
38 return 0;
39 }
41 int pci_find_next_cap(u8 bus, unsigned int devfn, u8 pos, int cap)
42 {
43 u8 id;
44 int ttl = 48;
46 while ( ttl-- )
47 {
48 pos = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn), pos);
49 if ( pos < 0x40 )
50 break;
52 pos &= ~3;
53 id = pci_conf_read8(bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
54 pos + PCI_CAP_LIST_ID);
56 if ( id == 0xff )
57 break;
58 if ( id == cap )
59 return pos;
61 pos += PCI_CAP_LIST_NEXT;
62 }
63 return 0;
64 }