2010-04-25 07:03:53

by Xiao Guangrong

[permalink] [raw]
Subject: [PATCH v2 5/10] KVM MMU: split kvm_sync_page() function

Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient()
to clarify the code address Avi's suggestion

kvm_sync_page_transient() function only update shadow page but not mark
it sync and not write protect sp->gfn. it will be used by later patch

Signed-off-by: Xiao Guangrong <[email protected]>
---
arch/x86/kvm/mmu.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index abf8bd4..60a91c6 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1196,6 +1196,23 @@ static void kvm_unlink_unsync_page(struct kvm *kvm, struct kvm_mmu_page *sp)

static int kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp);

+static int kvm_sync_page_transient(struct kvm_vcpu *vcpu,
+ struct kvm_mmu_page *sp)
+{
+ if (sp->role.cr4_pae != !!is_pae(vcpu)) {
+ kvm_mmu_zap_page(vcpu->kvm, sp);
+ return 1;
+ }
+
+ if (vcpu->arch.mmu.sync_page(vcpu, sp)) {
+ kvm_mmu_zap_page(vcpu->kvm, sp);
+ return 1;
+ }
+
+ kvm_mmu_flush_tlb(vcpu);
+ return 0;
+}
+
static int kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
{
if (sp->role.cr4_pae != !!is_pae(vcpu)) {
--
1.6.1.2


2010-04-25 09:50:43

by Avi Kivity

[permalink] [raw]
Subject: Re: [PATCH v2 5/10] KVM MMU: split kvm_sync_page() function

On 04/25/2010 10:00 AM, Xiao Guangrong wrote:
> Split kvm_sync_page() into kvm_sync_page() and kvm_sync_page_transient()
> to clarify the code address Avi's suggestion
>
> kvm_sync_page_transient() function only update shadow page but not mark
> it sync and not write protect sp->gfn. it will be used by later patch
>
> Signed-off-by: Xiao Guangrong<[email protected]>
> ---
> arch/x86/kvm/mmu.c | 17 +++++++++++++++++
> 1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index abf8bd4..60a91c6 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1196,6 +1196,23 @@ static void kvm_unlink_unsync_page(struct kvm *kvm, struct kvm_mmu_page *sp)
>
> static int kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp);
>
> +static int kvm_sync_page_transient(struct kvm_vcpu *vcpu,
> + struct kvm_mmu_page *sp)
> +{
> + if (sp->role.cr4_pae != !!is_pae(vcpu)) {
> + kvm_mmu_zap_page(vcpu->kvm, sp);
> + return 1;
> + }
> +
> + if (vcpu->arch.mmu.sync_page(vcpu, sp)) {
> + kvm_mmu_zap_page(vcpu->kvm, sp);
> + return 1;
> + }
> +
> + kvm_mmu_flush_tlb(vcpu);
> + return 0;
> +}
> +
>

This isn't a split; it duplicates the code.

Since there are some parts in the middle of kvm_sync_page() you don't
want in sync_page_transient(), you can put them into helpers so that
sync_page and sync_page_transient only call helpers.

--
error compiling committee.c: too many arguments to function

2010-04-26 03:14:33

by Xiao Guangrong

[permalink] [raw]
Subject: Re: [PATCH v2 5/10] KVM MMU: split kvm_sync_page() function



Avi Kivity wrote:

>
> This isn't a split; it duplicates the code.
>
> Since there are some parts in the middle of kvm_sync_page() you don't
> want in sync_page_transient(), you can put them into helpers so that
> sync_page and sync_page_transient only call helpers.
>

Will fix it in v3, thanks