[PATCH v2 09/15] KVM: MTRR: introduce fixed_mtrr_segment table

2015-06-15 Thread Xiao Guangrong
This table summarizes the information of fixed MTRRs and introduce some APIs to abstract its operation which helps us to clean up the code and will be used in later patches Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 200

[PATCH v2 11/15] KVM: MTRR: sort variable MTRRs

2015-06-15 Thread Xiao Guangrong
Sort all valid variable MTRRs based on its base address, it will help us to check a range to see if it's fully contained in variable MTRRs Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 3 ++ arch/x86/kvm/mtrr.c | 63

[PATCH v2 12/15] KVM: MTRR: introduce fixed_mtrr_addr_* functions

2015-06-15 Thread Xiao Guangrong
Two functions are introduced: - fixed_mtrr_addr_to_seg() translates the address to the fixed MTRR segment - fixed_mtrr_addr_seg_to_range_index() translates the address to the index of kvm_mtrr.fixed_ranges[] They will be used in the later patch Signed-off-by: Xiao Guangrong

[PATCH v2 07/15] KVM: MTRR: do not split 64 bits MSR content

2015-06-15 Thread Xiao Guangrong
Variable MTRR MSRs are 64 bits which are directly accessed with full length, no reason to split them to two 32 bits Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 7 ++- arch/x86/kvm/mtrr.c | 32 ++--

