[PATCH v5 11/12] KVM: x86: introduce set_mmio_exit_info

2012-08-07 Thread Xiao Guangrong
Introduce set_mmio_exit_info to cleanup the common code Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c | 33 + 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4c86239..8cde327 100644 --- a

[PATCH v5 10/12] KVM: introduce readonly memslot

2012-08-07 Thread Xiao Guangrong
memslot, write access on readonly memslot will cause KVM_EXIT_MMIO exit Signed-off-by: Xiao Guangrong --- Documentation/virtual/kvm/api.txt | 10 +++- arch/x86/include/asm/kvm.h|1 + arch/x86/kvm/mmu.c|9 arch/x86/kvm/x86.c|1 + include/linux

[PATCH v5 09/12] KVM: introduce KVM_HVA_ERR_RO_BAD

2012-08-07 Thread Xiao Guangrong
In the later patch, it indicates failure when we try to get a writable hva from the readonly slot Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index

[PATCH v5 08/12] KVM: introduce KVM_HVA_ERR_BAD

2012-08-07 Thread Xiao Guangrong
Then, remove bad_hva and inline kvm_is_error_hva Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |8 +++- virt/kvm/kvm_main.c | 13 + 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index

[PATCH v5 07/12] KVM: introduce KVM_PFN_ERR_RO_FAULT

2012-08-07 Thread Xiao Guangrong
In the later patch, it indicates failure when we try to get a writable pfn from the readonly memslot Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index

[PATCH v5 06/12] KVM: use 'writable' as a hint to map writable pfn

2012-08-07 Thread Xiao Guangrong
In current code, we always map writable pfn for the read-fault, in order to support readonly memslot, we map writable pfn only if 'writable' is not NULL Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 24 +++- 1 files changed, 23 insertions(+), 1 deletion

[PATCH v5 05/12] KVM: reorganize hva_to_pfn

2012-08-07 Thread Xiao Guangrong
We do too many things in hva_to_pfn, this patch reorganize the code, let it be better readable Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 159 +++ 1 files changed, 97 insertions(+), 62 deletions(-) diff --git a/virt/kvm/kvm_main.c b

[PATCH v5 04/12] KVM: introduce gfn_to_hva_read/kvm_read_hva/kvm_read_hva_atomic

2012-08-07 Thread Xiao Guangrong
This set of functions is only used to read data from host space, in the later patch, we will only get a readonly hva in gfn_to_hva_read, and the function name is a good hint to let gfn_to_hva_read to pair with kvm_read_hva()/kvm_read_hva_atomic() Signed-off-by: Xiao Guangrong --- virt/kvm

[PATCH v5 03/12] KVM: introduce gfn_to_pfn_memslot_atomic

2012-08-07 Thread Xiao Guangrong
It can instead of hva_to_pfn_atomic Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |5 + include/linux/kvm_host.h |3 ++- virt/kvm/kvm_main.c | 14 -- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm

[PATCH v5 02/12] KVM: hide KVM_MEMSLOT_INVALID from userspace

2012-08-07 Thread Xiao Guangrong
Quote Avi's comment: | KVM_MEMSLOT_INVALID is actually an internal symbol, not used by | userspace. Please move it to kvm_host.h. Also, move KVM_MEMSLOT_INVALID to the highest bit Signed-off-by: Xiao Guangrong --- include/linux/kvm.h |1 - include/linux/kvm_host.h |2 ++ 2

[PATCH v5 01/12] KVM: fix missing check for memslot flags

2012-08-07 Thread Xiao Guangrong
Check flags when memslot is registered from userspace as Avi's suggestion Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a2e85af..7b94d70 100644 --- a

[PATCH v5 00/12] KVM: introduce readonly memslot

2012-08-07 Thread Xiao Guangrong
Changelog: - introduce KVM_PFN_ERR_RO_FAULT instead of dummy page - introduce KVM_HVA_ERR_BAD and optimize error hva indicators The test case can be found at: http://lkml.indiana.edu/hypermail/linux/kernel/1207.2/00819/migrate-perf.tar.bz2 In current code, if we map a readonly memory space from h

