Re: [PATCH kvm-unit-tests 00/15] arm64: initial drop

2015-01-06 Thread Alex Bennée
Andrew Jones drjo...@redhat.com writes: On Fri, Dec 12, 2014 at 01:44:52PM +0100, Paolo Bonzini wrote: snip On 10/12/2014 20:59, Andrew Jones wrote: This series adds support for aarch64 to the kvm-unit-tests framework, bringing it to the same level as the arm support. In the process a

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Paolo Bonzini
On 05/01/2015 20:17, Marcelo Tosatti wrote: But there is no guarantee that vCPU-N has updated its pvti when vCPU-M resumes guest instruction execution. You're right. So the cost this patch removes is mainly from __getcpu (==RDTSCP?) ? Perhaps you can use Gleb's idea to stick vcpu id into

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Paolo Bonzini
On 05/01/2015 23:48, Marcelo Tosatti wrote: But there is no guarantee that vCPU-N has updated its pvti when vCPU-M resumes guest instruction execution. Still confused. So we can freeze all vCPUs in the host, then update pvti 1, then resume vCPU 1, then update pvti 0? In that case,

[PATCH v11 01/20] vfio/platform: initial skeleton of VFIO support for platform devices

2015-01-06 Thread Antonios Motakis
This patch forms the common skeleton code for platform devices support with VFIO. This will include the core functionality of VFIO_PLATFORM, however binding to the device and discovering the device resources will be done with the help of a separate file where any Linux platform bus specific code

[PATCH v11 06/20] vfio/platform: return info for bound device

2015-01-06 Thread Antonios Motakis
A VFIO userspace driver will start by opening the VFIO device that corresponds to an IOMMU group, and will use the ioctl interface to get the basic device info, such as number of memory regions and interrupts, and their properties. This patch enables the VFIO_DEVICE_GET_INFO ioctl call.

[PATCH v11 16/20] vfio: add local lock for virqfd instead of depending on VFIO PCI

2015-01-06 Thread Antonios Motakis
The Virqfd code needs to keep accesses to any struct *virqfd safe, but this comes into play only when creating or destroying eventfds, so sharing the same spinlock with the VFIO bus driver is not necessary. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com ---

[PATCH v11 13/20] vfio/platform: support for level sensitive interrupts

2015-01-06 Thread Antonios Motakis
Level sensitive interrupts are exposed as maskable and automasked interrupts and are masked and disabled automatically when they fire. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_irq.c | 99 ++-

[PATCH v11 20/20] vfio/platform: implement IRQ masking/unmasking via an eventfd

2015-01-06 Thread Antonios Motakis
With this patch the VFIO user will be able to set an eventfd that can be used in order to mask and unmask IRQs of platform devices. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_irq.c | 47 ---

[PATCH v11 18/20] vfio: move eventfd support code for VFIO_PCI to a separate file

2015-01-06 Thread Antonios Motakis
The virqfd functionality that is used by VFIO_PCI to implement interrupt masking and unmasking via an eventfd, is generic enough and can be reused by another driver. Move it to a separate file in order to allow the code to be shared. Signed-off-by: Antonios Motakis

[PATCH v11 17/20] vfio: pass an opaque pointer on virqfd initialization

2015-01-06 Thread Antonios Motakis
VFIO_PCI passes the VFIO device structure *vdev via eventfd to the handler that implements masking/unmasking of IRQs via an eventfd. We can replace it in the virqfd infrastructure with an opaque type so we can make use of the mechanism from other VFIO bus drivers. Signed-off-by: Antonios Motakis

[PATCH v11 12/20] vfio/platform: trigger an interrupt via eventfd

2015-01-06 Thread Antonios Motakis
This patch allows to set an eventfd for a platform device's interrupt, and also to trigger the interrupt eventfd from userspace for testing. Level sensitive interrupts are marked as maskable and are handled in a later patch. Edge triggered interrupts are not advertised as maskable and are

[PATCH v11 14/20] vfio: add a vfio_ prefix to virqfd_enable and virqfd_disable and export

