Re: [PATCH 2/4] KVM: SVM: use NPT page attributes

2015-07-09 Thread Xiao Guangrong
On 07/09/2015 11:18 PM, Paolo Bonzini wrote: On 09/07/2015 04:30, Xiao Guangrong wrote: diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 602b974a60a6..0f125c1860ec 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1085,6 +1085,47 @@ static u64 svm_compute_tsc_offset

Re: [PATCH 2/4] KVM: SVM: use NPT page attributes

2015-07-08 Thread Xiao Guangrong
On 07/08/2015 07:19 PM, Paolo Bonzini wrote: On 08/07/2015 07:59, Xiao Guangrong wrote: On 07/07/2015 09:45 PM, Paolo Bonzini wrote: Right now, NPT page attributes are not used, and the final page attribute depends solely on gPAT (which however is not synced correctly), the guest MTRRs

Re: [PATCH 2/4] KVM: SVM: use NPT page attributes

2015-07-08 Thread Xiao Guangrong
On 07/07/2015 09:45 PM, Paolo Bonzini wrote: Right now, NPT page attributes are not used, and the final page attribute depends solely on gPAT (which however is not synced correctly), the guest MTRRs and the guest page attributes. However, we can do better by mimicking what is done for VMX. In

Re: [PATCH 2/4] KVM: SVM: use NPT page attributes

2015-07-08 Thread Xiao Guangrong
On 07/07/2015 09:45 PM, Paolo Bonzini wrote: Right now, NPT page attributes are not used, and the final page attribute depends solely on gPAT (which however is not synced correctly), the guest MTRRs and the guest page attributes. However, we can do better by mimicking what is done for VMX. In

Re: [PATCH 2/4] KVM: SVM: use NPT page attributes

2015-07-08 Thread Xiao Guangrong
On 07/08/2015 07:19 PM, Paolo Bonzini wrote: On 08/07/2015 07:59, Xiao Guangrong wrote: On 07/07/2015 09:45 PM, Paolo Bonzini wrote: Right now, NPT page attributes are not used, and the final page attribute depends solely on gPAT (which however is not synced correctly), the guest MTRRs

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

2015-06-23 Thread Xiao Guangrong
On 06/23/2015 04:00 PM, Paolo Bonzini wrote: On 23/06/2015 04:29, Xiao Guangrong wrote: If so, can you look at kvm/queue and see if it is okay for you (so that we can get the series in 4.2)? Ping? If I don't get testing results before Wednesday, I'll drop this series from the 4.2 pull

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

2015-06-23 Thread Xiao Guangrong
On 06/23/2015 04:00 PM, Paolo Bonzini wrote: On 23/06/2015 04:29, Xiao Guangrong wrote: If so, can you look at kvm/queue and see if it is okay for you (so that we can get the series in 4.2)? Ping? If I don't get testing results before Wednesday, I'll drop this series from the 4.2 pull

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

2015-06-22 Thread Xiao Guangrong
On 06/22/2015 07:24 PM, Paolo Bonzini wrote: On 17/06/2015 18:11, Paolo Bonzini wrote: Also, this loop looks weird. Is this what you wanted? list_for_each_entry(tmp, _state->head, node) if (cur->base >= tmp->base) break;

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

2015-06-22 Thread Xiao Guangrong
On 06/22/2015 07:24 PM, Paolo Bonzini wrote: On 17/06/2015 18:11, Paolo Bonzini wrote: Also, this loop looks weird. Is this what you wanted? list_for_each_entry(tmp, mtrr_state-head, node) if (cur-base = tmp-base) break;

Re: [PATCH v2 12/13] KVM: x86: add SMM to the MMU role, support SMRAM address space

2015-06-17 Thread Xiao Guangrong
On 06/17/2015 04:18 PM, Paolo Bonzini wrote: On 09/06/2015 06:01, Xiao Guangrong wrote: On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is now very simple to do. The only interesting part is a simple trick to find the right memslot in gfn_to_rmap, retrieving the address space from

Re: [PATCH v2 09/13] KVM: x86: pass kvm_mmu_page to gfn_to_rmap

