Re: [PATCH] nVMX: Keep arch.pat in sync on L1-L2 switches

2013-08-04 Thread Jan Kiszka
On 2013-08-05 04:19, Arthur Chunqi Li wrote: > On Sun, Aug 4, 2013 at 11:17 PM, Jan Kiszka wrote: >> From: Jan Kiszka >> >> When asking vmx to load the PAT MSR for us while switching from L1 to L2 >> or vice versa, we have to update arch.pat as well as it may later be >> used again to load or rea

RE: [PATCH] KVM: nVMX: correctly set tr base on nested vmexit emulation

2013-08-04 Thread Ren, Yongjie
> -Original Message- > From: Gleb Natapov [mailto:g...@redhat.com] > Sent: Sunday, August 04, 2013 8:08 PM > To: kvm@vger.kernel.org > Cc: Ren, Yongjie; pbonz...@redhat.com; yzt...@gmail.com > Subject: [PATCH] KVM: nVMX: correctly set tr base on nested vmexit > emulation > > After commit 2

Re: [PATCH] KVM: MMU: fix check the reserved bits on the gpte of L2

2013-08-04 Thread Gleb Natapov
On Mon, Aug 05, 2013 at 12:59:19PM +0800, Xiao Guangrong wrote: > Current code always uses arch.mmu to check the reserved bits on guest gpte > which is valid only for L1 guest, we should use arch.nested_mmu instead when > we translate gva to gpa for the L2 guest > > Fix it by using @mmu instead si

Re: [PATCH] arch: powerpc: kvm: add signed type cast for comparation

