Re: [PATCH] KVM: x86: Keep masked bits unmodified on kvm_set_shared_msr

2014-08-22 Thread Nadav Amit

On Aug 22, 2014, at 7:13 AM, Wanpeng Li wanpeng...@linux.intel.com wrote:

 Hi Paolo,
 On Thu, Aug 21, 2014 at 01:56:46PM +0200, Paolo Bonzini wrote:
 Il 21/08/2014 10:05, Wanpeng Li ha scritto:
 Hi Nadav,
 On Wed, Aug 20, 2014 at 03:11:51PM +0300, Nadav Amit wrote:
 Currently, when an msr is updated using kvm_set_shared_msr the masked bits 
 are
 zeroed.  This behavior is currently valid since the only MSR with partial 
 mask
 
 Why zeroed? vmx_vcpu_setup() set all mask to -1ull.
 
 He meant they are passed as zero in the WRMSR but actually they're not
 
 I fail to understand they are passed as zero. Could you explain more
 in details? ;-)

Let’s ignore what I wrongly said. ;-)

Anyhow, the current semantics of kvm_set_shared_msr is that the unmasked bits 
of the value are compared against the current MSR value.
If they are not equal, the value is set to the MSR. This behaviour requires 
that the caller would set the value given as parameter according to the 
guest/host value.
If the caller naively does so (not setting the bits which are not in the mask), 
it would get zero in the unmasked bits in the MSR.
Currently, the only caller to kvm_set_shared_msr with a mask which is not full 
does it, and sets the unmasked bits of the value according to the host MSR 
value.
I argued that this behaviour is general, so the semantics of kvm_set_shared_msr 
should change. 
Paolo said that there are no current other callers to the function with a mask 
which is not full.

Nadav


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: [question] one vhost kthread servers mulitiple tx/rx queues which blong to one virtio-net device

2014-08-22 Thread Jason Wang
On 08/22/2014 10:30 AM, Zhang Haoyu wrote:
 Hi, Krishna, Shirley

 How got get the latest patch of M:N Implementation of mulitiqueue, 

 I am going to test the the combination of M:N Implementation of mulitiqueue 
 and vhost: add polling mode.

 Thanks,
 Zhang Haoyu



Just FYI. You may refer Bandan Das 's cwmq patch with vhost (search
Workqueue based vhost workers) and the recent vhost polling mode
patches by Razya Ladelsky.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 2/2] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-22 Thread Paolo Bonzini
Il 22/08/2014 01:30, Wanpeng Li ha scritto:
 Maybe I misunderstand your comments On real hardware you could point
 the virtual-APIC page to an invalid address.
 http://lists.openwall.net/linux-kernel/2014/08/07/344
 

That referred to an address that doesn't correspond to RAM.  You can use
addresses like these in a real processor.

But the manual says that if the “use TPR shadow” VM-execution control
is 1, VM entry ensures that the virtual-APIC address is 4-KByte aligned
(24.6.8 Controls For APIC Virtualization).  This is the check that is
missing.

Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 2/2] KVM: nVMX: nested TPR shadow/threshold emulation

2014-08-22 Thread Wanpeng Li
On Fri, Aug 22, 2014 at 10:36:07AM +0200, Paolo Bonzini wrote:
Il 22/08/2014 01:30, Wanpeng Li ha scritto:
 Maybe I misunderstand your comments On real hardware you could point
 the virtual-APIC page to an invalid address.
 http://lists.openwall.net/linux-kernel/2014/08/07/344
 

That referred to an address that doesn't correspond to RAM.  You can use
addresses like these in a real processor.

But the manual says that if the “use TPR shadow” VM-execution control
is 1, VM entry ensures that the virtual-APIC address is 4-KByte aligned
(24.6.8 Controls For APIC Virtualization).  This is the check that is
missing.

Ok, thanks.

Regards,
Wanpeng Li 

Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Nested paging in nested SVM setup

