From: Andrew Lyon Subject: Re: Experimental results for VGA passthrough Date: Mon, 8 Jun 2009 09:29:12 +0100 Message-ID: References: <4A27FFB0.6060108@eecs.umich.edu> <4A28120F.5060707@eecs.umich.edu> <4A2B2EEE.1090800@eecs.umich.edu> <4A2CA37B.4060206@eecs.umich.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4A2CA37B.4060206@eecs.umich.edu> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Beng Heng, Ng" , Xen-devel List-Id: xen-devel@lists.xenproject.org On Mon, Jun 8, 2009 at 6:36 AM, Beng Heng, Ng wro= te: > Certainly. I tried this on Xen 3.4.1 rc1 pre, changeset 19645. Most of > these stuff are from Jean and his team. Hopefully more people can update > their results. > > - Beng Heng > > Jun Koi wrote: >> Hi Beng, >> >> Would you please send the patch you applied on top of Xen to the list? >> I think many people are interested in that. >> >> Thanks, >> Jun >> >> >> > > > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/controller.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/contro= ller.c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/controller.c =A0 =A0 =A0200= 9-06-07 20:48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/controller.c =A0 =A0 =A0200= 9-06-07 19:04:11.000000000 -0400 > @@ -208,7 +208,7 @@ void pciback_release_pci_dev(struct pcib > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0spin_unlock_irqrestore(&dev_data->lock, flags); > - =A0 =A0 =A0 pcistub_put_pci_dev(found_dev); > + =A0 =A0 =A0 pcistub_put_pci_dev(found_dev, 0); > =A0} > > =A0int pciback_init_devices(struct pciback_device *pdev) > @@ -396,7 +396,7 @@ void pciback_release_devices(struct pcib > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_for_each_entry_safe(dev_entry, d, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 &cntrl_entry->dev_list, list) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_del(&dev_entry->list)= ; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(dev_ent= ry->dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(dev_ent= ry->dev, 0); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0kfree(dev_entry); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_del(&cntrl_entry->list); > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/passthrough.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/passt= hrough.c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/passthrough.c =A0 =A0 2009-= 06-07 20:48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/passthrough.c =A0 =A0 2009-= 06-07 19:04:11.000000000 -0400 > @@ -88,7 +88,7 @@ void pciback_release_pci_dev(struct pcib > =A0 =A0 =A0 =A0spin_unlock_irqrestore(&dev_data->lock, flags); > > =A0 =A0 =A0 =A0if (found_dev) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev, 1); > =A0} > > =A0int pciback_init_devices(struct pciback_device *pdev) > @@ -157,7 +157,7 @@ void pciback_release_devices(struct pcib > > =A0 =A0 =A0 =A0list_for_each_entry_safe(dev_entry, t, &dev_data->dev_list= , list) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_del(&dev_entry->list); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(dev_entry->dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(dev_entry->dev, 1); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0kfree(dev_entry); > =A0 =A0 =A0 =A0} > > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/pciback.h b/linux-2.6.18-xen.hg/drivers/xen/pciback/pciback.h > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/pciback.h 2009-06-07 20:48:= 21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/pciback.h 2009-06-07 19:04:= 11.000000000 -0400 > @@ -25,6 +25,14 @@ struct pci_dev_entry { > =A0#define _PCIB_op_pending =A0 =A0 =A0 (1) > =A0#define PCIB_op_pending =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(1<<(_PCIB_op_p= ending)) > > +#define PCIBACK_TYPE_UNKNOWN =A0 =A0 =A0 0 > +#define PCIBACK_TYPE_PCIe_ENDPOINT 1 > +#define PCIBACK_TYPE_PCIe_BRIDGE =A0 2 > +#define PCIBACK_TYPE_PCI_BRIDGE =A0 =A03 > +#define PCIBACK_TYPE_PCI =A0 =A0 =A0 =A0 =A0 4 > + > +#define DEV_CLASS_PCI_PCI_BRIDGE 0x0604 > + > =A0struct pciback_device { > =A0 =A0 =A0 =A0void *pci_dev_data; > =A0 =A0 =A0 =A0spinlock_t dev_lock; > @@ -48,6 +56,13 @@ struct pciback_dev_data { > =A0 =A0 =A0 =A0struct list_head config_fields; > =A0 =A0 =A0 =A0int permissive; > =A0 =A0 =A0 =A0int warned_on_write; > + =A0 =A0 =A0 u32 dev_type; > + =A0 =A0 =A0 int no_flr; > + =A0 =A0 =A0 int exp_flr_offset; > + =A0 =A0 =A0 int af_flr_offset; > + =A0 =A0 =A0 int use_sbr; > + =A0 =A0 =A0 int use_d3r; > + =A0 =A0 =A0 u8 *cfg_space; /* saved config space for device */ > =A0}; > > =A0/* Get/Put PCI Devices that are hidden from the PCI Backend Domain */ > @@ -56,11 +71,25 @@ struct pci_dev *pcistub_get_pci_dev_by_s > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0int slot, int func); > =A0struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0st= ruct pci_dev *dev); > -void pcistub_put_pci_dev(struct pci_dev *dev); > +void pcistub_put_pci_dev(struct pci_dev *dev, int do_flr); > + > +/* Reference/unreference PCI Devices and stubs without changing the stat= e */ > +struct pci_dev *pcistub_ref_pci_dev(struct pci_dev *dev); > +void pcistub_unref_pci_dev(struct pci_dev *dev); > + > +/* Store/reload config space for devices */ > +void pciback_store_config_space(struct pci_dev *dev); > +void pciback_reload_config_space(struct pci_dev *dev); > > =A0/* Ensure a device is turned off or reset */ > =A0void pciback_reset_device(struct pci_dev *pdev); > > +/* Do a function level reset (or approximage functionality) for device *= / > +void pciback_flr_device(struct pci_dev *dev); > + > +/* Helper to classify the device type */ > +void pciback_classify_device(struct pci_dev *dev); > + > =A0/* Access a virtual configuration space for a PCI device */ > =A0int pciback_config_init(void); > =A0int pciback_config_init_dev(struct pci_dev *dev); > @@ -102,6 +131,10 @@ void pciback_release_devices(struct pcib > =A0irqreturn_t pciback_handle_event(int irq, void *dev_id, struct pt_regs= *regs); > =A0void pciback_do_op(void *data); > > +/* Parse and load device specific module parameters */ > +int pciback_parse_device_params(const char *device_args, int type, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 int (*add_func) (int domain, int bus, int slot, int func, int type)); > + > =A0int pciback_xenbus_register(void); > =A0void pciback_xenbus_unregister(void); > > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/pciback_ops.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/pciba= ck_ops.c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/pciback_ops.c =A0 =A0 2009-= 06-07 20:48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/pciback_ops.c =A0 =A0 2009-= 06-07 19:04:11.000000000 -0400 > @@ -5,20 +5,189 @@ > =A0*/ > =A0#include > =A0#include > +#include /* For mdelay function */ > =A0#include > =A0#include > =A0#include "pciback.h" > > +#define PCIBACK_VENDOR_INTEL =A0 =A0 0x8086 > +#define PCIBACK_CLASS_ID_USB =A0 =A0 0x0c03 > +#define PCIBACK_CLASS_ID_VGA =A0 =A0 0x0300 > +#define PCIBACK_USB_FLRCTRL =A0 =A0 =A00x4 > + > +#define PCIBACK_IGFX_CAP09_OFFSET =A0 =A00xa4 > +#define PCIBACK_IGFX_CAP13_OFFSET =A0 =A00xa4 > + > +#define PCIBACK_IGFX_MEDIARST =A0 =A0 =A0 =A00x0d > +#define PCIBACK_IGFX_MEDIARST_OFFSET 0xc0 > + > =A0int verbose_request =3D 0; > =A0module_param(verbose_request, int, 0644); > > +struct pcistub_sbr_entry { > + =A0 =A0 =A0 struct list_head dev_list; > + =A0 =A0 =A0 struct pci_dev *dev; > +}; > + > +struct pcistub_sbr_list { > + =A0 =A0 =A0 struct list_head dev_list; > + =A0 =A0 =A0 struct pci_dev *bridge; > + =A0 =A0 =A0 struct pci_dev *dev; > + =A0 =A0 =A0 int find_all; > + =A0 =A0 =A0 int err; > +}; > + > +/* Used to store the config state so it can be restored after > + * resets. > + */ > +void pciback_store_config_space(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pciback_dev_data *dev_data =3D pci_get_drvdata(dev); > + =A0 =A0 =A0 u32 *ptr =3D (u32*)dev_data->cfg_space; > + =A0 =A0 =A0 int i, count =3D dev->cfg_size/sizeof(u32); > + > + =A0 =A0 =A0 for (i =3D 0; i < count; i +=3D sizeof(u32), ptr++) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_dword(dev, i, ptr); > +} > + > +/* Used to reload the config state after resets. > + */ > +void pciback_reload_config_space(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pciback_dev_data *dev_data =3D pci_get_drvdata(dev); > + =A0 =A0 =A0 u32 *ptr =3D (u32*)dev_data->cfg_space; > + =A0 =A0 =A0 int i, val, count =3D dev->cfg_size/sizeof(u32); > + > + =A0 =A0 =A0 for (i =3D 0; i < count; i +=3D sizeof(u32), ptr++) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_dword(dev, i, &val); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (val !=3D *ptr) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_dword(dev,= i, *ptr); > + =A0 =A0 =A0 } > +} > + > +static void pciback_walk_bus_cb(struct pci_dev *dev, void *userdata) > +{ > + =A0 =A0 =A0 struct pcistub_sbr_list *list =3D (struct pcistub_sbr_list*= )userdata; > + =A0 =A0 =A0 struct pcistub_sbr_entry *entry; > + =A0 =A0 =A0 struct pci_dev *dev_tmp; > + > + =A0 =A0 =A0 if (list->err !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + > + =A0 =A0 =A0 /* For PCIe endpoints we are only looking for co-assigned f= unctions */ > + =A0 =A0 =A0 if (!list->find_all && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dev->bus->number !=3D list->dev->bus->numb= er || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PCI_SLOT(dev->devfn) !=3D PCI_SLOT(list-= >dev->devfn))) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + > + =A0 =A0 =A0 dev_tmp =3D pcistub_ref_pci_dev(dev); > + =A0 =A0 =A0 if (dev_tmp =3D=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* not controlled by pciback, fail */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->err =3D ENXIO; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 entry =3D kzalloc(sizeof(*entry), GFP_ATOMIC); > + =A0 =A0 =A0 if (entry =3D=3D NULL) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_unref_pci_dev(dev_tmp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->err =3D ENOMEM; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 entry->dev =3D dev_tmp; > + =A0 =A0 =A0 list_add_tail(&entry->dev_list, &list->dev_list); > +} > + > +static void pciback_cleanup_sbr_list(struct pcistub_sbr_list *list) > +{ > + =A0 =A0 =A0 struct pcistub_sbr_entry *entry; > + > + =A0 =A0 =A0 list_for_each_entry(entry, &list->dev_list, dev_list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_unref_pci_dev(entry->dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 kfree(entry); > + =A0 =A0 =A0 } > +} > + > +/* Routine to find all devices and bridges that need to be reset > + * during a secondary bus reset. For PCIe this is simply all the > + * functions on the particular device. For PCI this is all devices > + * and bridges below the topmost PCI/PCI-X bridge. Note for PCI, > + * there is at least one something->PCI/PCI-X bridge to find since > + * the device is not on the host bus 0 and is on a PCI bus. > + */ > +static int pciback_get_sbr_list(struct pci_dev *dev, > + =A0 =A0 =A0 struct pcistub_sbr_list *list, int pcie_endpoint) > +{ > + =A0 =A0 =A0 struct pci_dev *bridge =3D dev->bus->self; > + =A0 =A0 =A0 struct pci_dev *last =3D NULL; > + =A0 =A0 =A0 int exp_pos; > + =A0 =A0 =A0 u16 exp_caps =3D 0; > + > + =A0 =A0 =A0 list->err =3D 0; > + =A0 =A0 =A0 list->dev =3D dev; > + =A0 =A0 =A0 INIT_LIST_HEAD(&list->dev_list); > + > + =A0 =A0 =A0 if (!pcie_endpoint) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (bridge) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Looking for the uppermos= t PCI/PCI-X bridge. If it is not PCIe then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* this is a PCI/PCI-X br= idge. If it is PCIe then except the PCIe to > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* PCI/PCI-X type 7, the = rest of the bridge types are PCIe so the last > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* bridge encountered was= the topmost PCI/PCI-X bridge. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exp_pos =3D pci_find_capabi= lity(bridge, PCI_CAP_ID_EXP); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (exp_pos !=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_co= nfig_word(bridge, exp_pos + PCI_EXP_FLAGS, &exp_caps); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (((exp_c= aps & PCI_EXP_FLAGS_TYPE) >> 4) !=3D PCI_EXP_TYPE_PCI_BRIDGE) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 break; /* don't want it in the list if it is a PCIe bridge */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 last =3D bridge; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bridge =3D last->bus->self; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->bridge =3D last; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->find_all =3D 1; /* find all devices/b= ridges below the topmost */ > + =A0 =A0 =A0 } > + =A0 =A0 =A0 else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (bridge) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* For PCIe, SBR logic is l= imited to PCIe endpoints behind a root/switch > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* port. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exp_pos =3D pci_find_capabi= lity(bridge, PCI_CAP_ID_EXP); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (likely(exp_pos !=3D 0))= { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_co= nfig_word(bridge, exp_pos + PCI_EXP_FLAGS, &exp_caps); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exp_caps = =3D ((exp_caps & PCI_EXP_FLAGS_TYPE) >> 4); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (exp_cap= s =3D=3D PCI_EXP_TYPE_ROOT_PORT || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 exp_caps =3D=3D PCI_EXP_TYPE_UPSTREAM || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 exp_caps =3D=3D PCI_EXP_TYPE_DOWNSTREAM) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 last =3D bridge; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->bridge =3D last; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 list->find_all =3D 0; /* find just function= s on this slot */ > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 /* Sanity check, there may not be any appropriate bridge to= reset */ > + =A0 =A0 =A0 if (!list->bridge) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(&dev->dev, "No appropriate bridge t= o reset\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ENXIO; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_walk_bus(list->bridge->subordinate, pciback_walk_bus_cb= , list); > + > + =A0 =A0 =A0 if (list->err) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_cleanup_sbr_list(list); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return list->err; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 return 0; > +} > + > =A0/* Ensure a device is "turned off" and ready to be exported. > =A0* (Also see pciback_config_reset to ensure virtual configuration space= is > =A0* ready to be re-exported) > =A0*/ > =A0void pciback_reset_device(struct pci_dev *dev) > =A0{ > - =A0 =A0 =A0 u16 cmd; > + =A0 =A0 =A0 u16 cmd =3D 0; > > =A0 =A0 =A0 =A0/* Disable devices (but not bridges) */ > =A0 =A0 =A0 =A0if (dev->hdr_type =3D=3D PCI_HEADER_TYPE_NORMAL) { > @@ -38,6 +207,425 @@ void pciback_reset_device(struct pci_dev > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0} > =A0} > + > +/* Do a PCIe type function level reset for a single function on this > + * device. > + */ > +static void pciback_do_pcie_flr(struct pci_dev *dev, int exp_pos) > +{ > + =A0 =A0 =A0 u16 status =3D 0; > + > + =A0 =A0 =A0 dev_dbg(&dev->dev, "doing PCIe FLR\n"); > + > + =A0 =A0 =A0 pci_block_user_cfg_access(dev); > + > + =A0 =A0 =A0 /* Wait for Transaction Pending bit clean */ > + =A0 =A0 =A0 msleep(100); > + =A0 =A0 =A0 pci_read_config_word(dev, exp_pos + PCI_EXP_DEVSTA, &status= ); > + =A0 =A0 =A0 if (status & PCI_EXP_DEVSTA_TRPND) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(&dev->dev, "Busy after 100ms while = trying to reset; sleeping for 1 second\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ssleep(1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_word(dev, exp_pos + PCI_EXP= _DEVSTA, &status); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (status & PCI_EXP_DEVSTA_TRPND) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&dev->dev, "Still = busy after 1s; proceeding with reset anyway\n"); > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_write_config_word(dev, exp_pos + PCI_EXP_DEVCTL, PCI_EX= P_DEVCTL_BCR_FLR); > + =A0 =A0 =A0 mdelay(200); > + > + =A0 =A0 =A0 pciback_reload_config_space(dev); > + > + =A0 =A0 =A0 pci_unblock_user_cfg_access(dev); > +} > + > +/* Do a PCI type function level reset for a single function on this > + * device. This uses the Advanced Features Capability extensions to > + * the PCI spec. > + */ > +static void pciback_do_pci_flr(struct pci_dev *dev, int af_pos, int clea= r_cmd) > +{ > + =A0 =A0 =A0 u8 status =3D 0; > + > + =A0 =A0 =A0 dev_dbg(&dev->dev, "doing PCI FLR\n"); > + > + =A0 =A0 =A0 pci_block_user_cfg_access(dev); > + > + =A0 =A0 =A0 /* Clear the command register to prevent new transactions *= / > + =A0 =A0 =A0 if (clear_cmd) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_word(dev, PCI_COMMAND, 0); > + > + =A0 =A0 =A0 /* Wait for Transaction Pending bit clean */ > + =A0 =A0 =A0 msleep(100); > + =A0 =A0 =A0 pci_read_config_byte(dev, af_pos + PCI_AF_STA, &status); > + =A0 =A0 =A0 if (status & PCI_AF_STA_TP) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(&dev->dev, "Busy after 100ms while = trying to reset; sleeping for 1 second\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 ssleep(1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_byte(dev, af_pos + PCI_AF_S= TA, &status); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (status & PCI_AF_STA_TP) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&dev->dev, "Still = busy after 1s; proceeding with reset anyway\n"); > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_write_config_byte(dev, af_pos + PCI_AF_CTRL, PCI_AF_CTR= L_FLR); > + =A0 =A0 =A0 mdelay(200); > + > + =A0 =A0 =A0 pciback_reload_config_space(dev); > + > + =A0 =A0 =A0 pci_unblock_user_cfg_access(dev); > +} > + > +/* Vendor specific resets. These can be set in the vendor specific > + * capabilities structures. Currently only the Intel USB and iGFX > + * reset is supported. > + */ > +static int pciback_do_vendor_specific_reset(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pci_dev *gmch; > + =A0 =A0 =A0 int vendor_pos, i; > + =A0 =A0 =A0 u32 reg32 =3D 0; > + =A0 =A0 =A0 u16 device_id, cmd; > + =A0 =A0 =A0 u8 reg8 =3D 0; > + > + =A0 =A0 =A0 dev_dbg(&dev->dev, "doing vendor specific resets\n"); > + > + =A0 =A0 =A0 if (dev->vendor !=3D PCIBACK_VENDOR_INTEL) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 if ((dev->class >> 8) =3D=3D PCIBACK_CLASS_ID_VGA) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev->bus->number !=3D 0 || dev->devfn != =3D PCI_DEVFN(2,0)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Locate the GMCH (north bridge) and test = for specific Intel devices */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 gmch =3D pci_get_bus_and_slot(0, PCI_DEVFN(= 0,0)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!gmch) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 device_id =3D gmch->device; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_dev_put(gmch); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (device_id !=3D PCI_DEVICE_ID_INTEL_GMCH= GM45) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Correct device and platform, assume vend= or specific offset */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_dword(dev, PCIBACK_IGFX_CAP= 09_OFFSET, ®32); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((reg32 & 0x000000FF) !=3D PCI_CAP_ID_VN= DR || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((reg32 >> 16) & 0x000000FF= ) !=3D 0x06 || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((reg32 >> 24) & 0x000000F0= ) !=3D 0x20) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vendor_pos =3D PCIBACK_IGFX_CAP09_OFFSET; > + =A0 =A0 =A0 } else if ((dev->class >> 8) =3D=3D PCIBACK_CLASS_ID_USB) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vendor_pos =3D pci_find_capability(dev, PCI= _CAP_ID_VNDR); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (vendor_pos =3D=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + =A0 =A0 =A0 } > + =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 if ((dev->class >> 8) =3D=3D PCIBACK_CLASS_ID_VGA) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_byte(dev, PCIBACK_IGFX_MED= IARST_OFFSET, PCIBACK_IGFX_MEDIARST); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i <=3D 10; i++) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 msleep(100); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_byte(dev, P= CIBACK_IGFX_MEDIARST_OFFSET, ®8); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((reg8 & 0x01) =3D=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (i =3D=3D 10) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&d= ev->dev, "media not reset after 1s; skipping FLR\n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* This specific reset will hang if the com= mand register does not have > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* memory space access enabled */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_word(dev, PCI_COMMAND, &cmd= ); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_word(dev, PCI_COMMAND, (cm= d | PCI_COMMAND_MEMORY)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* The rest is the same as a PCI AF FLR - u= se the same routine */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_do_pci_flr(dev, vendor_pos, 0); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_word(dev, PCI_COMMAND, cmd= ); > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_block_user_cfg_access(dev); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_write_config_byte(dev, vendor_pos + PCI= BACK_USB_FLRCTRL, 1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mdelay(200); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_reload_config_space(dev); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_unblock_user_cfg_access(dev); > + =A0 =A0 =A0 } > + > +out: > + =A0 =A0 =A0 return 0; > +} > + > +/* Use a D0-D3-D0 device state transition to reset the device. This > + * is a good enough reset for some devices (like NICs). > + */ > +static int pciback_do_dstate_transition_reset(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 int pm_pos; > + =A0 =A0 =A0 u32 pm_ctl =3D 0; > + > + =A0 =A0 =A0 pm_pos =3D pci_find_capability(dev, PCI_CAP_ID_PM); > + =A0 =A0 =A0 if (pm_pos =3D=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 dev_dbg(&dev->dev, "doing Dstate transition reset\n"); > + > + =A0 =A0 =A0 /* No_Soft_Reset - When set 1, this bit indicates that devi= ces > + =A0 =A0 =A0 =A0* transitioning from D3hot to D0 because of PowerState c= ommands > + =A0 =A0 =A0 =A0* do not perform an internal reset. > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 pci_read_config_dword(dev, pm_pos + PCI_PM_CTRL, &pm_ctl); > + =A0 =A0 =A0 if (pm_ctl & PCI_PM_CTRL_NO_SOFT_RESET) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENXIO; > + > + =A0 =A0 =A0 pci_block_user_cfg_access(dev); > + > + =A0 =A0 =A0 pm_ctl &=3D ~PCI_PM_CTRL_STATE_MASK; > + =A0 =A0 =A0 pm_ctl |=3D PCI_PM_CTRL_D3HOT; > + =A0 =A0 =A0 pci_write_config_word(dev, pm_pos + PCI_PM_CTRL, pm_ctl); > + =A0 =A0 =A0 mdelay(10); > + > + =A0 =A0 =A0 pm_ctl &=3D ~PCI_PM_CTRL_STATE_MASK; > + =A0 =A0 =A0 pm_ctl |=3D PCI_PM_CTRL_D0; > + =A0 =A0 =A0 pci_write_config_word(dev, pm_pos + PCI_PM_CTRL, pm_ctl); > + =A0 =A0 =A0 mdelay(10); > + > + =A0 =A0 =A0 pciback_reload_config_space(dev); > + > + =A0 =A0 =A0 pci_unblock_user_cfg_access(dev); > + > + =A0 =A0 =A0 return 0; > +} > + > +/* Do a secondary bus reset on a bridge. This is only done if all > + * co-assignment rules are satisfied and if it was explicitly > + * requested via pciback parameters. > + */ > +static int pciback_do_secondary_bus_reset(struct pci_dev *dev, u32 dev_t= ype) > +{ > + =A0 =A0 =A0 struct pcistub_sbr_list sbr_list; > + =A0 =A0 =A0 struct pcistub_sbr_entry *entry; > + =A0 =A0 =A0 u16 pci_bctl =3D 0; > + =A0 =A0 =A0 int err =3D 0; > + > + =A0 =A0 =A0 /* Call helper to get the device list needed for the device= type. */ > + =A0 =A0 =A0 err =3D pciback_get_sbr_list(dev, &sbr_list, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (dev_type =3D=3D PCIBACK_TY= PE_PCIe_ENDPOINT ? 1 : 0)); > + =A0 =A0 =A0 if (err) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&dev->dev, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "secondary bus reset failed= for device - all functions need to be co-assigned - err: %d\n", err); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return err; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_block_user_cfg_access(dev); > + > + =A0 =A0 =A0 /* Reset the secondary bus and restore the PCI space for al= l the devfn found above. > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 pci_read_config_word(sbr_list.bridge, PCI_BRIDGE_CONTROL, &= pci_bctl); > + =A0 =A0 =A0 pci_write_config_word(sbr_list.bridge, PCI_BRIDGE_CONTROL, = pci_bctl | PCI_BRIDGE_CTL_BUS_RESET); > + =A0 =A0 =A0 msleep(200); > + =A0 =A0 =A0 pci_write_config_word(sbr_list.bridge, PCI_BRIDGE_CONTROL, = pci_bctl); > + =A0 =A0 =A0 msleep(200); > + > + =A0 =A0 =A0 list_for_each_entry(entry, &sbr_list.dev_list, dev_list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_reload_config_space(entry->dev); > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_unblock_user_cfg_access(dev); > + > + =A0 =A0 =A0 pciback_cleanup_sbr_list(&sbr_list); > + > + =A0 =A0 =A0 return 0; > +} > + > +/* This function is used to do a function level reset on a singe > + * device/function. FLRs must be done on devices before they are > + * unassigned from one domain and passed through to another. The > + * preferred method is to do an actual FLR on the device but the > + * functionality may not be present or exposed. In the later case > + * we attempt to locate the capability even though it is not > + * chained into the capabilities list. > + * > + * In some cases, there is no way to perform the actual FLR so we > + * fall back to some alternate methods (which are not as effective > + * or useful). > + */ > +void pciback_flr_device(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pciback_dev_data *dev_data =3D pci_get_drvdata(dev); > + =A0 =A0 =A0 int err =3D 0; > + > + =A0 =A0 =A0 if (dev_data->no_flr) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(&dev->dev, "FLR disabled for device= \n"); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return; > + =A0 =A0 =A0 } > + =A0 =A0 =A0 dev_dbg(&dev->dev, "FLR invoked for device\n"); > + > + =A0 =A0 =A0 do { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* First, always try to do an FLR */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_data->dev_type =3D=3D PCIBACK_TYPE_= PCIe_ENDPOINT && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->exp_flr_offset != =3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_do_pcie_flr(dev, de= v_data->exp_flr_offset); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_data->dev_type =3D=3D PCIBACK_TYPE_= PCI && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->af_flr_offset != =3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_do_pci_flr(dev, dev= _data->af_flr_offset, 1); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Next for integrated devices on the host = bus 0, try some other methods */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev->bus->number =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D pciback_do_vendor_s= pecific_reset(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err && dev_data->use_d3= r) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D pci= back_do_dstate_transition_reset(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&d= ev->dev, "FLR functionality not supported; " > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 "attempts to use vendor FLR or D-states unsuccessful\n= "); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Else attempt a secondary bus reset if al= l conditions are met */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev_data->use_sbr) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D pciback_do_secondar= y_bus_reset(dev, dev_data->dev_type); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&d= ev->dev, "FLR functionality not supported; " > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 "attempts to use secondary bus reset unsuccessful;\n")= ; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -ENODEV; > + =A0 =A0 =A0 } while (0); > + > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_warn(&dev->dev, "FLR not performed for = device\n"); > +} > + > +/* Helper used to location the FLR capabilities for a PCIe device. > + * When the capability cannot be found in the chain but is present, > + * special logic is used to attempt to locate functionality. > + * > + * returns: the offset to the capability, zero if not found. > + */ > +static int pciback_find_pcie_flr_caps(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 int exp_pos; > + =A0 =A0 =A0 u32 cap =3D 0; > + > + =A0 =A0 =A0 /* First look for the PCIe FLR capabilities using the capab= ilities list */ > + =A0 =A0 =A0 exp_pos =3D pci_find_capability(dev, PCI_CAP_ID_EXP); > + =A0 =A0 =A0 if (exp_pos) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_dword(dev, exp_pos + PCI_EX= P_DEVCAP, &cap); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (cap & PCI_EXP_DEVCAP_FLR) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return exp_pos; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 return 0; > +} > + > +/* Helper used to location the AF FLR capabilities for a PCI device. > + * When the capability cannot be found in the chain but is present, > + * special logic is used to attempt to locate functionality. > + * > + * returns: the offset to the capability, zero if not found. > + */ > +static int pciback_find_pci_flr_caps(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pci_dev *gmch; > + =A0 =A0 =A0 int af_pos; > + =A0 =A0 =A0 u16 device_id; > + =A0 =A0 =A0 u8 cap =3D 0, reg8 =3D 0; > + > + =A0 =A0 =A0 /* First look for the PCI AF capabilities for FLR using the= capabilities list. This > + =A0 =A0 =A0 =A0* is only used on the devices on the root/host bus (inte= grated devices). > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 if (dev->bus->number !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; > + > + =A0 =A0 =A0 af_pos =3D pci_find_capability(dev, PCI_CAP_ID_AF); > + =A0 =A0 =A0 if (af_pos) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_byte(dev, af_pos + PCI_AF_D= EVCAP, &cap); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (cap & PCI_AF_CAP_FLR) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return af_pos; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 /* Next look for the unchained AF capabilities for FLR usin= g specific > + =A0 =A0 =A0 =A0* logic. Currently only the graphics device on the Intel= Q45 etc > + =A0 =A0 =A0 =A0* systems has special logic for locating the hidden FLR = caps. > + =A0 =A0 */ > + =A0 =A0 =A0 do { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (dev->bus->number !=3D 0 || dev->devfn != =3D PCI_DEVFN(2,0) || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev->vendor !=3D PCIBACK_VE= NDOR_INTEL || (dev->class >> 8) !=3D PCIBACK_CLASS_ID_VGA) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Locate the GMCH (north bridge) and test = for specific Intel devices */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 gmch =3D pci_get_bus_and_slot(0, PCI_DEVFN(= 0,0)); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!gmch) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 device_id =3D gmch->device; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_dev_put(gmch); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (device_id !=3D PCI_DEVICE_ID_INTEL_GMCH= Q45 && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 device_id !=3D PCI_DEVICE_I= D_INTEL_GMCHG45 && > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 device_id !=3D PCI_DEVICE_I= D_INTEL_GMCHG41) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Correct device and platform, assume AF o= ffset */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 af_pos =3D PCIBACK_IGFX_CAP13_OFFSET; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_byte(dev, af_pos + PCI_AF_L= ENFLD, ®8); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (reg8 =3D=3D PCI_AF_LENGTH) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pci_read_config_byte(dev, a= f_pos + PCI_AF_DEVCAP, &cap); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (cap & PCI_AF_CAP_FLR) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return af_p= os; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } while (0); > + > + =A0 =A0 =A0 /* Else not found */ > + =A0 =A0 =A0 return 0; > +} > + > +/* Classify the device, specifically determine if it is PCIe/PCI > + * and whether it is a PCIe endpoint, bridge, or other PCI device. > + */ > +void pciback_classify_device(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pciback_dev_data *dev_data; > + =A0 =A0 =A0 int exp_pos; > + =A0 =A0 =A0 u16 exp_caps =3D 0; > + > + =A0 =A0 =A0 dev_data =3D pci_get_drvdata(dev); > + =A0 =A0 =A0 dev_data->dev_type =3D PCIBACK_TYPE_UNKNOWN; > + > + =A0 =A0 =A0 exp_pos =3D pci_find_capability(dev, PCI_CAP_ID_EXP); > + > + =A0 =A0 =A0 if ((dev->class >> 8) !=3D DEV_CLASS_PCI_PCI_BRIDGE) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (exp_pos !=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->dev_type =3D PCIB= ACK_TYPE_PCIe_ENDPOINT; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->exp_flr_offset = =3D pciback_find_pcie_flr_caps(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->dev_type =3D PCIB= ACK_TYPE_PCI; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->af_flr_offset =3D= pciback_find_pci_flr_caps(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto classify_done; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 if (exp_pos =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->dev_type =3D PCIBACK_TYPE_PCI_BRI= DGE; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto classify_done; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 pci_read_config_word(dev, exp_pos + PCI_EXP_FLAGS, &exp_cap= s); > + =A0 =A0 =A0 dev_data->dev_type =3D (((exp_caps & PCI_EXP_FLAGS_TYPE) >>= 4) =3D=3D PCI_EXP_TYPE_PCI_BRIDGE) ? PCIBACK_TYPE_PCI_BRIDGE : PCIBACK_TYP= E_PCIe_BRIDGE; > + > +classify_done: > + > + =A0 =A0 =A0 return; > +} > + > =A0extern wait_queue_head_t aer_wait_queue; > =A0extern struct workqueue_struct *pciback_wq; > =A0/* > @@ -132,3 +720,51 @@ irqreturn_t pciback_handle_event(int irq > > =A0 =A0 =A0 =A0return IRQ_HANDLED; > =A0} > + > +/* Helper routine used to parse command line parameters passed to the > + * pciback module from the boot loader. These params all have the form > + * of a list of one or more devices, e.g.: > + * (XXXX:XX:XX.X)(XXXX:XX:XX.X) > + * Which is: (domain/segment:bus:dev.func) > + */ > +int pciback_parse_device_params(const char *device_args, int type, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int (*add_func) (int domain= , int bus, int slot, int func, int type)) > +{ > + =A0 =A0 =A0 int pos =3D 0; > + =A0 =A0 =A0 int err =3D 0; > + =A0 =A0 =A0 int domain, bus, slot, func; > + =A0 =A0 =A0 int parsed; > + > + =A0 =A0 =A0 if (device_args && *device_args) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 do { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 parsed =3D 0; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D sscanf(device_args = + pos, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= " (%x:%x:%x.%x) %n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= &domain, &bus, &slot, &func, &parsed); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err !=3D 4) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 domain =3D = 0; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D ssc= anf(device_args + pos, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0" (%x:%x.%x) %n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0&bus, &slot, &func, &parsed); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err != =3D 3) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 goto parse_error; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D add_func(domain, bu= s, slot, func, type); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* if parsed<=3D0, we've re= ached the end of the string */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pos +=3D parsed; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } while (parsed > 0 && device_args[pos]); > + =A0 =A0 =A0 } > + > +out: > + =A0 =A0 =A0 return err; > + > +parse_error: > + =A0 =A0 =A0 printk(KERN_ERR "pciback: Error parsing device parameters \= "%s\" at \"%s\"\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0device_args, device_args + pos); > + =A0 =A0 =A0 return -EINVAL; > +} > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/pci_stub.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/pci_stub= .c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/pci_stub.c =A0 =A0 =A0 =A02= 009-06-07 20:48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/pci_stub.c =A0 =A0 =A0 =A02= 009-06-07 19:04:11.000000000 -0400 > @@ -24,10 +24,28 @@ wait_queue_head_t aer_wait_queue; > =A0* We want to avoid in middle of AER ops, pciback devices is being remo= ved > =A0*/ > =A0static DECLARE_RWSEM(pcistub_sem); > -module_param_named(hide, pci_devs_to_hide, charp, 0444); > +module_param_named(hide, pci_devs_to_hide, charp, S_IRUGO); > + > +static char *pci_devs_use_sbr =3D NULL; > +module_param_named(sbr, pci_devs_use_sbr, charp, S_IRUGO); > + > +static char *pci_devs_use_d3r =3D NULL; > +module_param_named(d3r, pci_devs_use_d3r, charp, S_IRUGO); > + > +static char *pci_devs_no_flr =3D NULL; > +module_param_named(noflr, pci_devs_no_flr, charp, S_IRUGO); > + > +/* Device id list holding different device type listings > + * for hiding devices and reset logic. > + */ > +#define PCIBACK_ID_TYPE_HIDE =A01 > +#define PCIBACK_ID_TYPE_SBR =A0 2 > +#define PCIBACK_ID_TYPE_D3R =A0 3 > +#define PCIBACK_ID_TYPE_NOFLR 4 > > =A0struct pcistub_device_id { > =A0 =A0 =A0 =A0struct list_head slot_list; > + =A0 =A0 =A0 int type; > =A0 =A0 =A0 =A0int domain; > =A0 =A0 =A0 =A0unsigned char bus; > =A0 =A0 =A0 =A0unsigned int devfn; > @@ -56,6 +74,8 @@ static LIST_HEAD(pcistub_devices); > =A0static int initialize_devices =3D 0; > =A0static LIST_HEAD(seized_devices); > > +static int disable_all_flr =3D 0; > + > =A0static struct pcistub_device *pcistub_device_alloc(struct pci_dev *dev= ) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device *psdev; > @@ -78,6 +98,23 @@ static struct pcistub_device *pcistub_de > =A0 =A0 =A0 =A0return psdev; > =A0} > > +static struct pciback_dev_data *pcistub_dev_data_alloc(struct pci_dev *d= ev) > +{ > + =A0 =A0 =A0 struct pciback_dev_data *dev_data; > + > + =A0 =A0 =A0 dev_dbg(&dev->dev, "pcistub_dev_data_alloc\n"); > + > + =A0 =A0 =A0 dev_data =3D kzalloc(sizeof(*dev_data) + dev->cfg_size, GFP= _ATOMIC); > + =A0 =A0 =A0 if (!dev_data) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return NULL; > + > + =A0 =A0 =A0 pci_set_drvdata(dev, dev_data); > + > + =A0 =A0 =A0 dev_data->cfg_space =3D (u8*)(dev_data) + sizeof(*dev_data)= ; > + > + =A0 =A0 =A0 return dev_data; > +} > + > =A0/* Don't call this directly as it's called by pcistub_device_put */ > =A0static void pcistub_device_release(struct kref *kref) > =A0{ > @@ -200,7 +237,7 @@ struct pci_dev *pcistub_get_pci_dev(stru > =A0 =A0 =A0 =A0return found_dev; > =A0} > > -void pcistub_put_pci_dev(struct pci_dev *dev) > +void pcistub_put_pci_dev(struct pci_dev *dev, int do_flr) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device *psdev, *found_psdev =3D NULL; > =A0 =A0 =A0 =A0unsigned long flags; > @@ -220,6 +257,13 @@ void pcistub_put_pci_dev(struct pci_dev > =A0 =A0 =A0 =A0* pcistub and pciback when AER is in processing > =A0 =A0 =A0 =A0*/ > =A0 =A0 =A0 =A0down_write(&pcistub_sem); > + > + =A0 =A0 =A0 /* For pass-through devices, do an FLR (or approximate) for= the device > + =A0 =A0 =A0 =A0* before it is put back and ready for the next domain > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 if (!disable_all_flr && do_flr) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_flr_device(dev); > + > =A0 =A0 =A0 =A0/* Cleanup our device > =A0 =A0 =A0 =A0 * (so it's ready for the next domain) > =A0 =A0 =A0 =A0 */ > @@ -235,6 +279,43 @@ void pcistub_put_pci_dev(struct pci_dev > =A0 =A0 =A0 =A0up_write(&pcistub_sem); > =A0} > > +struct pci_dev *pcistub_ref_pci_dev(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pcistub_device *psdev; > + =A0 =A0 =A0 struct pci_dev *found_dev =3D NULL; > + =A0 =A0 =A0 unsigned long flags; > + > + =A0 =A0 =A0 spin_lock_irqsave(&pcistub_devices_lock, flags); > + > + =A0 =A0 =A0 list_for_each_entry(psdev, &pcistub_devices, dev_list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (psdev->dev =3D=3D dev) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_device_get(psdev); = /* just a ref count */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 found_dev =3D psdev->dev; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 spin_unlock_irqrestore(&pcistub_devices_lock, flags); > + =A0 =A0 =A0 return found_dev; > +} > + > +void pcistub_unref_pci_dev(struct pci_dev *dev) > +{ > + =A0 =A0 =A0 struct pcistub_device *psdev; > + =A0 =A0 =A0 unsigned long flags; > + > + =A0 =A0 =A0 spin_lock_irqsave(&pcistub_devices_lock, flags); > + > + =A0 =A0 =A0 list_for_each_entry(psdev, &pcistub_devices, dev_list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (psdev->dev =3D=3D dev) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_device_get(psdev); = /* just an unref count */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 spin_unlock_irqrestore(&pcistub_devices_lock, flags); > +} > + > =A0static int __devinit pcistub_match_one(struct pci_dev *dev, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 struct pcistub_device_id *pdev_id) > =A0{ > @@ -255,7 +336,7 @@ static int __devinit pcistub_match_one(s > =A0 =A0 =A0 =A0return 0; > =A0} > > -static int __devinit pcistub_match(struct pci_dev *dev) > +static int __devinit pcistub_match(struct pci_dev *dev, int type) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device_id *pdev_id; > =A0 =A0 =A0 =A0unsigned long flags; > @@ -263,6 +344,8 @@ static int __devinit pcistub_match(struc > > =A0 =A0 =A0 =A0spin_lock_irqsave(&device_ids_lock, flags); > =A0 =A0 =A0 =A0list_for_each_entry(pdev_id, &pcistub_device_ids, slot_lis= t) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pdev_id->type !=3D type) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (pcistub_match_one(dev, pdev_id)) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0found =3D 1; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > @@ -285,12 +368,11 @@ static int __devinit pcistub_init_device > =A0 =A0 =A0 =A0 * would need to be called somewhere to free the memory al= located > =A0 =A0 =A0 =A0 * here and then to call kfree(pci_get_drvdata(psdev->dev)= ). > =A0 =A0 =A0 =A0 */ > - =A0 =A0 =A0 dev_data =3D kzalloc(sizeof(*dev_data), GFP_ATOMIC); > + =A0 =A0 =A0 dev_data =3D pcistub_dev_data_alloc(dev); > =A0 =A0 =A0 =A0if (!dev_data) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0err =3D -ENOMEM; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out; > =A0 =A0 =A0 =A0} > - =A0 =A0 =A0 pci_set_drvdata(dev, dev_data); > > =A0 =A0 =A0 =A0dev_dbg(&dev->dev, "initializing config\n"); > > @@ -317,6 +399,22 @@ static int __devinit pcistub_init_device > =A0 =A0 =A0 =A0dev_dbg(&dev->dev, "reset device\n"); > =A0 =A0 =A0 =A0pciback_reset_device(dev); > > + =A0 =A0 =A0 /* Classify the device so we know if it is PCI/PCIe and if = it is > + =A0 =A0 =A0 =A0* a bridge - this information is used for FLR logic. Als= o store > + =A0 =A0 =A0 =A0* values if SBR/D3R reset logic was requested. > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 pciback_classify_device(dev); > + =A0 =A0 =A0 dev_data->no_flr =3D pcistub_match(dev, PCIBACK_ID_TYPE_NOF= LR); > + =A0 =A0 =A0 if (!dev_data->no_flr) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->use_sbr =3D pcistub_match(dev, PC= IBACK_ID_TYPE_SBR); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_data->use_d3r =3D pcistub_match(dev, PC= IBACK_ID_TYPE_D3R); > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 /* Store the config space here where the device is off and = ready to be > + =A0 =A0 =A0 =A0* exported before any FLRs or other resets are done > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 pciback_store_config_space(dev); > + > =A0 =A0 =A0 =A0return 0; > > =A0 =A0 =A0 config_release: > @@ -414,7 +512,7 @@ static int __devinit pcistub_probe(struc > > =A0 =A0 =A0 =A0dev_dbg(&dev->dev, "probing...\n"); > > - =A0 =A0 =A0 if (pcistub_match(dev)) { > + =A0 =A0 =A0 if (pcistub_match(dev, PCIBACK_ID_TYPE_HIDE)) { > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (dev->hdr_type !=3D PCI_HEADER_TYPE_NOR= MAL > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& dev->hdr_type !=3D PCI_HEADER_T= YPE_BRIDGE) { > @@ -851,7 +949,7 @@ static inline int str_to_quirk(const cha > =A0 =A0 =A0 =A0return -EINVAL; > =A0} > > -static int pcistub_device_id_add(int domain, int bus, int slot, int func= ) > +static int pcistub_device_id_add(int domain, int bus, int slot, int func= , int type) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device_id *pci_dev_id; > =A0 =A0 =A0 =A0unsigned long flags; > @@ -860,12 +958,13 @@ static int pcistub_device_id_add(int dom > =A0 =A0 =A0 =A0if (!pci_dev_id) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENOMEM; > > + =A0 =A0 =A0 pci_dev_id->type =3D type; > =A0 =A0 =A0 =A0pci_dev_id->domain =3D domain; > =A0 =A0 =A0 =A0pci_dev_id->bus =3D bus; > =A0 =A0 =A0 =A0pci_dev_id->devfn =3D PCI_DEVFN(slot, func); > > - =A0 =A0 =A0 pr_debug("pciback: wants to seize %04x:%02x:%02x.%01x\n", > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0domain, bus, slot, func); > + =A0 =A0 =A0 pr_debug("pciback: adding device ID type: %d for %04x:%02x:= %02x.%01x\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0type, domain, bus, slot, func); > > =A0 =A0 =A0 =A0spin_lock_irqsave(&device_ids_lock, flags); > =A0 =A0 =A0 =A0list_add_tail(&pci_dev_id->slot_list, &pcistub_device_ids)= ; > @@ -874,7 +973,7 @@ static int pcistub_device_id_add(int dom > =A0 =A0 =A0 =A0return 0; > =A0} > > -static int pcistub_device_id_remove(int domain, int bus, int slot, int f= unc) > +static int pcistub_device_id_remove(int domain, int bus, int slot, int f= unc, int type) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device_id *pci_dev_id, *t; > =A0 =A0 =A0 =A0int devfn =3D PCI_DEVFN(slot, func); > @@ -884,7 +983,7 @@ static int pcistub_device_id_remove(int > =A0 =A0 =A0 =A0spin_lock_irqsave(&device_ids_lock, flags); > =A0 =A0 =A0 =A0list_for_each_entry_safe(pci_dev_id, t, &pcistub_device_id= s, slot_list) { > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pci_dev_id->domain =3D=3D domain > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pci_dev_id->type =3D=3D type && pci_dev= _id->domain =3D=3D domain > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&& pci_dev_id->bus =3D=3D bus && p= ci_dev_id->devfn =3D=3D devfn) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Don't break; here becau= se it's possible the same > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * slot could be in the li= st more than once > @@ -939,6 +1038,32 @@ static int pcistub_reg_add(int domain, i > =A0 =A0 =A0 =A0return err; > =A0} > > +static int pcistub_device_do_flr(int domain, int bus, int slot, int func= ) > +{ > + =A0 =A0 =A0 int err =3D 0; > + =A0 =A0 =A0 struct pcistub_device *psdev; > + =A0 =A0 =A0 struct pci_dev *dev; > + > + =A0 =A0 =A0 psdev =3D pcistub_device_find(domain, bus, slot, func); > + =A0 =A0 =A0 if (!psdev || !psdev->dev) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -ENODEV; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + =A0 =A0 =A0 } > + =A0 =A0 =A0 dev =3D psdev->dev; > + > + =A0 =A0 =A0 /* Do an FLR (or approximate) for the device on demand and > + =A0 =A0 =A0 =A0* reload config > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 if (!disable_all_flr) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pciback_flr_device(dev); > + =A0 =A0 =A0 } > + =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_dbg(&dev->dev, "FLR disabled for all de= vices\n"); > + > +out: > + =A0 =A0 =A0 return err; > +} > + > =A0static ssize_t pcistub_slot_add(struct device_driver *drv, const char = *buf, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0size_t cou= nt) > =A0{ > @@ -949,7 +1074,7 @@ static ssize_t pcistub_slot_add(struct d > =A0 =A0 =A0 =A0if (err) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out; > > - =A0 =A0 =A0 err =3D pcistub_device_id_add(domain, bus, slot, func); > + =A0 =A0 =A0 err =3D pcistub_device_id_add(domain, bus, slot, func, PCIB= ACK_ID_TYPE_HIDE); > > =A0 =A0 =A0 out: > =A0 =A0 =A0 =A0if (!err) > @@ -969,7 +1094,7 @@ static ssize_t pcistub_slot_remove(struc > =A0 =A0 =A0 =A0if (err) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out; > > - =A0 =A0 =A0 err =3D pcistub_device_id_remove(domain, bus, slot, func); > + =A0 =A0 =A0 err =3D pcistub_device_id_remove(domain, bus, slot, func, P= CIBACK_ID_TYPE_HIDE); > > =A0 =A0 =A0 out: > =A0 =A0 =A0 =A0if (!err) > @@ -987,6 +1112,10 @@ static ssize_t pcistub_slot_show(struct > > =A0 =A0 =A0 =A0spin_lock_irqsave(&device_ids_lock, flags); > =A0 =A0 =A0 =A0list_for_each_entry(pci_dev_id, &pcistub_device_ids, slot_= list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* only want devices set for hide, not rese= t entries */ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pci_dev_id->type !=3D PCIBACK_ID_TYPE_H= IDE) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > + > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (count >=3D PAGE_SIZE) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > > @@ -1068,7 +1197,7 @@ static ssize_t pcistub_quirk_show(struct > > =A0DRIVER_ATTR(quirks, S_IRUSR | S_IWUSR, pcistub_quirk_show, pcistub_qui= rk_add); > > -static ssize_t permissive_add(struct device_driver *drv, const char *buf= , > +static ssize_t pcistub_permissive_add(struct device_driver *drv, const c= har *buf, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0size_t count) > =A0{ > =A0 =A0 =A0 =A0int domain, bus, slot, func; > @@ -1109,7 +1238,7 @@ static ssize_t permissive_add(struct dev > =A0 =A0 =A0 =A0return err; > =A0} > > -static ssize_t permissive_show(struct device_driver *drv, char *buf) > +static ssize_t pcistub_permissive_show(struct device_driver *drv, char *= buf) > =A0{ > =A0 =A0 =A0 =A0struct pcistub_device *psdev; > =A0 =A0 =A0 =A0struct pciback_dev_data *dev_data; > @@ -1132,7 +1261,68 @@ static ssize_t permissive_show(struct de > =A0 =A0 =A0 =A0return count; > =A0} > > -DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, permissive_show, permissive_a= dd); > +DRIVER_ATTR(permissive, S_IRUSR | S_IWUSR, pcistub_permissive_show, pcis= tub_permissive_add); > + > +static ssize_t pcistub_do_flr(struct device_driver *drv, const char *buf= , > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0size= _t count) > +{ > + =A0 =A0 =A0 int domain, bus, slot, func; > + =A0 =A0 =A0 int err; > + > + =A0 =A0 =A0 err =3D str_to_slot(buf, &domain, &bus, &slot, &func); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + > + =A0 =A0 =A0 err =3D pcistub_device_do_flr(domain, bus, slot, func); > + > +out: > + =A0 =A0 =A0 if (!err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D count; > + =A0 =A0 =A0 return err; > +} > + > +DRIVER_ATTR(do_flr, S_IWUSR, NULL, pcistub_do_flr); > + > +static ssize_t pcistub_resets(struct device_driver *drv, const char *buf= , > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0size= _t count) > +{ > + =A0 =A0 =A0 int domain, bus, slot, func; > + =A0 =A0 =A0 int type, err =3D 0; > + > + =A0 =A0 =A0 /* string begins with reset type specifier sbr=3D|dr3=3D|no= flr=3D */ > + =A0 =A0 =A0 if (!strncmp(buf, "sbr=3D", 4)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 type =3D PCIBACK_ID_TYPE_SBR; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 buf +=3D 4; > + =A0 =A0 =A0 } else if (!strncmp(buf, "d3r=3D", 4)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 type =3D PCIBACK_ID_TYPE_D3R; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 buf +=3D 4; > + =A0 =A0 =A0 } else if (!strncmp(buf, "noflr=3D", 6)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 type =3D PCIBACK_ID_TYPE_NOFLR; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 buf +=3D 6; > + =A0 =A0 =A0 } else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D -EINVAL; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 /* check special wildcard noflr */ > + =A0 =A0 =A0 if (type =3D=3D PCIBACK_ID_TYPE_NOFLR && !strncmp(buf, "(*)= ", 3)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 disable_all_flr =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + =A0 =A0 =A0 } > + > + =A0 =A0 =A0 err =3D str_to_slot(buf, &domain, &bus, &slot, &func); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + > + =A0 =A0 =A0 err =3D pcistub_device_id_add(domain, bus, slot, func, type= ); > + > +out: > + =A0 =A0 =A0 if (!err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D count; > + =A0 =A0 =A0 return err; > +} > + > +DRIVER_ATTR(resets, S_IWUSR, NULL, pcistub_resets); > > =A0#ifdef CONFIG_PCI_MSI > > @@ -1158,6 +1348,8 @@ static void pcistub_exit(void) > =A0 =A0 =A0 =A0driver_remove_file(&pciback_pci_driver.driver, &driver_att= r_slots); > =A0 =A0 =A0 =A0driver_remove_file(&pciback_pci_driver.driver, &driver_att= r_quirks); > =A0 =A0 =A0 =A0driver_remove_file(&pciback_pci_driver.driver, &driver_att= r_permissive); > + =A0 =A0 =A0 driver_remove_file(&pciback_pci_driver.driver, &driver_attr= _do_flr); > + =A0 =A0 =A0 driver_remove_file(&pciback_pci_driver.driver, &driver_attr= _resets); > > =A0 =A0 =A0 =A0pci_unregister_driver(&pciback_pci_driver); > =A0 =A0 =A0 =A0WARN_ON(unregister_msi_get_owner(pciback_get_owner)); > @@ -1165,35 +1357,27 @@ static void pcistub_exit(void) > > =A0static int __init pcistub_init(void) > =A0{ > - =A0 =A0 =A0 int pos =3D 0; > =A0 =A0 =A0 =A0int err =3D 0; > - =A0 =A0 =A0 int domain, bus, slot, func; > - =A0 =A0 =A0 int parsed; > > - =A0 =A0 =A0 if (pci_devs_to_hide && *pci_devs_to_hide) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 do { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 parsed =3D 0; > - > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D sscanf(pci_devs_to_= hide + pos, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= " (%x:%x:%x.%x) %n", > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= &domain, &bus, &slot, &func, &parsed); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err !=3D 4) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 domain =3D = 0; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D ssc= anf(pci_devs_to_hide + pos, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0" (%x:%x.%x) %n", > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0&bus, &slot, &func, &parsed); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err != =3D 3) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 goto parse_error; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 /* Parse device lists for hide, sbr, and d3r */ > + =A0 =A0 =A0 err =3D pciback_parse_device_params(pci_devs_to_hide, PCIBA= CK_ID_TYPE_HIDE, pcistub_device_id_add); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D pcistub_device_id_a= dd(domain, bus, slot, func); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (err) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + =A0 =A0 =A0 err =3D pciback_parse_device_params(pci_devs_use_sbr, PCIBA= CK_ID_TYPE_SBR, pcistub_device_id_add); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* if parsed<=3D0, we've re= ached the end of the string */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pos +=3D parsed; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } while (parsed > 0 && pci_devs_to_hide[pos= ]); > - =A0 =A0 =A0 } > + =A0 =A0 =A0 err =3D pciback_parse_device_params(pci_devs_use_d3r, PCIBA= CK_ID_TYPE_D3R, pcistub_device_id_add); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > + > + =A0 =A0 =A0 if (pci_devs_no_flr && *pci_devs_no_flr && !strncmp(pci_dev= s_no_flr, "(*)", 3)) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 disable_all_flr =3D 1; /* check special wil= dcard noflr */ > + =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D pciback_parse_device_params(pci_dev= s_no_flr, PCIBACK_ID_TYPE_NOFLR, pcistub_device_id_add); > + =A0 =A0 =A0 if (err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > > =A0 =A0 =A0 =A0/* If we're the first PCI Device Driver to register, we're= the > =A0 =A0 =A0 =A0 * first one to get offered PCI devices as they become > @@ -1217,6 +1401,12 @@ static int __init pcistub_init(void) > =A0 =A0 =A0 =A0if (!err) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0err =3D driver_create_file(&pciback_pci_dr= iver.driver, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 &driver_attr_permissive); > + =A0 =A0 =A0 if (!err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D driver_create_file(&pciback_pci_dri= ver.driver, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0&driver_attr_do_flr); > + =A0 =A0 =A0 if (!err) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 err =3D driver_create_file(&pciback_pci_dri= ver.driver, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0&driver_attr_resets); > > =A0 =A0 =A0 =A0if (!err) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0err =3D register_msi_get_owner(pciback_get= _owner); > @@ -1225,11 +1415,6 @@ static int __init pcistub_init(void) > > =A0 =A0 =A0 out: > =A0 =A0 =A0 =A0return err; > - > - =A0 =A0 =A0parse_error: > - =A0 =A0 =A0 printk(KERN_ERR "pciback: Error parsing pci_devs_to_hide at= \"%s\"\n", > - =A0 =A0 =A0 =A0 =A0 =A0 =A0pci_devs_to_hide + pos); > - =A0 =A0 =A0 return -EINVAL; > =A0} > > =A0#ifndef MODULE > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/slot.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/slot.c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/slot.c =A0 =A02009-06-07 20= :48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/slot.c =A0 =A02009-06-07 19= :04:11.000000000 -0400 > @@ -109,7 +109,7 @@ void pciback_release_pci_dev(struct pcib > =A0 =A0 =A0 =A0spin_unlock_irqrestore(&slot_dev->lock, flags); > > =A0 =A0 =A0 =A0if (found_dev) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev, 0); > =A0} > > =A0int pciback_init_devices(struct pciback_device *pdev) > @@ -149,7 +149,7 @@ void pciback_release_devices(struct pcib > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (slot =3D 0; slot < PCI_SLOT_MAX; slot= ++) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev =3D slot_dev->slots[bu= s][slot]; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (dev !=3D NULL) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put= _pci_dev(dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put= _pci_dev(dev, 0); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0kfree(slot_dev); > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/driver= s/xen/pciback/vpci.c b/linux-2.6.18-xen.hg/drivers/xen/pciback/vpci.c > --- a/linux-2.6.18-xen.hg/drivers/xen/pciback/vpci.c =A0 =A02009-06-07 20= :48:21.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/drivers/xen/pciback/vpci.c =A0 =A02009-06-07 19= :04:11.000000000 -0400 > @@ -162,7 +162,7 @@ void pciback_release_pci_dev(struct pcib > =A0 =A0 =A0 =A0spin_unlock_irqrestore(&vpci_dev->lock, flags); > > =A0 =A0 =A0 =A0if (found_dev) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(found_dev, 0); > =A0} > > =A0int pciback_init_devices(struct pciback_device *pdev) > @@ -202,7 +202,7 @@ void pciback_release_devices(struct pcib > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_for_each_entry_safe(e, tmp, &vpci_dev= ->dev_list[slot], > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 list) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_del(&e->list); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(e->dev)= ; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pcistub_put_pci_dev(e->dev,= 0); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0kfree(e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0} > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/includ= e/linux/pci_ids.h b/linux-2.6.18-xen.hg/include/linux/pci_ids.h > --- a/linux-2.6.18-xen.hg/include/linux/pci_ids.h =A0 =A0 =A0 2009-06-07 = 20:48:23.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/include/linux/pci_ids.h =A0 =A0 =A0 2009-06-07 = 19:04:11.000000000 -0400 > @@ -2259,6 +2259,14 @@ > =A0#define PCI_DEVICE_ID_INTEL_IXP2800 =A0 =A00x9004 > =A0#define PCI_DEVICE_ID_INTEL_S21152BB =A0 0xb152 > > +#define PCI_DEVICE_ID_INTEL_GMCHQ45 0x2e10 > +#define PCI_DEVICE_ID_INTEL_GMCHG45 0x2e20 > +#define PCI_DEVICE_ID_INTEL_MCHP45 =A00x2e20 > +#define PCI_DEVICE_ID_INTEL_GMCHG41 0x2e30 > +#define PCI_DEVICE_ID_INTEL_GMCHGM45 0x2a40 > + > +#define PCI_DEVICE_ID_INTEL_GMCHG41 0x2e30 > + > =A0#define PCI_VENDOR_ID_SCALEMP =A0 =A0 =A0 =A0 =A00x8686 > =A0#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010 > > diff -rupN --ignore-blank-lines-X diffignore a/linux-2.6.18-xen.hg/includ= e/linux/pci_regs.h b/linux-2.6.18-xen.hg/include/linux/pci_regs.h > --- a/linux-2.6.18-xen.hg/include/linux/pci_regs.h =A0 =A0 =A02009-06-07 = 20:48:23.000000000 -0400 > +++ b/linux-2.6.18-xen.hg/include/linux/pci_regs.h =A0 =A0 =A02009-06-07 = 19:04:11.000000000 -0400 > @@ -201,6 +201,7 @@ > =A0#define =A0PCI_CAP_ID_SHPC =A0 =A0 =A0 0x0C =A0 =A0/* PCI Standard Hot= -Plug Controller */ > =A0#define =A0PCI_CAP_ID_EXP =A0 =A0 =A0 =A00x10 =A0 =A0/* PCI Express */ > =A0#define =A0PCI_CAP_ID_MSIX =A0 =A0 =A0 0x11 =A0 =A0/* MSI-X */ > +#define =A0PCI_CAP_ID_AF =A0 =A0 =A00x13 =A0 =A0/* Advanced Features Cap= ability */ > =A0#define PCI_CAP_LIST_NEXT =A0 =A0 =A01 =A0 =A0 =A0 /* Next capability = in the list */ > =A0#define PCI_CAP_FLAGS =A0 =A0 =A0 =A0 =A02 =A0 =A0 =A0 /* Capability d= efined flags (16 bits) */ > =A0#define PCI_CAP_SIZEOF =A0 =A0 =A0 =A0 4 > @@ -229,6 +230,11 @@ > =A0#define =A0PCI_PM_CTRL_DATA_SEL_MASK =A0 =A0 0x1e00 =A0/* Data select = (??) */ > =A0#define =A0PCI_PM_CTRL_DATA_SCALE_MASK =A0 0x6000 =A0/* Data scale (??= ) */ > =A0#define =A0PCI_PM_CTRL_PME_STATUS =A0 =A0 =A0 =A00x8000 =A0/* PME pin = status */ > +#define =A0PCI_PM_CTRL_DATA_DSTATE_MASK 0x3 =A0 =A0 =A0/* D0 - D3 */ > +#define =A0PCI_PM_CTRL_D0 0x0 > +#define =A0PCI_PM_CTRL_D1 0x1 > +#define =A0PCI_PM_CTRL_D2 0x2 > +#define =A0PCI_PM_CTRL_D3HOT 0x3 > =A0#define PCI_PM_PPB_EXTENSIONS =A06 =A0 =A0 =A0 /* PPB support extensio= ns (??) */ > =A0#define =A0PCI_PM_PPB_B2_B3 =A0 =A0 =A00x40 =A0 =A0/* Stop clock when = in D3hot (??) */ > =A0#define =A0PCI_PM_BPCC_ENABLE =A0 =A00x80 =A0 =A0/* Bus power/clock co= ntrol enable (??) */ > @@ -346,6 +352,7 @@ > =A0#define =A0PCI_EXP_DEVCAP_PWR_IND =A0 =A0 =A0 =A00x4000 =A0/* Power In= dicator Present */ > =A0#define =A0PCI_EXP_DEVCAP_PWR_VAL =A0 =A0 =A0 =A00x3fc0000 /* Slot Pow= er Limit Value */ > =A0#define =A0PCI_EXP_DEVCAP_PWR_SCL =A0 =A0 =A0 =A00xc000000 /* Slot Pow= er Limit Scale */ > +#define =A0PCI_EXP_DEVCAP_FLR =A0 =A0 0x10000000 /* Function Level Reset= */ > =A0#define PCI_EXP_DEVCTL =A0 =A0 =A0 =A0 8 =A0 =A0 =A0 /* Device Control= */ > =A0#define =A0PCI_EXP_DEVCTL_CERE =A0 0x0001 =A0/* Correctable Error Repo= rting En. */ > =A0#define =A0PCI_EXP_DEVCTL_NFERE =A00x0002 =A0/* Non-Fatal Error Report= ing Enable */ > @@ -358,6 +365,7 @@ > =A0#define =A0PCI_EXP_DEVCTL_AUX_PME =A0 =A0 =A0 =A00x0400 =A0/* Auxiliar= y Power PM Enable */ > =A0#define =A0PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 =A0/* Enable No Snoop */ > =A0#define =A0PCI_EXP_DEVCTL_READRQ 0x7000 =A0/* Max_Read_Request_Size */ > +#define =A0PCI_EXP_DEVCTL_BCR_FLR 0x8000 =A0/* Bridge Configuration Retr= y / FLR */ > =A0#define PCI_EXP_DEVSTA =A0 =A0 =A0 =A0 10 =A0 =A0 =A0/* Device Status = */ > =A0#define =A0PCI_EXP_DEVSTA_CED =A0 =A00x01 =A0 =A0/* Correctable Error = Detected */ > =A0#define =A0PCI_EXP_DEVSTA_NFED =A0 0x02 =A0 =A0/* Non-Fatal Error Dete= cted */ > @@ -482,6 +490,17 @@ > =A0#define =A0PCI_ARI_CTRL_ACS =A0 =A0 =A00x0002 =A0/* ACS Function Group= s Enable */ > =A0#define =A0PCI_ARI_CTRL_FG(x) =A0 =A0(((x) >> 4) & 7) /* Function Grou= p */ > > +/* Advanced Features Capability */ > +#define PCI_AF_LENFLD =A0 =A00x02 /* Device length offset */ > +#define =A0PCI_AF_LENGTH =A0 0x06 > +#define PCI_AF_DEVCAP =A0 =A00x03 /* Device capabilities offset */ > +#define =A0PCI_AF_CAP_TP =A0 0x01 > +#define =A0PCI_AF_CAP_FLR =A00x02 > +#define PCI_AF_CTRL =A0 =A0 =A00x04 /* Device CTRL offset */ > +#define =A0PCI_AF_CTRL_FLR 0x01 > +#define PCI_AF_STA =A0 =A0 =A0 0x05 /* Device STATUS offset */ > +#define =A0PCI_AF_STA_TP =A0 0x01 > + > =A0/* Single Root I/O Virtualization */ > =A0#define PCI_SRIOV_CAP =A0 =A0 =A0 =A0 =A00x04 =A0 =A0/* SR-IOV Capabil= ities */ > =A0#define =A0PCI_SRIOV_CAP_VFM =A0 =A0 0x01 =A0 =A0/* VF Migration Capab= le */ > diff -rupN --ignore-blank-lines-X diffignore a/tools/firmware/hvmloader/h= vmloader.c b/tools/firmware/hvmloader/hvmloader.c > --- a/tools/firmware/hvmloader/hvmloader.c =A0 =A0 =A02009-06-07 20:44:47= .000000000 -0400 > +++ b/tools/firmware/hvmloader/hvmloader.c =A0 =A0 =A02009-06-07 19:04:11= .000000000 -0400 > @@ -673,6 +673,7 @@ int main(void) > =A0 =A0 =A0 =A0 break; > =A0 =A0 default: > =A0 =A0 =A0 =A0 printf("No emulated VGA adaptor ...\n"); > + =A0 =A0 =A0 =A0vgabios_sz =3D round_option_rom((*(uint8_t *)(VGABIOS_PH= YSICAL_ADDRESS+2)) * 512); > =A0 =A0 =A0 =A0 break; > =A0 =A0 } > > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/console= .h b/tools/ioemu-remote/console.h > --- a/tools/ioemu-remote/console.h =A0 =A0 =A02009-06-07 21:14:47.0000000= 00 -0400 > +++ b/tools/ioemu-remote/console.h =A0 =A0 =A02009-06-07 19:04:11.0000000= 00 -0400 > @@ -290,6 +290,9 @@ void vga_hw_update(void); > =A0void vga_hw_invalidate(void); > =A0void vga_hw_screen_dump(const char *filename); > > +void unset_vga_acc(void); > +void set_vga_acc(void); > + > =A0int is_graphic_console(void); > =A0int is_fixedsize_console(void); > =A0CharDriverState *text_console_init(const char *p); > @@ -341,4 +344,9 @@ const char *readline_get_history(unsigne > =A0void readline_start(const char *prompt, int is_password, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ReadLineFunc *readline_func, void= *opaque); > > +/* intel.c */ > +int intel_enter(void); > +int intel_leave(void); > +void intel_display_init(DisplayState *ds); > + > =A0#endif > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/hw/pass= -through.c b/tools/ioemu-remote/hw/pass-through.c > --- a/tools/ioemu-remote/hw/pass-through.c =A0 =A0 =A02009-06-07 21:14:48= .000000000 -0400 > +++ b/tools/ioemu-remote/hw/pass-through.c =A0 =A0 =A02009-06-07 19:04:11= .000000000 -0400 > @@ -90,6 +90,8 @@ > =A0#include "qemu-xen.h" > =A0#include > > +extern int vga_passthrough; > + > =A0struct php_dev { > =A0 =A0 struct pt_dev *pt_dev; > =A0 =A0 uint8_t valid; > @@ -1573,10 +1575,11 @@ static int pt_dev_is_virtfn(struct pci_d > > =A0static int pt_register_regions(struct pt_dev *assigned_device) > =A0{ > - =A0 =A0int i =3D 0; > + =A0 =A0int i =3D 0, ret =3D 0; > =A0 =A0 uint32_t bar_data =3D 0; > =A0 =A0 struct pci_dev *pci_dev =3D assigned_device->pci_dev; > =A0 =A0 PCIDevice *d =3D &assigned_device->dev; > + =A0 =A0uint16_t class, vendor_id; > > =A0 =A0 /* Register PIO/MMIO BARs */ > =A0 =A0 for ( i =3D 0; i < PCI_BAR_ENTRIES; i++ ) > @@ -1632,6 +1635,25 @@ static int pt_register_regions(struct pt > =A0 =A0 =A0 =A0 =A0 =A0 (uint32_t)(pci_dev->rom_size), (uint32_t)(pci_dev= ->rom_base_addr)); > =A0 =A0 } > > + =A0 =A0/* Map legacy ioport and iomem, for specific devices */ > + =A0 =A0vendor_id =3D pci_read_word(pci_dev, 0x00); > + =A0 =A0class =3D pci_read_word(pci_dev, 0x0a); > + > + =A0 =A0PT_LOG("Real device vendor_id=3D0x%x class=3D0x%x\n", vendor_id,= class); > + =A0 =A0if ( vga_passthrough && class =3D=3D 0x0300 ) > + =A0 =A0{ > + =A0 =A0 =A0 =A0PT_LOG("add an intel graphic card\n"); > + > + =A0 =A0 =A0 =A0ret =3D xc_domain_ioport_mapping(xc_handle, domid, 0x3B0= , 0x3B0, 0xb, DPCI_ADD_MAPPING); > + =A0 =A0 =A0 =A0ret =3D xc_domain_ioport_mapping(xc_handle, domid, 0x3C0= , 0x3C0, 32, DPCI_ADD_MAPPING); > + =A0 =A0 =A0 =A0ret |=3D xc_domain_memory_mapping(xc_handle, domid, 0xa0= , 0xa0, 32, DPCI_ADD_MAPPING); > + =A0 =A0 =A0 =A0if ( ret !=3D 0 ) > + =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 =A0 =A0PT_LOG("legacy mapping failed!\n"); > + =A0 =A0 =A0 =A0 =A0 =A0return ret; > + =A0 =A0 =A0 =A0} > + =A0 =A0} > + > =A0 =A0 return 0; > =A0} > > @@ -1640,6 +1662,7 @@ static void pt_unregister_regions(struct > =A0 =A0 int i, type, ret; > =A0 =A0 uint32_t e_size; > =A0 =A0 PCIDevice *d =3D (PCIDevice*)assigned_device; > + =A0 =A0uint16_t class, vendor_id; > > =A0 =A0 for ( i =3D 0; i < PCI_NUM_REGIONS; i++ ) > =A0 =A0 { > @@ -1681,6 +1704,24 @@ static void pt_unregister_regions(struct > > =A0 =A0 } > > + =A0 =A0/* unmap legacy ioport and iomem, for specific devices */ > + =A0 =A0vendor_id =3D pci_read_word(assigned_device->pci_dev, 0x00); > + =A0 =A0class =3D pci_read_word(assigned_device->pci_dev, 0x0a); > + > + =A0 =A0PT_LOG("Real device vendor_id=3D0x%x class=3D0x%x\n", vendor_id,= class); > + =A0 =A0if ( vga_passthrough && class =3D=3D 0x0300 ) > + =A0 =A0{ > + =A0 =A0 =A0 =A0PT_LOG("remove an intel graphic card\n"); > + > + =A0 =A0 =A0 =A0ret =3D xc_domain_ioport_mapping(xc_handle, domid, 0x3B0= , 0x3B0, 0xb, DPCI_REMOVE_MAPPING); > + =A0 =A0 =A0 =A0ret =3D xc_domain_ioport_mapping(xc_handle, domid, 0x3C0= , 0x3C0, 32, DPCI_REMOVE_MAPPING); > + =A0 =A0 =A0 =A0ret |=3D xc_domain_memory_mapping(xc_handle, domid, 0xa0= , 0xa0, 32, DPCI_REMOVE_MAPPING); > + =A0 =A0 =A0 =A0if ( ret !=3D 0 ) > + =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 =A0 =A0PT_LOG("legacy unmapping failed !\n"); > + =A0 =A0 =A0 =A0} > + =A0 =A0} > + > =A0} > > =A0static uint8_t find_cap_offset(struct pci_dev *pci_dev, uint8_t cap) > @@ -3759,7 +3800,7 @@ static struct pt_dev * register_real_dev > =A0 =A0 struct pci_config_cf8 machine_bdf; > =A0 =A0 char *key, *val; > =A0 =A0 int msi_translate, power_mgmt; > - > + > =A0 =A0 PT_LOG("Assigning real physical device %02x:%02x.%x ...\n", > =A0 =A0 =A0 =A0 r_bus, r_dev, r_func); > > @@ -3931,7 +3972,7 @@ static struct pt_dev * register_real_dev > =A0 =A0 } > > =A0out: > - =A0 =A0PT_LOG("Real physical device %02x:%02x.%x registered successfuly= !\n" > + =A0 =A0PT_LOG("Real physical device %02x:%02x.%x registered successfull= y!\n" > =A0 =A0 =A0 =A0 =A0 =A0"IRQ type =3D %s\n", r_bus, r_dev, r_func, > =A0 =A0 =A0 =A0 =A0 =A0assigned_device->msi_trans_en? "MSI-INTx":"INTx"); > > @@ -4113,3 +4154,47 @@ err: > =A0 =A0 return status; > =A0} > > +u8 pt_pci_host_read_byte(int bus, int dev, int fn, u32 addr) > +{ > + =A0 =A0struct pci_dev *pci_dev; > + =A0 =A0u8 =A0 =A0 =A0 =A0 =A0 =A0 val; > + > + =A0 =A0pci_dev =3D pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn); > + =A0 =A0if (!pci_dev) > + =A0 =A0 =A0 =A0return 0; > + > + =A0 =A0val =3D pci_read_byte(pci_dev, addr); > + =A0 =A0pci_free_dev(pci_dev); > + > + =A0 =A0return val; > +} > + > +u16 pt_pci_host_read_word(int bus, int dev, int fn, u32 addr) > +{ > + =A0 =A0struct pci_dev *pci_dev; > + =A0 =A0u16 =A0 =A0 =A0 =A0 =A0 =A0 val; > + > + =A0 =A0pci_dev =3D pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn); > + =A0 =A0if (!pci_dev) > + =A0 =A0 =A0 =A0return 0; > + > + =A0 =A0val =3D pci_read_word(pci_dev, addr); > + =A0 =A0pci_free_dev(pci_dev); > + > + =A0 =A0return val; > +} > + > +u32 pt_pci_host_read_long(int bus, int dev, int fn, u32 addr) > +{ > + =A0 =A0struct pci_dev *pci_dev; > + =A0 =A0u32 =A0 =A0 =A0 =A0 =A0 =A0 val; > + > + =A0 =A0pci_dev =3D pci_get_dev(dpci_infos.pci_access, 0, bus, dev, fn); > + =A0 =A0if (!pci_dev) > + =A0 =A0 =A0 =A0return 0; > + > + =A0 =A0val =3D pci_read_long(pci_dev, addr); > + =A0 =A0pci_free_dev(pci_dev); > + > + =A0 =A0return val; > +} > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/hw/pc.c= b/tools/ioemu-remote/hw/pc.c > --- a/tools/ioemu-remote/hw/pc.c =A0 =A0 =A0 =A02009-06-07 21:14:47.00000= 0000 -0400 > +++ b/tools/ioemu-remote/hw/pc.c =A0 =A0 =A0 =A02009-06-07 19:04:11.00000= 0000 -0400 > @@ -65,6 +65,8 @@ void tpm_tis_init(SetIRQFunc *set_irq, v > =A0extern uint8_t *acpi_tables; > =A0extern size_t acpi_tables_len; > > +extern int vga_passthrough; > + > =A0static fdctrl_t *floppy_controller; > =A0static RTCState *rtc_state; > =A0static PITState *pit; > @@ -984,6 +986,7 @@ vga_bios_error: > > =A0 =A0 register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); > > + =A0 =A0if (!vga_passthrough) { > =A0 =A0 if (cirrus_vga_enabled) { > =A0 =A0 =A0 =A0 if (pci_enabled) { > =A0 =A0 =A0 =A0 =A0 =A0 pci_cirrus_vga_init(pci_bus, > @@ -1010,6 +1013,7 @@ vga_bios_error: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vga_ram_addr, vga_ram_= size); > =A0 =A0 =A0 =A0 } > =A0 =A0 } > + =A0 =A0} > > =A0#ifdef CONFIG_PASSTHROUGH > =A0 =A0 /* Pass-through Initialization > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/hw/pci.= c b/tools/ioemu-remote/hw/pci.c > --- a/tools/ioemu-remote/hw/pci.c =A0 =A0 =A0 2009-06-07 21:14:47.0000000= 00 -0400 > +++ b/tools/ioemu-remote/hw/pci.c =A0 =A0 =A0 2009-06-07 19:04:11.0000000= 00 -0400 > @@ -28,11 +28,14 @@ > =A0#include "virtio-net.h" > =A0#include "sysemu.h" > > +#include "pass-through.h" > =A0#include "exec-all.h" > =A0#include "qemu-xen.h" > > =A0//#define DEBUG_PCI > > +extern int vga_passthrough; > + > =A0struct PCIBus { > =A0 =A0 int bus_num; > =A0 =A0 int devfn_min; > @@ -611,7 +614,24 @@ uint32_t pci_data_read(void *opaque, uin > =A0 =A0 =A0 =A0 goto the_end; > =A0 =A0 } > =A0 =A0 config_addr =3D addr & 0xff; > - =A0 =A0val =3D pci_dev->config_read(pci_dev, config_addr, len); > + =A0 =A0if (vga_passthrough && pci_dev->devfn =3D=3D 0x00) //Host Bridge > + =A0 =A0{ > + =A0 =A0 =A0 =A0val =3D pci_dev->config_read(pci_dev, config_addr, len); > + > + =A0 =A0 =A0 =A0if (config_addr =3D=3D 0x52) // GMCH > + =A0 =A0 =A0 =A0 =A0 =A0val =3D pt_pci_host_read_word(0, 0, 0, 0x52); > + =A0 =A0 =A0 =A0if (config_addr =3D=3D 0x02) // Device ID > + =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 =A0 =A0if (len =3D=3D 2) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D pt_pci_host_read_word(0, 0, 0, 0= x00); > + =A0 =A0 =A0 =A0 =A0 =A0else if (len =3D=3D 4) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0val =3D pt_pci_host_read_long(0, 0, 0, 0= x00); > + =A0 =A0 =A0 =A0} > + =A0 =A0} else if (vga_passthrough && pci_dev->devfn =3D=3D 0x10 && // i= ntel graphic card > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 config_addr =3D=3D 0xfc) // OpRegion addres= s > + =A0 =A0 =A0 =A0val =3D 0; // force to fall back to SMI mode > + =A0 =A0else > + =A0 =A0 =A0 =A0val =3D pci_dev->config_read(pci_dev, config_addr, len); > =A0#if defined(DEBUG_PCI) > =A0 =A0 printf("pci_config_read: %s: addr=3D%02x val=3D%08x len=3D%d\n", > =A0 =A0 =A0 =A0 =A0 =A0pci_dev->name, config_addr, val, len); > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/hw/vga.= c b/tools/ioemu-remote/hw/vga.c > --- a/tools/ioemu-remote/hw/vga.c =A0 =A0 =A0 2009-06-07 21:14:47.0000000= 00 -0400 > +++ b/tools/ioemu-remote/hw/vga.c =A0 =A0 =A0 2009-06-07 19:04:11.0000000= 00 -0400 > @@ -34,9 +34,9 @@ > > =A0#include "qemu-timer.h" > > -//#define DEBUG_VGA > -//#define DEBUG_VGA_MEM > -//#define DEBUG_VGA_REG > +#define DEBUG_VGA > +#define DEBUG_VGA_MEM > +#define DEBUG_VGA_REG > > =A0//#define DEBUG_BOCHS_VBE > > @@ -161,6 +161,18 @@ static uint8_t expand4to8[16]; > =A0static void vga_bios_init(VGAState *s); > =A0static void vga_screen_dump(void *opaque, const char *filename); > > +static VGAState *xen_vga_state; > + > +void set_vga_acc(void) > +{ > + =A0 =A0set_vram_mapping(xen_vga_state, xen_vga_state->lfb_addr, xen_vga= _state->lfb_end); > +} > + > +void unset_vga_acc(void) > +{ > + =A0 =A0unset_vram_mapping(xen_vga_state); > +} > + > =A0static void vga_dumb_update_retrace_info(VGAState *s) > =A0{ > =A0 =A0 (void) s; > @@ -2473,8 +2485,6 @@ static void vga_bios_init(VGAState *s) > =A0} > > > -static VGAState *xen_vga_state; > - > =A0/* Allocate video memory in the GPFN space */ > =A0void xen_vga_populate_vram(uint64_t vram_addr, uint32_t vga_ram_size) > =A0{ > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/intel.c= b/tools/ioemu-remote/intel.c > --- a/tools/ioemu-remote/intel.c =A0 =A0 =A0 =A01969-12-31 19:00:00.00000= 0000 -0500 > +++ b/tools/ioemu-remote/intel.c =A0 =A0 =A0 =A02009-06-07 19:04:11.00000= 0000 -0400 > @@ -0,0 +1,494 @@ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "qemu-common.h" > +#include "console.h" > +#include "sysemu.h" > + > +#define INTEL_DEBUG(format, args...) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\ > + =A0 =A0fprintf (stderr, "intel.c:%d:%s " format , __LINE__, __func__, #= # args) > + > +#define TileW =A0 =A0 =A0 =A0 =A0 128 > +#define TileH =A0 =A0 =A0 =A0 =A0 8 > + > +#define REG_DR_DSPASURF =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x7019C > +#define REG_DR_DSPACNTR =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x70180 > +#define REG_DR_DSPASTRIDE =A0 =A0 =A00x70188 > +#define REG_DR_PIPEACONF =A0 =A0 =A0 0x70008 > + > +#define REG_DR_DSPBSURF =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x7119C > +#define REG_DR_DSPBCNTR =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x71180 > +#define REG_DR_DSPBSTRIDE =A0 =A0 =A00x71188 > +#define REG_DR_PIPEBCONF =A0 =A0 =A0 0x71008 > + > +#define REG_DE_PIPEASRC =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A00x6001c > + > +extern int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vga_passthrough; > +uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0guest_framebuffe= r; > + > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0display =3D 0; > + > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mmio_fd =3D -1; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mem_fd =3D -1; > +static uint8_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*intel_mem =3D NULL; > +static uint8_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*intel_mmio =3D NULL; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intel_force_full_u= pdate =3D 0; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intel_have_focus; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IntelPitch =3D 16; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IntelX =3D 1280; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IntelY =3D 1024; > +static DisplayState =A0 =A0 =A0 =A0 =A0 =A0 *lds =3D NULL; > +static uint8_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*old_data =3D NULL; > +static uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 intel_fb_base, intel_mmi= o_base; > +static uint32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 map_s, map_d, map_size; > +static int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0refresh; > + > +static void set_data_mappings(void); > +static void unset_data_mappings(int mapping); > +static void set_data_pointer(void); > +static void intel_resize(DisplayState *ds); > + > +static inline unsigned int intel_get_reg(unsigned int reg) > +{ > + =A0 =A0return *(unsigned int*)(intel_mmio + reg); > +} > + > +static inline int is_linear(void) > +{ > + =A0 =A0unsigned int *dspacntr =3D (unsigned int *)(intel_mmio + REG_DR_= DSPACNTR); > + =A0 =A0if (((*dspacntr) & (1 << 10)) =3D=3D 0) > + =A0 =A0 =A0 =A0return 1; > + =A0 =A0else > + =A0 =A0 =A0 =A0return 0; > +} > + > +static inline unsigned int intel_get_pitch(void) > +{ > + =A0 =A0unsigned int *dspastride =3D (unsigned int *)(intel_mmio + REG_D= R_DSPASTRIDE); > + =A0 =A0return *dspastride; > +} > + > +static inline unsigned int intel_get_offset(DisplaySurface *ds, int x, i= nt y) > +{ > + =A0 =A0return (y * ds->width + x) * 4; > +} > + > +static void intel_update_linear(DisplaySurface *ds, int x, int y, int w,= int h) > +{ > + =A0 =A0int i, bpp =3D ds->pf.depth / 8; > + =A0 =A0unsigned char *s, *d; > + =A0 =A0s =3D ds->data; > + =A0 =A0d =3D (unsigned char *)(intel_mem + intel_get_reg(REG_DR_DSPASUR= F)); > + =A0 =A0s +=3D (ds->linesize * y) + bpp * x; > + =A0 =A0d +=3D (ds->linesize * y) + bpp * x; > + =A0 =A0for (i =3D 0; i < h; i++) { > + =A0 =A0 =A0 =A0memcpy(d, s, w * bpp); > + =A0 =A0 =A0 =A0s +=3D ds->linesize; > + =A0 =A0 =A0 =A0d +=3D ds->linesize; > + =A0 =A0} > +} > + > +static void intel_force_linear(int linesize) > +{ > + =A0 =A0unsigned int *dspacntr =3D (unsigned int *)(intel_mmio + REG_DR_= DSPACNTR); > + =A0 =A0unsigned int *pipeaconf =3D (unsigned int *)(intel_mmio + REG_DR= _PIPEACONF); > + =A0 =A0unsigned int *dspasurf =3D (unsigned int *)(intel_mmio + REG_DR_= DSPASURF); > + =A0 =A0unsigned int *dspastride =3D (unsigned int *)(intel_mmio + REG_D= R_DSPASTRIDE); > + > + =A0 =A0unsigned int *dspbcntr =3D (unsigned int *)(intel_mmio + REG_DR_= DSPBCNTR); > + =A0 =A0unsigned int *pipebconf =3D (unsigned int *)(intel_mmio + REG_DR= _PIPEBCONF); > + =A0 =A0unsigned int *dspbsurf =3D (unsigned int *)(intel_mmio + REG_DR_= DSPBSURF); > + =A0 =A0unsigned int *dspbstride =3D (unsigned int *)(intel_mmio + REG_D= R_DSPBSTRIDE); > + > + =A0 =A0unsigned int surfa =3D 0, surfb =3D 0, pipea =3D 0, pipeb =3D 0; > + =A0 =A0char pipebenabled =3D !!(*pipebconf & (1 << 30)); > + > + > + =A0 =A0INTEL_DEBUG("DSPASURF CTRL: 0x%x\n", intel_get_reg(REG_DR_DSPACN= TR)); > + > + =A0 =A0/* Disable surface */ > + =A0 =A0pipea =3D *pipeaconf & (0x3 << 18); > + =A0 =A0*pipeaconf &=3D ~(0x3 << 18); > + =A0 =A0*dspacntr |=3D (1 << 31); > + =A0 =A0/* Address of the surface to map to */ > + =A0 =A0surfa =3D *dspasurf; > + =A0 =A0*dspasurf =3D 0x00000000; > + =A0 =A0*dspacntr &=3D ~(1 << 31); > + =A0 =A0*dspasurf =3D 0x00000000; > + =A0 =A0*pipeaconf |=3D pipea; > + > + =A0 =A0if (pipebenabled) { > + =A0 =A0 =A0 =A0INTEL_DEBUG("PIPEBCONF enabled.\n"); > + > + =A0 =A0 =A0 =A0/* Disable surface */ > + =A0 =A0 =A0 =A0pipeb =3D *pipebconf & (0x3 << 18); > + =A0 =A0 =A0 =A0*pipebconf &=3D ~(0x3 << 18); > + =A0 =A0 =A0 =A0*dspbcntr |=3D (1 << 31); > + =A0 =A0 =A0 =A0/* Address of the surface to map to */ > + =A0 =A0 =A0 =A0surfb =3D *dspbsurf; > + =A0 =A0 =A0 =A0*dspbsurf =3D 0x00000000; > + =A0 =A0 =A0 =A0*dspbcntr &=3D ~(1 << 31); > + =A0 =A0 =A0 =A0*dspbsurf =3D 0x00000000; > + =A0 =A0 =A0 =A0*pipebconf |=3D pipeb; > + =A0 =A0} > + > + =A0 =A0usleep(20000); > + > + =A0 =A0*pipeaconf &=3D ~(0x3 << 18); > + =A0 =A0/* Enable surface linear mode */ > + =A0 =A0*dspacntr &=3D ~(1 << 10); > + =A0 =A0if (linesize) *dspastride =3D linesize; > + =A0 =A0*dspasurf =3D surfa; > + =A0 =A0*dspacntr |=3D (1 << 31); > + =A0 =A0*pipeaconf |=3D pipea; > + > + =A0 =A0if (pipebenabled) { > + =A0 =A0 =A0 =A0*pipebconf &=3D ~(0x3 << 18); > + =A0 =A0 =A0 =A0/* Enable surface linear mode */ > + =A0 =A0 =A0 =A0*dspbcntr &=3D ~(1 << 10); > + =A0 =A0 =A0 =A0if (linesize) *dspbstride =3D linesize; > + =A0 =A0 =A0 =A0*dspbsurf =3D surfb; > + =A0 =A0 =A0 =A0*dspbcntr |=3D (1 << 31); > + =A0 =A0 =A0 =A0*pipebconf |=3D pipeb; > + =A0 =A0} > + > + =A0 =A0usleep(20000); > +} > + > +static void intel_update(DisplayState *ds, int x, int y, int w, int h) > +{ > + =A0 =A0if (intel_have_focus && !old_data && !map_size) > + =A0 =A0 =A0 =A0intel_update_linear(ds->surface, x, y, w, h); > +} > + > +static void set_fb_mapping(void) > +{ > + =A0 =A0DisplaySurface *surf =3D lds->surface; > + =A0 =A0int rc; > + =A0 =A0unsigned long nr_pfn; > + > + =A0 =A0unset_vga_acc(); > + =A0 =A0fprintf(stderr, "set_fb_mapping: %x %x\n", (intel_fb_base + inte= l_get_reg(REG_DR_DSPASURF)), guest_framebuffer); > + =A0 =A0nr_pfn =3D (surf->linesize * surf->height) >> TARGET_PAGE_BITS; > + > + =A0 =A0rc =3D xc_domain_memory_mapping(xc_handle, > + =A0 =A0 =A0 =A0 =A0 =A0domid, > + =A0 =A0 =A0 =A0 =A0 =A0(guest_framebuffer >> TARGET_PAGE_BITS), > + =A0 =A0 =A0 =A0 =A0 =A0((intel_fb_base + intel_get_reg(REG_DR_DSPASURF)= ) >> TARGET_PAGE_BITS), > + =A0 =A0 =A0 =A0 =A0 =A0nr_pfn, > + =A0 =A0 =A0 =A0 =A0 =A0DPCI_ADD_MAPPING); > + =A0 =A0if (rc) { > + =A0 =A0 =A0 =A0fprintf(stderr, "xc_domain_memory_mapping failed %d\n", = rc); > + =A0 =A0 =A0 =A0return; > + =A0 =A0} > + =A0 =A0map_s =3D ((intel_fb_base + intel_get_reg(REG_DR_DSPASURF)) >> T= ARGET_PAGE_BITS); > + =A0 =A0map_d =3D (guest_framebuffer >> TARGET_PAGE_BITS); > + =A0 =A0map_size =3D nr_pfn; > +} > + > +static void unset_fb_mapping(void) > +{ > + =A0 =A0int rc; > + > + =A0 =A0fprintf(stderr, "unset_fb_mapping: %x %x\n", map_d, map_s); > + > + =A0 =A0rc =3D xc_domain_memory_mapping(xc_handle, > + =A0 =A0 =A0 =A0 =A0 =A0domid, > + =A0 =A0 =A0 =A0 =A0 =A0map_d, > + =A0 =A0 =A0 =A0 =A0 =A0map_s, > + =A0 =A0 =A0 =A0 =A0 =A0map_size, > + =A0 =A0 =A0 =A0 =A0 =A0DPCI_REMOVE_MAPPING); > + =A0 =A0if (rc) { > + =A0 =A0 =A0 =A0fprintf(stderr, "xc_domain_memory_mapping failed %d\n", = rc); > + =A0 =A0 =A0 =A0return; > + =A0 =A0} > + > + =A0 =A0set_vga_acc(); > + =A0 =A0map_s =3D 0; > + =A0 =A0map_d =3D 0; > + =A0 =A0map_size =3D 0; > +} > + > +static void intel_setdata(DisplayState *ds) > +{ > + =A0 =A0if (map_size) > + =A0 =A0 =A0 =A0unset_fb_mapping(); > + =A0 =A0set_fb_mapping(); > +} > + > +static void intel_resize_shared(DisplayState *ds, int w, int h, int dept= h, int linesize, void *pixels) > +{ > + =A0 =A0DisplaySurface *surf =3D ds->surface; > + > + =A0 =A0if (!intel_have_focus) { > + =A0 =A0 =A0 =A0surf->width =3D w; > + =A0 =A0 =A0 =A0surf->height =3D h; > + =A0 =A0 =A0 =A0intel_resize(ds); > + =A0 =A0 =A0 =A0return; > + =A0 =A0} > + =A0 =A0if (depth =3D=3D 32 && w =3D=3D IntelX && h =3D=3D IntelY) > + =A0 =A0 =A0 =A0surf->flags =3D QEMU_ALLOCATED_FLAG; > + =A0 =A0else > + =A0 =A0 =A0 =A0surf->flags &=3D ~QEMU_ALLOCATED_FLAG; > + =A0 =A0if (surf->flags & QEMU_ALLOCATED_FLAG) { > + =A0 =A0 =A0 =A0surf->width =3D w; > + =A0 =A0 =A0 =A0surf->height =3D h; > + =A0 =A0 =A0 =A0surf->pf.depth =3D 32; > + =A0 =A0 =A0 =A0surf->linesize =3D linesize; > + =A0 =A0 =A0 =A0/* adjust linesize */ > + =A0 =A0 =A0 =A0intel_force_linear(linesize); > + =A0 =A0 =A0 =A0set_data_mappings(); > + =A0 =A0 =A0 =A0if (refresh) { > + =A0 =A0 =A0 =A0 =A0 =A0memcpy(surf->data, pixels, surf->linesize * surf= ->height); > + =A0 =A0 =A0 =A0 =A0 =A0refresh =3D 0; > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0surf->data =3D pixels; > + =A0 =A0 =A0 =A0intel_setdata(ds); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0surf->width =3D w; > + =A0 =A0 =A0 =A0surf->height =3D h; > + =A0 =A0 =A0 =A0intel_resize(ds); > + =A0 =A0} > +} > + > +static void intel_resize(DisplayState *ds) > +{ > + =A0 =A0DisplaySurface *surf =3D ds->surface; > + =A0 =A0int old_linesize =3D surf->linesize; > + > + =A0 =A0if (surf->pf.depth =3D=3D 32 && surf->width =3D=3D IntelX && sur= f->height =3D=3D IntelY) > + =A0 =A0 =A0surf->flags =3D QEMU_ALLOCATED_FLAG; > + =A0 =A0else > + =A0 =A0 =A0surf->flags &=3D ~QEMU_ALLOCATED_FLAG; > + > + =A0 =A0if (is_buffer_shared(surf)) > + =A0 =A0{ > + =A0 =A0 =A0INTEL_DEBUG("intel_resize_shared: enable shared buffer, line= size %d\n", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->linesize); > + =A0 =A0 =A0intel_force_linear(surf->linesize); > + =A0 =A0 =A0set_data_mappings(); > + =A0 =A0 =A0if (refresh) > + =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0// Pixels doesn't exist anymore ?? > + =A0 =A0 =A0 =A0//memcpy(surf->data, pixels, surf->linesize * surf->heig= ht); > + =A0 =A0 =A0 =A0refresh =3D 0; > + =A0 =A0 =A0} > + =A0 =A0 =A0intel_setdata(ds); > + =A0 =A0 =A0return; > + =A0 =A0} > + > + =A0 =A0INTEL_DEBUG("intel_resize: no shared buffer, linesize=3D%d\n", s= urf->linesize); > + =A0 =A0surf->linesize =3D intel_get_pitch(); > + =A0 =A0if (map_size) { > + =A0 =A0 =A0 =A0unset_fb_mapping(); > + =A0 =A0 =A0 =A0unset_data_mappings(1); > + =A0 =A0} > + =A0 =A0if (intel_have_focus && !is_linear()) { > + =A0 =A0 =A0 =A0intel_force_linear(0); > + =A0 =A0} > + =A0 =A0surf->flags &=3D ~QEMU_ALLOCATED_FLAG; > + =A0 =A0if (intel_have_focus && !old_data && > + =A0 =A0 =A0 =A0surf->width * surf->height <=3D IntelX * IntelY) > + =A0 =A0 =A0 =A0set_data_mappings(); > + =A0 =A0else if (intel_have_focus && old_data && > + =A0 =A0 =A0 =A0 =A0 =A0 surf->width * surf->height > IntelX * IntelY) > + =A0 =A0 =A0 =A0unset_data_mappings(0); > + =A0 =A0if (!old_data) { > + =A0 =A0 =A0 =A0qemu_free(surf->data); > + =A0 =A0 =A0 =A0surf->data =3D qemu_mallocz(surf->height * surf->linesiz= e); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0INTEL_DEBUG("intel_resize: set_data_pointer\n"); > + =A0 =A0 =A0 =A0set_data_pointer(); > + =A0 =A0} > + =A0 =A0if (intel_have_focus) > + =A0 =A0 =A0 =A0memset((unsigned char *)(intel_mem + intel_get_reg(REG_D= R_DSPASURF)), 0x0, IntelX * IntelY); > + =A0 =A0if (refresh) { > + =A0 =A0 =A0 =A0if (old_data) { > + =A0 =A0 =A0 =A0 =A0 =A0unsigned char *s, *d; > + =A0 =A0 =A0 =A0 =A0 =A0int i; > + =A0 =A0 =A0 =A0 =A0 =A0s =3D old_data; > + =A0 =A0 =A0 =A0 =A0 =A0d =3D surf->data; > + =A0 =A0 =A0 =A0 =A0 =A0for (i =3D 0; i < surf->height; i++) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0memcpy(d, s, surf->width * 4); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s +=3D old_linesize; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0d +=3D surf->linesize; > + =A0 =A0 =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0refresh =3D 0; > + =A0 =A0} > +} > + > +static void intel_refresh(DisplayState *ds) > +{ > + =A0 =A0vga_hw_update(); > +} > + > +static void intel_init_mapping(void) > +{ > + =A0 =A0struct pci_access =A0 *pci_bus; > + =A0 =A0struct pci_dev =A0 =A0 =A0*pci_dev; > + > + =A0 =A0mmio_fd =3D open("/dev/mem", O_RDWR); > + =A0 =A0if (mmio_fd =3D=3D -1) > + =A0 =A0{ > + =A0 =A0 =A0 =A0perror("open"); > + =A0 =A0 =A0 =A0exit(1); > + =A0 =A0} > + =A0 =A0mem_fd =3D open("/dev/mem", O_RDWR); > + =A0 =A0if (mem_fd =3D=3D -1) > + =A0 =A0{ > + =A0 =A0 =A0 =A0perror("open"); > + =A0 =A0 =A0 =A0exit(1); > + =A0 =A0} > + > + =A0 =A0pci_bus =3D pci_alloc(); > + =A0 =A0pci_init(pci_bus); > + =A0 =A0pci_dev =3D pci_get_dev(pci_bus, 0, 0, 2, 0); > + =A0 =A0pci_fill_info(pci_dev, PCI_FILL_BASES); > + =A0 =A0intel_fb_base =3D pci_dev->base_addr[2] & 0xfffff000; > + =A0 =A0intel_mmio_base =3D pci_dev->base_addr[0] & 0xfffff000; > + =A0 =A0pci_free_dev(pci_dev); > + =A0 =A0pci_cleanup(pci_bus); > + > + =A0 =A0INTEL_DEBUG("Map intel main mem 0x%x\n", intel_fb_base); > + =A0 =A0intel_mem =3D mmap(NULL, 0x10000000, PROT_READ | PROT_WRITE, MAP= _SHARED, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mem_fd, intel_fb_base); > + =A0 =A0if (intel_mem =3D=3D MAP_FAILED) > + =A0 =A0{ > + =A0 =A0 =A0 =A0perror("mmap"); > + =A0 =A0 =A0 =A0exit(1); > + =A0 =A0} > + > + =A0 =A0INTEL_DEBUG("Map intel mmio 0x%x\n", intel_mmio_base); > + =A0 =A0intel_mmio =3D mmap(NULL, 4 * 1024 * 1024, PROT_READ | PROT_WRIT= E, MAP_SHARED, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mmio_fd, intel_mmio_base); > + =A0 =A0if (intel_mem =3D=3D MAP_FAILED) > + =A0 =A0{ > + =A0 =A0 =A0 =A0perror("mmap"); > + =A0 =A0 =A0 =A0exit(1); > + =A0 =A0} > +} > + > +static void set_data_pointer(void) > +{ > + =A0 =A0DisplaySurface *surf =3D lds->surface; > + > + =A0 =A0surf->data =3D (unsigned char *)(intel_mem + intel_get_reg(REG_D= R_DSPASURF)); > + =A0 =A0surf->data =3D surf->data + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->linesize * ((IntelY - surf->height= ) / 2) + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A04 * ((IntelX - surf->width) / 2); > +} > + > +static void set_data_mappings(void) > +{ > + =A0 =A0INTEL_DEBUG("set_data_mappings\n"); > + =A0 =A0if (!old_data) > + =A0 =A0 =A0 =A0old_data =3D lds->surface->data; > + =A0 =A0set_data_pointer(); > +} > + > +static void unset_data_mappings(int mapping) > +{ > + =A0 =A0DisplaySurface *surf =3D lds->surface; > + =A0 =A0if (!old_data) > + =A0 =A0 =A0 =A0return; > + =A0 =A0if (mapping) { > + =A0 =A0 =A0 =A0uint8_t * buffer_pointer =3D surf->data; > + =A0 =A0 =A0 =A0surf->data =3D old_data; > + =A0 =A0 =A0 =A0old_data =3D NULL; > + =A0 =A0 =A0 =A0surf->data =3D realloc(surf->data, surf->linesize * surf= ->height); > + =A0 =A0 =A0 =A0memcpy(surf->data, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(unsigned char *)(intel_mem + intel_get_= reg(REG_DR_DSPASURF)), > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->linesize * surf->height); > + =A0 =A0 =A0 =A0memcpy(buffer_pointer, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->data, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->linesize * surf->height); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0uint8_t * buffer_pointer =3D surf->data; > + =A0 =A0 =A0 =A0surf->data =3D old_data; > + =A0 =A0 =A0 =A0old_data =3D NULL; > + =A0 =A0 =A0 =A0surf->data =3D realloc(surf->data, surf->linesize * surf= ->height); > + =A0 =A0 =A0 =A0memcpy(surf->data, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0buffer_pointer, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0surf->linesize * surf->height); > + =A0 =A0} > + =A0 =A0INTEL_DEBUG("unset_data_mappings %d: success\n", mapping); > +} > + > +static int intel_getfocus(void) > +{ > + =A0 =A0return intel_have_focus; > +} > + > +static void intel_focus(int focus) > +{ > + =A0 =A0if (intel_have_focus =3D=3D focus) > + =A0 =A0 =A0 =A0return; > + > + =A0 =A0INTEL_DEBUG("intel_focus %d\n", focus); > + =A0 =A0intel_have_focus =3D focus; > + =A0 =A0if (focus) { > + =A0 =A0 =A0 =A0if (!is_linear()) { > + =A0 =A0 =A0 =A0 =A0 IntelPitch =3D intel_get_reg(REG_DR_DSPASTRIDE); > + =A0 =A0 =A0 =A0 =A0 IntelX =3D ((intel_get_reg(REG_DE_PIPEASRC) >> 16) = & 0xfff) + 1; > + =A0 =A0 =A0 =A0 =A0 IntelY =3D (intel_get_reg(REG_DE_PIPEASRC) & 0xfff)= + 1; > + =A0 =A0 =A0 =A0 =A0 INTEL_DEBUG("Resolution is %dx%d\n", IntelX, IntelY= ); > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0refresh =3D 1; > + =A0 =A0 =A0 =A0lds->listeners->dpy_resize =3D intel_resize; > + =A0 =A0 =A0 =A0lds->listeners->dpy_setdata =3D intel_setdata; > + =A0 =A0 =A0 =A0vga_hw_invalidate(); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0if (map_size) { > + =A0 =A0 =A0 =A0 =A0 =A0unset_fb_mapping(); > + =A0 =A0 =A0 =A0 =A0 =A0unset_data_mappings(1); > + =A0 =A0 =A0 =A0} else if (old_data) { > + =A0 =A0 =A0 =A0 =A0 =A0unset_data_mappings(0); > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0lds->listeners->dpy_resize =3D NULL; > + =A0 =A0 =A0 =A0lds->listeners->dpy_setdata =3D NULL; > + =A0 =A0 =A0 =A0lds->surface->flags &=3D ~QEMU_ALLOCATED_FLAG; > + =A0 =A0} > +} > + > +int intel_enter(void) > +{ > + =A0 =A0intel_focus(1); > + =A0 =A0return 1; > +} > + > +int intel_leave(void) > +{ > + =A0 =A0intel_focus(0); > + =A0 =A0return 1; > +} > + > +void intel_display_init(DisplayState *ds) > +{ > + =A0 =A0DisplaySurface *surf =3D ds->surface; > + > + =A0 =A0INTEL_DEBUG("\n"); > + > + =A0 =A0intel_init_mapping(); > + > + =A0 =A0INTEL_DEBUG("Frambuffer is at 0x%x\n", intel_get_reg(REG_DR_DSPA= SURF)); > + > + =A0 =A0surf->flags =3D 0; > + =A0 =A0surf->width =3D 640; > + =A0 =A0surf->height =3D 480; > + =A0 =A0surf->pf.depth =3D 32; > + =A0 =A0intel_resize(ds); > + =A0 =A0lds =3D ds; > + > + =A0 =A0ds->listeners->dpy_update =3D intel_update; > + =A0 =A0ds->listeners->dpy_resize =3D intel_resize; > + =A0 =A0ds->listeners->dpy_refresh =3D intel_refresh; > +} > \ No newline at end of file > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/vl.c b/= tools/ioemu-remote/vl.c > --- a/tools/ioemu-remote/vl.c =A0 2009-06-07 21:14:47.000000000 -0400 > +++ b/tools/ioemu-remote/vl.c =A0 2009-06-07 19:29:12.000000000 -0400 > @@ -233,6 +233,9 @@ CharDriverState *virtcon_hds[MAX_VIRTIO_ > =A0#ifdef TARGET_I386 > =A0int win2k_install_hack =3D 0; > =A0int rtc_td_hack =3D 0; > +int vga_passthrough =3D 0; > +const char *dom0_input =3D NULL; > +int intel =3D 0; > =A0#endif > =A0int usb_enabled =3D 0; > =A0int smp_cpus =3D 1; > @@ -4039,6 +4042,9 @@ static void help(int exitcode) > =A0 =A0 =A0 =A0 =A0 =A0"-disable-opengl disable OpenGL rendering, using S= DL" > =A0#endif > =A0#endif > + =A0 =A0 =A0 =A0 =A0 "-vga_passthrough enable graphics card passthrough\= n" > + =A0 =A0 =A0 =A0 =A0 "-dom0-input =A0 =A0 enable dom0 controlling qemu\n= " > + =A0 =A0 =A0 =A0 =A0 "-intel =A0 =A0 =A0 =A0 =A0use intel gfx\n" > =A0 =A0 =A0 =A0 =A0 =A0"-portrait =A0 =A0 =A0 rotate graphical output 90 = deg left (only PXA LCD)\n" > =A0 =A0 =A0 =A0 =A0 =A0"-vga [std|cirrus|vmware|none]\n" > =A0 =A0 =A0 =A0 =A0 =A0" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0select video card= type\n" > @@ -4275,6 +4281,9 @@ enum { > =A0 =A0 QEMU_OPTION_domainname, > =A0 =A0 QEMU_OPTION_acpi, > =A0 =A0 QEMU_OPTION_vcpus, > + =A0 =A0QEMU_OPTION_vga_passthrough, > + =A0 =A0QEMU_OPTION_dom0_input, > + =A0 =A0QEMU_OPTION_intel, > > =A0 =A0 /* Debug/Expert options: */ > =A0 =A0 QEMU_OPTION_serial, > @@ -4448,6 +4457,9 @@ static const QEMUOption qemu_options[] =3D > =A0 =A0 { "pciemulation", HAS_ARG, QEMU_OPTION_pci_emulation }, > =A0 =A0 { "vncunused", 0, QEMU_OPTION_vncunused }, > =A0 =A0 { "vcpus", HAS_ARG, QEMU_OPTION_vcpus }, > + =A0 =A0{ "vga_passthrough", 0, QEMU_OPTION_vga_passthrough }, > + =A0 =A0{ "dom0-input", HAS_ARG, QEMU_OPTION_dom0_input }, > + =A0 =A0{ "intel", 0, QEMU_OPTION_intel }, > =A0#if defined(CONFIG_XEN) && !defined(CONFIG_DM) > =A0 =A0 { "xen-domid", HAS_ARG, QEMU_OPTION_xen_domid }, > =A0 =A0 { "xen-create", 0, QEMU_OPTION_xen_create }, > @@ -5281,6 +5293,15 @@ int main(int argc, char **argv, char **e > =A0 =A0 =A0 =A0 =A0 =A0 case QEMU_OPTION_disable_opengl: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 opengl_enabled =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 =A0 =A0case QEMU_OPTION_vga_passthrough: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vga_passthrough =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > + =A0 =A0 =A0 =A0 =A0 =A0case QEMU_OPTION_dom0_input: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dom0_input =3D optarg; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > + =A0 =A0 =A0 =A0 =A0 =A0case QEMU_OPTION_intel: > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0intel =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; > =A0 =A0 =A0 =A0 =A0 =A0 case QEMU_OPTION_direct_pci: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0direct_pci =3D optarg; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; > @@ -5876,6 +5897,14 @@ int main(int argc, char **argv, char **e > =A0 =A0 =A0 =A0 =A0 =A0 fprintf(stderr, "fatal: -nographic can't be used = with -curses\n"); > =A0 =A0 =A0 =A0 =A0 =A0 exit(1); > =A0 =A0 =A0 =A0 } > + > +#ifdef CONFIG_DM > + =A0 =A0 =A0 =A0if(vga_passthrough) > + =A0 =A0 =A0 =A0 =A0 =A0fprintf(stderr, "Replace if initializing dom0_dr= iver\n" ); > +#else > + =A0 =A0 =A0 =A0dumb_display_init(ds); > +#endif > + > =A0 =A0 } else { > =A0#if defined(CONFIG_CURSES) > =A0 =A0 =A0 =A0 =A0 =A0 if (curses) { > diff -rupN --ignore-blank-lines-X diffignore a/tools/ioemu-remote/xen-hoo= ks.mak b/tools/ioemu-remote/xen-hooks.mak > --- a/tools/ioemu-remote/xen-hooks.mak =A02009-06-07 21:14:47.000000000 -= 0400 > +++ b/tools/ioemu-remote/xen-hooks.mak =A02009-06-07 19:04:12.000000000 -= 0400 > @@ -35,6 +35,7 @@ OBJS +=3D exec-dm.o > =A0OBJS +=3D pci_emulation.o > =A0OBJS +=3D helper2.o > =A0OBJS +=3D battery_mgmt.o > +OBJS +=3D intel.o > > =A0ifdef CONFIG_STUBDOM > =A0CPPFLAGS +=3D $(TARGET_CPPFLAGS) -DNEED_CPU_H \ > diff -rupN --ignore-blank-lines-X diffignore a/tools/libxc/xc_hvm_build.c= b/tools/libxc/xc_hvm_build.c > --- a/tools/libxc/xc_hvm_build.c =A0 =A0 =A0 =A02009-06-07 20:44:47.00000= 0000 -0400 > +++ b/tools/libxc/xc_hvm_build.c =A0 =A0 =A0 =A02009-06-07 19:04:12.00000= 0000 -0400 > @@ -1,7 +1,3 @@ > -/***********************************************************************= ******* > - * xc_hvm_build.c > - */ > - > =A0#include > =A0#include > =A0#include > @@ -66,6 +62,82 @@ static void build_hvm_info(void *hvm_inf > =A0 =A0 hvm_info->checksum =3D -sum; > =A0} > > +static int init_vgabios(int =A0 =A0 =A0 =A0 =A0 =A0xc_handle, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uint32_t =A0 =A0 =A0 dom= , > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned char *buffer, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uint32_t =A0 =A0 =A0 bio= s_size) > +{ > + =A0 =A0char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*va_bios =3D NULL; > + =A0 =A0uint32_t =A0 =A0 =A0 =A0 =A0 =A0va_size =3D 0; > + > + =A0 =A0va_size =3D bios_size + bios_size % XC_PAGE_SIZE; > + =A0 =A0va_bios =3D xc_map_foreign_range(xc_handle, dom, va_size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 PRO= T_READ | PROT_WRITE, 0xC0); > + =A0 =A0if (!va_bios) > + =A0 =A0{ > + =A0 =A0 =A0 =A0IPRINTF("Unable to map vga bios!\n"); > + =A0 =A0 =A0 =A0return -1; > + =A0 =A0} > + > + =A0 =A0if ( buffer !=3D NULL) > + =A0 =A0 =A0 =A0memcpy(va_bios, buffer, bios_size); > + =A0 =A0else > + =A0 =A0 =A0 =A0memset(va_bios, 0, bios_size); > + > + =A0 =A0munmap(va_bios, va_size); > + =A0 =A0return 0; > +} > + > +static int =A0setup_vga_pt(int =A0 =A0 =A0 =A0 =A0 =A0xc_handle, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint32_t =A0 =A0 =A0 do= m) > +{ > + =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D 0; > + =A0 =A0unsigned char =A0 =A0 =A0 *bios =3D NULL; > + =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 bios_size =3D 0; > + =A0 =A0char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*c =3D NULL; > + =A0 =A0char =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0checksum =3D 0; > + > + =A0 =A0IPRINTF("Setting up vga passthrough.\n"); > + > + =A0 =A0/* Allocated 64K for the vga bios */ > + =A0 =A0if (!(bios =3D malloc(64 * 1024))) { > + =A0 =A0 =A0 =A0IPRINTF("Error allocating memory for vga bios.\n"); > + =A0 =A0 =A0 =A0return -1; > + =A0 =A0} > + > +#ifdef __linux__ > + =A0 =A0bios_size =3D xc_get_vgabios(bios, 64 * 1024); > +#else > + =A0 =A0bios_size =3D 0; > +#endif /* __linux__ */ > + > + =A0 =A0if (bios_size =3D=3D 0) > + =A0 =A0{ > + =A0 =A0 =A0 =A0IPRINTF("vga bios size is 0!\n"); > + =A0 =A0 =A0 =A0rc =3D -1; > + =A0 =A0 =A0 =A0goto error; > + =A0 =A0} > + > + =A0 =A0/* Adjust the bios checksum */ > + =A0 =A0for ( c =3D (char*)bios; c < ((char*)bios + bios_size); c++ ) > + =A0 =A0 =A0 =A0checksum +=3D *c; > + =A0 =A0if (checksum) > + =A0 =A0 =A0 =A0bios[bios_size - 1] -=3D checksum; > + =A0 =A0init_vgabios(xc_handle, dom, bios, bios_size); > + > +error: > + =A0 =A0free(bios); > + > + =A0 =A0if( rc =3D=3D -1 ) { > + =A0 =A0 =A0 =A0IPRINTF("Error setting up vga passthrough.\n"); > + =A0 =A0} > + =A0 =A0else { > + =A0 =A0 =A0 =A0IPRINTF("Success setting up vga passthrough.\n"); > + =A0 =A0} > + > + =A0 =A0return rc; > +} > + > =A0static int loadelfimage( > =A0 =A0 struct elf_binary *elf, int xch, uint32_t dom, unsigned long *par= ray) > =A0{ > @@ -381,7 +453,8 @@ int xc_hvm_build_target_mem(int xc_handl > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uint32_t domid, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int memsize, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int target, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *image_n= ame) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 const char *image_n= ame, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int vga_pt_enabled) > =A0{ > =A0 =A0 char *image; > =A0 =A0 int =A0sts; > @@ -392,6 +465,12 @@ int xc_hvm_build_target_mem(int xc_handl > =A0 =A0 =A0 =A0 return -1; > > =A0 =A0 sts =3D xc_hvm_build_internal(xc_handle, domid, memsize, target, = image, image_size); > + =A0 =A0if ( vga_pt_enabled ) { > + =A0 =A0 =A0 =A0sts |=3D setup_vga_pt(xc_handle, domid); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0sts |=3D init_vgabios(xc_handle, domid, NULL, 0x800); > + =A0 =A0} > + > > =A0 =A0 free(image); > > diff -rupN --ignore-blank-lines-X diffignore a/tools/libxc/xc_linux.c b/t= ools/libxc/xc_linux.c > --- a/tools/libxc/xc_linux.c =A0 =A02009-06-07 20:44:47.000000000 -0400 > +++ b/tools/libxc/xc_linux.c =A0 =A02009-06-07 19:04:12.000000000 -0400 > @@ -562,6 +562,57 @@ int xc_gnttab_set_max_grants(int xcg_han > =A0 =A0 return 0; > =A0} > > +int xc_get_vgabios(unsigned char =A0 =A0 =A0 =A0*buf, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0len) > +{ > + =A0 =A0int =A0 =A0 =A0 =A0 mem; > + =A0 =A0uint32_t =A0 =A0start, size =3D 0; > + =A0 =A0uint16_t =A0 =A0magic =3D 0; > + > + =A0 =A0start =3D 0xC0000; > + =A0 =A0if (len < size) > + =A0 =A0 =A0 =A0return 0; > + =A0 =A0if ((mem =3D open("/dev/mem", O_RDONLY)) < 0) > + =A0 =A0 =A0 =A0return 0; > + > + =A0 =A0/* > + =A0 =A0** Check if it a real bios extension. > + =A0 =A0** The magic number is 0xAA55. > + =A0 =A0*/ > + =A0 =A0if (start !=3D lseek(mem, start, SEEK_SET)) > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0if (read(mem, &magic, 2) !=3D 2) > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0if (magic !=3D 0xAA55) > + =A0 =A0 =A0 =A0goto out; > + > + =A0 =A0/* Find the size of the rom extension */ > + =A0 =A0if (start !=3D lseek(mem, start, SEEK_SET)) > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0if (lseek(mem, 2, SEEK_CUR) !=3D (start + 2)) > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0if (read(mem, &size, 1) !=3D 1) > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0/* This size is in 512K */ > + =A0 =A0size *=3D 512; > + > + =A0 =A0/* > + =A0 =A0** Set the file to the begining of the rombios, > + =A0 =A0** to start the copy. > + =A0 =A0*/ > + =A0 =A0if (start !=3D lseek(mem, start, SEEK_SET)) > + =A0 =A0{ > + =A0 =A0 =A0 =A0size =3D 0; > + =A0 =A0 =A0 =A0goto out; > + =A0 =A0} > + =A0 =A0if (size !=3D read(mem, buf, size)) > + =A0 =A0 =A0 =A0size =3D 0; > + > +out: > + =A0 =A0close(mem); > + =A0 =A0return size; > +} > + > =A0/* > =A0* Local variables: > =A0* mode: C > diff -rupN --ignore-blank-lines-X diffignore a/tools/libxc/xenctrl.h b/to= ols/libxc/xenctrl.h > --- a/tools/libxc/xenctrl.h =A0 =A0 2009-06-07 20:44:47.000000000 -0400 > +++ b/tools/libxc/xenctrl.h =A0 =A0 2009-06-07 19:04:12.000000000 -0400 > @@ -145,6 +145,10 @@ int xc_waitdomain( > =A0 =A0 int *status, > =A0 =A0 int options); > > +int xc_get_vgabios( > + =A0 =A0unsigned char =A0 =A0 =A0 *bios, > + =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 len); > + > =A0#endif /* __linux__ */ > > =A0/* > diff -rupN --ignore-blank-lines-X diffignore a/tools/libxc/xenguest.h b/t= ools/libxc/xenguest.h > --- a/tools/libxc/xenguest.h =A0 =A02009-06-07 20:44:47.000000000 -0400 > +++ b/tools/libxc/xenguest.h =A0 =A02009-06-07 19:04:12.000000000 -0400 > @@ -134,7 +134,8 @@ int xc_hvm_build_target_mem(int xc_handl > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uint32_t domid, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int memsize, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int target, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *imag= e_name); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0const char *imag= e_name, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int vga_pt_enabl= ed); > > =A0int xc_hvm_build_mem(int xc_handle, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uint32_t domid, > diff -rupN --ignore-blank-lines-X diffignore a/tools/python/xen/lowlevel/= xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c > --- a/tools/python/xen/lowlevel/xc/xc.c 2009-06-07 20:44:47.000000000 -04= 00 > +++ b/tools/python/xen/lowlevel/xc/xc.c 2009-06-07 19:04:12.000000000 -04= 00 > @@ -890,21 +890,21 @@ static PyObject *pyxc_hvm_build(XcObject > =A0 =A0 int i; > =A0#endif > =A0 =A0 char *image; > - =A0 =A0int memsize, target=3D-1, vcpus =3D 1, acpi =3D 0, apic =3D 1; > + =A0 =A0int memsize, target=3D-1, vcpus =3D 1, acpi =3D 0, apic =3D 1, v= ga_pt =3D 0; > > =A0 =A0 static char *kwd_list[] =3D { "domid", > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "memsize"= , "image", "target", "vcpus", "acpi", > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"apic", = NULL }; > - =A0 =A0if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_li= st, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"apic", = "vga_pt", NULL }; > + =A0 =A0if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiiii", kwd_l= ist, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 &dom, &memsize, &image, &target, &vcpus, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0&acpi, &apic) ) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0&acpi, &apic, &vga_pt) ) > =A0 =A0 =A0 =A0 return NULL; > > =A0 =A0 if ( target =3D=3D -1 ) > =A0 =A0 =A0 =A0 target =3D memsize; > > =A0 =A0 if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 target,= image) !=3D 0 ) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 target,= image, vga_pt) !=3D 0 ) > =A0 =A0 =A0 =A0 return pyxc_error_to_exception(); > > =A0#if !defined(__ia64__) > diff -rupN --ignore-blank-lines-X diffignore a/tools/python/xen/xend/imag= e.py b/tools/python/xen/xend/image.py > --- a/tools/python/xen/xend/image.py =A0 =A02009-06-07 20:44:47.000000000= -0400 > +++ b/tools/python/xen/xend/image.py =A0 =A02009-06-07 19:04:12.000000000= -0400 > @@ -279,6 +279,9 @@ class ImageHandler: > =A0 =A0 =A0 =A0 vnc_config =3D {} > =A0 =A0 =A0 =A0 has_vnc =3D int(vmConfig['platform'].get('vnc', 0)) !=3D = 0 > =A0 =A0 =A0 =A0 has_sdl =3D int(vmConfig['platform'].get('sdl', 0)) !=3D = 0 > + =A0 =A0 =A0 =A0has_vga_passthrough =3D int(vmConfig['platform'].get('vg= a_passthrough', 0)) !=3D 0 > + =A0 =A0 =A0 =A0has_intel =3D int(vmConfig['platform'].get('intel', 0)) = !=3D 0 > + > =A0 =A0 =A0 =A0 opengl =3D 1 > =A0 =A0 =A0 =A0 keymap =3D vmConfig['platform'].get("keymap") > =A0 =A0 =A0 =A0 for dev_uuid in vmConfig['console_refs']: > @@ -302,7 +305,7 @@ class ImageHandler: > =A0 =A0 =A0 =A0 =A0 =A0 ret.append("-k") > =A0 =A0 =A0 =A0 =A0 =A0 ret.append(keymap) > > - =A0 =A0 =A0 =A0if has_vnc: > + =A0 =A0 =A0 =A0if has_vnc and not has_vga_passthrough: > =A0 =A0 =A0 =A0 =A0 =A0 if not vnc_config: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 for key in ('vncunused', 'vnclisten', 'vn= cdisplay', > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'vncpasswd'): > @@ -353,6 +356,15 @@ class ImageHandler: > > =A0 =A0 =A0 =A0 if int(vmConfig['platform'].get('monitor', 0)) !=3D 0: > =A0 =A0 =A0 =A0 =A0 =A0 ret =3D ret + ['-monitor', 'vc'] > + > + =A0 =A0 =A0 =A0if has_vga_passthrough: > + =A0 =A0 =A0 =A0 =A0 =A0ret.append('-vga_passthrough') > + =A0 =A0 =A0 =A0 =A0 =A0dom0_input =3D str(vmConfig['platform'].get('dom= 0_input')) > + =A0 =A0 =A0 =A0 =A0 =A0ret =3D ret + ['-dom0-input', dom0_input] > + > + =A0 =A0 =A0 =A0if has_intel: > + =A0 =A0 =A0 =A0 =A0 =A0ret.append('-intel') > + > =A0 =A0 =A0 =A0 return ret > > =A0 =A0 def getDeviceModelArgs(self, restore =3D False): > @@ -754,7 +766,9 @@ class HVMImageHandler(ImageHandler): > =A0 =A0 =A0 =A0 self.apic =3D int(vmConfig['platform'].get('apic', 0)) > =A0 =A0 =A0 =A0 self.acpi =3D int(vmConfig['platform'].get('acpi', 0)) > =A0 =A0 =A0 =A0 self.guest_os_type =3D vmConfig['platform'].get('guest_os= _type') > - > + =A0 =A0 =A0 =A0self.vga_pt =3D int(vmConfig['platform'].get('vga_passth= rough', 0)) > + =A0 =A0 =A0 =A0self.dom0_input =3D str(vmConfig['platform'].get('dom0_i= nput')) > + =A0 =A0 =A0 =A0self.intel =3D int(vmConfig['platform'].get('intel', 0)) > > =A0 =A0 # Return a list of cmd line args to the device models based on th= e > =A0 =A0 # xm config file > @@ -869,6 +883,7 @@ class HVMImageHandler(ImageHandler): > =A0 =A0 =A0 =A0 log.debug("vcpus =A0 =A0 =A0 =A0 =A0=3D %d", self.vm.getV= CpuCount()) > =A0 =A0 =A0 =A0 log.debug("acpi =A0 =A0 =A0 =A0 =A0 =3D %d", self.acpi) > =A0 =A0 =A0 =A0 log.debug("apic =A0 =A0 =A0 =A0 =A0 =3D %d", self.apic) > + =A0 =A0 =A0 =A0log.debug("vga_pt =A0 =A0 =A0 =A0 =3D %d", self.vga_pt) > > =A0 =A0 =A0 =A0 rc =3D xc.hvm_build(domid =A0 =A0 =A0 =A0 =A0=3D self.vm.= getDomid(), > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 image =A0 =A0 =A0 =A0= =A0=3D self.loader, > @@ -876,7 +891,8 @@ class HVMImageHandler(ImageHandler): > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 target =A0 =A0 =A0 = =A0 =3D mem_mb, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 vcpus =A0 =A0 =A0 =A0= =A0=3D self.vm.getVCpuCount(), > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 acpi =A0 =A0 =A0 =A0 = =A0 =3D self.acpi, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0apic =A0 =A0 =A0 =A0= =A0 =3D self.apic) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0apic =A0 =A0 =A0 =A0= =A0 =3D self.apic, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vga_pt =A0 =A0 =A0 = =A0 =3D self.vga_pt) > =A0 =A0 =A0 =A0 rc['notes'] =3D { 'SUSPEND_CANCEL': 1 } > > =A0 =A0 =A0 =A0 rc['store_mfn'] =3D xc.hvm_get_param(self.vm.getDomid(), > diff -rupN --ignore-blank-lines-X diffignore a/tools/python/xen/xend/Xend= Config.py b/tools/python/xen/xend/XendConfig.py > --- a/tools/python/xen/xend/XendConfig.py =A0 =A0 =A0 2009-06-07 20:44:47= .000000000 -0400 > +++ b/tools/python/xen/xend/XendConfig.py =A0 =A0 =A0 2009-06-07 19:04:12= .000000000 -0400 > @@ -171,6 +171,9 @@ XENAPI_PLATFORM_CFG_TYPES =3D { > =A0 =A0 'pci_msitranslate': int, > =A0 =A0 'pci_power_mgmt': int, > =A0 =A0 'xen_platform_pci': int, > + =A0 =A0'vga_passthrough': int, > + =A0 =A0'dom0_input': str, > + =A0 =A0'intel': int, > =A0} > > =A0# Xen API console 'other_config' keys. > diff -rupN --ignore-blank-lines-X diffignore a/tools/python/xen/xm/create= .py b/tools/python/xen/xm/create.py > --- a/tools/python/xen/xm/create.py =A0 =A0 2009-06-07 20:44:47.000000000= -0400 > +++ b/tools/python/xen/xm/create.py =A0 =A0 2009-06-07 19:04:12.000000000= -0400 > @@ -618,6 +618,18 @@ gopts.var('xen_platform_pci', val=3D'0|1', > =A0 =A0 =A0 =A0 =A0 =A0fn=3Dset_int, default=3D1, > =A0 =A0 =A0 =A0 =A0 =A0use=3D"Is xen_platform_pci used?") > > +gopts.var('vga_passthrough', val=3D'0|1', > + =A0 =A0 =A0 =A0 =A0 fn=3Dset_int, default=3DNone, > + =A0 =A0 =A0 =A0 =A0 use=3D"Enable the passthrough for the graphic card.= ") > + > +gopts.var('dom0_input', val=3D'DOM0_INPUT', > + =A0 =A0 =A0 =A0 =A0 fn=3Dset_value, default=3DNone, > + =A0 =A0 =A0 =A0 =A0 use=3D"Input arguments for dom0 driver") > + > +gopts.var('intel', val=3D'INTEL', > + =A0 =A0 =A0 =A0 =A0 fn=3Dset_int, default=3DNone, > + =A0 =A0 =A0 =A0 =A0 use=3D"Use Intel GFX.") > + > =A0def err(msg): > =A0 =A0 """Print an error to stderr and exit. > =A0 =A0 """ > @@ -932,7 +944,8 @@ def configure_hvm(config_image, vals): > =A0 =A0 =A0 =A0 =A0 =A0 =A0'acpi', 'apic', 'usb', 'usbdevice', 'keymap', = 'pci', 'hpet', > =A0 =A0 =A0 =A0 =A0 =A0 =A0'guest_os_type', 'hap', 'opengl', 'cpuid', 'cp= uid_check', > =A0 =A0 =A0 =A0 =A0 =A0 =A0'viridian', 'xen_extended_power_mgmt', 'pci_ms= itranslate', > - =A0 =A0 =A0 =A0 =A0 =A0 'vpt_align', 'pci_power_mgmt', 'xen_platform_pc= i' ] > + =A0 =A0 =A0 =A0 =A0 =A0 'vpt_align', 'pci_power_mgmt', 'xen_platform_pc= i', > + =A0 =A0 =A0 =A0 =A0 =A0 'vga_passthrough', 'dom0_input', 'intel' ] > > =A0 =A0 for a in args: > =A0 =A0 =A0 =A0 if a in vals.__dict__ and vals.__dict__[a] is not None: > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > > Where did this patch come from? I plan to try using a ati card with a windows domU this week but first I need to port this patch to 2.6.29, before I start I want to make sure I am working with the latest version of the patch. Andy