Re: [PATCH 4/9] KVM: define kvm_bad_pfn statically

2012-08-03 Thread Xiao Guangrong
Marcelo, Paul, Thanks for your review! On 08/03/2012 08:01 AM, Paul Mackerras wrote: > On Thu, Aug 02, 2012 at 10:15:27AM -0300, Marcelo Tosatti wrote: > >> Remind me what is the guarantee that -Exxx does not clash with >> a valid pfn number? > > A pfn number is an address >> PAGE_SHIFT, so it

Re: [PATCH 8/9] KVM: do not release the error pfn

2012-08-03 Thread Xiao Guangrong
On 08/02/2012 09:14 PM, Marcelo Tosatti wrote: > On Sun, Jul 29, 2012 at 04:18:58PM +0800, Xiao Guangrong wrote: >> After commit a2766325cf9f9, the error pfn is replaced by the >> error code, it need not be released anymore >> >> [ The patch is compiling tested for po

[PATCH v2 10/10] KVM: let the error pfn not depend on error code

2012-08-03 Thread Xiao Guangrong
bits to indicate the error. Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h | 24 +++- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a8989fc..2aaff6e 100644 --- a/include/linux/kvm_host.h

[PATCH v2 09/10] KVM: do not release the error page

2012-08-03 Thread Xiao Guangrong
After commit a2766325cf9f9, the error page is replaced by the error code, it need not be released anymore [ The patch has been compiling tested for powerpc ] Signed-off-by: Xiao Guangrong --- arch/powerpc/kvm/44x_tlb.c |1 - arch/powerpc/kvm/book3s_pr.c |4 +--- arch/x86/kvm/svm.c

[PATCH v2 08/10] KVM: do not release the error pfn

2012-08-03 Thread Xiao Guangrong
After commit a2766325cf9f9, the error pfn is replaced by the error code, it need not be released anymore [ The patch has been compiling tested for powerpc ] Signed-off-by: Xiao Guangrong --- arch/powerpc/kvm/e500_tlb.c |1 - arch/x86/kvm/mmu.c |7 +++ arch/x86/kvm

[PATCH v2 07/10] KVM: introduce KVM_ERR_PTR_BAD_PAGE

2012-08-03 Thread Xiao Guangrong
It is used to eliminate the overload of function call and cleanup the code Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |9 +++-- virt/kvm/async_pf.c |2 +- virt/kvm/kvm_main.c | 13 + 3 files changed, 9 insertions(+), 15 deletions(-) diff

[PATCH v2 06/10] KVM: remove the unused declare

2012-08-03 Thread Xiao Guangrong
Remove it since it is not used anymore Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f604d1d..bdf2182 100644 --- a/include/linux/kvm_host.h +++ b

[PATCH v2 05/10] KVM: inline is_*_pfn functions

2012-08-03 Thread Xiao Guangrong
These functions are exported and can not inline, move them to kvm_host.h to eliminate the overload of function call Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h | 19 --- virt/kvm/kvm_main.c | 18 -- 2 files changed, 16 insertions(+), 21

[PATCH v2 04/10] KVM: introduce KVM_PFN_ERR_BAD

2012-08-03 Thread Xiao Guangrong
Then, remove get_bad_pfn Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |1 + virt/kvm/kvm_main.c |7 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index cbd5af8..ba8b222 100644 --- a/include

[PATCH v2 03/10] KVM: introduce KVM_PFN_ERR_HWPOISON

2012-08-03 Thread Xiao Guangrong
Then, get_hwpoison_pfn and is_hwpoison_pfn can be removed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |2 +- include/linux/kvm_host.h |2 +- virt/kvm/kvm_main.c | 13 + 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/mmu.c b

[PATCH v2 02/10] KVM: introduce KVM_PFN_ERR_FAULT

2012-08-03 Thread Xiao Guangrong
After that, the exported and un-inline function, get_fault_pfn, can be removed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |2 +- include/linux/kvm_host.h |3 ++- virt/kvm/kvm_main.c | 12 +++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a

[PATCH v2 01/10] KVM: iommu: fix releasing unmapped page

2012-08-03 Thread Xiao Guangrong
There are two bugs: - the 'error page' is forgot to be released [ it is unneeded after commit a2766325cf9f9, for backport, we still do kvm_release_pfn_clean for the error pfn ] - guest pages are always released regardless of the unmapped page (e,g, caused by hwpoison) Signed-of

Re: [PATCH 8/9] KVM: do not release the error pfn

2012-07-29 Thread Xiao Guangrong
kvm_release_pfn_clean in kvm_handle_bad_page() also can be removed, please review this one instead. Changelog: remove kvm_release_pfn_clean in kvm_handle_bad_page() From: Xiao Guangrong Subject: [PATCH 08/21] KVM: do not release the error pfn After commit a2766325cf9f9, the error pfn is

[PATCH 9/9] KVM: do not release the error page

2012-07-29 Thread Xiao Guangrong
After commit a2766325cf9f9, the error page is replaced by the error code, it need not be released anymore [ The patch is compiling tested for powerpc ] Signed-off-by: Xiao Guangrong --- arch/powerpc/kvm/44x_tlb.c |1 - arch/powerpc/kvm/book3s_pr.c |4 +--- arch/x86/kvm/svm.c

[PATCH 8/9] KVM: do not release the error pfn

2012-07-29 Thread Xiao Guangrong
After commit a2766325cf9f9, the error pfn is replaced by the error code, it need not be released anymore [ The patch is compiling tested for powerpc ] Signed-off-by: Xiao Guangrong --- arch/powerpc/kvm/e500_tlb.c |1 - arch/x86/kvm/mmu.c |6 +++--- arch/x86/kvm/mmu_audit.c

[PATCH 7/9] KVM: define kvm_bad_page statically

2012-07-29 Thread Xiao Guangrong
It is used to eliminate the overload of function call and cleanup the code Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |9 +++-- virt/kvm/async_pf.c |2 +- virt/kvm/kvm_main.c | 13 + 3 files changed, 9 insertions(+), 15 deletions(-) diff

[PATCH 6/9] KVM: remove the unused declare

2012-07-29 Thread Xiao Guangrong
Remove it since it is not used anymore Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 98255ce..387ecc5 100644 --- a/include/linux/kvm_host.h +++ b

[PATCH 5/9] KVM: inline is_*_pfn functions

2012-07-29 Thread Xiao Guangrong
These functions are exported and can not inline, move them to kvm_host.h to eliminate the overload of function call Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h | 19 --- virt/kvm/kvm_main.c | 18 -- 2 files changed, 16 insertions(+), 21

[PATCH 4/9] KVM: define kvm_bad_pfn statically

2012-07-29 Thread Xiao Guangrong
Then, remove get_bad_pfn Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |1 + virt/kvm/kvm_main.c |7 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 4de56cd..b02203f 100644 --- a/include

[PATCH 3/9] KVM: define kvm_hwpoison_pfn statically

2012-07-29 Thread Xiao Guangrong
Then, get_hwpoison_pfn and is_hwpoison_pfn can be removed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |2 +- include/linux/kvm_host.h |4 ++-- virt/kvm/kvm_main.c | 13 + 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/mmu.c

[PATCH 2/9] KVM: define kvm_fault_pfn statically

2012-07-29 Thread Xiao Guangrong
After that, the exported and un-inline function, get_fault_pfn, can be removed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |2 +- include/linux/kvm_host.h |3 ++- virt/kvm/kvm_main.c | 12 +++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a

[PATCH 1/9] KVM: iommu: fix releasing unmapped page

2012-07-29 Thread Xiao Guangrong
There are two bugs: - the 'error page' is forgot to be released [ it is unneeded after commit a2766325cf9f9, for backport, we still do kvm_release_pfn_clean for the error pfn ] - guest pages are always released regardless of the unmapped page (e,g, caused by hwpoison) Signed-of

Re: [PATCH v2 3/3] KVM: remove dummy pages

2012-07-26 Thread Xiao Guangrong
On 07/26/2012 05:20 PM, Takuya Yoshikawa wrote: > On Thu, 26 Jul 2012 11:56:15 +0300 > Avi Kivity wrote: > >> Since my comments are better done as a separate patch, I applied all >> three patches. Thanks! > > Is this patch really safe for all architectures? > > IS_ERR_VALUE() casts -MAX_ERRNO

Re: [PATCH v2 3/3] KVM: remove dummy pages

2012-07-26 Thread Xiao Guangrong
On 07/26/2012 04:56 PM, Avi Kivity wrote: > On 07/26/2012 06:58 AM, Xiao Guangrong wrote: >> Currently, kvm allocates some pages and use them as error indicators, >> it wastes memory and is not good for scalability >> >> Base on Avi's suggestion, we use the error co

[PATCH v2] KVM: x86: simplify read_emulated

2012-07-25 Thread Xiao Guangrong
No need split mmio read region into 8-bits pieces since we do it in emulator_read_write_onepage Changelog: Add a WARN_ON to check read-cache overflow Acked-by: Marcelo Tosatti Signed-off-by: Xiao Guangrong --- arch/x86/kvm/emulate.c | 31 ++- 1 files changed

[PATCH v2 3/3] KVM: remove dummy pages

2012-07-25 Thread Xiao Guangrong
Currently, kvm allocates some pages and use them as error indicators, it wastes memory and is not good for scalability Base on Avi's suggestion, we use the error codes instead of these pages to indicate the error conditions Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |

[PATCH v2 1/3] KVM: MMU: use kvm_release_pfn_clean to release pfn

2012-07-25 Thread Xiao Guangrong
The current code depends on the fact that fault_page is the normal page, however, we will use the error code instead of these dummy pages in the later patch, so we use kvm_release_pfn_clean to release pfn which will release the error code properly Signed-off-by: Xiao Guangrong --- arch/x86/kvm

[PATCH v2 2/3] KVM: use kvm_release_page_clean to release the page

2012-07-25 Thread Xiao Guangrong
the error code properly Signed-off-by: Xiao Guangrong --- virt/kvm/async_pf.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 74268b4..ebae24b 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -112,7 +112,7

[PATCH v2 0/3] KVM: remove dummy pages

2012-07-25 Thread Xiao Guangrong
Changelog: correct some typos in the title/changelog. Currently, kvm allocates some pages (e.g: bad_page/fault_page) and use them as error indicators, it wastes memory and is not good for scalability. Base on Avi's suggestion, in this patchset, we introduce some error codes instead of these pag

Re: [PATCH 0/3] KVM: remove dummy pages

2012-07-23 Thread Xiao Guangrong
On 07/23/2012 10:03 PM, Xiao Guangrong wrote: > Currently, kvm allocates some pages and use then as error indicators, > it wastes memory and is not good for scalability. > > In this patchset, we introduce some error code instead of the pages to > indicate the error conditions. &g

[PATCH 3/3] KVM: remove dummy pages

2012-07-23 Thread Xiao Guangrong
Currently, kvm allocate some pages and use them as error indicators, it wastes memory and is not good for scalability. So we use the error code instead of the pages to indicate the error Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |3 +- virt/kvm/async_pf.c |3

[PATCH 2/3] KVM: use kvm_release_page_clean to guest page

2012-07-23 Thread Xiao Guangrong
probably Signed-off-by: Xiao Guangrong --- virt/kvm/async_pf.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 74268b4..ebae24b 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -112,7 +112,7 @@ void

[PATCH 1/3] KVM: MMU: using kvm_release_pfn_clean to release pfn

2012-07-23 Thread Xiao Guangrong
The current code depends on fault_page is the normal page, but we will use the error code instead of dummy page in the later patch, so using kvm_release_pfn_clean to release pfn which will release error code probably Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |2 +- 1 files

[PATCH 0/3] KVM: remove dummy pages

2012-07-23 Thread Xiao Guangrong
Currently, kvm allocates some pages and use then as error indicators, it wastes memory and is not good for scalability. In this patchset, we introduce some error code instead of the pages to indicate the error conditions. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel"

Re: [PATCH 2/9] KVM: x86: simplify read_emulated

2012-07-22 Thread Xiao Guangrong
On 07/21/2012 03:52 AM, Marcelo Tosatti wrote: > On Fri, Jul 20, 2012 at 09:15:44PM +0800, Xiao Guangrong wrote: >> On 07/20/2012 06:58 PM, Marcelo Tosatti wrote: >>> On Fri, Jul 20, 2012 at 10:17:36AM +0800, Xiao Guangrong wrote: >>>> On 07/20/2012 0

Re: [PATCH 5/9] KVM: MMU: fask check write-protect for direct mmu

2012-07-20 Thread Xiao Guangrong
On 07/20/2012 07:09 PM, Marcelo Tosatti wrote: > On Fri, Jul 20, 2012 at 10:34:28AM +0800, Xiao Guangrong wrote: >> On 07/20/2012 08:39 AM, Marcelo Tosatti wrote: >>> On Tue, Jul 17, 2012 at 09:53:29PM +0800, Xiao Guangrong wrote: >>>> If it have no indirect shadow

Re: [PATCH 2/9] KVM: x86: simplify read_emulated

2012-07-20 Thread Xiao Guangrong
On 07/20/2012 06:58 PM, Marcelo Tosatti wrote: > On Fri, Jul 20, 2012 at 10:17:36AM +0800, Xiao Guangrong wrote: >> On 07/20/2012 07:58 AM, Marcelo Tosatti wrote: >> >>>> - } >>>> + rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end

