Re: [RFC PATCH 2/2] vfio: Include no-iommu mode

2015-10-11 Thread Gleb Natapov
On Sun, Oct 11, 2015 at 12:19:54PM +0300, Michael S. Tsirkin wrote: > > But since you must pass the same value to open(), you already know that > > you're using noiommu. > > > > >VFIO_IOMMU_MAP_DMA, VFIO_IOMMU_ENABLE and VFIO_IOMMU_DISABLE > > >will probably also fail ... > > > > > > > Don't you

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 11:32:50AM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 08:33:45AM +0300, Avi Kivity wrote: > > On 08/10/15 00:05, Michael S. Tsirkin wrote: > > >On Wed, Oct 07, 2015 at 07:39:16PM +0300, Avi Kivity wrote: > > >>That's what I thought as well, but apparently

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 10:41:53AM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 07:19:13AM +0300, Gleb Natapov wrote: > > Well > > the alternative is to add /dev/vfio/nommu like you've said, but what > > would be the difference between this and uio eludes me.

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 12:38:28PM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 10:59:10AM +0300, Gleb Natapov wrote: > > I do not remember this been an issue when uio_generic was accepted > > into the kernel. The reason was because it meant to be accessible b

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 03:06:07PM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 12:44:09PM +0300, Avi Kivity wrote: > > > > > > On 10/08/2015 12:16 PM, Michael S. Tsirkin wrote: > > >On Thu, Oct 08, 2015 at 11:46:30AM +0300, Avi Kivity wrote: > > >> > > >>On 10/08/2015 10:32 AM,

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 04:20:04PM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 03:27:37PM +0300, Gleb Natapov wrote: > > On Thu, Oct 08, 2015 at 03:06:07PM +0300, Michael S. Tsirkin wrote: > > > On Thu, Oct 08, 2015 at 12:44:09PM +0300

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 07:43:04PM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 04:28:34PM +0300, Gleb Natapov wrote: > > On Thu, Oct 08, 2015 at 04:20:04PM +0300, Michael S. Tsirkin wrote: > > > On Thu, Oct 08, 2015 at 03:27:37PM +0300, Gleb Natapov wrote: >

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-08 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 08:39:10PM +0300, Michael S. Tsirkin wrote: > On Thu, Oct 08, 2015 at 08:01:21PM +0300, Gleb Natapov wrote: > > On Thu, Oct 08, 2015 at 07:43:04PM +0300, Michael S. Tsirkin wrote: > > > On Thu, Oct 08, 2015 at 04:28:34PM +0300, Gleb Natapov wrote: >

Re: [PATCH v3 2/3] uio_pci_generic: add MSI/MSI-X support

2015-10-07 Thread Gleb Natapov
On Thu, Oct 08, 2015 at 12:05:11AM +0300, Michael S. Tsirkin wrote: > On Wed, Oct 07, 2015 at 07:39:16PM +0300, Avi Kivity wrote: > > That's what I thought as well, but apparently adding msix support to the > > already insecure uio drivers is even worse. > > I'm glad you finally agree what these

Re: [PATCH v3 1/3] uio: add ioctl support

2015-10-06 Thread Gleb Natapov
On Tue, Oct 06, 2015 at 05:19:22PM +0300, Michael S. Tsirkin wrote: > On Tue, Oct 06, 2015 at 11:33:56AM +0300, Vlad Zolotarov wrote: > > the solution u propose should be a matter of a separate patch and is > > obviously orthogonal to this series. > > Doesn't work this way, sorry. You want a

Re: [PATCH v3 1/3] uio: add ioctl support

2015-10-06 Thread Gleb Natapov
On Tue, Oct 06, 2015 at 06:19:34PM +0300, Michael S. Tsirkin wrote: > On Tue, Oct 06, 2015 at 05:30:31PM +0300, Gleb Natapov wrote: > > On Tue, Oct 06, 2015 at 05:19:22PM +0300, Michael S. Tsirkin wrote: > > > On Tue, Oct 06, 2015 at 11:33:56AM +0300, Vlad Zolotarov wrote: >

Re: [PATCH v3 0/3] uio: add MSI/MSI-X support to uio_pci_generic driver

2015-10-06 Thread Gleb Natapov
On Tue, Oct 06, 2015 at 06:15:54PM +0300, Michael S. Tsirkin wrote: > > While it is possible that userspace malfunctions and accidentally programs > > MSI incorrectly, the risk is dwarfed by the ability of userspace to program > > DMA incorrectly. > > That seems to imply that for the upstream

Re: [PATCH] KVM: ia64: remove

2014-11-19 Thread Gleb Natapov
On Wed, Nov 19, 2014 at 10:05:43PM +0100, Paolo Bonzini wrote: KVM for ia64 has been marked as broken not just once, but twice even, and the last patch from the maintainer is now roughly 5 years old. Time for it to rest in piece. Acked-by: Gleb Natapov g...@kernel.org Next step is to move

Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls

2014-09-23 Thread Gleb Natapov
On Mon, Sep 22, 2014 at 09:29:19PM +0200, Paolo Bonzini wrote: Il 22/09/2014 21:20, Christian Borntraeger ha scritto: while using trinity to fuzz KVM, we noticed long stalls on invalid ioctls. Lets bail out early on invalid ioctls. or similar? Okay. David, can you explain how you found

