From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel Date: Mon, 17 Jan 2011 13:52:54 -0200 Message-ID: <20110117155254.GA12350@amt.cnet> References: <1294309185-21417-1-git-send-email-sheng@linux.intel.com> <1294309185-21417-3-git-send-email-sheng@linux.intel.com> <20110117115447.GA8145@amt.cnet> <201101172018.22478.sheng@linux.intel.com> <4D3433A3.2010305@redhat.com> <20110117124816.GB8985@amt.cnet> <4D343B59.4070507@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sheng Yang , "Michael S. Tsirkin" , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:27889 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751Ab1AQPxU (ORCPT ); Mon, 17 Jan 2011 10:53:20 -0500 Content-Disposition: inline In-Reply-To: <4D343B59.4070507@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jan 17, 2011 at 02:51:37PM +0200, Avi Kivity wrote: > On 01/17/2011 02:48 PM, Marcelo Tosatti wrote: > >On Mon, Jan 17, 2011 at 02:18:43PM +0200, Avi Kivity wrote: > >> On 01/17/2011 02:18 PM, Sheng Yang wrote: > >> >> > + > >> >> > + if (copy_to_user((void __user *)(entry_base + offset), val, len)) > >> >> > + goto out; > >> >> > >> >> Instead of copying to/from userspace (which is subject to swapin, > >> >> unexpected values), you could include the guest written value in a > >> >> kvm_run structure, along with address. Qemu-kvm would use that to > >> >> synchronize its copy of the table, on KVM_EXIT_MSIX_ROUTING_UPDATE exit. > >> > > >> >We want to acelerate MSI-X mask bit accessing, which won't exit to userspace in > >> >the most condition. That's the cost we want to optimize. Also it's possible to > >> >userspace to read the correct value of MMIO(but mostly userspace can't write to it > >> >in order to prevent synchronize issue). > >> > >> It's also good to have the values in just one place; using userspace > >> makes it easy for both the kernel and userspace to see the values > >> (and set them after migration, if/when we extend this to virtio). > > > >Right, thats an advantage, but: > > > >- How can userspace ever synchronize with updates by the kernel > > to the MSI-X entry? > > What a value is written by the guest, which kvm cannot handle itself > (i.e. a change to anything other than the mask bit), we exit with > the table and entry ids, so userspace can reread them. OK. But regarding access to the MSI-X entry in userspace, it can only be accessed safely wrt parallel updates by the kernel in the exit handler. Is the exit handler the only location where the MSI-X entry will be read or written to, in userspace? > >- Reading/writing to the userspace area must be done carefully, > > values must be validated before used. > > True every time... > > >- Swapping issue (minor?). > > I don't see the issue... just like any part of qemu that may be > swapped out, blocking the vcpu thread.