Re: [PATCH 5/9] KVM: MMU: fask check write-protect for direct mmu

2012-07-19 Thread Xiao Guangrong
wrote:can > On Tue, Jul 17, 2012 at 09:53:29PM +0800, Xiao Guangrong wrote: >> If it have no indirect shadow pages we need not protect any gfn, >> this is always true for direct mmu without nested >> >> Signed-off-by: Xiao Guangrong > > Xiao, > > What is the m

Re: [PATCH 08/10] KVM: introduce readonly_bad_hva

2012-07-19 Thread Xiao Guangrong
On 07/19/2012 06:16 PM, Avi Kivity wrote: > On 07/17/2012 05:45 PM, Xiao Guangrong wrote: >> In the later patch, it indicates failure when we try to get a writable >> hva from the readonly slot >> >> Signed-off-by: Xiao Guangrong >> --- >> virt/kvm/kvm

Re: [PATCH 07/10] KVM: introduce readonly_fault_pfn

2012-07-19 Thread Xiao Guangrong
On 07/19/2012 06:15 PM, Avi Kivity wrote: > On 07/17/2012 05:44 PM, Xiao Guangrong wrote: >> Introduce readonly_fault_pfn, in the later patch, it indicates failure >> when we try to get a writable pfn from the readonly memslot >> >> + >> inline int kvm_is_mmi

