Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-25 Thread Michael S. Tsirkin
On Fri, Feb 25, 2011 at 02:12:42PM +0800, Sheng Yang wrote: On Thursday 24 February 2011 18:17:34 Michael S. Tsirkin wrote: On Thu, Feb 24, 2011 at 05:44:20PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Sheng Yang
On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: Then we can support mask bit operation of

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Sheng Yang
On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: Then we can support mask bit operation of

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Michael S. Tsirkin
On Thu, Feb 24, 2011 at 04:08:22PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Michael S. Tsirkin
On Thu, Feb 24, 2011 at 05:44:20PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Sheng Yang
On Thursday 24 February 2011 18:11:44 Michael S. Tsirkin wrote: On Thu, Feb 24, 2011 at 04:08:22PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-24 Thread Sheng Yang
On Thursday 24 February 2011 18:17:34 Michael S. Tsirkin wrote: On Thu, Feb 24, 2011 at 05:44:20PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 16:45:37 Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-23 Thread Michael S. Tsirkin
On Wed, Feb 23, 2011 at 02:59:04PM +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Looks pretty good overall. A few comments

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-23 Thread Alex Williamson
On Wed, 2011-02-23 at 14:59 +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: +static int msix_table_mmio_read(struct kvm_io_device *this, gpa_t addr, int len, +void

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-23 Thread Michael S. Tsirkin
On Wed, Feb 23, 2011 at 09:34:19AM -0700, Alex Williamson wrote: On Wed, 2011-02-23 at 14:59 +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: +static int msix_table_mmio_read(struct kvm_io_device

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-23 Thread Alex Williamson
On Wed, 2011-02-23 at 20:39 +0200, Michael S. Tsirkin wrote: On Wed, Feb 23, 2011 at 09:34:19AM -0700, Alex Williamson wrote: On Wed, 2011-02-23 at 14:59 +0800, Sheng Yang wrote: On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-22 Thread Marcelo Tosatti
On Fri, Feb 18, 2011 at 04:15:38PM +0800, Sheng Yang wrote: Why allow this ioctl to succeed if there's an entry already present? This case is broken as mmio_dev-mmio_nr is increased below. Oh, It's a bug to let mmio_nr increase even with MMIO found. I've fixed it. The reason we allow

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-22 Thread Alex Williamson
On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Looks pretty good overall. A few comments below. It seems like we should be able to hook this into vfio with a small stub in kvm. We just need to be able to communicate

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-22 Thread Sheng Yang
On Wednesday 23 February 2011 08:19:21 Alex Williamson wrote: On Sun, 2011-01-30 at 13:11 +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Looks pretty good overall. A few comments below. It seems like we should be able to hook this into vfio with a

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-18 Thread Sheng Yang
On Thursday 03 February 2011 09:05:55 Marcelo Tosatti wrote: On Sun, Jan 30, 2011 at 01:11:15PM +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Signed-off-by: Sheng Yang sh...@linux.intel.com +int kvm_vm_ioctl_register_msix_mmio(struct kvm

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-02-02 Thread Marcelo Tosatti
On Sun, Jan 30, 2011 at 01:11:15PM +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Signed-off-by: Sheng Yang sh...@linux.intel.com +int kvm_vm_ioctl_register_msix_mmio(struct kvm *kvm, + struct kvm_msix_mmio_user

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-31 Thread Avi Kivity
On 01/30/2011 06:38 AM, Sheng Yang wrote: (Sorry, missed this mail...) On Mon, Jan 17, 2011 at 02:29:44PM +0200, Avi Kivity wrote: On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. +int

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-31 Thread Sheng Yang
On Mon, Jan 31, 2011 at 03:09:09PM +0200, Avi Kivity wrote: On 01/30/2011 06:38 AM, Sheng Yang wrote: (Sorry, missed this mail...) On Mon, Jan 17, 2011 at 02:29:44PM +0200, Avi Kivity wrote: On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-29 Thread Sheng Yang
(Sorry, missed this mail...) On Mon, Jan 17, 2011 at 02:29:44PM +0200, Avi Kivity wrote: On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. +int kvm_assigned_device_update_msix_mask_bit(struct kvm *kvm, +

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-19 Thread Sheng Yang
On Monday 17 January 2011 20:39:30 Marcelo Tosatti wrote: On Mon, Jan 17, 2011 at 08:18:22PM +0800, Sheng Yang wrote: + goto out; + + mmio = mmio_dev-mmio[idx]; + entry = (addr - mmio-table_base_addr) / PCI_MSIX_ENTRY_SIZE; + entry_base =

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Marcelo Tosatti
On Thu, Jan 06, 2011 at 06:19:44PM +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Signed-off-by: Sheng Yang sh...@linux.intel.com --- arch/x86/kvm/Makefile|2 +- arch/x86/kvm/x86.c |8 +- include/linux/kvm.h | 21

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Sheng Yang
On Monday 17 January 2011 19:54:47 Marcelo Tosatti wrote: On Thu, Jan 06, 2011 at 06:19:44PM +0800, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. Signed-off-by: Sheng Yang sh...@linux.intel.com --- arch/x86/kvm/Makefile|2 +-

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Avi Kivity
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

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Avi Kivity
On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. +int kvm_assigned_device_update_msix_mask_bit(struct kvm *kvm, + int assigned_dev_id, int entry, bool mask) +{ + int r = -EFAULT; + struct

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Marcelo Tosatti
On Mon, Jan 17, 2011 at 08:18:22PM +0800, Sheng Yang wrote: + goto out; + + mmio = mmio_dev-mmio[idx]; + entry = (addr - mmio-table_base_addr) / PCI_MSIX_ENTRY_SIZE; + entry_base = mmio-table_base_va + entry * PCI_MSIX_ENTRY_SIZE; + ctrl_pos = (u32 *)(entry_base +

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Marcelo Tosatti
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,

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Avi Kivity
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

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Michael S. Tsirkin
On Mon, Jan 17, 2011 at 02:29:44PM +0200, Avi Kivity wrote: On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. +int kvm_assigned_device_update_msix_mask_bit(struct kvm *kvm, +int assigned_dev_id, int

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Jan Kiszka
On 2011-01-17 13:29, Avi Kivity wrote: On 01/06/2011 12:19 PM, Sheng Yang wrote: Then we can support mask bit operation of assigned devices now. +int kvm_assigned_device_update_msix_mask_bit(struct kvm *kvm, +int assigned_dev_id, int entry, bool mask) +{ +int r =

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Marcelo Tosatti
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),

Re: [PATCH 2/3] KVM: Emulate MSI-X table in kernel

2011-01-17 Thread Avi Kivity
On 01/17/2011 05:52 PM, Marcelo Tosatti wrote: 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