From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: qemu/hw/device-assignment: questions about msix_table_page Date: Tue, 5 May 2009 15:46:04 +0300 Message-ID: <20090505124604.GG15418@redhat.com> References: <20090427104117.GB29082@redhat.com> <200904272203.59909.sheng@linux.intel.com> <20090427141504.GC2504@redhat.com> <200904272230.18253.sheng@linux.intel.com> <20090505095136.GA12797@redhat.com> <20090505101945.GA11426@amt.cnet> <20090505103450.GB15418@redhat.com> <20090505104910.GA4038@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sheng Yang , Avi Kivity , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx2.redhat.com ([66.187.237.31]:57378 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbZEEMrE (ORCPT ); Tue, 5 May 2009 08:47:04 -0400 Content-Disposition: inline In-Reply-To: <20090505104910.GA4038@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, May 05, 2009 at 07:49:10AM -0300, Marcelo Tosatti wrote: > On Tue, May 05, 2009 at 01:34:50PM +0300, Michael S. Tsirkin wrote: > > On Tue, May 05, 2009 at 07:19:45AM -0300, Marcelo Tosatti wrote: > > > On Tue, May 05, 2009 at 12:51:36PM +0300, Michael S. Tsirkin wrote: > > > > On Mon, Apr 27, 2009 at 10:30:17PM +0800, Sheng Yang wrote: > > > > > > > > > If guest can write to the real device MSI-X table directly, it would > > > > > > > > > cause chaos on interrupt delivery, for what guest see is totally > > > > > > > > > different with what's host see... > > > > > > > > > > > > > > > > Obviously. > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > What's the reason that this page is unmapped from the qemu memory space? > > > > Specifically what do these lines do: > > > > int offset = r_dev->msix_table_addr - real_region->base_addr; > > > > ret = munmap(region->u.r_virtbase + offset, TARGET_PAGE_SIZE); > > > > > > I believe this allows accesses to this page (the MSI-X table), which > > > is part of the guest address space (through kvm memory slots), to be > > > trapped by qemu. > > > > > > Since there is no actual page in this guest address, KVM treats accesses > > > as MMIO and forwards them to QEMU. > > > > > > > > > > I thought about this too. > > But why is this necessary for assigned MSI-X but not for emulated devices such as > > e.g. e1000? All e1000 does seems to be cpu_register_physical_memory ... > > Because there is no registered (kvm) memory slot for the range which > e1000 registers its MMIO? Not sure about the address of the MSI-X table > page, but you could achieve the same effect by splitting the slot which > it lives in two, with a 1 page hole between them. You could also move the emulated MSI-X table, sticking it on top of the existing BAR. Since PCI config includes the pointer to the table, a driver that reads this pointer will continue to work. Of course, there's no guarantee that guest drivers don't just hard-code this offset. > BTW this is why you can't map the MSI-X table page directly, you want > accesses to be trapped. BTW current design won't work if the base page size is > 4K, will it? The hole covers a page, so you'll get faults outside the MSI-X table. -- MST