Re: [PATCH 5/9] KVM: MMU: fask check write-protect for direct mmu

2012-07-19 Thread Xiao Guangrong
On 07/20/2012 08:39 AM, Marcelo Tosatti wrote: > On Tue, Jul 17, 2012 at 09:53:29PM +0800, Xiao Guangrong wrote: >> If it have no indirect shadow pages we need not protect any gfn, >> this is always true for direct mmu without nested >> >> Signed-off-by: Xiao Guangrong

Re: [PATCH 3/9] KVM: x86: introduce set_mmio_exit_info

2012-07-19 Thread Xiao Guangrong
On 07/20/2012 08:03 AM, Marcelo Tosatti wrote: > On Tue, Jul 17, 2012 at 09:52:13PM +0800, Xiao Guangrong wrote: >> Introduce set_mmio_exit_info to cleanup the common code >> >> Signed-off-by: Xiao Guangrong >> --- >> arch/x86/kvm/x86.c | 33

Re: [PATCH 2/9] KVM: x86: simplify read_emulated

2012-07-19 Thread Xiao Guangrong
On 07/20/2012 07:58 AM, Marcelo Tosatti wrote: >> -} >> +rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, size, >> + &ctxt->exception); >> +if (rc != X86EMUL_CONTINUE) >> +return rc; >> + >> +mc->end += size; >> + >> +read_c