[PATCH v2 13/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-15 Thread Xiao Guangrong
It walks all MTRRs and gets all the memory cache type setting for the specified range also it checks if the range is fully covered by MTRRs Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 188 1 file

[PATCH v2 10/15] KVM: MTRR: introduce var_mtrr_range

2015-06-15 Thread Xiao Guangrong
It gets the range for the specified variable MTRR Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index df73149..cb9702d 100644

[PATCH v2 04/15] KVM: MTRR: remove mtrr_state.have_fixed

2015-06-15 Thread Xiao Guangrong
vMTRR does not depend on any host MTRR feature and fixed MTRRs have always been implemented, so drop this field Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 9 - arch/x86/kvm/mtrr.c | 7 +++ arch/x86/kvm/x86.c

[PATCH v2 03/15] KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr

2015-06-15 Thread Xiao Guangrong
MSR_MTRRcap is a MTRR msr so move the handler to the common place, also add some comments to make the hard code more readable Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 12 arch/x86/kvm/x86.c | 2 -- 2 files changed, 12 insertions(+), 2

[PATCH v2 05/15] KVM: MTRR: exactly define the size of variable MTRRs

2015-06-15 Thread Xiao Guangrong
Only KVM_NR_VAR_MTRR variable MTRRs are available in KVM guest Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h

[PATCH v2 02/15] KVM: x86: move MTRR related code to a separate file

2015-06-15 Thread Xiao Guangrong
MTRR code locates in x86.c and mmu.c so that move them to a separate file to make the organization more clearer and it will be the place where we fully implement vMTRR Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/Makefile

[PATCH v2 01/15] KVM: x86: fix CR0.CD virtualization

2015-06-15 Thread Xiao Guangrong
Currently, CR0.CD is not checked when we virtualize memory cache type for noncoherent_dma guests, this patch fixes it by : - setting UC for all memory if CR0.CD = 1 - zapping all the last sptes in MMU if CR0.CD is changed Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com ---

Re: [PATCH 1/2] arm64: qcom: Add define for ARMv8 implementer (MIDR)

2015-06-15 Thread Catalin Marinas
On Fri, Jun 12, 2015 at 04:57:42PM -0500, Timur Tabi wrote: From: Shanker Donthineni shank...@codeaurora.org This patch adds define for Qualcomm Technologies ARMv8 CPU implementer ID 0x51 and part number for Kryo in asm/cputype.h. Signed-off-by: Shanker Donthineni shank...@codeaurora.org

[PATCH 4/5] kvmtool: Save datamatch as little endian in {add,del}_event

2015-06-15 Thread Andreas Herrmann
W/o dedicated endianess it's impossible to find reliably a match e.g. in kernel/virt/kvm/eventfd.c ioeventfd_in_range. Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com --- ioeventfd.c |5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ioeventfd.c

[PATCH 5/5] kvmtool: Fix length of ioevent for VIRTIO_PCI_QUEUE_NOTIFY

2015-06-15 Thread Andreas Herrmann
VIRTIO_PCI_QUEUE_NOTIFY is 16-bit and iowrite16 is used in drivers/virtio/virtio_pci.c to notify the other side. If the size doesn't match notification via mmio write will fail. Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com --- virtio/pci.c |2 +- 1 file changed, 1

[PATCH 1/5] kvmtool: Fix compile error on MIPS

2015-06-15 Thread Andreas Herrmann
When including asm-generic/types.h instead of asm/types.h it results in conflicting types for __s64 et al (at least with my toolchain). Other header files are including asm/types.h (e.g. include/kvm/ioport.h) and types defined there don't necessarily match the types defined in asm-generic/types.h.

[PATCH 0/5] kvmtool: Misc fixes

2015-06-15 Thread Andreas Herrmann
Hi Will, Following some patches to fix misc issues found when testing the standalone kvmtool version. Please apply. Thanks, Andreas -- 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

[PATCH 2/5] kvmtool: Fix regression introduced with d2a7ddff4

2015-06-15 Thread Andreas Herrmann
Since commit d2a7ddff4 (Add minimal support for macvtap) opening of tap device might fail. lkvm shows Warning: Config tap device error. Are you root? virtio_net_request_tap passed wrong pointer for struct ifreq to TUNSETIFF ioctl. Signed-off-by: Andreas Herrmann

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Marc Zyngier
Hi Mario, I was working on a more ambitious patch series, but we probably ought to start small, and this looks fairly sensible to me. A few minor comments below. On 13/06/15 23:20, Mario Smarduch wrote: Currently VFP/SIMD registers are always saved and restored on Guest entry and exit.

Re: [PATCH] kvmtool: don't use PCI config space IRQ line field

2015-06-15 Thread Andre Przywara
On 06/05/2015 05:41 PM, Will Deacon wrote: On Thu, Jun 04, 2015 at 04:20:45PM +0100, Andre Przywara wrote: Hi Will, sorry, almost forgot about this email... In PCI config space there is an interrupt line field (offset 0x3f), which is used to initially communicate the IRQ line number from

Re: [PATCH v2 6/8] arm: prepare for instantiating different IRQ chip devices

2015-06-15 Thread Andre Przywara
Hi Marc, On 06/10/2015 06:21 PM, Marc Zyngier wrote: On 05/06/15 09:37, Andre Przywara wrote: Extend the vGIC handling code to potentially deal with different IRQ chip devices instead of hard-coding the GICv2 in. We extend most vGIC functions to take a type parameter, but still put GICv2 in

Re: [PATCH v2 7/8] arm: add support for supplying GICv3 redistributor addresses

2015-06-15 Thread Marc Zyngier
On 15/06/15 12:12, Andre Przywara wrote: On 06/10/2015 06:40 PM, Marc Zyngier wrote: On 05/06/15 09:37, Andre Przywara wrote: The code currently is assuming fixed sized memory regions for the distributor and CPU interface. GICv3 needs a dynamic allocation of its redistributor region, since

[PATCH v2 08/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type

2015-06-15 Thread Xiao Guangrong
- kvm_mtrr_get_guest_memory_type() only checks one page in MTRRs so that it's unnecessary to check to see if the range is partially covered in MTRR - optimize the check of overlap memory type and add some comments to explain the precedence Signed-off-by: Xiao Guangrong

[PATCH v2 06/15] KVM: MTRR: clean up mtrr default type

2015-06-15 Thread Xiao Guangrong
Drop kvm_mtrr-enable, omit the decode/code workload and get rid of all the hard code Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/mtrr.c | 40 2 files changed, 29

[PATCH v2 14/15] KVM: MTRR: simplify kvm_mtrr_get_guest_memory_type

2015-06-15 Thread Xiao Guangrong
mtrr_for_each_mem_type() is ready now, use it to simplify kvm_mtrr_get_guest_memory_type() Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/kvm/mtrr.c | 64 ++--- 1 file changed, 16 insertions(+), 48 deletions(-) diff

[PATCH v2 00/15] vMTRR bugfix and optimization

2015-06-15 Thread Xiao Guangrong
Changlog: - let's fix the bugs for noncoherent_dma guests first - these changes are from Paolo's review 1) use inline functions instead of union definition for 'struct kvm_mtrr' 2) improve code style 3) fix fixed_msr_to_range_index which does not return the actual value 4) introduce