2015-01-06 Thread Antonios Motakis
We want to reuse virqfd functionality in multiple VFIO drivers; before moving these functions to core VFIO, add the vfio_ prefix to the virqfd_enable and virqfd_disable functions, and export them so they can be used from other modules. Signed-off-by: Antonios Motakis

[PATCH v11 11/20] vfio/platform: initial interrupts support code

2015-01-06 Thread Antonios Motakis
This patch is a skeleton for the VFIO_DEVICE_SET_IRQS IOCTL, around which most IRQ functionality is implemented in VFIO. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 52 +--

[PATCH v11 08/20] vfio/platform: read and write support for the device fd

2015-01-06 Thread Antonios Motakis
VFIO returns a file descriptor which we can use to manipulate the memory regions of the device. Usually, the user will mmap memory regions that are addressable on page boundaries, however for memory regions where this is not the case we cannot provide mmap functionality due to security concerns.

[PATCH v11 10/20] vfio/platform: return IRQ info

2015-01-06 Thread Antonios Motakis
Return information for the interrupts exposed by the device. This patch extends VFIO_DEVICE_GET_INFO with the number of IRQs and enables VFIO_DEVICE_GET_IRQ_INFO. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/Makefile| 2 +-

[PATCH v11 09/20] vfio/platform: support MMAP of MMIO regions

2015-01-06 Thread Antonios Motakis
Allow to memory map the MMIO regions of the device so userspace can directly access them. PIO regions are not being handled at this point. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 65 1 file

[PATCH v11 07/20] vfio/platform: return info for device memory mapped IO regions

2015-01-06 Thread Antonios Motakis
This patch enables the IOCTLs VFIO_DEVICE_GET_REGION_INFO ioctl call, which allows the user to learn about the available MMIO resources of a device. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform_common.c | 106 +-

[PATCH v11 03/20] vfio: platform: add the VFIO PLATFORM module to Kconfig

2015-01-06 Thread Antonios Motakis
Enable building the VFIO PLATFORM driver that allows to use Linux platform devices with VFIO. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/Kconfig | 1 + drivers/vfio/Makefile | 1 + drivers/vfio/platform/Kconfig | 9 +

[PATCH v11 05/20] vfio: amba: add the VFIO for AMBA devices module to Kconfig

2015-01-06 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

[PATCH v11 04/20] vfio: amba: VFIO support for AMBA devices

2015-01-06 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 | 115 ++ include/uapi/linux/vfio.h | 1 +

[PATCH v11 02/20] vfio: platform: probe to devices on the platform bus

2015-01-06 Thread Antonios Motakis
Driver to bind to Linux platform devices, and callbacks to discover their resources to be used by the main VFIO PLATFORM code. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/platform/vfio_platform.c | 103 ++

[PATCH v11 15/20] vfio: virqfd: rename vfio_pci_virqfd_init and vfio_pci_virqfd_exit

2015-01-06 Thread Antonios Motakis
The functions vfio_pci_virqfd_init and vfio_pci_virqfd_exit are not really PCI specific, since we plan to reuse the virqfd code with more VFIO drivers in addition to VFIO_PCI. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/pci/vfio_pci.c | 6 +++---

[PATCH v11 19/20] vfio: initialize the virqfd workqueue in VFIO generic code

2015-01-06 Thread Antonios Motakis
Now we have finally completely decoupled virqfd from VFIO_PCI. We can initialize it from the VFIO generic code, in order to safely use it from multiple independent VFIO bus drivers. Signed-off-by: Antonios Motakis a.mota...@virtualopensystems.com --- drivers/vfio/Makefile | 4 +++-

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Paolo Bonzini
On 06/01/2015 09:42, Paolo Bonzini wrote: Still confused. So we can freeze all vCPUs in the host, then update pvti 1, then resume vCPU 1, then update pvti 0? In that case, we have a problem, because vCPU 1 can observe pvti 0 mid-update, and KVM doesn't increment the version