[PATCH 10/10] KVM: indicate readonly access fault

2012-07-17 Thread Xiao Guangrong
Introduce write_readonly_mem in mmio-exit-info to indicate this exit is caused by write access on readonly memslot Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c | 12 include/linux/kvm.h |3 +++ include/linux/kvm_host.h |1 + virt/kvm/kvm_main.c

[PATCH 09/10] KVM: introduce readonly memslot

2012-07-17 Thread Xiao Guangrong
memslot, write access on readonly memslot will cause KVM_EXIT_MMIO exit Signed-off-by: Xiao Guangrong --- Documentation/virtual/kvm/api.txt | 10 +++- arch/x86/include/asm/kvm.h|1 + arch/x86/kvm/mmu.c| 10 arch/x86/kvm/x86.c|1 + include/linux

[PATCH 08/10] KVM: introduce readonly_bad_hva

2012-07-17 Thread Xiao Guangrong
In the later patch, it indicates failure when we try to get a writable hva from the readonly slot Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 12 +++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index b70f1a4

[PATCH 07/10] KVM: introduce readonly_fault_pfn

2012-07-17 Thread Xiao Guangrong
Introduce readonly_fault_pfn, in the later patch, it indicates failure when we try to get a writable pfn from the readonly memslot Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |1 + virt/kvm/kvm_main.c | 92 +++-- 2 files changed