2013-08-04 Thread Chen Gang
On 08/05/2013 12:34 PM, Paul Mackerras wrote: > On Mon, Jul 22, 2013 at 02:32:35PM +0800, Chen Gang wrote: >> > 'rmls' is 'unsigned long', lpcr_rmls() will return negative number when >> > failure occurs, so it need a type cast for comparing. >> > >> > 'lpid' is 'unsigned long', kvmppc_alloc_lpid(

Re: [PATCH] arch: powerpc: kvm: add signed type cast for comparation

2013-08-04 Thread Paul Mackerras
On Mon, Jul 22, 2013 at 02:32:35PM +0800, Chen Gang wrote: > 'rmls' is 'unsigned long', lpcr_rmls() will return negative number when > failure occurs, so it need a type cast for comparing. > > 'lpid' is 'unsigned long', kvmppc_alloc_lpid() return negative number > when failure occurs, so it need a

[PATCH] KVM: MMU: fix check the reserved bits on the gpte of L2

2013-08-04 Thread Xiao Guangrong
Current code always uses arch.mmu to check the reserved bits on guest gpte which is valid only for L1 guest, we should use arch.nested_mmu instead when we translate gva to gpa for the L2 guest Fix it by using @mmu instead since it is adapted to the current mmu mode automatically The bug can be tr

Re: KVM Test report, kernel bf640876... qemu 0779caeb...

2013-08-04 Thread Arthur Chunqi Li
On Fri, Aug 2, 2013 at 7:50 PM, Gleb Natapov wrote: > On Fri, Aug 02, 2013 at 07:19:28AM +, Ren, Yongjie wrote: >> Hi All, >> >> This is KVM upstream test result against kvm.git next branch and >> qemu-kvm.git uq/master branch. >> kvm.git next branch: bf640876e21fe603f7f52b0c27d66b77

Re: [PATCH V2 4/4] x86: correctly detect hypervisor

2013-08-04 Thread Jason Wang
On 07/25/2013 04:54 PM, Jason Wang wrote: > We try to handle the hypervisor compatibility mode by detecting hypervisor > through a specific order. This is not robust, since hypervisors may implement > each others features. > > This patch tries to handle this situation by always choosing the last on

[PATCH v3] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Arthur Chunqi Li
Reconstruct VMX codes and put all VMX test suites in x86/vmx_tests.c. Signed-off-by: Arthur Chunqi Li --- ChangeLog to v2: Remove some unused extern definitions in vmx.h. config-x86-common.mak |2 +- x86/vmx.c | 115 - x8

Re: [PATCH] nVMX: Keep arch.pat in sync on L1-L2 switches

2013-08-04 Thread Arthur Chunqi Li
On Sun, Aug 4, 2013 at 11:17 PM, Jan Kiszka wrote: > From: Jan Kiszka > > When asking vmx to load the PAT MSR for us while switching from L1 to L2 > or vice versa, we have to update arch.pat as well as it may later be > used again to load or read out the MSR content. > > Signed-off-by: Jan Kiszka

Re: [PATCH v2] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Arthur Chunqi Li
On Mon, Aug 5, 2013 at 2:46 AM, Jan Kiszka wrote: > On 2013-08-04 20:25, Gmail wrote: >> 在 2013-8-5,2:08,Jan Kiszka 写道: >> >>> On 2013-08-04 20:04, Arthur Chunqi Li wrote: @@ -432,6 +432,22 @@ enum Ctrl1 { #define HYPERCALL_MASK0xFFF #define HYPERCALL_VMEXIT0x1 >>>

Re: [PATCH v2] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Jan Kiszka
On 2013-08-04 20:25, Gmail wrote: > 在 2013-8-5,2:08,Jan Kiszka 写道: > >> On 2013-08-04 20:04, Arthur Chunqi Li wrote: >>> @@ -432,6 +432,22 @@ enum Ctrl1 { >>> #define HYPERCALL_MASK0xFFF >>> #define HYPERCALL_VMEXIT0x1 >>> >>> + >>> +extern u64 hypercall_field; >>> +extern u32 vpid_cn

Re: [PATCH v2] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Gmail
在 2013-8-5,2:08,Jan Kiszka 写道: > On 2013-08-04 20:04, Arthur Chunqi Li wrote: >> @@ -432,6 +432,22 @@ enum Ctrl1 { >> #define HYPERCALL_MASK0xFFF >> #define HYPERCALL_VMEXIT0x1 >> >> + >> +extern u64 hypercall_field; >> +extern u32 vpid_cnt; >> +extern ulong fix_cr0_set, fix_cr0_clr;

Re: [PATCH v2] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Jan Kiszka
On 2013-08-04 20:04, Arthur Chunqi Li wrote: > @@ -432,6 +432,22 @@ enum Ctrl1 { > #define HYPERCALL_MASK 0xFFF > #define HYPERCALL_VMEXIT 0x1 > > + > +extern u64 hypercall_field; > +extern u32 vpid_cnt; > +extern ulong fix_cr0_set, fix_cr0_clr; > +extern ulong fix_cr4_set, fi

[PATCH v2] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Arthur Chunqi Li
Reconstruct VMX codes and put all VMX test suites in x86/vmx_tests.c. Signed-off-by: Arthur Chunqi Li --- ChangeLog to v1: Reassign places of global variants. Move vmx_tests to vmx_tests.c. config-x86-common.mak |2 +- x86/vmx.c | 108 --

[PATCH 4/7] KVM: nVMX: Fix guest CR3 read-back on VM-exit

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka If nested EPT is enabled, the L2 guest may change CR3 without any exits. We therefore have to read the current value from the VMCS when switching to L1. However, if paging wasn't enabled, L0 tracks L2's CR3, and GUEST_CR3 rather contains the real-mode identity map. So we need to

[PATCH 3/7] KVM: nVMX: Enable unrestricted guest mode support

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka Now that we provide EPT support, there is no reason to torture our guests by hiding the relieving unrestricted guest mode feature. We just need to relax CR0 checks for always-on bits as PE and PG can now be switched off. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c | 18

[PATCH 7/7] KVM: nVMX: Update mmu.base_role.nxe after EFER loading on VM-entry/exit

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka This job is normally performed by the architectural EFER set service which we cannot use as it prevents transitions that are valid when switching between L1 and L2. So open-code the update of base_role.nxe after changing EFER on VM-entry and exit. Signed-off-by: Jan Kiszka ---

[PATCH 6/7] KVM: nVMX: Implement support for EFER saving on VM-exit

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka Implement and advertise VM_EXIT_SAVE_IA32_EFER. L0 traps EFER writes unconditionally, so we always find the current L2 value in the architectural state. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a

[PATCH 5/7] KVM: nVMX: Load nEPT state after EFER

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka We need to update EFER.NX before building the nEPT state via nested_ept_init_mmu_context. Otherwise, we risk to create an MMU context that claims to have NX disabled while the guest EPT used NX. This will cause spurious faults for L2. Signed-off-by: Jan Kiszka --- arch/x86/kvm

[PATCH 0/7] KVM: nVMX: Enable unrestricted guest mode and fix some nEPT issues

2013-08-04 Thread Jan Kiszka
These patches apply on top of nEPT v6 and basically enable unrestricted guest mode to be used by L1. Jan Kiszka (7): KVM: nEPT: Advertise WB type EPTP KVM: nVMX: Replace kvm_set_cr0 with vmx_set_cr0 in load_vmcs12_host_state KVM: nVMX: Enable unrestricted guest mode support KVM: nVMX:

[PATCH 1/7] KVM: nEPT: Advertise WB type EPTP

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka At least WB must be possible. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e51bf4a..53050a0 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@

[PATCH 2/7] KVM: nVMX: Replace kvm_set_cr0 with vmx_set_cr0 in load_vmcs12_host_state

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka Likely a typo, but a fatal one as kvm_set_cr0 performs checks on the state transition that may prevent loading L1's cr0. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Gleb Natapov
On Mon, Aug 05, 2013 at 01:19:26AM +0800, Xiao Guangrong wrote: > > On Aug 5, 2013, at 12:58 AM, Gleb Natapov wrote: > > > On Sun, Aug 04, 2013 at 06:42:09PM +0200, Jan Kiszka wrote: > >> On 2013-08-04 18:15, Xiao Guangrong wrote: > >>> > >>> On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: > >>

Re: [PATCH] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Jan Kiszka
On 2013-08-04 19:18, Arthur Chunqi Li wrote: >>> diff --git a/x86/vmx.h b/x86/vmx.h >>> index d80e000..f82bf5a 100644 >>> --- a/x86/vmx.h >>> +++ b/x86/vmx.h >>> @@ -1,5 +1,5 @@ >>> -#ifndef __HYPERVISOR_H >>> -#define __HYPERVISOR_H >>> +#ifndef __VMX_H >>> +#define __VMX_H >>> >>> #include "libc

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Xiao Guangrong
On Aug 5, 2013, at 12:58 AM, Gleb Natapov wrote: > On Sun, Aug 04, 2013 at 06:42:09PM +0200, Jan Kiszka wrote: >> On 2013-08-04 18:15, Xiao Guangrong wrote: >>> >>> On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: >>> On 2013-08-04 15:44, Gleb Natapov wrote: > On Sun, Aug 04, 2013 at 1

Re: [PATCH] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Arthur Chunqi Li
On Mon, Aug 5, 2013 at 12:54 AM, Jan Kiszka wrote: > On 2013-07-31 11:22, Arthur Chunqi Li wrote: >> Reconstruct VMX codes and put all VMX test suites in x86/vmx_tests.c. >> >> Signed-off-by: Arthur Chunqi Li >> --- >> config-x86-common.mak |2 +- >> x86/vmx.c | 71 >> +++-

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Gleb Natapov
On Sun, Aug 04, 2013 at 06:42:09PM +0200, Jan Kiszka wrote: > On 2013-08-04 18:15, Xiao Guangrong wrote: > > > > On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: > > > >> On 2013-08-04 15:44, Gleb Natapov wrote: > >>> On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: > On Sun, Aug

Re: [PATCH] kvm-unit-tests: VMX: Split VMX test suites to separate file

2013-08-04 Thread Jan Kiszka
On 2013-07-31 11:22, Arthur Chunqi Li wrote: > Reconstruct VMX codes and put all VMX test suites in x86/vmx_tests.c. > > Signed-off-by: Arthur Chunqi Li > --- > config-x86-common.mak |2 +- > x86/vmx.c | 71 > +++-- > x86/vmx.h

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Jan Kiszka
On 2013-08-04 18:15, Xiao Guangrong wrote: > > On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: > >> On 2013-08-04 15:44, Gleb Natapov wrote: >>> On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: > On Sun, Aug 04, 2

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Xiao Guangrong
On Aug 4, 2013, at 11:14 PM, Jan Kiszka wrote: > On 2013-08-04 15:44, Gleb Natapov wrote: >> On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: >>> On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: > On 2

[PATCH] nVMX: Keep arch.pat in sync on L1-L2 switches

2013-08-04 Thread Jan Kiszka
From: Jan Kiszka When asking vmx to load the PAT MSR for us while switching from L1 to L2 or vice versa, we have to update arch.pat as well as it may later be used again to load or read out the MSR content. Signed-off-by: Jan Kiszka --- Arthur, please add your tested-by also officially. arch

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Jan Kiszka
On 2013-08-04 15:44, Gleb Natapov wrote: > On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: >> On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: >>> On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: On 2013-08-01 16:08, Gleb Natapov wrote: > Another day -

Re: [RFC PATCH 00/12] KVM: MMU: locklessly wirte-protect

2013-08-04 Thread Xiao Guangrong
On Aug 3, 2013, at 1:09 PM, Takuya Yoshikawa wrote: > On Tue, 30 Jul 2013 21:01:58 +0800 > Xiao Guangrong wrote: > >> Background >> == >> Currently, when mark memslot dirty logged or get dirty page, we need to >> write-protect large guest memory, it is the heavy work, especially, we ne

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Gleb Natapov
On Sun, Aug 04, 2013 at 12:53:56PM +0300, Gleb Natapov wrote: > On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: > > On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: > > > On 2013-08-01 16:08, Gleb Natapov wrote: > > > > Another day -- another version of the nested EPT patch

Re: [PATCH] KVM: nVMX: correctly set tr base on nested vmexit emulation

2013-08-04 Thread Gleb Natapov
On Sun, Aug 04, 2013 at 08:21:00PM +0800, Arthur Chunqi Li wrote: > Yes, I have just retraced and found the bug. This is my negligence. > Reviewers could have done a better job too :) > Reviewed-by: Arthur Chunqi Li > > On Sun, Aug 4, 2013 at 8:08 PM, Gleb Natapov wrote: > > After commit 21feb

Re: kernel 3.10.1 - "NMI received for unknown reason"

2013-08-04 Thread Gleb Natapov
On Fri, Aug 02, 2013 at 08:24:38AM +0200, Stefan Pietsch wrote: > On 31.07.2013 11:20, Gleb Natapov wrote: > > On Wed, Jul 31, 2013 at 11:10:01AM +0200, Stefan Pietsch wrote: > >> On 30.07.2013 07:31, Gleb Natapov wrote: > >> > >>> What happen if you run perf on your host (perf record -a)? > >>> Do

Re: [PATCH] KVM: nVMX: correctly set tr base on nested vmexit emulation

2013-08-04 Thread Arthur Chunqi Li
Yes, I have just retraced and found the bug. This is my negligence. Reviewed-by: Arthur Chunqi Li On Sun, Aug 4, 2013 at 8:08 PM, Gleb Natapov wrote: > After commit 21feb4eb64e21f8dc91136b91ee886b978ce6421 tr base is zeroed > during vmexit. Set it to L1's HOST_TR_BASE. This should fix > https:/

[PATCH] KVM: nVMX: correctly set tr base on nested vmexit emulation

2013-08-04 Thread Gleb Natapov
After commit 21feb4eb64e21f8dc91136b91ee886b978ce6421 tr base is zeroed during vmexit. Set it to L1's HOST_TR_BASE. This should fix https://bugzilla.kernel.org/show_bug.cgi?id=60679 Signed-off-by: Gleb Natapov diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b533cf8..7d31e7b 100644 ---

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Gleb Natapov
On Sun, Aug 04, 2013 at 12:32:06PM +0300, Gleb Natapov wrote: > On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: > > On 2013-08-01 16:08, Gleb Natapov wrote: > > > Another day -- another version of the nested EPT patches. In this version > > > included fix for need_remote_flush() with sh

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Gleb Natapov
On Sun, Aug 04, 2013 at 11:24:41AM +0200, Jan Kiszka wrote: > On 2013-08-01 16:08, Gleb Natapov wrote: > > Another day -- another version of the nested EPT patches. In this version > > included fix for need_remote_flush() with shadowed ept, set bits 6:8 > > of exit_qualification during ept_violatio

Re: [PATCH v6 00/15] Nested EPT

2013-08-04 Thread Jan Kiszka
On 2013-08-01 16:08, Gleb Natapov wrote: > Another day -- another version of the nested EPT patches. In this version > included fix for need_remote_flush() with shadowed ept, set bits 6:8 > of exit_qualification during ept_violation, update_permission_bitmask() > made to work with shadowed ept page