2014-08-22 Thread Paolo Bonzini
Il 22/08/2014 06:33, Valentine Sinitsyn ha scritto:
 On 22.08.2014 02:31, Paolo Bonzini wrote:
 VMX used the right access size already, the tests are separate for VMX
 and SVM.
 Sure. So the bug is NPT-specific?

Looks like that, yes.

Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 2/5] vfio: platform: decouple code probing devices from the platform bus

2014-08-22 Thread Antonios Motakis
Hide functionality related to discovering Linux platform device resources
in separate callback functions. This will allow us to implement AMBA support
while reusing a lot of the code.

Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com
---
 drivers/vfio/platform/vfio_platform.c | 28 +++
 drivers/vfio/platform/vfio_platform_irq.c |  6 +++---
 drivers/vfio/platform/vfio_platform_private.h |  7 ++-
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/drivers/vfio/platform/vfio_platform.c 
b/drivers/vfio/platform/vfio_platform.c
index f4c06c6..99aa9af 100644
--- a/drivers/vfio/platform/vfio_platform.c
+++ b/drivers/vfio/platform/vfio_platform.c
@@ -38,7 +38,7 @@ static int vfio_platform_regions_init(struct 
vfio_platform_device *vdev)
 {
int cnt = 0, i;
 
-   while (platform_get_resource(vdev-pdev, IORESOURCE_MEM, cnt))
+   while (vdev-get_resource(vdev, cnt))
cnt++;
 
vdev-region = kzalloc(sizeof(struct vfio_platform_region) * cnt,
@@ -47,8 +47,7 @@ static int vfio_platform_regions_init(struct 
vfio_platform_device *vdev)
return -ENOMEM;
 
for (i = 0; i  cnt;  i++) {
-   struct resource *res =
-   platform_get_resource(vdev-pdev, IORESOURCE_MEM, i);
+   struct resource *res = vdev-get_resource(vdev, i);
 
if (!res)
goto err;
@@ -385,6 +384,24 @@ static const struct vfio_device_ops vfio_platform_ops = {
.mmap   = vfio_platform_mmap,
 };
 
+/* probing devices from the linux platform bus */
+
+static struct resource* get_platform_resource(struct vfio_platform_device 
*vdev,
+   int i)
+{
+   struct platform_device *pdev = (struct platform_device *) vdev-opaque;
+
+   return platform_get_resource(pdev, IORESOURCE_MEM, i);
+}
+
+static int get_platform_irq(struct vfio_platform_device *vdev, int i)
+{
+   struct platform_device *pdev = (struct platform_device *) vdev-opaque;
+
+   return platform_get_irq(pdev, i);
+}
+
+
 static int vfio_platform_probe(struct platform_device *pdev)
 {
struct vfio_platform_device *vdev;
@@ -403,7 +420,10 @@ static int vfio_platform_probe(struct platform_device 
*pdev)
return -ENOMEM;
}
 
-   vdev-pdev = pdev;
+   vdev-opaque = (void *) pdev;
+   vdev-get_resource = get_platform_resource;
+   vdev-get_irq = get_platform_irq;
+   vdev-name = pdev-name;
 
ret = vfio_add_group_dev(pdev-dev, vfio_platform_ops, vdev);
if (ret) {
diff --git a/drivers/vfio/platform/vfio_platform_irq.c 
b/drivers/vfio/platform/vfio_platform_irq.c
index 6768508..50c8293 100644
--- a/drivers/vfio/platform/vfio_platform_irq.c
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -38,7 +38,7 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev)
 {
int cnt = 0, i;
 
-   while (platform_get_irq(vdev-pdev, cnt)  0)
+   while (vdev-get_irq(vdev, cnt)  0)
cnt++;
 
vdev-irq = kzalloc(sizeof(struct vfio_platform_irq) * cnt, GFP_KERNEL);
@@ -46,7 +46,7 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev)
return -ENOMEM;
 
for (i = 0; i  cnt; i++) {
-   int hwirq = platform_get_irq(vdev-pdev, i);
+   int hwirq = vdev-get_irq(vdev, i);
 
if (hwirq  0)
goto err;
@@ -172,7 +172,7 @@ static int vfio_set_trigger(struct vfio_platform_device 
*vdev,
return 0;
 
irq-name = kasprintf(GFP_KERNEL, vfio-irq[%d](%s),
-   irq-hwirq, vdev-pdev-name);
+   irq-hwirq, vdev-name);
if (!irq-name)
return -ENOMEM;
 
diff --git a/drivers/vfio/platform/vfio_platform_private.h 
b/drivers/vfio/platform/vfio_platform_private.h
index 86a9201..b79f485 100644
--- a/drivers/vfio/platform/vfio_platform_private.h
+++ b/drivers/vfio/platform/vfio_platform_private.h
@@ -44,11 +44,16 @@ struct vfio_platform_region {
 };
 
 struct vfio_platform_device {
-   struct platform_device  *pdev;
struct vfio_platform_region *region;
u32 num_regions;
struct vfio_platform_irq*irq;
u32 num_irqs;
+   void*opaque;
+   const char  *name;
+   /* callbacks to discover device resources */
+   struct resource*
+   (*get_resource)(struct vfio_platform_device *vdev, int i);
+   int (*get_irq)(struct vfio_platform_device *vdev, int i);
 };
 
 extern int vfio_platform_irq_init(struct vfio_platform_device *vdev);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo 

[RFC 1/5] driver core: amba: add device binding path 'driver_override'

2014-08-22 Thread Antonios Motakis
As already demonstrated with PCI [1] and the platform bus [2], a
driver_override property in sysfs can be used to bypass the id matching
of a device to a AMBA driver. This can be used by VFIO to bind to any AMBA
device requested by the user.

[1] 
http://lists-archives.com/linux-kernel/28030441-pci-introduce-new-device-binding-path-using-pci_dev-driver_override.html
[2] https://www.redhat.com/archives/libvir-list/2014-April/msg00382.html

Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com
---
 drivers/amba/bus.c   | 43 +++
 include/linux/amba/bus.h |  1 +
 2 files changed, 44 insertions(+)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 3cf61a1..8174a9a 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -17,6 +17,7 @@
 #include linux/pm_runtime.h
 #include linux/amba/bus.h
 #include linux/sizes.h
+#include linux/limits.h
 
 #include asm/irq.h
 
@@ -42,6 +43,10 @@ static int amba_match(struct device *dev, struct 
device_driver *drv)
struct amba_device *pcdev = to_amba_device(dev);
struct amba_driver *pcdrv = to_amba_driver(drv);
 
+   /* When driver_override is set, only bind to the matching driver */
+   if (pcdev-driver_override)
+   return !strcmp(pcdev-driver_override, drv-name);
+
return amba_lookup(pcdrv-id_table, pcdev) != NULL;
 }
 
@@ -58,6 +63,43 @@ static int amba_uevent(struct device *dev, struct 
kobj_uevent_env *env)
return retval;
 }
 
+static ssize_t driver_override_show(struct device *_dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct amba_device *dev = to_amba_device(_dev);
+   return sprintf(buf, %s\n, dev-driver_override);
+}
+
+static ssize_t driver_override_store(struct device *_dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct amba_device *dev = to_amba_device(_dev);
+   char *driver_override, *old = dev-driver_override, *cp;
+
+   if (count  PATH_MAX)
+  return -EINVAL;
+
+   driver_override = kstrndup(buf, count, GFP_KERNEL);
+   if (!driver_override)
+  return -ENOMEM;
+
+   cp = strchr(driver_override, '\n');
+   if (cp)
+  *cp = '\0';
+
+   if (strlen(driver_override)) {
+  dev-driver_override = driver_override;
+   } else {
+  kfree(driver_override);
+  dev-driver_override = NULL;
+   }
+
+   kfree(old);
+
+   return count;
+}
+
 #define amba_attr_func(name,fmt,arg...)
\
 static ssize_t name##_show(struct device *_dev,
\
   struct device_attribute *attr, char *buf)\
@@ -80,6 +122,7 @@ amba_attr_func(resource, \t%016llx\t%016llx\t%016lx\n,
 static struct device_attribute amba_dev_attrs[] = {
__ATTR_RO(id),
__ATTR_RO(resource),
+   __ATTR_RW(driver_override),
__ATTR_NULL,
 };
 
diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h
index fdd7e1b..7c011e7 100644
--- a/include/linux/amba/bus.h
+++ b/include/linux/amba/bus.h
@@ -32,6 +32,7 @@ struct amba_device {
struct clk  *pclk;
unsigned intperiphid;
unsigned intirq[AMBA_NR_IRQS];
+   char*driver_override;
 };
 
 struct amba_driver {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 0/5] vfio: AMBA devices support

2014-08-22 Thread Antonios Motakis
This patch series depends on the VFIO for PLATFORM devices patch series,
and implements AMBA device support for VFIO.

This can be used for example with the PL330 DMA Controller, which is an
AMBA device and not a proper platform device. By using the VFIO AMBA driver
introduced here, one can bind VFIO directly to such a device without hacking
the host device tree to make the device look like a platform device to the
system.

Also adding driver_override support to ARM AMBA bus devices, one can
alternate between using the proper host device driver and VFIO without
restarting the host system with a new device tree.

Antonios Motakis (5):
  driver core: amba: add device binding path 'driver_override'
  vfio: platform: decouple code probing devices from the platform bus
  vfio: platform: move code that can be shared with AMBA to a common
file
  vfio: amba: VFIO support for AMBA devices
  vfio: amba: add the VFIO for AMBA devices module to Kconfig

 drivers/amba/bus.c|  43 +++
 drivers/vfio/platform/Kconfig |  10 +
 drivers/vfio/platform/Makefile|   6 +-
 drivers/vfio/platform/vfio_amba.c | 129 +
 drivers/vfio/platform/vfio_platform.c | 355 +---
 drivers/vfio/platform/vfio_platform_common.c  | 380 ++
 drivers/vfio/platform/vfio_platform_irq.c |   6 +-
 drivers/vfio/platform/vfio_platform_private.h |   9 +-
 include/linux/amba/bus.h  |   1 +
 9 files changed, 591 insertions(+), 348 deletions(-)
 create mode 100644 drivers/vfio/platform/vfio_amba.c
 create mode 100644 drivers/vfio/platform/vfio_platform_common.c

-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 4/5] vfio: amba: VFIO support for AMBA devices

2014-08-22 Thread Antonios Motakis
Add support for discovering AMBA devices with VFIO and handle them
similarly to Linux platform devices.

Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com
---
 drivers/vfio/platform/vfio_amba.c | 129 ++
 1 file changed, 129 insertions(+)
 create mode 100644 drivers/vfio/platform/vfio_amba.c

diff --git a/drivers/vfio/platform/vfio_amba.c 
b/drivers/vfio/platform/vfio_amba.c
new file mode 100644
index 000..9fc0ae6
--- /dev/null
+++ b/drivers/vfio/platform/vfio_amba.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2013 - Virtual Open Systems
+ * Author: Antonios Motakis a.mota...@virtualopensystems.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/device.h
+#include linux/interrupt.h
+#include linux/iommu.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/notifier.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/types.h
+#include linux/uaccess.h
+#include linux/vfio.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/amba/bus.h
+
+#include vfio_platform_private.h
+
+#define DRIVER_VERSION  0.6
+#define DRIVER_AUTHOR   Antonios Motakis a.mota...@virtualopensystems.com
+#define DRIVER_DESC VFIO for AMBA devices - User Level meta-driver
+
+/* probing devices from the AMBA bus */
+
+static struct resource* get_amba_resource(struct vfio_platform_device *vdev,
+   int i)
+{
+   struct amba_device *adev = (struct amba_device *) vdev-opaque;
+
+   if (i == 0)
+   return adev-res;
+   else
+   return NULL;
+}
+
+static int get_amba_irq(struct vfio_platform_device *vdev, int i)
+{
+   struct amba_device *adev = (struct amba_device *) vdev-opaque;
+
+   if (i  AMBA_NR_IRQS)
+   return adev-irq[i];
+   else
+   return 0;
+}
+
+static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id)
+{
+
+   struct vfio_platform_device *vdev;
+   struct iommu_group *group;
+   int ret;
+
+   group = iommu_group_get(adev-dev);
+   if (!group) {
+   pr_err(VFIO: No IOMMU group for amba device with id%d\n,
+   adev-periphid);
+   return -EINVAL;
+   }
+
+   vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
+   if (!vdev) {
+   iommu_group_put(group);
+   return -ENOMEM;
+   }
+
+   vdev-opaque = (void *) adev;
+   vdev-get_resource = get_amba_resource;
+   vdev-get_irq = get_amba_irq;
+   vdev-name = AMBA device;
+
+   ret = vfio_add_group_dev(adev-dev, vfio_platform_ops, vdev);
+   if (ret) {
+   iommu_group_put(group);
+   kfree(vdev);
+   }
+
+   return ret;
+}
+
+static int vfio_amba_remove(struct amba_device *adev)
+{
+
+   struct vfio_platform_device *vdev;
+
+   vdev = vfio_del_group_dev(adev-dev);
+   if (!vdev)
+   return -EINVAL;
+
+   iommu_group_put(adev-dev.iommu_group);
+   kfree(vdev);
+
+   return 0;
+}
+
+static struct amba_id pl330_ids[] = {
+   { 0, 0 },
+};
+
+MODULE_DEVICE_TABLE(amba, pl330_ids);
+
+static struct amba_driver vfio_amba_driver = {
+   .probe = vfio_amba_probe,
+   .remove = vfio_amba_remove,
+   .id_table = pl330_ids,
+   .drv = {
+   .name = vfio-amba,
+   .owner = THIS_MODULE,
+   },
+};
+
+module_amba_driver(vfio_amba_driver);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE(GPL v2);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC 3/5] vfio: platform: move code that can be shared with AMBA to a common file