[PATCH v2 15/15] KVM: MTRR: do not map huage page for non-consistent range

2015-06-15 Thread Xiao Guangrong
Based on Intel's SDM, mapping huge page which do not have consistent memory cache for each 4k page will cause undefined behavior In order to avoiding this kind of undefined behavior, we force to use 4k pages under this case Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com ---

Re: [PATCH v2 7/8] arm: add support for supplying GICv3 redistributor addresses

2015-06-15 Thread Andre Przywara
On 06/10/2015 06:40 PM, Marc Zyngier wrote: On 05/06/15 09:37, Andre Przywara wrote: The code currently is assuming fixed sized memory regions for the distributor and CPU interface. GICv3 needs a dynamic allocation of its redistributor region, since its size depends on the number of vCPUs.

[PATCH 3/5] kvmtool: Register each guest memory bank as vhost_memory_region

2015-06-15 Thread Andreas Herrmann
Otherwise vhost does not work if a virtio descriptor is used that was allocated from a guest memory bank not registered as vhost_memory_region. Signed-off-by: Andreas Herrmann andreas.herrm...@caviumnetworks.com --- virtio/net.c | 21 + 1 file changed, 13 insertions(+), 8

Re: [PATCH 1/2] kvm/x86: Hyper-V based guest crash data handling

2015-06-15 Thread Andrey Smetanin
Hi Peter, thank you for comments. See answers below. On Fri, 2015-06-12 at 16:03 -0700, Peter Hornyack wrote: Hi Denis, Andrey, I have a few comments and questions. (re-sending in plain-text mode, apologies for sending twice.) On Thu, Jun 11, 2015 at 6:18 AM, Denis V. Lunev d...@openvz.org

Re: [PATCH 06/10] KVM: arm/arm64: vgic: Allow dynamic mapping of physical/virtual interrupts

2015-06-15 Thread Eric Auger
Hi Marc, On 06/08/2015 07:04 PM, Marc Zyngier wrote: In order to be able to feed physical interrupts to a guest, we need to be able to establish the virtual-physical mapping between the two worlds. The mapping is kept in a rbtree, indexed by virtual interrupts. Signed-off-by: Marc Zyngier

RE: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding

2015-06-15 Thread Wu, Feng
-Original Message- From: Alex Williamson [mailto:alex.william...@redhat.com] Sent: Saturday, June 13, 2015 3:04 AM To: Avi Kivity Cc: Wu, Feng; kvm@vger.kernel.org; linux-ker...@vger.kernel.org; pbonz...@redhat.com; mtosa...@redhat.com; eric.au...@linaro.org Subject: Re: [v4

[RFC PATCH] perf/kvm: Guest Symbol Resolution for powerpc

2015-06-15 Thread Hemant Kumar
perf kvm {record|report} is used to record and report the performance profile of any workload on a guest. From the host, we can collect guest kernel statistics which is useful in finding out any contentions in guest kernel symbols for a certain workload. This feature is not available on powerpc

[PATCH v4 4/4] KVM: x86: Add support for local interrupt requests from userspace

2015-06-15 Thread Steve Rutherford
In order to enable userspace PIC support, the userspace PIC needs to be able to inject local interrupt requests. This adds the ioctl KVM_REQUEST_PIC_INJECTION and kvm exit KVM_EXIT_GET_EXTINT. The vm ioctl KVM_REQUEST_PIC_INJECTION makes a KVM_REQ_EVENT request on the BSP, which causes the BSP

[PATCH v4 2/4] KVM: x86: Add KVM exit for IOAPIC EOIs

2015-06-15 Thread Steve Rutherford
Adds KVM_EXIT_IOAPIC_EOI which allows the kernel to EOI level-triggered IOAPIC interrupts. Uses a per VCPU exit bitmap to decide whether or not the IOAPIC needs to be informed (which is identical to the EOI_EXIT_BITMAP field used by modern x86 processors, but can also be used to elide kvm IOAPIC

[PATCH v4 1/4] KVM: x86: Split the APIC from the rest of IRQCHIP.

2015-06-15 Thread Steve Rutherford
First patch in a series which enables the relocation of the PIC/IOAPIC to userspace. Adds capability KVM_CAP_SPLIT_IRQCHIP; KVM_CAP_SPLIT_IRQCHIP enables the construction of LAPICs without the rest of the irqchip. Compile tested for x86. Signed-off-by: Steve Rutherford srutherf...@google.com

[PATCH v4 3/4] KVM: x86: Add EOI exit bitmap inference

2015-06-15 Thread Steve Rutherford
In order to support a userspace IOAPIC interacting with an in kernel APIC, the EOI exit bitmaps need to be configurable. If the IOAPIC is in userspace (i.e. the irqchip has been split), the EOI exit bitmaps will be set whenever the GSI Routes are configured. In particular, for the low MSI routes

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Mario Smarduch
On 06/15/2015 11:20 AM, Marc Zyngier wrote: On 15/06/15 19:04, Mario Smarduch wrote: On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, [ ... ] On 13/06/15 23:20, Mario Smarduch wrote: Currently VFP/SIMD registers are always saved and restored on Guest entry and exit. This patch only

[PATCH 0/7] userfault21 update

2015-06-15 Thread Andrea Arcangeli
This is an incremental update to the userfaultfd code in -mm. This fixes two bugs that could cause some malfunction (but nothing that could cause memory corruption or kernel crashes of any sort, neither in kernel nor userland). This also introduces some enhancement: gdb now runs fine, signals

[PATCH 3/7] userfaultfd: allow signals to interrupt a userfault

2015-06-15 Thread Andrea Arcangeli
This is only simple to achieve if the userfault is going to return to userland (not to the kernel) because we can avoid returning VM_FAULT_RETRY despite we temporarily released the mmap_sem. The fault would just be retried by userland then. This is safe at least on x86 and powerpc (the two archs

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Marc Zyngier
On 15/06/15 19:44, Mario Smarduch wrote: On 06/15/2015 11:20 AM, Marc Zyngier wrote: On 15/06/15 19:04, Mario Smarduch wrote: On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, I was working on a more ambitious patch series, but we probably ought to start small, and this looks fairly

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Mario Smarduch
On 06/15/2015 11:51 AM, Marc Zyngier wrote: On 15/06/15 19:44, Mario Smarduch wrote: On 06/15/2015 11:20 AM, Marc Zyngier wrote: On 15/06/15 19:04, Mario Smarduch wrote: On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, [...] The 32bit code is starting to show its age, and could

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Mario Smarduch
On 06/15/2015 11:20 AM, Marc Zyngier wrote: On 15/06/15 19:04, Mario Smarduch wrote: On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, I was working on a more ambitious patch series, but we probably ought to start small, and this looks fairly sensible to me. Hi Marc, thanks for

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Mario Smarduch
On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, I was working on a more ambitious patch series, but we probably ought to start small, and this looks fairly sensible to me. Hi Marc, thanks for reviewing, I was thinking to post this first and next iteration on guest access switch

Re: [PATCH] arm64: KVM: Optimize arm64 guest exit VFP/SIMD register save/restore

2015-06-15 Thread Marc Zyngier
On 15/06/15 19:04, Mario Smarduch wrote: On 06/15/2015 03:00 AM, Marc Zyngier wrote: Hi Mario, I was working on a more ambitious patch series, but we probably ought to start small, and this looks fairly sensible to me. Hi Marc, thanks for reviewing, I was thinking to post this first

[PATCH 6/7] userfaultfd: Revert userfaultfd: waitqueue: add nr wake parameter to __wake_up_locked_key

2015-06-15 Thread Andrea Arcangeli
This reverts commit 855c5a9026b0fce58c8de5382ef8ce00f74c1331 and adapts fs/userfaultfd.c to use the old version of that function. It didn't look robust to call __wake_up_common with nr == 1 when we absolutely require wakeall semantics, but we've full control of what we insert in the two waitqueue

Re: [PATCH 07/10] KVM: arm/arm64: vgic: Allow HW interrupts to be queued to a guest

2015-06-15 Thread Eric Auger
On 06/11/2015 12:02 PM, Marc Zyngier wrote: On 11/06/15 10:44, Andre Przywara wrote: On 06/11/2015 10:15 AM, Marc Zyngier wrote: On 11/06/15 09:44, Andre Przywara wrote: On 06/08/2015 06:04 PM, Marc Zyngier wrote: ... @@ -1344,6 +1364,35 @@ static bool vgic_process_maintenance(struct

Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding

2015-06-15 Thread Eric Auger
Hi Alex, all, On 06/12/2015 09:03 PM, Alex Williamson wrote: On Fri, 2015-06-12 at 21:48 +0300, Avi Kivity wrote: On 06/12/2015 06:41 PM, Alex Williamson wrote: On Fri, 2015-06-12 at 00:23 +, Wu, Feng wrote: -Original Message- From: Avi Kivity [mailto:avi.kiv...@gmail.com] Sent:

[PATCH 2/7] userfaultfd: propagate the full address in THP faults

2015-06-15 Thread Andrea Arcangeli
The THP faults were not propagating the original fault address. The latest version of the API with uffd.arg.pagefault.address is supposed to propagate the full address through THP faults. This was not a kernel crashing bug and it wouldn't risk to corrupt user memory, but it would cause a SIGBUS

[PATCH 7/7] userfaultfd: selftest

2015-06-15 Thread Andrea Arcangeli
This test allocates two virtual areas and bounces the physical memory across the two virtual areas using only userfaultfd. This exposed a race condition in the refile of the userfault in userfaultfd_read and an alignment issue with the address returned to userland with THP enabled. It also

[PATCH 4/7] userfaultfd: avoid missing wakeups during refile in userfaultfd_read

2015-06-15 Thread Andrea Arcangeli
During the refile in userfaultfd_read both waitqueues could look empty to the lockless wake_userfault(). Use a seqcount to prevent this false negative that could leave an userfault blocked. Signed-off-by: Andrea Arcangeli aarca...@redhat.com --- fs/userfaultfd.c | 26 --

[PATCH 5/7] userfaultfd: switch to exclusive wakeup for blocking reads

2015-06-15 Thread Andrea Arcangeli
Blocking reads can easily use exclusive wakeups. Poll in theory could too but there's no poll_wait_exclusive in common code yet. If a poll() non-exclusive waitqueue is encountered before the exclusive readblocking waitqueue, then everything will be waken. If a read exclusive waitqueue is

[PATCH 1/7] userfaultfd: require UFFDIO_API before other ioctls

2015-06-15 Thread Andrea Arcangeli
UFFDIO_API was already forced before read/poll could work. This makes the code more strict to force it also for all other ioctls. All users would already have been required to call UFFDIO_API before invoking other ioctls but this makes it more explicit. This will ensure we can change all ioctls

Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding

2015-06-15 Thread Alex Williamson
On Mon, 2015-06-15 at 18:17 +0200, Eric Auger wrote: Hi Alex, all, On 06/12/2015 09:03 PM, Alex Williamson wrote: On Fri, 2015-06-12 at 21:48 +0300, Avi Kivity wrote: On 06/12/2015 06:41 PM, Alex Williamson wrote: On Fri, 2015-06-12 at 00:23 +, Wu, Feng wrote: -Original

Re: [PATCH 1/7] userfaultfd: require UFFDIO_API before other ioctls

2015-06-15 Thread Andrea Arcangeli
On Mon, Jun 15, 2015 at 08:11:50AM -1000, Linus Torvalds wrote: On Jun 15, 2015 7:22 AM, Andrea Arcangeli aarca...@redhat.com wrote: + if (cmd != UFFDIO_API) { + if (ctx-state == UFFD_STATE_WAIT_API) + return -EINVAL; +

Re: [PATCH 5/7] userfaultfd: switch to exclusive wakeup for blocking reads

2015-06-15 Thread Andrea Arcangeli
On Mon, Jun 15, 2015 at 08:19:07AM -1000, Linus Torvalds wrote: What if the process doing the polling never doors anything with the end result? Maybe it meant to, but it got killed before it could? Are you going to leave everybody else blocked, even though there are pending events? Yes, it