[PATCH 06/10] KVM: use 'writable' as a hint to map writable pfn

2012-07-17 Thread Xiao Guangrong
In current code, we always map writable pfn for the read-fault, in order to support readonly memslot, we map writable pfn only if 'writable' is not NULL Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 24 +++- 1 files changed, 23 insertions(+), 1 deletion

[PATCH 05/10] KVM: reorganize hva_to_pfn

2012-07-17 Thread Xiao Guangrong
We do too many things in hva_to_pfn, this patch reorganize the code, let it be better readable Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 161 +++ 1 files changed, 99 insertions(+), 62 deletions(-) diff --git a/virt/kvm/kvm_main.c b

[PATCH 04/10] KVM: introduce gfn_to_hva_read/kvm_read_hva/kvm_read_hva_atomic

2012-07-17 Thread Xiao Guangrong
This set of functions is only used to read data from host space, in the later patch, we will only get a readonly hva in gfn_to_hva_read, and the function name is a good hint to let gfn_to_hva_read to pair with kvm_read_hva()/kvm_read_hva_atomic() Signed-off-by: Xiao Guangrong --- virt/kvm

[PATCH 03/10] KVM: introduce gfn_to_pfn_memslot_atomic

2012-07-17 Thread Xiao Guangrong
It can instead of hva_to_pfn_atomic Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |5 + include/linux/kvm_host.h |3 ++- virt/kvm/kvm_main.c | 14 -- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm

[PATCH 02/10] KVM: hide KVM_MEMSLOT_INVALID from userspace

2012-07-17 Thread Xiao Guangrong
Quote Avi's comment: | KVM_MEMSLOT_INVALID is actually an internal symbol, not used by | userspace. Please move it to kvm_host.h. Also, move KVM_MEMSLOT_INVALID to the highest bit Signed-off-by: Xiao Guangrong --- include/linux/kvm.h |1 - include/linux/kvm_host.h |2 ++ 2

[PATCH 01/10] KVM: fix missing check for memslot flags

2012-07-17 Thread Xiao Guangrong
Check flags when memslot is registered from userspace as Avi's suggestion Signed-off-by: Xiao Guangrong --- virt/kvm/kvm_main.c | 12 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 78cf42f..7cb29bb 100644 --- a

[PATCH 9/9] KVM: remove the unused parameter of gfn_to_pfn_memslot