Re: [PATCH v2] kvm: Faults which trigger IO release the mmap_sem

2014-09-18 Thread Gleb Natapov
On Thu, Sep 18, 2014 at 08:29:17AM +0800, Wanpeng Li wrote: Hi Andres, On Wed, Sep 17, 2014 at 10:51:48AM -0700, Andres Lagar-Cavilla wrote: [...] static inline int check_user_page_hwpoison(unsigned long addr) { int rc, flags = FOLL_TOUCH | FOLL_HWPOISON | FOLL_WRITE; @@ -1177,9

Re: [PATCH v2] kvm: Faults which trigger IO release the mmap_sem

2014-09-18 Thread Gleb Natapov
on the IO. This is a bad thing, as other mmap semaphore users now stall as a function of swap or filemap latency. This patch ensures both the regular and async PF path re-enter the fault allowing for the mmap semaphore to be relinquished in the case of IO wait. Reviewed-by: Gleb Natapov g

Re: [PATCH] kvm: Faults which trigger IO release the mmap_sem

2014-09-17 Thread Gleb Natapov
On Mon, Sep 15, 2014 at 01:11:25PM -0700, Andres Lagar-Cavilla wrote: When KVM handles a tdp fault it uses FOLL_NOWAIT. If the guest memory has been swapped out or is behind a filemap, this will trigger async readahead and return immediately. The rationale is that KVM will kick back the guest

Re: [PATCH] kvm: Faults which trigger IO release the mmap_sem

2014-09-17 Thread Gleb Natapov
On Wed, Sep 17, 2014 at 01:27:14PM +0200, Radim Krčmář wrote: 2014-09-17 13:26+0300, Gleb Natapov: For async_pf_execute() you do not need to even retry. Next guest's page fault will retry it for you. Wouldn't that be a waste of vmentries? This is how it will work with or without

Re: [PATCH] kvm: Faults which trigger IO release the mmap_sem

2014-09-17 Thread Gleb Natapov
On Wed, Sep 17, 2014 at 10:00:32AM -0700, Andres Lagar-Cavilla wrote: On Wed, Sep 17, 2014 at 4:42 AM, Gleb Natapov g...@kernel.org wrote: On Wed, Sep 17, 2014 at 01:27:14PM +0200, Radim Krčmář wrote: 2014-09-17 13:26+0300, Gleb Natapov: For async_pf_execute() you do not need to even retry

Re: [PATCH] kvm: Faults which trigger IO release the mmap_sem

2014-09-17 Thread Gleb Natapov
On Wed, Sep 17, 2014 at 10:13:45AM -0700, Andres Lagar-Cavilla wrote: On Wed, Sep 17, 2014 at 10:08 AM, Gleb Natapov g...@kernel.org wrote: On Wed, Sep 17, 2014 at 10:00:32AM -0700, Andres Lagar-Cavilla wrote: On Wed, Sep 17, 2014 at 4:42 AM, Gleb Natapov g...@kernel.org wrote: On Wed, Sep

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 11:21:49AM +0200, Paolo Bonzini wrote: Il 11/09/2014 07:38, Tang Chen ha scritto: diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 63c4c3e..da6d55d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7093,6 +7093,11 @@ static void

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 12:47:16PM +0200, Paolo Bonzini wrote: Il 11/09/2014 12:12, Gleb Natapov ha scritto: On Thu, Sep 11, 2014 at 11:21:49AM +0200, Paolo Bonzini wrote: Il 11/09/2014 07:38, Tang Chen ha scritto: diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 63c4c3e

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 03:05:05PM +0200, Paolo Bonzini wrote: Il 11/09/2014 13:30, Gleb Natapov ha scritto: +vmcs_write64(APIC_ACCESS_ADDR, page_to_phys(page)); +/* + * Do not pin apic access page in memory so

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:06:58PM +0200, Paolo Bonzini wrote: Il 11/09/2014 15:59, Gleb Natapov ha scritto: Suppose vmcs01-APIC_ACCESS_ADDR = 0xf000. During L2 entry vmcs02-APIC_ACCESS_ADDR is set to 0xf000 too (by prepare_vmcs02). Now 0xf000 is migrated to 0x8000, mmu notifier

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:24:04PM +0200, Paolo Bonzini wrote: Il 11/09/2014 16:21, Gleb Natapov ha scritto: As far as I can tell the if that is needed there is: if (!is_guest_mode() || !(vmcs12-secondary_vm_exec_control ECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) write

Re: [PATCH v5 4/7] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-11 Thread Gleb Natapov
On Thu, Sep 11, 2014 at 04:37:39PM +0200, Paolo Bonzini wrote: Il 11/09/2014 16:31, Gleb Natapov ha scritto: What if the page being swapped out is L1's APIC access page? We don't run prepare_vmcs12 in that case because it's an L2-L0-L2 entry, so we need to do something. We will do

Re: [PATCH v4 1/6] kvm: Use APIC_DEFAULT_PHYS_BASE macro as the apic access page address.

2014-09-10 Thread Gleb Natapov
On Wed, Aug 27, 2014 at 06:17:36PM +0800, Tang Chen wrote: We have APIC_DEFAULT_PHYS_BASE defined as 0xfee0, which is also the address of apic access page. So use this macro. Reviewed-by: Gleb Natapov g...@kernel.org Signed-off-by: Tang Chen tangc...@cn.fujitsu.com --- arch/x86/kvm

Re: [PATCH v4 2/6] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-09-10 Thread Gleb Natapov
, it cannot be migrated/hot-removed. After this patch, since kvm_arch-ept_identity_pagetable is removed, ept identity pagetable page is no longer pinned in memory. And it can be migrated/hot-removed. Reviewed-by: Gleb Natapov g...@kernel.org Signed-off-by: Tang Chen tangc

Re: [PATCH v4 4/6] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-10 Thread Gleb Natapov
On Tue, Sep 09, 2014 at 03:13:07PM +0800, tangchen wrote: Hi Gleb, On 09/03/2014 11:04 PM, Gleb Natapov wrote: On Wed, Sep 03, 2014 at 09:42:30AM +0800, tangchen wrote: Hi Gleb, On 09/03/2014 12:00 AM, Gleb Natapov wrote: .. +static void vcpu_reload_apic_access_page(struct kvm_vcpu

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-05 Thread Gleb Natapov
On Thu, Sep 04, 2014 at 07:44:51PM +0200, Paolo Bonzini wrote: Il 04/09/2014 17:05, Gleb Natapov ha scritto: If you do that, KVM gets down to the if (writeback) and writes the ctxt-eip from L2 into the L1 EIP. Heh, that's a bummer. We should not write back if an instruction caused

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Gleb Natapov
On Tue, Sep 02, 2014 at 05:13:49PM +0200, Paolo Bonzini wrote: This is required for the following patch to work correctly. If a nested page fault happens during emulation, we must inject a vmexit, not a page fault. Luckily we already have the required machinery: it is enough to return

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Gleb Natapov
On Thu, Sep 04, 2014 at 04:12:19PM +0200, Paolo Bonzini wrote: Il 04/09/2014 09:02, Gleb Natapov ha scritto: On Tue, Sep 02, 2014 at 05:13:49PM +0200, Paolo Bonzini wrote: This is required for the following patch to work correctly. If a nested page fault happens during emulation, we

Re: [PATCH v4 5/6] kvm, mem-hotplug: Reload L1's apic access page on migration when L2 is running.

2014-09-03 Thread Gleb Natapov
On Wed, Aug 27, 2014 at 06:17:40PM +0800, Tang Chen wrote: This patch only handle L1 and L2 vm share one apic access page situation. When L1 vm is running, if the shared apic access page is migrated, mmu_notifier will request all vcpus to exit to L0, and reload apic access page physical

Re: [PATCH v4 4/6] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-03 Thread Gleb Natapov
On Wed, Sep 03, 2014 at 09:42:30AM +0800, tangchen wrote: Hi Gleb, On 09/03/2014 12:00 AM, Gleb Natapov wrote: .. +static void vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) +{ +/* + * apic access page could be migrated. When the page is being migrated, + * GUP

Re: [PATCH v4 4/6] kvm, mem-hotplug: Reload L1' apic access page on migration in vcpu_enter_guest().

2014-09-02 Thread Gleb Natapov
On Wed, Aug 27, 2014 at 06:17:39PM +0800, Tang Chen wrote: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When the page is migrated,

Re: GET_RNG_SEED hypercall ABI? (Re: [PATCH v5 0/5] random,x86,kvm: Rework arch RNG seeds and get some from kvm)

2014-08-28 Thread Gleb Natapov
On Tue, Aug 26, 2014 at 04:58:34PM -0700, Andy Lutomirski wrote: hpa pointed out that the ABI that I chose (an MSR from the KVM range and a KVM cpuid bit) is unnecessarily KVM-specific. It would be nice to allocate an MSR that everyone involved can agree on and, rather than relying on a cpuid

Re: [PATCH] KVM-Use value reading from MSR when construct the eptp in VMX mode

2014-08-25 Thread Gleb Natapov
On Mon, Aug 25, 2014 at 11:16:34AM +0800, Dennis Chen wrote: On Sun, Aug 24, 2014 at 5:38 PM, Gleb Natapov g...@kernel.org wrote: On Sun, Aug 24, 2014 at 11:54:32AM +0800, Dennis Chen wrote: This patch is used to construct the eptp in vmx mode with values readed from MSR according

Re: [PATCH] KVM-Use value reading from MSR when construct the eptp in VMX mode

2014-08-24 Thread Gleb Natapov
On Sun, Aug 24, 2014 at 11:54:32AM +0800, Dennis Chen wrote: This patch is used to construct the eptp in vmx mode with values readed from MSR according to the intel x86 software developer's manual. Signed-off-by: Dennis Chen kernel.org@gmail.com --- arch/x86/include/asm/vmx.h |1 +

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-18 Thread Gleb Natapov
On Fri, Jul 18, 2014 at 05:05:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/17/2014 09:57 PM, Gleb Natapov wrote: On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-17 Thread Gleb Natapov
On Thu, Jul 17, 2014 at 09:34:20PM +0800, Tang Chen wrote: Hi Gleb, On 07/15/2014 08:40 PM, Gleb Natapov wrote: .. And yes, we have the problem you said here. We can migrate the page while L2 vm is running. So I think we should enforce L2 vm to exit to L1. Right ? We can request

Re: [PATCH 0/4] random,x86,kvm: Add and use MSR_KVM_GET_RNG_SEED

2014-07-16 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 07:48:06PM -0700, Andy Lutomirski wrote: virtio-rng is both too complicated and insufficient for initial rng seeding. It's far too complicated to use for KASLR or any other early boot random number needs. It also provides /dev/random-style bits, which means that

Re: [PATCH 0/4] random,x86,kvm: Add and use MSR_KVM_GET_RNG_SEED

2014-07-16 Thread Gleb Natapov
On Wed, Jul 16, 2014 at 09:10:27AM +0200, Daniel Borkmann wrote: On 07/16/2014 08:41 AM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 07:48:06PM -0700, Andy Lutomirski wrote: virtio-rng is both too complicated and insufficient for initial rng seeding. It's far too complicated to use for KASLR

Re: [PATCH 0/4] random,x86,kvm: Add and use MSR_KVM_GET_RNG_SEED

2014-07-16 Thread Gleb Natapov
On Wed, Jul 16, 2014 at 04:32:19PM +0200, Paolo Bonzini wrote: Il 16/07/2014 16:07, Andy Lutomirski ha scritto: This patch has nothing whatsoever to do with how much I trust the CPU vs the hypervisor. It's for the enormous installed base of machines without RDRAND. Ok. I think an MSR is

Re: [PATCH 0/4] random,x86,kvm: Add and use MSR_KVM_GET_RNG_SEED

2014-07-16 Thread Gleb Natapov
On Wed, Jul 16, 2014 at 09:13:23AM -0700, H. Peter Anvin wrote: On 07/16/2014 09:08 AM, Paolo Bonzini wrote: Il 16/07/2014 18:03, H. Peter Anvin ha scritto: I suggested emulating RDRAND *but not set the CPUID bit*. We already developed a protocol in KVM/Qemu to enumerate emulated features

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: On 2014-07-14 16:58, Gleb Natapov wrote: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ffbe557..7080eda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5929,6 +5929,18 @@ static void vcpu_scan_ioapic

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow your concerns yet. Specifically, how should APIC_ACCESS_ADDR (the VMCS field, right?) change while L2

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 03:10:15PM +0200, Jan Kiszka wrote: On 2014-07-15 14:40, Gleb Natapov wrote: .. 7922 if (!vmx-nested.apic_access_page) 7923 exec_control = 7924 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; 7925

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-15 Thread Gleb Natapov
On Tue, Jul 15, 2014 at 08:54:01PM +0800, Tang Chen wrote: On 07/15/2014 08:40 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 08:28:22PM +0800, Tang Chen wrote: On 07/15/2014 08:09 PM, Gleb Natapov wrote: On Tue, Jul 15, 2014 at 01:52:40PM +0200, Jan Kiszka wrote: .. I cannot follow

Re: [RESEND PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-14 Thread Gleb Natapov
On Mon, Jul 14, 2014 at 05:17:04PM +0800, Tang Chen wrote: On 07/12/2014 03:44 PM, Gleb Natapov wrote: On Wed, Jul 09, 2014 at 10:08:03AM +0800, Tang Chen wrote: kvm_arch-ept_identity_pagetable holds the ept identity pagetable page. But it is never used to refer to the page at all. In vcpu

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-14 Thread Gleb Natapov
CCing Jan to check my nested kvm findings below. On Mon, Jul 14, 2014 at 03:57:09PM +0800, Tang Chen wrote: Hi Gleb, Thanks for the reply. Please see below. On 07/12/2014 04:04 PM, Gleb Natapov wrote: On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned

Re: [RESEND PATCH v2 4/5] kvm: Remove ept_identity_pagetable from struct kvm_arch.

2014-07-12 Thread Gleb Natapov
On Wed, Jul 09, 2014 at 10:08:03AM +0800, Tang Chen wrote: kvm_arch-ept_identity_pagetable holds the ept identity pagetable page. But it is never used to refer to the page at all. In vcpu initialization, it indicates two things: 1. indicates if ept page is allocated 2. indicates if a memory

Re: [PATCH v2 5/5] kvm, mem-hotplug: Do not pin apic access page in memory.

2014-07-12 Thread Gleb Natapov
On Tue, Jul 08, 2014 at 09:01:32PM +0800, Tang Chen wrote: apic access page is pinned in memory. As a result, it cannot be migrated/hot-removed. Actually, it is not necessary to be pinned. The hpa of apic access page is stored in VMCS APIC_ACCESS_ADDR pointer. When the page is migrated,

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-07 Thread Gleb Natapov
On Mon, Jul 07, 2014 at 02:42:27PM +0300, Nadav Amit wrote: Tang, Running some (unrelated) tests I see that KVM does not handle APIC base relocation correctly. When the base is changed, kvm_lapic_set_base just changes lapic-base_address without taking further action (i.e., modifying the

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-07 Thread Gleb Natapov
On Mon, Jul 07, 2014 at 03:10:23PM +0300, Nadav Amit wrote: On 7/7/14, 2:54 PM, Gleb Natapov wrote: On Mon, Jul 07, 2014 at 02:42:27PM +0300, Nadav Amit wrote: Tang, Running some (unrelated) tests I see that KVM does not handle APIC base relocation correctly. When the base is changed

Re: [PATCH] x86: Make x2APIC support depend on interrupt remapping or guest support

2014-07-06 Thread Gleb Natapov
On Sat, Jul 05, 2014 at 09:47:54AM +0200, Jan Kiszka wrote: From: Jan Kiszka jan.kis...@siemens.com We are able to use x2APIC mode in the absence of interrupt remapping on certain hypervisors. So it if fine to disable IRQ_REMAP without having to give up x2APIC support. FWIW I did similar

Re: [PATCH] x86: Make x2APIC support depend on interrupt remapping or guest support

2014-07-06 Thread Gleb Natapov
On Sun, Jul 06, 2014 at 05:24:27PM +0200, Jan Kiszka wrote: On 2014-07-06 17:12, Gleb Natapov wrote: On Sat, Jul 05, 2014 at 09:47:54AM +0200, Jan Kiszka wrote: From: Jan Kiszka jan.kis...@siemens.com We are able to use x2APIC mode in the absence of interrupt remapping on certain

Re: [PATCH] x86: Make x2APIC support depend on interrupt remapping or guest support

2014-07-06 Thread Gleb Natapov
On Sun, Jul 06, 2014 at 05:49:09PM +0200, Jan Kiszka wrote: On 2014-07-06 17:41, Gleb Natapov wrote: On Sun, Jul 06, 2014 at 05:24:27PM +0200, Jan Kiszka wrote: On 2014-07-06 17:12, Gleb Natapov wrote: On Sat, Jul 05, 2014 at 09:47:54AM +0200, Jan Kiszka wrote: From: Jan Kiszka jan.kis

Re: [PATCH 3/4] kvm, memory-hotplug: Update ept identity pagetable when it is migrated.

2014-07-04 Thread Gleb Natapov
On Fri, Jul 04, 2014 at 10:36:06AM +0800, Tang Chen wrote: Hi Gleb, On 07/03/2014 12:34 AM, Gleb Natapov wrote: On Wed, Jul 02, 2014 at 05:00:36PM +0800, Tang Chen wrote: ept identity pagetable is pinned in memory, and as a result it cannot be migrated/hot-removed. But actually

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-04 Thread Gleb Natapov
On Fri, Jul 04, 2014 at 10:18:25AM +0800, Tang Chen wrote: Hi Gleb, Thanks for the advices. Please see below. On 07/03/2014 09:55 PM, Gleb Natapov wrote: .. @@ -575,6 +575,7 @@ struct kvm_arch { unsigned int tss_addr; struct page *apic_access_page; + bool

Re: [PATCH 0/4] kvm, mem-hotplug: Do not pin ept identity pagetable and apic access page.

2014-07-03 Thread Gleb Natapov
On Thu, Jul 03, 2014 at 09:17:59AM +0800, Tang Chen wrote: Hi Gleb, On 07/02/2014 05:00 PM, Tang Chen wrote: Hi Gleb, Marcelo, Please help to review this patch-set. NOTE: This patch-set doesn't work properly. ept identity pagetable and apic access page in kvm are pinned in memory.

Re: [PATCH 4/4] kvm, mem-hotplug: Update apic access page when it is migrated.

2014-07-03 Thread Gleb Natapov
On Wed, Jul 02, 2014 at 05:00:37PM +0800, Tang Chen wrote: apic access page is pinned in memory, and as a result it cannot be migrated/hot-removed. Actually it doesn't need to be pinned in memory. This patch introduces a new vcpu request: KVM_REQ_MIGRATE_EPT. This requet will be made when

Re: [PATCH 2/4] kvm: Add macro VMX_APIC_ACCESS_PAGE_ADDR

2014-07-02 Thread Gleb Natapov
On Wed, Jul 02, 2014 at 05:00:35PM +0800, Tang Chen wrote: Define guest phys_addr of apic access page. --- arch/x86/include/asm/vmx.h | 2 +- arch/x86/kvm/svm.c | 3 ++- arch/x86/kvm/vmx.c | 7 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git

Re: [PATCH 3/4] kvm, memory-hotplug: Update ept identity pagetable when it is migrated.

2014-07-02 Thread Gleb Natapov
On Wed, Jul 02, 2014 at 05:00:36PM +0800, Tang Chen wrote: ept identity pagetable is pinned in memory, and as a result it cannot be migrated/hot-removed. But actually it doesn't need to be pinned in memory. This patch introduces a new vcpu request: KVM_REQ_MIGRATE_EPT to reset ept

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-30 Thread Gleb Natapov
On Mon, Jun 30, 2014 at 09:45:32AM +0800, Tang Chen wrote: On 06/21/2014 04:39 AM, Marcelo Tosatti wrote: On Fri, Jun 20, 2014 at 05:31:46PM -0300, Marcelo Tosatti wrote: IIRC your shadow page pinning patch series support flushing of ptes by mmu notifier by forcing MMU reload and, as a result,

Re: [PATCH] KVM: x86: Pending interrupt may be delivered after INIT

2014-06-30 Thread Gleb Natapov
On Mon, Jun 30, 2014 at 11:35:27AM +0300, Nadav Amit wrote: We encountered a scenario in which after an INIT is delivered, a pending interrupt is delivered, although it was sent before the INIT. As the SDM states in section 10.4.7.1, the ISR and the IRR should be cleared after INIT as KVM

Re: [PATCH] KVM: SVM: Fix CPL export via SS.DPL

2014-06-30 Thread Gleb Natapov
On Mon, Jun 30, 2014 at 05:15:44PM +0200, Borislav Petkov wrote: On Mon, Jun 30, 2014 at 05:03:57PM +0200, Jan Kiszka wrote: 15.5.1: When examining segment attributes after a #VMEXIT: [...] • Retrieve the CPL from the CPL field in the VMCB, not from any segment DPL. Heey, it is

Re: __schedule #DF splat

2014-06-29 Thread Gleb Natapov
On Sat, Jun 28, 2014 at 01:44:31PM +0200, Borislav Petkov wrote: qemu-system-x86-20240 [006] ...1 9406.484134: kvm_page_fault: address 7fffb62ba318 error_code 2 qemu-system-x86-20240 [006] ...1 9406.484136: kvm_inj_exception: #PF (0x2)a kvm injects the #PF into the guest.

Re: __schedule #DF splat

2014-06-29 Thread Gleb Natapov
On Sun, Jun 29, 2014 at 11:56:03AM +0200, Jan Kiszka wrote: On 2014-06-29 08:46, Gleb Natapov wrote: On Sat, Jun 28, 2014 at 01:44:31PM +0200, Borislav Petkov wrote: qemu-system-x86-20240 [006] ...1 9406.484134: kvm_page_fault: address 7fffb62ba318 error_code 2 qemu-system-x86-20240

Re: __schedule #DF splat

2014-06-29 Thread Gleb Natapov
On Sun, Jun 29, 2014 at 12:31:50PM +0200, Jan Kiszka wrote: On 2014-06-29 12:24, Gleb Natapov wrote: On Sun, Jun 29, 2014 at 11:56:03AM +0200, Jan Kiszka wrote: On 2014-06-29 08:46, Gleb Natapov wrote: On Sat, Jun 28, 2014 at 01:44:31PM +0200, Borislav Petkov wrote: qemu-system-x86-20240

Re: __schedule #DF splat

2014-06-29 Thread Gleb Natapov
On Sun, Jun 29, 2014 at 03:14:43PM +0200, Borislav Petkov wrote: On Sun, Jun 29, 2014 at 02:22:35PM +0200, Jan Kiszka wrote: OK, looks like I won ;): I gladly let you win. :-P The issue was apparently introduced with KVM: x86: get CPL from SS.DPL (ae9fedc793). Maybe we are not properly

Re: __schedule #DF splat

2014-06-29 Thread Gleb Natapov
On Sun, Jun 29, 2014 at 04:01:04PM +0200, Borislav Petkov wrote: On Sun, Jun 29, 2014 at 04:42:47PM +0300, Gleb Natapov wrote: Please do so and let us know. Yep, just did. Reverting ae9fedc793 fixes the issue. reinj:1 means that previous injection failed due to another #PF

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-22 Thread Gleb Natapov
On Fri, Jun 20, 2014 at 05:31:46PM -0300, Marcelo Tosatti wrote: Same with the APIC access page. APIC page is always mapped into guest's APIC base address 0xfee0. The way it works is that when vCPU accesses page at 0xfee0 the access is translated to APIC access page physical

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-20 Thread Gleb Natapov
On Thu, Jun 19, 2014 at 04:00:24PM -0300, Marcelo Tosatti wrote: On Thu, Jun 19, 2014 at 12:20:32PM +0300, Gleb Natapov wrote: CCing Marcelo, On Wed, Jun 18, 2014 at 02:50:44PM +0800, Tang Chen wrote: Hi Gleb, Thanks for the quick reply. Please see below. On 06/18/2014 02

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-20 Thread Gleb Natapov
On Fri, Jun 20, 2014 at 09:53:26AM -0300, Marcelo Tosatti wrote: On Fri, Jun 20, 2014 at 02:15:10PM +0300, Gleb Natapov wrote: On Thu, Jun 19, 2014 at 04:00:24PM -0300, Marcelo Tosatti wrote: On Thu, Jun 19, 2014 at 12:20:32PM +0300, Gleb Natapov wrote: CCing Marcelo, On Wed

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-19 Thread Gleb Natapov
CCing Marcelo, On Wed, Jun 18, 2014 at 02:50:44PM +0800, Tang Chen wrote: Hi Gleb, Thanks for the quick reply. Please see below. On 06/18/2014 02:12 PM, Gleb Natapov wrote: On Wed, Jun 18, 2014 at 01:50:00PM +0800, Tang Chen wrote: [Questions] And by the way, would you guys please

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-19 Thread Gleb Natapov
On Thu, Jun 19, 2014 at 01:53:36PM +0300, Nadav Amit wrote: On Jun 19, 2014, at 1:18 PM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Jun 18, 2014 at 02:46:01PM -0400, Gabriel L. Somlo wrote: On Wed, Jun 18, 2014 at 10:59:14AM -0700, Eric Northup wrote: On Wed, Jun 18, 2014 at 7:19

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-19 Thread Gleb Natapov
On Thu, Jun 19, 2014 at 02:52:20PM +0300, Nadav Amit wrote: On 6/19/14, 2:23 PM, Gleb Natapov wrote: On Thu, Jun 19, 2014 at 01:53:36PM +0300, Nadav Amit wrote: On Jun 19, 2014, at 1:18 PM, Michael S. Tsirkin m...@redhat.com wrote: On Wed, Jun 18, 2014 at 02:46:01PM -0400, Gabriel L. Somlo

Re: [PATCH 3/3] KVM: x86: correct mwait and monitor emulation

2014-06-19 Thread Gleb Natapov
On Thu, Jun 19, 2014 at 03:10:21PM +0300, Nadav Amit wrote: On 6/19/14, 3:07 PM, Gleb Natapov wrote: On Thu, Jun 19, 2014 at 02:52:20PM +0300, Nadav Amit wrote: On 6/19/14, 2:23 PM, Gleb Natapov wrote: On Thu, Jun 19, 2014 at 01:53:36PM +0300, Nadav Amit wrote: On Jun 19, 2014, at 1:18 PM

Re: [RFC PATCH 1/1] Move two pinned pages to non-movable node in kvm.

2014-06-18 Thread Gleb Natapov
On Wed, Jun 18, 2014 at 01:50:00PM +0800, Tang Chen wrote: [Questions] And by the way, would you guys please answer the following questions for me ? 1. What's the ept identity pagetable for ? Only one page is enough ? 2. Is the ept identity pagetable only used in realmode ? Can we

Re: [PATCH 4/4] kvm: Implement PEBS virtualization

2014-06-02 Thread Gleb Natapov
On Fri, May 30, 2014 at 09:24:24AM -0700, Andi Kleen wrote: To avoid any problems with guest pages being swapped by the host we pin the pages when the PEBS buffer is setup, by intercepting that MSR. It will avoid guest page to be swapped, but shadow paging code may still drop

Re: [PATCH 4/4] kvm: Implement PEBS virtualization

2014-05-30 Thread Gleb Natapov
On Thu, May 29, 2014 at 06:12:07PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com PEBS (Precise Event Bases Sampling) profiling is very powerful, allowing improved sampling precision and much additional information, like address or TSX abort profiling. cycles:p and :pp uses

Re: [PATCH 4/5] KVM: x86: RSI/RDI/RCX are zero-extended when affected by string ops

2014-04-20 Thread Gleb Natapov
On Fri, Apr 18, 2014 at 07:11:33AM +0300, Nadav Amit wrote: When using address-size override prefix with string instructions in long-mode, ESI/EDI/ECX are zero extended if they are affected by the instruction (incremented/decremented). Currently, the KVM emulator does not do so. In

Re: GPF in intel_pmu_lbr_reset() with qemu -cpu host

2014-03-22 Thread Gleb Natapov
On Fri, Mar 21, 2014 at 12:04:32PM -0700, Venkatesh Srinivas wrote: On Fri, Mar 21, 2014 at 10:46 AM, Peter Wu pe...@lekensteyn.nl wrote: [skip] When -cpu host is used, qemu/kvm passed the host CPUID F/M/S to the guest. intel_pmu_cpu_*() - intel_pmu_lbr_reset() uses rdmsr() / wrmsr(), rather

Re: GPF in intel_pmu_lbr_reset() with qemu -cpu host

2014-03-22 Thread Gleb Natapov
On Sat, Mar 22, 2014 at 11:05:03AM +0100, Peter Wu wrote: On Saturday 22 March 2014 10:50:45 Gleb Natapov wrote: On Fri, Mar 21, 2014 at 12:04:32PM -0700, Venkatesh Srinivas wrote: On Fri, Mar 21, 2014 at 10:46 AM, Peter Wu pe...@lekensteyn.nl wrote: [skip] When -cpu host is used

Re: [PATCH] KVM: SVM: fix cr8 intercept window

2014-03-13 Thread Gleb Natapov
On Wed, Mar 12, 2014 at 06:20:01PM +0100, Paolo Bonzini wrote: Il 12/03/2014 11:40, Radim Krčmář ha scritto: 2014-03-11 22:05-0300, Marcelo Tosatti: On Tue, Mar 11, 2014 at 07:11:18PM +0100, Radim Krčmář wrote: We always disable cr8 intercept in its handler, but only re-enable it if handling

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2014-01-07 Thread Gleb Natapov
On Mon, Jan 06, 2014 at 09:18:44AM -0800, Dirk Brandewie wrote: On 01/03/2014 02:06 PM, Paolo Bonzini wrote: Il 03/01/2014 21:00, Dirk Brandewie ha scritto: +case MSR_IA32_MPERF: +case MSR_IA32_APERF: OK I will spin the patch to only add MSR_PLATFORM_INFO. These should never be

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2014-01-04 Thread Gleb Natapov
On Sat, Jan 04, 2014 at 06:38:59PM +0100, Paolo Bonzini wrote: Il 04/01/2014 15:38, Rafael J. Wysocki ha scritto: Well, it's just a sanity check and it makes the problem go away for the reporter. Your patch is welcome but perhaps it should have a WARN_ON too. It has been pulled in

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2014-01-03 Thread Gleb Natapov
On Fri, Jan 03, 2014 at 09:30:28AM -0800, Dirk Brandewie wrote: Hi All, Sorry for being late to the party but I just got back from vacation. There is something deeply wrong here. We should have never gotten to intel_pstate_init_cpu(). The VM had to have returned value from the read of

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2013-12-27 Thread Gleb Natapov
On Fri, Dec 27, 2013 at 12:24:22PM +, One Thousand Gnomes wrote: On Tue, 24 Dec 2013 21:36:01 +0530 Viresh Kumar viresh.ku...@linaro.org wrote: Adding Dirk.. On 24 December 2013 20:06, Josh Boyer jwbo...@fedoraproject.org wrote: Hi All, We've had a report [1] that the

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2013-12-27 Thread Gleb Natapov
On Fri, Dec 27, 2013 at 03:15:39PM +0100, Kashyap Chamarthy wrote: [. . .] KVM does not emulate P-states at all. intel_pstate_init() calls intel_pstate_msrs_not_valid() before printing Intel P-state driver initializing. which suppose to fail since it checks that two reads of

Re: intel_pstate divide error with v3.13-rc4-256-gb7000ad

2013-12-27 Thread Gleb Natapov
On Fri, Dec 27, 2013 at 06:52:48PM +0200, Gleb Natapov wrote: On Fri, Dec 27, 2013 at 03:15:39PM +0100, Kashyap Chamarthy wrote: [. . .] KVM does not emulate P-states at all. intel_pstate_init() calls intel_pstate_msrs_not_valid() before printing Intel P-state driver initializing

Re: [PATCH] KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376)

2013-12-16 Thread Gleb Natapov
On Mon, Dec 16, 2013 at 01:01:10PM +0100, Radim Krčmář wrote: - Where does the 'only one supported cluster' come from? only one supported cluster comes from 8 bit cpuid limitation of KVM's x2apic implementation. With 8 bit cpuid you can only address cluster 0 in logical mode.

Re: [PATCH] KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376)

2013-12-16 Thread Gleb Natapov
On Mon, Dec 16, 2013 at 02:31:43PM +0100, Radim Krčmář wrote: 2013-12-16 13:55+0100, Radim Krčmář: 2013-12-16 14:16+0200, Gleb Natapov: On Mon, Dec 16, 2013 at 01:01:10PM +0100, Radim Krčmář wrote: - Where does the 'only one supported cluster' come from? only one supported

Re: [PATCH] KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376)

2013-12-14 Thread Gleb Natapov
On Fri, Dec 13, 2013 at 05:07:54PM +0100, Radim Krčmář wrote: 2013-12-12 21:36+0100, Paolo Bonzini: From: Gleb Natapov g...@redhat.com A guest can cause a BUG_ON() leading to a host kernel crash. When the guest writes to the ICR to request an IPI, while in x2apic mode the following

Re: [PATCH] KVM: x86: fix guest-initiated crash with x2apic (CVE-2013-6376)

2013-12-14 Thread Gleb Natapov
On Fri, Dec 13, 2013 at 06:25:20PM +0100, Paolo Bonzini wrote: Il 13/12/2013 17:07, Radim Krčmář ha scritto: This bug can only be hit when the destination cpu is 256, so the request itself is buggy -- we don't support that many in kvm and it would crash when initializing the vcpus

Re: KVM/KGDB integration

2013-11-27 Thread Gleb Natapov
Copying KGDB maintainer to get some feedback. On Tue, Nov 19, 2013 at 04:53:28PM +0200, Dan Aloni wrote: Hello, The following two patches address an integration issue between KVM and KGDB. The issue described in the patches can be triggered with vanilla kernels that enable KGDB and KVM

Re: [PATCH v3 07/15] KVM: MMU: introduce nulls desc

2013-11-26 Thread Gleb Natapov
On Tue, Nov 26, 2013 at 11:21:37AM +0800, Xiao Guangrong wrote: On 11/26/2013 02:12 AM, Marcelo Tosatti wrote: On Mon, Nov 25, 2013 at 02:29:03PM +0800, Xiao Guangrong wrote: Also, there is no guarantee of termination (as long as sptes are deleted with the correct timing). BTW, can't see

Re: [PATCH v3 07/15] KVM: MMU: introduce nulls desc

2013-11-26 Thread Gleb Natapov
On Tue, Nov 26, 2013 at 11:10:19AM +0800, Xiao Guangrong wrote: On 11/25/2013 10:23 PM, Marcelo Tosatti wrote: On Mon, Nov 25, 2013 at 02:48:37PM +0200, Avi Kivity wrote: On Mon, Nov 25, 2013 at 8:11 AM, Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com wrote: On Nov 23, 2013, at 3:14 AM,

Re: [PATCH v3 07/15] KVM: MMU: introduce nulls desc

2013-11-25 Thread Gleb Natapov
On Mon, Nov 25, 2013 at 02:11:31PM +0800, Xiao Guangrong wrote: For example, nothing prevents lockless walker to move into some parent_ptes chain, right? No. The nulls can help us to detect this case, for parent_ptes, the nulls points to shadow page but for rmaps, the nulls points to

Re: [PATCH v3 07/15] KVM: MMU: introduce nulls desc

2013-11-25 Thread Gleb Natapov
On Mon, Nov 25, 2013 at 12:23:51PM -0200, Marcelo Tosatti wrote: On Mon, Nov 25, 2013 at 02:48:37PM +0200, Avi Kivity wrote: On Mon, Nov 25, 2013 at 8:11 AM, Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com wrote: On Nov 23, 2013, at 3:14 AM, Marcelo Tosatti mtosa...@redhat.com wrote:

  1   2   3   4   5   6   7   8   >