From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: Re: APIC rework Date: Thu, 3 Dec 2009 09:38:14 -0500 Message-ID: <20091203143814.GA14973@phenom.dumpdata.com> References: <706158FABBBA044BAD4FE898A02E4BC201CD3A074E@pdsmsx503.ccr.corp.intel.com> <20091124194401.GA29566@phenom.dumpdata.com> <706158FABBBA044BAD4FE898A02E4BC201CD3A08EB@pdsmsx503.ccr.corp.intel.com> <20091125134144.GA2586@phenom.dumpdata.com> <706158FABBBA044BAD4FE898A02E4BC201CD419316@pdsmsx503.ccr.corp.intel.com> <20091125180031.GA5531@phenom.dumpdata.com> <706158FABBBA044BAD4FE898A02E4BC201CD419656@pdsmsx503.ccr.corp.intel.com> <20091130143419.GB19527@phenom.dumpdata.com> <706158FABBBA044BAD4FE898A02E4BC201CF56AAA9@pdsmsx503.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <706158FABBBA044BAD4FE898A02E4BC201CF56AAA9@pdsmsx503.ccr.corp.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Zhang, Xiantao" Cc: Jeremy Fitzhardinge , Xen-devel , "Jiang, Yunhong" , "Han, Weidong" , "Keir@acsinet11.oracle.com" , Fraser List-Id: xen-devel@lists.xenproject.org > I am also confusing about how to assign a device to a PV guest. Originally I thought the logic should be it should be hidden first through pciback in dom0, and pv guest uses its pci subsystem (pcifront end) to require pciback to mapping this device. In the first step, once pciback.hide logic is called in dom0, this device should be released by dom0 and avaliable for PV guests at this time. And the in subsequent step, pciback or dom0's pci system should help PV guests to do the irq mapping, otherwise I can't see how the irqs from the assigned device are delivered to PV guests. That is correct. Here is an URL of the correct steps: http://wiki.xensource.com/xenwiki/Assign_hardware_to_DomU_with_PCIBack_as_module >>From the unprivileged side (domU), when it makes a call to pci_enable_device, it gets routed to pcifront_bus_write. On the privileged side (dom0), pciback picks up the write and routes it to 'command_write' (conf_space_header.c). It does the pci_enable_device in the dom0 side. The pci_enable_device ends up calling xen_allocate_pirq which gets the IRQ from PHYSDEVOP_alloc_irq_vector. That IRQ is saved in dev->irq and is visible to the DomU. Also during the pci_enable_device (in the DomU side), pcibios_enable_device gets called - which in domU is called 'xen_pcifront_enable_irq'. The xen_pcifront_enable_irq allocates an irq_desc with xen_pirq_chip structure. The GSI it requests is actually the IRQ number from dev->irq. To summarize, dom0 on behalf of domU, calls PHYSDEVOP_alloc_irq_vector for the device in question. Saves the GSI in dev->irq which is visible to the DomU. DomU sets up a xen_pirq_chip structure for the device and starts/stop/etc through that function structure. Please note that there is nothing in PHYSDEVOP_alloc.. about which domain owns the device. That is only done with PHYSDEVOP_map_pirq calls. With your patch instead of PHYSDEVOP_alloc_irq_vector, it would be PHYSDEVOP_map_pirq.