Re: [Qemu-devel] E5-2620v2 - emulation stop error

2015-03-10 Thread Bandan Das
"Dr. David Alan Gilbert" writes: > * Paolo Bonzini (pbonz...@redhat.com) wrote: >> >> >> On 10/03/2015 19:21, Bandan Das wrote: >> > Paolo Bonzini writes: >> > >> >> On 10/03/2015 17:57, Dr. David Alan Gilbert wrote: >> >

Re: [Qemu-devel] E5-2620v2 - emulation stop error

2015-03-10 Thread Bandan Das
Paolo Bonzini writes: > On 10/03/2015 17:57, Dr. David Alan Gilbert wrote: >> I'm seeing something similar; it's very intermittent and generally >> happening right at boot of the guest; I'm running this on qemu >> head+my postcopy world (but it's happening right at boot before postcopy >> gets

Re: [Qemu-devel] E5-2620v2 - emulation stop error

2015-03-06 Thread Bandan Das
Andrey Korolyov writes: > On Fri, Mar 6, 2015 at 1:14 AM, Andrey Korolyov wrote: >> Hello, >> >> recently I`ve got a couple of shiny new Intel 2620v2s for future >> replacement of the E5-2620v1, but I experienced relatively many events >> with emulation errors, all traces looks simular to the on

Re: [PATCH 1/5] vfio-pci: Allow PCI IDs to be specified as module options

2015-03-04 Thread Bandan Das
Alex Williamson writes: > On Wed, 2015-03-04 at 15:49 -0500, Bandan Das wrote: >> Hi Alex, >> >> Alex Williamson writes: >> ... >> > + if (fields < 2) { >> > + pr_warn("vfio-pci: invalid id st

Re: [PATCH 1/5] vfio-pci: Allow PCI IDs to be specified as module options

2015-03-04 Thread Bandan Das
Hi Alex, Alex Williamson writes: ... > + if (fields < 2) { > + pr_warn("vfio-pci: invalid id string \"%s\"\n", id); > + continue; > + } > + > + pr_info("vfio-pci: add %04X:%04X sub=%04X:%04X cls=%08X/%08X\n", > +

Re: [PATCH v2] KVM: vmx: Set msr bitmap correctly if vcpu is in guest mode

2015-03-04 Thread Bandan Das
Hi Wincy, Wincy Van writes: > In commit 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap"), > we are setting MSR_BITMAP in prepare_vmcs02 if we should use hardware. This > is not enough since the field will be modified by following vmx_set_efer. > > Fix this by setting vmx_msr_bit

Re: [PATCH] KVM: vmx: Set msr bitmap correctly if vcpu is in guest mode

2015-03-03 Thread Bandan Das
Wincy Van writes: > On Wed, Mar 4, 2015 at 1:39 AM, Bandan Das wrote: >> Wincy Van writes: >> >>> In commit 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap"), >>> we are setting MSR_BITMAP in prepare_vmcs02 if we should use hardware.

Re: [PATCH] KVM: make halt_poll_ns static

2015-03-03 Thread Bandan Das
Christian Borntraeger writes: > halt_poll_ns is used only locally. Make it static. > > Signed-off-by: Christian Borntraeger > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 34310a8..58bc2a9 100

Re: [PATCH] KVM: vmx: Set msr bitmap correctly if vcpu is in guest mode

2015-03-03 Thread Bandan Das
Wincy Van writes: > In commit 3af18d9c5fe9 ("KVM: nVMX: Prepare for using hardware MSR bitmap"), > we are setting MSR_BITMAP in prepare_vmcs02 if we should use hardware. This > is not enough since the field will be modified by following vmx_set_efer. > > Fix this by setting vmx_msr_bitmap_nested

Re: [PATCH] x86: svm: make wbinvd faster

2015-03-02 Thread Bandan Das
Radim Krčmář writes: > 2015-03-01 21:29-0500, Bandan Das: >> Joel Schopp writes: >> >> > From: David Kaplan >> > No need to re-decode WBINVD since we know what it is from the intercept. >> > >> > Signed-off-by: David Kaplan >> > [ex

Re: [PATCH] x86: svm: make wbinvd faster

2015-03-01 Thread Bandan Das
Joel Schopp writes: > From: David Kaplan > No need to re-decode WBINVD since we know what it is from the intercept. > > Signed-off-by: David Kaplan > [extracted from larger unlrelated patch, forward ported, tested] > Signed-off-by: Joel Schopp > --- > arch/x86/kvm/svm.c | 10 +- > 1

Re: [PATCH] KVM: Get rid of kvm_kvfree()

2015-02-24 Thread Bandan Das
Thomas Huth writes: > kvm_kvfree() provides exactly the same functionality as the > new common kvfree() function - so let's simply replace the > kvm function with the common function. I assumed there would be a wrapper kvzalloc as well, seems not :) > Signed-off-by: Thomas Huth > --- > arch/x

Re: [PATCH] KVM: nVMX: mask unrestricted_guest if disabled on L0

2015-02-24 Thread Bandan Das
Jan Kiszka writes: > On 2015-02-24 17:30, Radim Krčmář wrote: >> 2015-02-23 19:05+0100, Kashyap Chamarthy: >>> Tested with the _correct_ Kernel[1] (that has Radim's patch) now -- >>> applied it on both L0 and L1. >>> >>> Result: Same as before -- Booting L2 causes L1 to reboot. However, the >>>

Re: [nVMX] With 3.20.0-0.rc0.git5.1 on L0, booting L2 guest results in L1 *rebooting*

2015-02-17 Thread Bandan Das
Kashyap Chamarthy writes: .. >> >> Does enable_apicv make a difference? > > Actually, I did perform a test (on Paolo's suggestion on IRC) with > enable_apicv=0 on physical host, and it didn't make any difference: > > $ cat /proc/cmdline > BOOT_IMAGE=/vmlinuz-3.20.0-0.rc0.git5.1.fc23.x86_64 > ro

Re: [PATCH] KVM: x86: nVMX: support for MSR loading/storing

2014-12-10 Thread Bandan Das
Eugene Korenevsky writes: >> Hi, Eugene, is it okay to split my part up? > > I think the patch is atomic. No ideas how this patch could be split > without breaking its integrity. > You are a co-author of the patch since your ideas make significant part of it. I was suggesting adding the interfac

Re: [PATCH] KVM: x86: nVMX: support for MSR loading/storing

2014-12-09 Thread Bandan Das
Eugene Korenevsky writes: > Several hypervisors use MSR loading/storing to run guests. > This patch implements emulation of this feature and allows these > hypervisors to work in L1. > > The following is emulated: > - Loading MSRs on VM-entries > - Saving MSRs on VM-exits > - Loading MSRs on VM-e

Re: [PATCH RFC] KVM: x86: nested: support for MSR loading/storing

2014-12-07 Thread Bandan Das
[Ccing a few others who might be interested] Hi Eugene, Did you look at the other patch that was posted for this functionality by Wincy Van ? https://lkml.org/lkml/2014/11/21/749 Eugene Korenevsky writes: > BitVisor hypervisor fails to start a nested guest due to lack of MSR > load/store supp

[PATCH] KVM: nVMX: Disable unrestricted mode if ept=0

2014-12-06 Thread Bandan Das
If L0 has disabled EPT, don't advertise unrestricted mode at all since it depends on EPT to run real mode code. Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3e

Re: Nested VMX guest tsc_deadline OOPS

2014-10-14 Thread Bandan Das
Andy Lutomirski writes: > I don't know what's going on here, but a nested VMX boot using -cpu > host on SNB on L0 and L1 fails with the OOPS below. I kind of suspect > that there's both a KVM bug and an APIC driver bug here. What kernel version is this ? What are you running for L1 and L2 ? >

Re: [PATCH] KVM: nVMX: Disable preemption while reading from shadow VMCS

2014-10-08 Thread Bandan Das
Jan Kiszka writes: > In order to access the shadow VMCS, we need to load it. At this point, > vmx->loaded_vmcs->vmcs and the actually loaded one start to differ. If > we now get preempted by Linux, vmx_vcpu_put and, on return, the > vmx_vcpu_load will work against the wrong vmcs. That can cause >

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

2014-07-16 Thread Bandan Das
Andy Lutomirski writes: > 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 making guest boot wait for virtio-rng is

Re: [PATCH kvm-unit-tests 2/2] vmx: actually test vmptrld, not vmclear

2014-07-08 Thread Bandan Das
Paolo Bonzini writes: > test_vmptrld was actually invoking vmclear. make_vmcs_current is > the wrapper for vmptrld, not vmcs_clear! Oops, this was my fault, sorry!! > Signed-off-by: Paolo Bonzini > --- > x86/vmx.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-07 Thread Bandan Das
Wanpeng Li writes: ... > > As Jan metioned in http://www.spinics.net/lists/kvm/msg105238.html, "In any > case, > unconditionally setting KVM_REQ_EVENT seems strange and should be changed." > Your > trick still keep the unconditionally setting KVM_REQ_EVENT which is the root > cause > of the

[PATCH] KVM: x86: Check for nested events if there is an injectable interrupt

2014-07-07 Thread Bandan Das
check for injectable interrupt returns true Signed-off-by: Bandan Das --- arch/x86/kvm/x86.c | 13 + 1 file changed, 13 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 73537ec..56327a6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5907,6 +59

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-07 Thread Bandan Das
Paolo Bonzini writes: > Il 07/07/2014 19:31, Bandan Das ha scritto: >>> > >>> > Which patch? Yours or Bandan's? >> Why don't we hold off on Wanpeng's patch and instead apply the one I proposed >> to call check_nested_events() w

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-07 Thread Bandan Das
Paolo Bonzini writes: > Il 07/07/2014 10:46, Wanpeng Li ha scritto: >> Hi Paolo, >> >> Is it ok for you to apply this patch and then more effort should be taken >> to figure out the other bug which don't have any relationship with the race >> that this patch fixed? > > Which patch? Yours or Band

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-06 Thread Bandan Das
Wanpeng Li writes: > On Thu, Jul 03, 2014 at 01:15:26AM -0400, Bandan Das wrote: >>Jan Kiszka writes: >> >>> On 2014-07-02 08:54, Wanpeng Li wrote: >>>> This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=72381 >>>> >>&g

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-03 Thread Bandan Das
Wanpeng Li writes: > On Thu, Jul 03, 2014 at 01:15:26AM -0400, Bandan Das wrote: >>Jan Kiszka writes: >> >>> On 2014-07-02 08:54, Wanpeng Li wrote: >>>> This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=72381 >>>> >>&g

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-02 Thread Bandan Das
Wanpeng Li writes: > Hi Bandan, > On Wed, Jul 02, 2014 at 12:27:59PM -0400, Bandan Das wrote: >>Wanpeng Li writes: >> >>> This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=72381 >>I can also reproduce this easily with Linux as L1 by "slowi

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-02 Thread Bandan Das
Jan Kiszka writes: > On 2014-07-02 08:54, Wanpeng Li wrote: >> This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=72381 >> >> If we didn't inject a still-pending event to L1 since nested_run_pending, >> KVM_REQ_EVENT should be requested after the vmexit in order to inject the >> ev

Re: [PATCH] KVM: nVMX: Fix IRQs inject to L2 which belong to L1 since race

2014-07-02 Thread Bandan Das
Wanpeng Li writes: > This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=72381 I can also reproduce this easily with Linux as L1 by "slowing it down" eg. running with ept = 0 I suggest changing the subject to - KVM: nVMX: Fix race that incorrectly injects L1's irq to L2 > If we didn

Re: [PATCH] KVM: x86: Fix lapic.c debug prints

2014-06-30 Thread Bandan Das
Paolo Bonzini writes: > Il 30/06/2014 03:03, Nadav Amit ha scritto: sipi_vector = apic->sipi_vector; -pr_debug("vcpu %d received sipi with vector # %x\n", +apic_debug("vcpu %d received sipi with vector # %x\n", >>> >>> Why don't we just use pr_debug a

Re: [PATCH] KVM: x86: Fix lapic.c debug prints

2014-06-30 Thread Bandan Das
Paolo Bonzini writes: > Il 30/06/2014 19:39, Bandan Das ha scritto: >> Paolo Bonzini writes: >> >>> Il 30/06/2014 03:03, Nadav Amit ha scritto: >>>>>> >>>>>> sipi_vector = apic->sipi_vector; >

Re: [PATCH] KVM: x86: Fix lapic.c debug prints

2014-06-29 Thread Bandan Das
Nadav Amit writes: > In two cases lapic.c does not use the apic_debug macro correctly. This patch > fixes them. > > Signed-off-by: Nadav Amit > --- > arch/x86/kvm/lapic.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > i

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

2014-06-18 Thread Bandan Das
"Gabriel L. Somlo" writes: > On Wed, Jun 18, 2014 at 10:59:14AM -0700, Eric Northup wrote: >> On Wed, Jun 18, 2014 at 7:19 AM, Nadav Amit wrote: >> > mwait and monitor are currently handled as nop. Considering this behavior, >> > they >> > should still be handled correctly, i.e., check executio

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

2014-06-18 Thread Bandan Das
Paolo Bonzini writes: > Il 18/06/2014 18:43, Bandan Das ha scritto: >>> > mwait and monitor are currently handled as nop. Considering this >>> > behavior, they >>> > should still be handled correctly, i.e., check execution conditions and >>> >

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

2014-06-18 Thread Bandan Das
Nadav Amit writes: > mwait and monitor are currently handled as nop. Considering this behavior, > they > should still be handled correctly, i.e., check execution conditions and > generate > exceptions when required. mwait and monitor may also be executed in real-mode Is this necessary ? They a

Re: [PATCH 2/6] KVM: x86: Wrong emulation on 'xadd X, X'

2014-06-17 Thread Bandan Das
Paolo Bonzini writes: > Il 16/06/2014 19:38, Bandan Das ha scritto: >> Nadav Amit writes: >> >>> The emulator does not emulate the xadd instruction correctly if the two >>> operands are the same. In this (unlikely) situation the result should be >>&

Re: [PATCH 2/6] KVM: x86: Wrong emulation on 'xadd X, X'

2014-06-16 Thread Bandan Das
Nadav Amit writes: > The emulator does not emulate the xadd instruction correctly if the two > operands are the same. In this (unlikely) situation the result should be the > sum of X and X (2X) when it is currently X. The solution is to first perform > writeback to the source, before writing to

Re: [PATCH 2/5] VMX: Only use get_stage accessor

2014-06-16 Thread Bandan Das
Jan Kiszka writes: > From: Jan Kiszka > > Consistently make sure we are not affected by any compiler reordering > when evaluating the current stage. Should we prevent accidental calls to the variable directly by moving get/set to vmx.c or a separate file in lib/x86 altogether ? > Signed-off-

Re: [PATCH v2 4/5] KVM: nVMX: Allow to disable VM_{ENTRY_LOAD,EXIT_SAVE}_DEBUG_CONTROLS

2014-06-16 Thread Bandan Das
Jan Kiszka writes: ... > /* cpu-based controls */ > rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, > nested_vmx_procbased_ctls_low, nested_vmx_procbased_ctls_high); > @@ -2409,11 +2422,17 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 > msr_index, u64 *pdata) >

Re: [PATCH v2 3/5] KVM: nVMX: Fix returned value of MSR_IA32_VMX_PROCBASED_CTLS

2014-06-16 Thread Bandan Das
Jan Kiszka writes: > SDM says bits 1, 4-6, 8, 13-16, and 26 have to be set. > > Signed-off-by: Jan Kiszka > --- > arch/x86/include/asm/vmx.h | 3 +++ > arch/x86/kvm/vmx.c | 5 +++-- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/vmx.h b/arch/x86

Re: [PATCH v2 1/5] KVM: nVMX: Advertise support for MSR_IA32_VMX_TRUE_*_CTLS

2014-06-16 Thread Bandan Das
Jan Kiszka writes: > We already implemented them but failed to advertise them. Currently they > all return the identical values to the capability MSRs they are > augmenting. So there is no change in exposed features yet. > > Drop related comments at this chance that are partially incorrect and >

Re: [PATCH] vfio/pci: Add extra test for extended capabilities

2014-06-12 Thread Bandan Das
Alex Williamson writes: > On Thu, 2014-06-12 at 16:12 -0400, Bandan Das wrote: >> Alex Williamson writes: >> >> > If the PCI core set cfg_size isn't large enough for extended >> > capabilities, then they're not there. Extended config space may b

Re: [PATCH] vfio/pci: Add extra test for extended capabilities

2014-06-12 Thread Bandan Das
Alex Williamson writes: > If the PCI core set cfg_size isn't large enough for extended > capabilities, then they're not there. Extended config space may be > inaccessible due to a PCI bridge, in which case cfg_size may be cut > short. Just curious, is this part of the spec or just a convention

Re: [PATCH] x86: realmode: report failures

2014-06-09 Thread Bandan Das
Nadav Amit writes: > The current realmode tests always report success when done, regardless to > whether any of the tests failed. Although the log includes the individual > test > results, this behavior complicates the life of the tester. Please include kvm-unit-tests in the subject line for e

[PATCH kvm-unit-tests v2 1/3] VMX: move write_rflags inside asm blocks for vmx instructions

2014-06-09 Thread Bandan Das
This makes sure that the flags register doesn't get accidentally overwritten due to compiler optimizations or other means Signed-off-by: Bandan Das --- lib/x86/processor.h | 7 --- x86/vmx.c | 31 ++- x86/vmx.h | 10 -- 3

[PATCH kvm-unit-tests v2 3/3] VMX: Updated test_vmclear and test_vmptrld

2014-06-09 Thread Bandan Das
Check if the vmcs pointer is not aligned to page size, and if bits beyond physical address width are set. Also, vmclear and vmptrld should fail if the vmxon region is supplied instead of the vmcs Signed-off-by: Bandan Das --- x86/vmx.c | 52

[PATCH kvm-unit-tests v2 2/3] VMX: Add more checks to test_vmxon

2014-06-09 Thread Bandan Das
Verify that vmon fails with unaligned vmxon region or any bits set beyong the physical address width. Also verify failure with an invalid revision identifier. Signed-off-by: Bandan Das --- x86/vmx.c | 40 +--- 1 file changed, 37 insertions(+), 3 deletions

[PATCH kvm-unit-tests v2 0/3] More nvmx unit tests changes

2014-06-09 Thread Bandan Das
writing of flags register inside asm blocks Bandan Das (3): VMX: move write_rflags inside asm blocks for vmx instructions VMX: Add more checks to test_vmxon VMX: Updated test_vmclear and test_vmptrld lib/x86/processor.h | 7 --- x86/vmx.c | 121

Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000

2014-06-04 Thread Bandan Das
Jidong Xiao writes: .. >> > Hi, Bandan, > > Thanks for the advice. I think Paolo has incorporated this patch into > his patch sets, and he sent the revised version in a separate email > earlier today with the subject "[PULL 11/11] kvm: Fix eax for cpuid > leaf 0x4000". Oops! Sorry, must have

[PATCH kvm-unit-tests 0/2] More nvmx unit tests changes

2014-06-04 Thread Bandan Das
A couple more updates to test_vmxon, test_vmptrld and test_vmclear based on kvm commits - 3573e22cfecaac83f82ef4f6847d90e466fc8e10 KVM: nVMX: additional checks on vmxon region 96ec146330d18a938b4773be8d6dd1f93399507c KVM: nVMX: fail on invalid vmclear/vmptrld pointer Bandan Das (2): VMX: Add

[PATCH kvm-unit-tests 2/2] VMX: Check for validity of vmcs region when calling vmclear/vmptrld

2014-06-04 Thread Bandan Das
Check if the vmcs pointer is not aligned to page size, and if bits beyond physical address width are set. Also, vmclear and vmptrld should fail if the vmxon region is supplied instead of the vmcs Signed-off-by: Bandan Das --- x86/vmx.c | 63

[PATCH kvm-unit-tests 1/2] VMX: checks for validity of vmxon region

2014-06-04 Thread Bandan Das
Verify that vmon fails with unaligned vmxon region or any bits set beyong the physical address width. Also verify failure with an invalid revision identifier. Signed-off-by: Bandan Das --- x86/vmx.c | 46 +++--- 1 file changed, 43 insertions(+), 3

Re: [Qemu-devel] [PATCH] Qemu: Fix eax for cpuid leaf 0x40000000

2014-06-04 Thread Bandan Das
Jidong Xiao writes: > On Wed, Jun 4, 2014 at 3:09 AM, Paolo Bonzini wrote: >> Il 04/06/2014 03:10, Jidong Xiao ha scritto: >> >>> diff --git a/qemu-2.0.0/target-i386/kvm.c.orig >>> b/qemu-2.0.0/target-i386/kvm.c >>> index 4389959..b8b282d 100644 >>> --- a/qemu-2.0.0/target-i386/kvm.c.orig >>> ++

[PATCH kvm-unit-tests 1/2] VMX: check for supported contexts before calling invept

2014-06-03 Thread Bandan Das
It's incorrect to assume the context in which invept is called. Check what is supported and fallback if single context invalidation isn't supported Signed-off-by: Bandan Das --- x86/vmx.c | 20 x86/vmx.h | 1 + x86/vmx_tests.c | 14 +++--

[PATCH kvm-unit-tests 2/2] VMX: Add test for interrupt acknowledgement

2014-06-03 Thread Bandan Das
If the hypervisor has the interrupt acknowledgement bit set, vector information is already present in intr_info during a vmexit. The hypervisor then uses it to call the appropriate handler. Signed-off-by: Bandan Das --- lib/x86/isr.c | 32 lib/x86/isr.h | 2

[PATCH kvm-unit-tests 0/2] nvmx unit test cases changes

2014-06-03 Thread Bandan Das
Adds a simple test for interrupt acknowledgement and change invept behavior to check for supported invalidation contexts Bandan Das (2): VMX: check for supported contexts before calling invept VMX: Add test for interrupt acknowledgement lib/x86/isr.c | 32

Re: [PATCH v2 0/4] Emulate VMXON region correctly

2014-06-03 Thread Bandan Das
Paolo Bonzini writes: > Il 06/05/2014 08:19, Bandan Das ha scritto: >> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=54521 >> >> The vmxon region is unused by nvmx, but adding these checks >> are probably harmless and may detect buggy L1 hypervisors in >&g

Re: [Qemu-devel] [PATCH] kvm: Enable -cpu option to hide KVM

2014-06-02 Thread Bandan Das
Alex Williamson writes: > The latest Nvidia driver (337.88) specifically checks for KVM as the > hypervisor and reports Code 43 for the driver in a Windows guest when > found. Removing or changing the KVM signature is sufficient for the > driver to load and work. This patch adds an option to ea

Re: [RFC PATCH] kvm: Enable -cpu option to hide KVM

2014-06-02 Thread Bandan Das
Michael Tokarev writes: > 02.06.2014 17:30, Alex Williamson wrote: >> On Mon, 2014-06-02 at 14:32 +0400, Michael Tokarev wrote: >>> 01.06.2014 20:25, Alex Williamson wrote: The latest Nvidia driver (337.88) specifically checks for KVM as the hypervisor and reports Code 43 for the driver

Re: [PATCH 4/5] KVM: x86: Wrong register masking in 64-bit mode

2014-05-07 Thread Bandan Das
Nadav Amit writes: > 32-bit operations are zero extended in 64-bit mode. Currently, the code does > not handle them correctly and keeps the high bits. In 16-bit mode, the high > 32-bits are kept intact. > > In addition, although it is not well-documented, when address override prefix It would be

Re: [PATCH 5/5] KVM: x86: Fix wrong masking on relative jump/call

2014-05-07 Thread Bandan Das
Nadav Amit writes: > Relative jumps and calls do the masking according to the operand size, and not > according to the address size as the KVM emulator does today. In 64-bit mode, > the resulting RIP is always 64-bit. Otherwise it is masked according to the > instruction operand-size. Note that

Re: [RFC PATCH 3/3] KVM: x86: cache userspace address for faster fetches

2014-05-06 Thread Bandan Das
Paolo Bonzini writes: > Il 06/05/2014 02:40, Bandan Das ha scritto: >> On every instruction fetch, kvm_read_guest_virt_helper >> does the gva to gpa translation followed by searching for the >> memslot. Store the gva hva mapping so that if there's a match >> we ca

Re: [RFC PATCH 3/4] KVM: emulate: avoid per-byte copying in instruction fetches

2014-05-06 Thread Bandan Das
Paolo Bonzini writes: > We do not need a memory copying loop anymore in insn_fetch; we > can use a byte-aligned pointer to access instruction fields directly Nice approach! > from the fetch_cache. This eliminates 40-80 cycles (corresponding to > a 5-7% improvement in performance) from each ins

Re: [RFC PATCH 2/4] KVM: emulate: avoid repeated calls to do_insn_fetch_bytes

2014-05-06 Thread Bandan Das
Paolo Bonzini writes: > do_insn_fetch_bytes will only be called once in a given insn_fetch and > insn_fetch_arr, because in fact it will only be called at most twice > for any instruction and the first call is explicit in x86_decode_insn. > This observation lets us hoist the call out of the memor

Re: [RFC PATCH 1/4] KVM: emulate: speed up do_insn_fetch

2014-05-06 Thread Bandan Das
Ok! Now that you posted your changes, I am getting to understand this a little :) Paolo Bonzini writes: > Hoist the common case up from do_insn_fetch_byte to do_insn_fetch, > and prime the fetch_cache in x86_decode_insn. This helps both the > compiler and the branch predictor. > > Signed-off-b

[PATCH v2 1/4] KVM: nVMX: rearrange get_vmx_mem_address

2014-05-05 Thread Bandan Das
Our common function for vmptr checks (in 2/4) needs to fetch the memory address Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 106 ++--- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

[PATCH v2 3/4] KVM: nVMX: fail on invalid vmclear/vmptrld pointer

2014-05-05 Thread Bandan Das
The spec mandates that if the vmptrld or vmclear address is equal to the vmxon region pointer, the instruction should fail with error "VMPTRLD with VMXON pointer" or "VMCLEAR with VMXON pointer" Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 12 1 file ch

[PATCH v2 0/4] Emulate VMXON region correctly

2014-05-05 Thread Bandan Das
() - Fix a leak with kunmap() - Remove unnecessary braces around comparisions - Move all checks into a common function, this will be later used by handle_vmptrld and handle_vmclear in 4/4 4/4 - New patch - use common function to perform checks on vmptr Bandan Das (4): KVM: nVMX

[PATCH v2 4/4] KVM: nVMX: move vmclear and vmptrld pre-checks to nested_vmx_check_vmptr

2014-05-05 Thread Bandan Das
Some checks are common to all, and moreover, according to the spec, the check for whether any bits beyond the physical address width are set are also applicable to all of them Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 83 -- 1 file

[PATCH v2 2/4] KVM: nVMX: additional checks on vmxon region

2014-05-05 Thread Bandan Das
Currently, the vmxon region isn't used in the nested case. However, according to the spec, the vmxon instruction performs additional sanity checks on this region and the associated pointer. Modify emulated vmxon to better adhere to the spec requirements Signed-off-by: Bandan Das --- arc

[RFC PATCH 0/3] Emulator Speedups - Optimize Instruction fetches

2014-05-05 Thread Bandan Das
uction (9.0%) Bandan Das (3): KVM: x86: pass ctxt to fetch helper function KVM: x86: use memory_prepare in fetch helper function KVM: x86: cache userspace address for faster fetches arch/x86/include/asm/kvm_emulate.h | 7 +- arch/x86/kvm/x86.c

[RFC PATCH 3/3] KVM: x86: cache userspace address for faster fetches

2014-05-05 Thread Bandan Das
On every instruction fetch, kvm_read_guest_virt_helper does the gva to gpa translation followed by searching for the memslot. Store the gva hva mapping so that if there's a match we can directly call __copy_from_user() Suggested-by: Paolo Bonzini Signed-off-by: Bandan Das --- arch/x86/in

[RFC PATCH 2/3] KVM: x86: use memory_prepare in fetch helper function

2014-05-05 Thread Bandan Das
Insn fetch fastpath function. Not that arch.walk_mmu->gva_to_gpa can't be used but let's piggyback on top of interface meant for our purpose Signed-off-by: Bandan Das --- arch/x86/kvm/x86.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --g

[RFC PATCH 1/3] KVM: x86: pass ctxt to fetch helper function

2014-05-05 Thread Bandan Das
In the following patches, our adress caching struct that's embedded within struct x86_emulate_ctxt will need to be accessed Signed-off-by: Bandan Das --- arch/x86/kvm/x86.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/

Re: KVM Nested L2 guest startup problems

2014-05-02 Thread Bandan Das
Hu Yaohui writes: > On Fri, May 2, 2014 at 11:52 AM, Paolo Bonzini wrote: >> Il 02/05/2014 17:17, Hu Yaohui ha scritto: >> >>> Hi Paolo, >>> I have tried L0 with linux kernel 3.14.2 and L1 with linux kernel 3.14.2 >>> L1 QEMU qemu-1.7.0 >>> L2 QEMU qemu-1.7.0. >> >> >> Do you mean L0 and L1? > Y

Re: [PATCH 2/3] KVM: nVMX: additional checks on vmxon region

2014-04-29 Thread Bandan Das
Jan Kiszka writes: > On 2014-04-28 07:00, Bandan Das wrote: >> Currently, the vmxon region isn't used in the nested case. >> However, according to the spec, the vmxon instruction performs >> additional sanity checks on this region and the associated >> pointer.

Re: [PATCH 0/3] Emulate VMXON region correctly

2014-04-29 Thread Bandan Das
Jan Kiszka writes: > On 2014-04-28 07:00, Bandan Das wrote: >> Reference: https://bugzilla.kernel.org/show_bug.cgi?id=54521 >> >> The vmxon region is unused by nvmx, but adding these checks >> are probably harmless and may detect buggy L1 hypervisors in >>

[PATCH 2/3] KVM: nVMX: additional checks on vmxon region

2014-04-27 Thread Bandan Das
Currently, the vmxon region isn't used in the nested case. However, according to the spec, the vmxon instruction performs additional sanity checks on this region and the associated pointer. Modify emulated vmxon to better adhere to the spec requirements Signed-off-by: Bandan Das --- arc

[PATCH 1/3] KVM: nVMX: rearrange get_vmx_mem_address

2014-04-27 Thread Bandan Das
handle_vmon will call this function to get the vmxon region pointer in the next patch Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 106 ++--- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm

[PATCH 0/3] Emulate VMXON region correctly

2014-04-27 Thread Bandan Das
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=54521 The vmxon region is unused by nvmx, but adding these checks are probably harmless and may detect buggy L1 hypervisors in the future! Bandan Das (3): KVM: nVMX: rearrange get_vmx_mem_address KVM: nVMX: additional checks on vmxon

[PATCH 3/3] KVM: nVMX: fail on invalid vmclear/vmptrld pointer

2014-04-27 Thread Bandan Das
The spec mandates that if the vmptrld or vmclear address is equal to the vmxon region pointer, the instruction should fail with error "VMPTRLD with VMXON pointer" or "VMCLEAR with VMXON pointer" Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 12 1 file ch

Re: [PATCH v2] KVM: x86: Check for host supported fields in shadow vmcs

2014-04-22 Thread Bandan Das
Paolo Bonzini writes: > Il 22/04/2014 12:25, Bandan Das ha scritto: >>>> >> + if (j < i) >>>> >> + shadow_read_write_fields[j] = >>>> >> + shadow_read_write_fields[

Re: [PATCH v2] KVM: x86: Check for host supported fields in shadow vmcs

2014-04-22 Thread Bandan Das
Paolo Bonzini writes: > Il 21/04/2014 15:20, Bandan Das ha scritto: >> +for (i = j = 0; i < max_shadow_read_write_fields; i++) { >> + > > Extra empty line. Not a big deal, but... > >> +switch (shadow_read_write_fields[i]) { &

[PATCH v2] KVM: x86: Check for host supported fields in shadow vmcs

2014-04-21 Thread Bandan Das
example, commit 36be0b9deb23161 introduced GUEST_BNDCFGS, which is not supported by all processors. Filter out host unsupported fields before letting guests use shadow vmcs Signed-off-by: Bandan Das --- v2: - Just compress the original lists instead of creating new ones - Change commit message

Re: [PATCH] KVM: x86: Check for host supported fields in shadow vmcs

2014-04-21 Thread Bandan Das
Paolo Bonzini writes: > Il 19/04/2014 19:34, Bandan Das ha scritto: >> >> We track shadow vmcs fields through two static lists, >> one for read only fields and another for r/w. However, with >> addition of new vmcs fields, not all fields may be suppo

[PATCH] KVM: x86: Check for host supported fields in shadow vmcs

2014-04-19 Thread Bandan Das
, commit 36be0b9deb23161 introduced GUEST_BNDCFGS, which is not supported for all processors. Create new lists based out of intersection of static lists and host support and use them for tracking shadow fields instead Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 98

[PATCH v3 3/3] KVM: nVMX: Advertise support for interrupt acknowledgement

2014-04-19 Thread Bandan Das
Some Type 1 hypervisors such as XEN won't enable VMX without it present Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 5c0b74d..7bed3e3 100644 --- a/arch/x86/kvm/vmx.c

[PATCH v3 0/3] nVMX: Fixes to run Xen as L1

2014-04-19 Thread Bandan Das
ommit description to 2/3 and change comment for nested_exit_intr_ack_set Jan, I will send a separate unit-test patch Bandan Das (3): KVM: nVMX: Don't advertise single context invalidation for invept KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to KVM: nVMX: Adverti

[PATCH v3 1/3] KVM: nVMX: Don't advertise single context invalidation for invept

2014-04-19 Thread Bandan Das
be true. Signed-off-by: Bandan Das --- arch/x86/kvm/vmx.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1f68c58..ce8f6c4 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2353,12 +2353,11 @@ static

[PATCH v3 2/3] KVM: nVMX: Ack and write vector info to intr_info if L1 asks us to

2014-04-19 Thread Bandan Das
This feature emulates the "Acknowledge interrupt on exit" behavior. We can safely emulate it for L1 to run L2 even if L0 itself has it disabled (to run L1). Signed-off-by: Bandan Das --- arch/x86/kvm/irq.c | 1 + arch/x86/kvm/vmx.c | 18 ++ 2 files changed, 19

[RFC PATCH v3 3/6] KVM: emulate: cleanup decode_modrm

2014-04-16 Thread Bandan Das
Remove the if conditional - that will help us avoid an "else initialize to 0" Also, rearrange operators for slightly better code. Signed-off-by: Bandan Das --- arch/x86/kvm/emulate.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/emulat

[RFC PATCH v3 0/6] Emulator speedups - avoid initializations where possible

2014-04-16 Thread Bandan Das
unctions - 6/6 - new patch, remove memopp and move rip_relative to a local variable in decode_modrm Bandan Das (6): KVM: emulate: move init_decode_cache to emulate.c KVM: emulate: Remove ctxt->intercept and ctxt->check_perm checks KVM: emulate: cleanup decode_modrm KVM: emu

[RFC PATCH v3 1/6] KVM: emulate: move init_decode_cache to emulate.c

2014-04-16 Thread Bandan Das
Core emulator functions all belong in emulator.c, x86 should have no knowledge of emulator internals Signed-off-by: Bandan Das --- arch/x86/include/asm/kvm_emulate.h | 1 + arch/x86/kvm/emulate.c | 13 + arch/x86/kvm/x86.c | 13 - 3 files

[RFC PATCH v3 4/6] KVM: emulate: clean up initializations in init_decode_cache

2014-04-16 Thread Bandan Das
A lot of initializations are unnecessary as they get set to appropriate values before actually being used. Optimize placement of fields in x86_emulate_ctxt Signed-off-by: Bandan Das --- arch/x86/include/asm/kvm_emulate.h | 20 +++- arch/x86/kvm/emulate.c | 7

[RFC PATCH v3 2/6] KVM: emulate: Remove ctxt->intercept and ctxt->check_perm checks

2014-04-16 Thread Bandan Das
The same information can be gleaned from ctxt->d and avoids having to zero/NULL initialize intercept and check_perm Signed-off-by: Bandan Das --- arch/x86/kvm/emulate.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulat

[RFC PATCH v3 6/6] KVM: emulate: remove memopp and rip_relative

2014-04-16 Thread Bandan Das
Move typecast on "out of range value" of mem.ea to decode_modrm. rip_relative is only set in decode_modrm, change it to a local var Signed-off-by: Bandan Das --- arch/x86/include/asm/kvm_emulate.h | 8 +--- arch/x86/kvm/emulate.c | 20 +--- 2 files c

[RFC PATCH v3 5/6] KVM: emulate: rework seg_override

2014-04-16 Thread Bandan Das
x86_decode_insn already sets a default for seg_override, so remove it from the zeroed area. Also replace set/get functions with direct access to the field. Signed-off-by: Bandan Das --- arch/x86/include/asm/kvm_emulate.h | 3 +-- arch/x86/kvm/emulate.c | 41

Re: [RFC PATCH v2 6/6] KVM: emulate: remove memopp and rip_relative

2014-04-14 Thread Bandan Das
Paolo Bonzini writes: > Il 10/04/2014 20:03, Bandan Das ha scritto: >> /* Fields above regs are cleared together. */ > > This comment is not accurate anymore after patch 4. Since you're > fixing it, please add another comment saying where the cleared fields > star

<    1   2   3   >