2014-08-22 Thread Antonios Motakis
Having decoupled a portion of the VFIO_PLATFORM code from platform bus
specific resource discovery code, we can now move that code separate file.
This will allow us to implement discovering AMBA devices and their resources,
but reuse the a large part of the VFIO_PLATFORM implementation.

Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com
---
 drivers/vfio/platform/Makefile|   2 +-
 drivers/vfio/platform/vfio_platform.c | 351 
 drivers/vfio/platform/vfio_platform_common.c  | 380 ++
 drivers/vfio/platform/vfio_platform_private.h |   2 +
 4 files changed, 383 insertions(+), 352 deletions(-)
 create mode 100644 drivers/vfio/platform/vfio_platform_common.c

diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile
index 2c53327..115d1b5 100644
--- a/drivers/vfio/platform/Makefile
+++ b/drivers/vfio/platform/Makefile
@@ -1,4 +1,4 @@
 
-vfio-platform-y := vfio_platform.o vfio_platform_irq.o
+vfio-platform-y := vfio_platform.o vfio_platform_irq.o vfio_platform_common.o
 
 obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o
diff --git a/drivers/vfio/platform/vfio_platform.c 
b/drivers/vfio/platform/vfio_platform.c
index 99aa9af..6be305a 100644
--- a/drivers/vfio/platform/vfio_platform.c
+++ b/drivers/vfio/platform/vfio_platform.c
@@ -13,7 +13,6 @@
  */
 
 #include linux/device.h