2012-07-17 Thread Xiao Guangrong
The parameter, 'kvm', is not used in gfn_to_pfn_memslot, we can happily remove it Signed-off-by: Xiao Guangrong --- arch/powerpc/kvm/e500_tlb.c |2 +- arch/x86/kvm/mmu.c |2 +- include/linux/kvm_host.h|5 ++--- virt/kvm/iommu.c| 10 +-

[PATCH 8/9] KVM: remove is_error_hpa

2012-07-17 Thread Xiao Guangrong
Remove them since they are not used anymore Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |4 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index bafcc56..f1ef5fc 100644 --- a/include/linux/kvm_host.h

[PATCH 7/9] KVM: mark do not extern bad_pfn

2012-07-17 Thread Xiao Guangrong
bad_pfn is not used out of kvm_main.c, so mark it static, also move it near hwpoison_pfn and fault_pfn Signed-off-by: Xiao Guangrong --- include/linux/kvm_host.h |1 - virt/kvm/kvm_main.c |6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux

[PATCH 6/9] KVM: using get_fault_pfn to get the fault pfn

2012-07-17 Thread Xiao Guangrong
Using get_fault_pfn to cleanup the code Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |6 ++ include/linux/kvm_host.h |5 + virt/kvm/kvm_main.c | 13 - 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86

[PATCH 5/9] KVM: MMU: fask check write-protect for direct mmu

2012-07-17 Thread Xiao Guangrong
If it have no indirect shadow pages we need not protect any gfn, this is always true for direct mmu without nested Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index

[PATCH 4/9] KVM: MMU: track the refcount when unmap the page

2012-07-17 Thread Xiao Guangrong
It will trigger a WARN_ON if the page has been freed but it is still used in mmu, it can help us to detect mm bug early Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c

[PATCH 3/9] KVM: x86: introduce set_mmio_exit_info

2012-07-17 Thread Xiao Guangrong
Introduce set_mmio_exit_info to cleanup the common code Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c | 33 + 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 875b8d8..8171836 100644 --- a

[PATCH 2/9] KVM: x86: simplify read_emulated

2012-07-17 Thread Xiao Guangrong
No need split mmio read region into 8-bits pieces since we do it in emulator_read_write_onepage Signed-off-by: Xiao Guangrong --- arch/x86/kvm/emulate.c | 29 - 1 files changed, 12 insertions(+), 17 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm

[PATCH 1/9] KVM: x86: remvoe unnecessary mark_page_dirty

2012-07-17 Thread Xiao Guangrong
te vcpu->arch.time at this time, mark_page_dirty should be removed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ff0b487..875b8d8 100644 --- a/arch/x86/kvm/x86.c +++ b/ar

Re: [PATCH 1/2] KVM: X86: remove read buffer for mmio read

2012-07-09 Thread Xiao Guangrong
On 07/09/2012 08:49 PM, Avi Kivity wrote: > On 07/09/2012 02:23 PM, Gleb Natapov wrote: >> >>> kvm-unit-tests.git has a test for xchg to mmio. Does it still work? >>> >>> I agree this code has to go, but it needs to be replaced by something. >>> Maybe a .valid flag in struct operand. >>> >> Valid

[PATCH 2/2] KVM: X86: introduce set_mmio_exit_info

2012-07-09 Thread Xiao Guangrong
Introduce set_mmio_exit_info to cleanup the common code Signed-off-by: Xiao Guangrong --- arch/x86/kvm/x86.c | 33 + 1 files changed, 17 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 7445545..7771f45 100644 --- a

[PATCH 1/2] KVM: X86: remove read buffer for mmio read

2012-07-09 Thread Xiao Guangrong
fer is not needed anymore Signed-off-by: Xiao Guangrong --- arch/x86/include/asm/kvm_emulate.h |1 - arch/x86/kvm/emulate.c | 43 --- arch/x86/kvm/x86.c |2 - 3 files changed, 5 insertions(+), 41 deletions(-) diff --git a/arch/x

<    6   7   8   9   10   11