[PATCH] kvmtool: Add parameter to specifiy number of threads in thread_pool

2015-01-06 Thread Andreas Herrmann
With current code the number of threads added to the thread_pool equals number of online CPUs. IMHO on systems with many CPUs this is overkill for guests that just have a few vCPUs and/or if a guest is pinned to a subset of host CPUs. E.g. of a system with 48 cores # numactl -C 4,5,7,8 ./lkvm

[PATCH] kvmtool: Set names for virtio-net-ctrl and term-poll threads

2015-01-06 Thread Andreas Herrmann
Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com --- tools/kvm/term.c |2 ++ tools/kvm/virtio/net.c |2 ++ 2 files changed, 4 insertions(+) diff --git a/tools/kvm/term.c b/tools/kvm/term.c index 1b8131a..5754510 100644 --- a/tools/kvm/term.c +++

Re: [Xen-devel] [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Konrad Rzeszutek Wilk
On Mon, Jan 05, 2015 at 10:56:07AM -0800, Andy Lutomirski wrote: On Mon, Jan 5, 2015 at 7:25 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Mon, Dec 22, 2014 at 04:39:57PM -0800, Andy Lutomirski wrote: The pvclock vdso code was too abstracted to understand easily and excessively

[ÞATCH] kvmtool, mips: Support more than 256 MB guest memory

2015-01-06 Thread Andreas Herrmann
Two guest memory regions need to be defined and two mem= parameters need to be passed to guest kernel to support more than 256 MB. Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com --- tools/kvm/mips/include/kvm/kvm-arch.h | 10 + tools/kvm/mips/kvm.c

Re: [PATCH 1/3] x86_64,entry: Fix RCX for traced syscalls

2015-01-06 Thread Borislav Petkov
On Tue, Jan 06, 2015 at 10:43:57AM -0800, Andy Lutomirski wrote: Sure, but the code would be simpler if we shoved that value in the EFLAGS slot. There probably is some reason for that but it's not like we can change it :-) Hmm. I added and pushed a test for fork, but that didn't turn

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Marcelo Tosatti
On Tue, Jan 06, 2015 at 10:26:22AM -0800, Andy Lutomirski wrote: On Tue, Jan 6, 2015 at 10:13 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Tue, Jan 06, 2015 at 08:56:40AM -0800, Andy Lutomirski wrote: On Jan 6, 2015 4:01 AM, Paolo Bonzini pbonz...@redhat.com wrote: On

Re: [PATCH 1/3] x86_64,entry: Fix RCX for traced syscalls

2015-01-06 Thread Andy Lutomirski
On Jan 6, 2015 7:34 AM, Borislav Petkov b...@alien8.de wrote: On Mon, Jan 05, 2015 at 12:31:15PM -0800, Andy Lutomirski wrote: Do you have context tracking on? Yap, it is enabled for whatever reason: CONFIG_CONTEXT_TRACKING=y CONFIG_CONTEXT_TRACKING_FORCE=y CONFIG_HAVE_CONTEXT_TRACKING=y

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Andy Lutomirski
On Tue, Jan 6, 2015 at 10:45 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Tue, Jan 06, 2015 at 10:26:22AM -0800, Andy Lutomirski wrote: On Tue, Jan 6, 2015 at 10:13 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Tue, Jan 06, 2015 at 08:56:40AM -0800, Andy Lutomirski wrote: On Jan 6,

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Marcelo Tosatti
On Tue, Jan 06, 2015 at 11:49:09AM -0800, Andy Lutomirski wrote: What is the point with the new flags bit though? To try to work around the problem on old hosts. I'm not at all convinced that this is worthwhile or that it helps, though. Don't think so. Just fix the host bug. Also, if

Re: [PATCH v8 34/50] vhost/net: virtio 1.0 byte swap

2015-01-06 Thread Alex Williamson
On Mon, 2014-12-01 at 18:05 +0200, Michael S. Tsirkin wrote: I had to add an explicit tag to suppress compiler warning: gcc isn't smart enough to notice that len is always initialized since function is called with size 0. I'm getting a panic inside a guest when this change is applied on the

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Andy Lutomirski
On Tue, Jan 6, 2015 at 12:20 PM, Marcelo Tosatti mtosa...@redhat.com wrote: On Tue, Jan 06, 2015 at 11:49:09AM -0800, Andy Lutomirski wrote: What is the point with the new flags bit though? To try to work around the problem on old hosts. I'm not at all convinced that this is worthwhile or

Re: [RFC PATCH] KVM: introduce kvm_check_device

2015-01-06 Thread Scott Wood
On Tue, 2015-01-06 at 16:12 +, Andre Przywara wrote: While we can easily register and unregister KVM devices, there is currently no easy way of checking whether a device has been registered. Introduce kvm_check_device() for that purpose and use it in two existing functions. Also change

Re: [PATCH 1/3] x86_64,entry: Fix RCX for traced syscalls

2015-01-06 Thread Borislav Petkov
On Mon, Jan 05, 2015 at 12:31:15PM -0800, Andy Lutomirski wrote: Do you have context tracking on? Yap, it is enabled for whatever reason: CONFIG_CONTEXT_TRACKING=y CONFIG_CONTEXT_TRACKING_FORCE=y CONFIG_HAVE_CONTEXT_TRACKING=y I assume that's in the historical tree? Yeah. [ 180.059170]

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Paolo Bonzini
On 06/01/2015 17:56, Andy Lutomirski wrote: Still no good. We can migrate a bunch of times so we see the same CPU all three times There are no three times. The CPU you see here: // ... compute nanoseconds from pvti and tsc ... rmb(); } while(v != pvti-version); is the

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Paolo Bonzini
On 06/01/2015 19:26, Andy Lutomirski wrote: Don't you stil need: version++; write the rest; version++; with possible smp_wmb() in there to keep the compiler from messing around? No, see my other reply. Separating the version write is a real bug, but that should be all that it's

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Andy Lutomirski
On Tue, Jan 6, 2015 at 9:38 PM, Paolo Bonzini pbonz...@redhat.com wrote: On 06/01/2015 17:56, Andy Lutomirski wrote: Still no good. We can migrate a bunch of times so we see the same CPU all three times There are no three times. The CPU you see here: // ... compute nanoseconds

[RFC PATCH] KVM: introduce kvm_check_device

2015-01-06 Thread Andre Przywara
While we can easily register and unregister KVM devices, there is currently no easy way of checking whether a device has been registered. Introduce kvm_check_device() for that purpose and use it in two existing functions. Also change the return code for an invalid type number from ENOSPC to

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Andy Lutomirski
On Tue, Jan 6, 2015 at 10:13 AM, Marcelo Tosatti mtosa...@redhat.com wrote: On Tue, Jan 06, 2015 at 08:56:40AM -0800, Andy Lutomirski wrote: On Jan 6, 2015 4:01 AM, Paolo Bonzini pbonz...@redhat.com wrote: On 06/01/2015 09:42, Paolo Bonzini wrote: Still confused. So we can freeze

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Andy Lutomirski
On Jan 6, 2015 4:01 AM, Paolo Bonzini pbonz...@redhat.com wrote: On 06/01/2015 09:42, Paolo Bonzini wrote: Still confused. So we can freeze all vCPUs in the host, then update pvti 1, then resume vCPU 1, then update pvti 0? In that case, we have a problem, because vCPU 1 can

Re: [RFC 2/2] x86, vdso, pvclock: Simplify and speed up the vdso pvclock reader

2015-01-06 Thread Marcelo Tosatti
On Tue, Jan 06, 2015 at 08:56:40AM -0800, Andy Lutomirski wrote: On Jan 6, 2015 4:01 AM, Paolo Bonzini pbonz...@redhat.com wrote: On 06/01/2015 09:42, Paolo Bonzini wrote: Still confused. So we can freeze all vCPUs in the host, then update pvti 1, then resume vCPU 1, then