2015-06-17 Thread Xiao Guangrong
On 06/17/2015 04:15 PM, Paolo Bonzini wrote: On 09/06/2015 05:28, Xiao Guangrong wrote: -rmapp = gfn_to_rmap(kvm, sp->gfn, PT_PAGE_TABLE_LEVEL); +slots = kvm_memslots(kvm); +slot = __gfn_to_memslot(slots, sp->gfn); +rmapp = __gfn_to_rmap(sp->gfn, PT_PAGE_TABLE_LE

Re: [PATCH v2 12/13] KVM: x86: add SMM to the MMU role, support SMRAM address space

2015-06-17 Thread Xiao Guangrong
On 06/17/2015 04:18 PM, Paolo Bonzini wrote: On 09/06/2015 06:01, Xiao Guangrong wrote: On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is now very simple to do. The only interesting part is a simple trick to find the right memslot in gfn_to_rmap, retrieving the address space from

Re: [PATCH v2 09/13] KVM: x86: pass kvm_mmu_page to gfn_to_rmap

2015-06-17 Thread Xiao Guangrong
On 06/17/2015 04:15 PM, Paolo Bonzini wrote: On 09/06/2015 05:28, Xiao Guangrong wrote: -rmapp = gfn_to_rmap(kvm, sp-gfn, PT_PAGE_TABLE_LEVEL); +slots = kvm_memslots(kvm); +slot = __gfn_to_memslot(slots, sp-gfn); +rmapp = __gfn_to_rmap(sp-gfn, PT_PAGE_TABLE_LEVEL, slot

[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 --- 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 index cbf9f07..fe9cbe4 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 --- arch/x86/include/asm/kvm_host.h | 9 - arch/x86/kvm/mtrr.c | 7 +++ arch/x86/kvm/x86.c | 1 - 3 files changed

[PATCH v2 00/15] vMTRR bugfix and optimization

2015-06-15 Thread Xiao Guangrong
as it expected This patchset fixes these bugs and also do optimization and cleanups. Xiao Guangrong (15): KVM: x86: fix CR0.CD virtualization KVM: x86: move MTRR related code to a separate file KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr KVM: MTRR: remove mtrr_state.have_fixed KVM: MTRR

[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 --- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/Makefile | 2 +- arch/x86

[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 --- arch/x86/kvm/mtrr.c | 12 arch/x86/kvm/x86.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git

[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 --- arch/x86

[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 --- 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 --- a/arch/x86/kvm/mtrr.c

[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 --- arch/x86/include/asm/kvm_host.h | 3 ++ arch/x86/kvm/mtrr.c | 63

[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 --- arch/x86/kvm/mtrr.c | 200 ++-- 1 file

[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 --- arch/x86/kvm/vmx.c | 32

[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 --- arch/x86/kvm/mmu.c | 20

[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 --- arch/x86/kvm/mtrr.c | 64 ++--- 1 file changed, 16 insertions(+), 48 deletions(-) diff --git a/arch/x86/kvm/mtrr.c b/arch

[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 --- arch/x86/kvm/mtrr.c | 188 1 file changed, 188 insertions(+) diff

[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 --- arch/x86

[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 --- arch/x86/include/asm/kvm_host.h | 7 ++- arch/x86/kvm/mtrr.c | 32 ++-- 2 files changed, 16

[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 --- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/mtrr.c | 40 2 files changed, 29 insertions(+), 14 deleti

[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 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 guangrong.x

[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 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 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 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 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 00/15] vMTRR bugfix and optimization

2015-06-15 Thread Xiao Guangrong
as it expected This patchset fixes these bugs and also do optimization and cleanups. Xiao Guangrong (15): KVM: x86: fix CR0.CD virtualization KVM: x86: move MTRR related code to a separate file KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr KVM: MTRR: remove mtrr_state.have_fixed KVM: MTRR

[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 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 --- arch

[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 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 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 --- arch/x86

[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 guangrong.x

Re: [PATCH v2 12/13] KVM: x86: add SMM to the MMU role, support SMRAM address space

2015-06-08 Thread Xiao Guangrong
ks good to me: Reviewed-by: Xiao Guangrong -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

Re: [PATCH v2 11/13] KVM: x86: work on all available address spaces

2015-06-08 Thread Xiao Guangrong
introduced in order to operate on all address spaces when adding or deleting private memory slots. Reviewed-by: Xiao Guangrong -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.

Re: [PATCH v2 10/13] KVM: x86: use vcpu-specific functions to read/write/translate GFNs

2015-06-08 Thread Xiao Guangrong
* to the newly-introduced kvm_vcpu_*, which call into kvm_arch_vcpu_memslots_id. Reviewed-by: Xiao Guangrong -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo

Re: [PATCH v2 09/13] KVM: x86: pass kvm_mmu_page to gfn_to_rmap

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is always available (with one exception in the auditing code). Later we will also use the role to look up the right memslots array. return; @@ -191,11 +191,15 @@ static void audit_write_protection(struct kvm *kvm,

Re: [PATCH v2 08/13] KVM: implement multiple address spaces

2015-06-08 Thread Xiao Guangrong
t these decoding into a separate function? Nice idea indeed. Reviewed-by: Xiao Guangrong -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Pl

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-08 Thread Xiao Guangrong
On 06/09/2015 08:36 AM, David Matlack wrote: On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong wrote: 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 --- arch/x86/kvm

Re: [PATCH 09/15] KVM: MTRR: introduce var_mtrr_range

2015-06-08 Thread Xiao Guangrong
Thanks for your review, David! On 06/09/2015 08:36 AM, David Matlack wrote: static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) { struct kvm_mtrr *mtrr_state = >arch.mtrr_state; - gfn_t start, end, mask; + gfn_t start, end; int index; if (msr

Re: [PATCH 09/15] KVM: MTRR: introduce var_mtrr_range

2015-06-08 Thread Xiao Guangrong
Thanks for your review, David! On 06/09/2015 08:36 AM, David Matlack wrote: static void update_mtrr(struct kvm_vcpu *vcpu, u32 msr) { struct kvm_mtrr *mtrr_state = vcpu-arch.mtrr_state; - gfn_t start, end, mask; + gfn_t start, end; int index; if

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-08 Thread Xiao Guangrong
On 06/09/2015 08:36 AM, David Matlack wrote: On Sat, May 30, 2015 at 3:59 AM, Xiao Guangrong guangrong.x...@linux.intel.com wrote: 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

Re: [PATCH v2 09/13] KVM: x86: pass kvm_mmu_page to gfn_to_rmap

2015-06-08 Thread Xiao Guangrong
On 05/28/2015 01:05 AM, Paolo Bonzini wrote: This is always available (with one exception in the auditing code). Later we will also use the role to look up the right memslots array. return; @@ -191,11 +191,15 @@ static void audit_write_protection(struct kvm *kvm,

Re: [PATCH v2 10/13] KVM: x86: use vcpu-specific functions to read/write/translate GFNs

2015-06-08 Thread Xiao Guangrong
* to the newly-introduced kvm_vcpu_*, which call into kvm_arch_vcpu_memslots_id. Reviewed-by: Xiao Guangrong guangrong.x...@linux.intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http

Re: [PATCH v2 08/13] KVM: implement multiple address spaces

2015-06-08 Thread Xiao Guangrong
into a separate function? Nice idea indeed. Reviewed-by: Xiao Guangrong guangrong.x...@linux.intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please

Re: [PATCH v2 11/13] KVM: x86: work on all available address spaces

2015-06-08 Thread Xiao Guangrong
to operate on all address spaces when adding or deleting private memory slots. Reviewed-by: Xiao Guangrong guangrong.x...@linux.intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http

Re: [PATCH v2 12/13] KVM: x86: add SMM to the MMU role, support SMRAM address space

2015-06-08 Thread Xiao Guangrong
good to me: Reviewed-by: Xiao Guangrong guangrong.x...@linux.intel.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http

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

2015-06-05 Thread Xiao Guangrong
[ CCed Zhang Yang ] On 06/04/2015 04:36 PM, Paolo Bonzini wrote: On 04/06/2015 10:23, Xiao Guangrong wrote: So, why do you need to always use IPAT=0? Can patch 15 keep the current logic for RAM, like this: if (is_mmio || kvm_arch_has_noncoherent_dma(vcpu->kvm))

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

2015-06-05 Thread Xiao Guangrong
[ CCed Zhang Yang ] On 06/04/2015 04:36 PM, Paolo Bonzini wrote: On 04/06/2015 10:23, Xiao Guangrong wrote: So, why do you need to always use IPAT=0? Can patch 15 keep the current logic for RAM, like this: if (is_mmio || kvm_arch_has_noncoherent_dma(vcpu-kvm)) ret

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

2015-06-04 Thread Xiao Guangrong
On 06/04/2015 04:23 PM, Xiao Guangrong wrote: On 06/03/2015 03:55 PM, Paolo Bonzini wrote: On 03/06/2015 04:56, Xiao Guangrong wrote: On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop

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

2015-06-04 Thread Xiao Guangrong
On 06/03/2015 03:55 PM, Paolo Bonzini wrote: On 03/06/2015 04:56, Xiao Guangrong wrote: On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop is supported on IOMMU (!noncoherent_dma

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

2015-06-04 Thread Xiao Guangrong
On 06/03/2015 03:55 PM, Paolo Bonzini wrote: On 03/06/2015 04:56, Xiao Guangrong wrote: On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop is supported on IOMMU (!noncoherent_dma

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

2015-06-04 Thread Xiao Guangrong
On 06/04/2015 04:23 PM, Xiao Guangrong wrote: On 06/03/2015 03:55 PM, Paolo Bonzini wrote: On 03/06/2015 04:56, Xiao Guangrong wrote: On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 10:26 PM, Paolo Bonzini wrote: On 01/06/2015 11:33, Paolo Bonzini wrote: + looker->mem_type = looker->mtrr_state->fixed_ranges[index]; + looker->start = fixed_mtrr_range_end_addr(seg, index); + return true; in mtrr_lookup_fixed_start is the same as this:

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

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop is supported on IOMMU (!noncoherent_dma) and host does the emulation based on the knowledge from host side, however, host side is not the good

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:33 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: +struct mtrr_looker { + /* input fields. */ + struct kvm_mtrr *mtrr_state; + u64 start; + u64 end; s/looker/iter/ or s/looker/lookup/ Good to me. +static void

Re: [PATCH 10/15] KVM: MTRR: sort variable MTRRs

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:27 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: 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 --- arch/x86/include/asm

Re: [PATCH 08/15] KVM: MTRR: introduce fixed_mtrr_segment table

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:25 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: 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

Re: [PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:16 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: - 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

Re: [PATCH 05/15] KVM: MTRR: clean up mtrr default type

2015-06-02 Thread Xiao Guangrong
Thanks for your review, Paolo! On 06/01/2015 05:11 PM, Paolo Bonzini wrote: struct kvm_vcpu_arch { diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index 562341b..6de49dd 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -105,7 +105,6 @@ EXPORT_SYMBOL_GPL(kvm_mtrr_valid);

Re: [PATCH 05/15] KVM: MTRR: clean up mtrr default type

2015-06-02 Thread Xiao Guangrong
Thanks for your review, Paolo! On 06/01/2015 05:11 PM, Paolo Bonzini wrote: struct kvm_vcpu_arch { diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c index 562341b..6de49dd 100644 --- a/arch/x86/kvm/mtrr.c +++ b/arch/x86/kvm/mtrr.c @@ -105,7 +105,6 @@ EXPORT_SYMBOL_GPL(kvm_mtrr_valid);

Re: [PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:16 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: - 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

Re: [PATCH 10/15] KVM: MTRR: sort variable MTRRs

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:27 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: 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

Re: [PATCH 08/15] KVM: MTRR: introduce fixed_mtrr_segment table

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:25 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: 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

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:33 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: +struct mtrr_looker { + /* input fields. */ + struct kvm_mtrr *mtrr_state; + u64 start; + u64 end; s/looker/iter/ or s/looker/lookup/ Good to me. +static void

Re: [PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 10:26 PM, Paolo Bonzini wrote: On 01/06/2015 11:33, Paolo Bonzini wrote: + looker-mem_type = looker-mtrr_state-fixed_ranges[index]; + looker-start = fixed_mtrr_range_end_addr(seg, index); + return true; in mtrr_lookup_fixed_start is the same as this: +

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

2015-06-02 Thread Xiao Guangrong
On 06/01/2015 05:36 PM, Paolo Bonzini wrote: On 30/05/2015 12:59, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop is supported on IOMMU (!noncoherent_dma) and host does the emulation based on the knowledge from host side, however, host side is not the good

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

2015-05-30 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 --- arch/x86/kvm/mtrr.c | 12 arch/x86/kvm/x86.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git

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

2015-05-30 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 --- arch/x86/include/asm/kvm_host.h | 7 ++- arch/x86/kvm/mtrr.c | 32 ++-- 2 files changed, 16

Re: [PATCH 00/15] KVM: x86: fully implement vMTRR

2015-05-30 Thread Xiao Guangrong
On 05/30/2015 06:59 PM, Xiao Guangrong wrote: Currently guest MTRR is completely prohibited if cache snoop is supported on IOMMU (!noncoherent_dma) and host does the emulation based on the knowledge from host side, however, host side is not the good point to know what the purpose of guest

[PATCH 12/15] KVM: MTRR: introduce mtrr_for_each_mem_type

2015-05-30 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 --- arch/x86/kvm/mtrr.c | 183 1 file changed, 183 insertions(+) diff

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

2015-05-30 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 --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/Makefile | 2 +- arch/x86

[PATCH 10/15] KVM: MTRR: sort variable MTRRs

2015-05-30 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 --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/mtrr.c | 39

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

2015-05-30 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 --- arch/x86

[PATCH 13/15] KVM: MTRR: simplify kvm_mtrr_get_guest_memory_type

2015-05-30 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 --- arch/x86/kvm/mtrr.c | 61 + 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/arch/x86/kvm/mtrr.c b/arch

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

2015-05-30 Thread Xiao Guangrong
Only KVM_NR_VAR_MTRR variable MTRRs are available in KVM guest Signed-off-by: Xiao Guangrong --- 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 index 65de1b3..2c3c52d 100644

[PATCH 08/15] KVM: MTRR: introduce fixed_mtrr_segment table

2015-05-30 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 --- arch/x86/kvm/mtrr.c | 191 ++-- 1 file

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

2015-05-30 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 --- arch/x86/kvm/mmu.c | 20

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

2015-05-30 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 --- arch/x86/include/asm/kvm_host.h | 9 - arch/x86/kvm/mtrr.c | 7 +++ arch/x86/kvm/x86.c | 1 - 3 files changed

[PATCH 07/15] KVM: MTRR: improve kvm_mtrr_get_guest_memory_type

2015-05-30 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 --- arch/x86

[PATCH 09/15] KVM: MTRR: introduce var_mtrr_range

2015-05-30 Thread Xiao Guangrong
It gets the range for the specified variable MTRR Signed-off-by: Xiao Guangrong --- 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 888441e..aeb9767 100644 --- a/arch/x86/kvm/mtrr.c

[PATCH 15/15] KVM: VMX: fully implement guest MTRR virtualization

2015-05-30 Thread Xiao Guangrong
buffer is not always UC as host expected This patchset enables full MTRR virtualization and currently only works on Intel EPT architecture Signed-off-by: Xiao Guangrong --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/mmu.c | 3 +-- arch/x86/kvm/mtrr.c | 3

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

2015-05-30 Thread Xiao Guangrong
Use union definition to avoid the decode/code workload and drop all the hard code Signed-off-by: Xiao Guangrong --- arch/x86/include/asm/kvm_host.h | 12 ++-- arch/x86/kvm/mtrr.c | 19 --- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/arch

[PATCH 00/15] KVM: x86: fully implement vMTRR

2015-05-30 Thread Xiao Guangrong
regression is detected Xiao Guangrong (15): KVM: x86: move MTRR related code to a separate file KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr KVM: MTRR: remove mtrr_state.have_fixed KVM: MTRR: exactly define the size of variable MTRRs KVM: MTRR: clean up mtrr default type KVM: MTRR

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

2015-05-30 Thread Xiao Guangrong
Use union definition to avoid the decode/code workload and drop all the hard code Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 12 ++-- arch/x86/kvm/mtrr.c | 19 --- 2 files changed, 18 insertions(+), 13

[PATCH 00/15] KVM: x86: fully implement vMTRR

2015-05-30 Thread Xiao Guangrong
regression is detected Xiao Guangrong (15): KVM: x86: move MTRR related code to a separate file KVM: MTRR: handle MSR_MTRRcap in kvm_mtrr_get_msr KVM: MTRR: remove mtrr_state.have_fixed KVM: MTRR: exactly define the size of variable MTRRs KVM: MTRR: clean up mtrr default type KVM: MTRR

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

2015-05-30 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 15/15] KVM: VMX: fully implement guest MTRR virtualization

2015-05-30 Thread Xiao Guangrong
buffer is not always UC as host expected This patchset enables full MTRR virtualization and currently only works on Intel EPT architecture Signed-off-by: Xiao Guangrong guangrong.x...@linux.intel.com --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/mmu.c | 3 +-- arch/x86/kvm

<    1   2   3   4   5   6   7   8   9   10   >