-#include linux/eventfd.h
 #include linux/interrupt.h
 #include linux/iommu.h
 #include linux/module.h
@@ -34,356 +33,6 @@
 #define DRIVER_AUTHOR   Antonios Motakis a.mota...@virtualopensystems.com
 #define DRIVER_DESC VFIO for platform devices - User Level meta-driver
 
-static int vfio_platform_regions_init(struct vfio_platform_device *vdev)
-{
-   int cnt = 0, i;
-
-   while (vdev-get_resource(vdev, cnt))
-   cnt++;
-
-   vdev-region = kzalloc(sizeof(struct vfio_platform_region) * cnt,
-   GFP_KERNEL);
-   if (!vdev-region)
-   return -ENOMEM;
-
-   for (i = 0; i  cnt;  i++) {
-   struct resource *res = vdev-get_resource(vdev, i);
-
-   if (!res)
-   goto err;
-
-   vdev-region[i].addr = res-start;
-   vdev-region[i].size = resource_size(res);
-   vdev-region[i].flags = VFIO_REGION_INFO_FLAG_READ
-   | VFIO_REGION_INFO_FLAG_WRITE;
-   /* Only regions addressed with PAGE granularity may be MMAPed
-* securely. */
-   if (!(vdev-region[i].addr  ~PAGE_MASK)
-!(vdev-region[i].size  ~PAGE_MASK))
-   vdev-region[i].flags |= VFIO_REGION_INFO_FLAG_MMAP;
-   }
-
-   vdev-num_regions = cnt;
-
-   return 0;
-err:
-   kfree(vdev-region);
-   return -EINVAL;
-}
-
-static void vfio_platform_regions_cleanup(struct vfio_platform_device *vdev)
-{
-   vdev-num_regions = 0;
-   kfree(vdev-region);
-}
-
-static void vfio_platform_release(void *device_data)
-{
-   struct vfio_platform_device *vdev = device_data;
-
-   vfio_platform_regions_cleanup(vdev);
-   vfio_platform_irq_cleanup(vdev);
-
-   module_put(THIS_MODULE);
-}
-
-static int vfio_platform_open(void *device_data)
-{
-   struct vfio_platform_device *vdev = device_data;
-   int ret;
-
-   if (!try_module_get(THIS_MODULE))
-   return -ENODEV;
-
-   ret = vfio_platform_regions_init(vdev);
-   if (ret)
-   goto err_reg;
-
-   ret = vfio_platform_irq_init(vdev);
-   if (ret)
-   goto err_irq;
-
-   return 0;
-
-err_irq:
-   vfio_platform_regions_cleanup(vdev);
-err_reg:
-   module_put(THIS_MODULE);
-
-   return ret;
-}
-
-static long vfio_platform_ioctl(void *device_data,
-  unsigned int cmd, unsigned long arg)
-{
-   struct vfio_platform_device *vdev = device_data;
-   unsigned long minsz;
-
-   if (cmd == VFIO_DEVICE_GET_INFO) {
-   struct vfio_device_info info;
-
-   minsz = offsetofend(struct vfio_device_info, num_irqs);
-
-   if (copy_from_user(info, (void __user *)arg, minsz))
-   return -EFAULT;
-
-   if (info.argsz  minsz)
-   return -EINVAL;
-
-   info.flags = VFIO_DEVICE_FLAGS_PLATFORM;
-   info.num_regions = vdev-num_regions;
-   info.num_irqs = vdev-num_irqs;
-
-   return copy_to_user((void __user *)arg, info, minsz);
-
-   } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
-   struct vfio_region_info info;
-
-   minsz = offsetofend(struct vfio_region_info, offset);
-
-   if (copy_from_user(info, (void __user *)arg, minsz))
-   return -EFAULT;
-
-   if (info.argsz  minsz)
-   return -EINVAL;
-
-   if (info.index = 

[RFC 5/5] vfio: amba: add the VFIO for AMBA devices module to Kconfig

2014-08-22 Thread Antonios Motakis
Enable building the VFIO AMBA driver. VFIO_AMBA depends on VFIO_PLATFORM,
since it is sharing a portion of the code, and it is essentially implemented
as a platform device whose resources are discovered via AMBA specific APIs
in the kernel.

Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com
---
 drivers/vfio/platform/Kconfig  | 10 ++
 drivers/vfio/platform/Makefile |  4 
 2 files changed, 14 insertions(+)

diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig
index c51af17..8b97786 100644
--- a/drivers/vfio/platform/Kconfig
+++ b/drivers/vfio/platform/Kconfig
@@ -7,3 +7,13 @@ config VFIO_PLATFORM
  framework.
 
  If you don't know what to do here, say N.
+
+config VFIO_AMBA
+   tristate VFIO support for AMBA devices
+   depends on VFIO  VFIO_PLATFORM  EVENTFD  ARM_AMBA
+   help
+ Support for ARM AMBA devices with VFIO. This is required to make
+ use of ARM AMBA devices present on the system using the VFIO
+ framework.
+
+ If you don't know what to do here, say N.
diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile
index 115d1b5..1cb5e94 100644
--- a/drivers/vfio/platform/Makefile
+++ b/drivers/vfio/platform/Makefile
@@ -2,3 +2,7 @@
 vfio-platform-y := vfio_platform.o vfio_platform_irq.o vfio_platform_common.o
 
 obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o
+
+vfio-amba-y := vfio_amba.o
+
+obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o
-- 
1.8.3.2

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: Add polling mode

2014-08-22 Thread Zhang Haoyu
  
  Results:
  
  Netperf, 1 vm:
  The polling patch improved throughput by ~33% (1516 MB/sec - 2046 MB/sec).
  Number of exits/sec decreased 6x.
  The same improvement was shown when I tested with 3 vms running netperf
  (4086 MB/sec - 5545 MB/sec).
  
  filebench, 1 vm:
  ops/sec improved by 13% with the polling patch. Number of exits 
 was reduced by
  31%.
  The same experiment with 3 vms running filebench showed similar numbers.
  
  Signed-off-by: Razya Ladelsky ra...@il.ibm.com
 
 Gave it a quick try on s390/kvm. As expected it makes no difference 
 for big streaming workload like iperf.
 uperf with a 1-1 round robin got indeed faster by about 30%.
 The high CPU consumption is something that bothers me though, as 
 virtualized systems tend to be full.
 
 

Thanks for confirming the results!
The best way to use this patch would be along with a shared vhost thread 
for multiple
devices/vms, as described in:
http://domino.research.ibm.com/library/cyberdig.nsf/1e4115aea78b6e7c85256b360066f0d4/479e3578ed05bfac85257b4200427735!OpenDocument
This work assumes having a dedicated I/O core where the vhost thread 
serves multiple vms, which 
makes the high cpu utilization less of a concern. 

Hi, Razya, Shirley
I am going to test the combination of 
several (depends on total number of cpu on host, e.g.,  total_number * 1/3) 
vhost threads server all VMs and vhost: add polling mode,
now I get the patch 
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88682/focus=88723; 
posted by Shirley,
any update to this patch?

And, I want to make a bit change on this patch, create total_cpu_number * 
1/N(N={3,4}) vhost threads instead of per-cpu vhost thread to server all VMs,
any ideas?

Thanks,
Zhang Haoyu


  +static int poll_start_rate = 0;
  +module_param(poll_start_rate, int, S_IRUGO|S_IWUSR);
  +MODULE_PARM_DESC(poll_start_rate, Start continuous polling of 
 virtqueue when rate of events is at least this number per jiffy. If 
 0, never start polling.);
  +
  +static int poll_stop_idle = 3*HZ; /* 3 seconds */
  +module_param(poll_stop_idle, int, S_IRUGO|S_IWUSR);
  +MODULE_PARM_DESC(poll_stop_idle, Stop continuous polling of 
 virtqueue after this many jiffies of no work.);
 
 This seems ridicoudly high. Even one jiffie is an eternity, so 
 setting it to 1 as a default would reduce the CPU overhead for most cases.
 If we dont have a packet in one millisecond, we can surely go back 
 to the kick approach, I think.
 
 Christian
 

Good point, will reduce it and recheck.
Thank you,
Razya

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: Add polling mode

2014-08-22 Thread Zhang Haoyu
  
  Results:
  
  Netperf, 1 vm:
  The polling patch improved throughput by ~33% (1516 MB/sec - 2046 
  MB/sec).
  Number of exits/sec decreased 6x.
  The same improvement was shown when I tested with 3 vms running netperf
  (4086 MB/sec - 5545 MB/sec).
  
  filebench, 1 vm:
  ops/sec improved by 13% with the polling patch. Number of exits 
 was reduced by
  31%.
  The same experiment with 3 vms running filebench showed similar numbers.
  
  Signed-off-by: Razya Ladelsky ra...@il.ibm.com
 
 Gave it a quick try on s390/kvm. As expected it makes no difference 
 for big streaming workload like iperf.
 uperf with a 1-1 round robin got indeed faster by about 30%.
 The high CPU consumption is something that bothers me though, as 
 virtualized systems tend to be full.
 
 

Thanks for confirming the results!
The best way to use this patch would be along with a shared vhost thread 
for multiple
devices/vms, as described in:
http://domino.research.ibm.com/library/cyberdig.nsf/1e4115aea78b6e7c85256b360066f0d4/479e3578ed05bfac85257b4200427735!OpenDocument
This work assumes having a dedicated I/O core where the vhost thread 
serves multiple vms, which 
makes the high cpu utilization less of a concern. 

Hi, Razya, Shirley
I am going to test the combination of 
several (depends on total number of cpu on host, e.g.,  total_number * 1/3) 
vhost threads server all VMs and vhost: add polling mode,
now I get the patch 
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/88682/focus=88723; 
posted by Shirley,
any update to this patch?

And, I want to make a bit change on this patch, create total_cpu_number * 
1/N(N={3,4}) vhost threads instead of per-cpu vhost thread to server all VMs,
Just like xen netback threads, whose number is equal to num_online_cpus on 
Dom0, 
but for kvm host, I think per-cpu vhost thread is too many.
any ideas?

Thanks,
Zhang Haoyu


  +static int poll_start_rate = 0;
  +module_param(poll_start_rate, int, S_IRUGO|S_IWUSR);
  +MODULE_PARM_DESC(poll_start_rate, Start continuous polling of 
 virtqueue when rate of events is at least this number per jiffy. If 
 0, never start polling.);
  +
  +static int poll_stop_idle = 3*HZ; /* 3 seconds */
  +module_param(poll_stop_idle, int, S_IRUGO|S_IWUSR);
  +MODULE_PARM_DESC(poll_stop_idle, Stop continuous polling of 
 virtqueue after this many jiffies of no work.);
 
 This seems ridicoudly high. Even one jiffie is an eternity, so 
 setting it to 1 as a default would reduce the CPU overhead for most cases.
 If we dont have a packet in one millisecond, we can surely go back 
 to the kick approach, I think.
 
 Christian
 

Good point, will reduce it and recheck.
Thank you,
Razya

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 00/14] kvm-unit-tests/arm: initial drop

2014-08-22 Thread Paolo Bonzini
Il 16/07/2014 10:47, Andrew Jones ha scritto:
 These patches (v7) are also available from a git repo here
 https://github.com/rhdrjones/kvm-unit-tests/commits/arm/v7-initial-drop

Thanks, I pulled from here -- it's not yet on kernel.org, but it should
get there on Monday.

Paolo
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html