kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Avi Kivity <avi@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	kvm@vger.kernel.org
Subject: Re: [PATCH] kvm mmu: reduce 50% memory usage
Date: Fri, 7 May 2010 17:14:16 -0300	[thread overview]
Message-ID: <20100507201416.GA12974@amt.cnet> (raw)
In-Reply-To: <4BE3CE80.8050408@cn.fujitsu.com>

On Fri, May 07, 2010 at 04:25:36PM +0800, Lai Jiangshan wrote:
> Subject: [PATCH] kvm, tdp: calculate correct base gfn for non-DIR level
> 
> the base gfn calculation is incorrect in __direct_map(),
> it does not calculate correctly when level=3 or 4.
> 
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
> ---
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index a5c6719..6986a6f 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -1955,7 +1956,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
>  		}
>  
>  		if (*iterator.sptep == shadow_trap_nonpresent_pte) {
> -			pseudo_gfn = (iterator.addr & PT64_DIR_BASE_ADDR_MASK) >> PAGE_SHIFT;
> +			u64 base_addr = iterator.addr;
> +
> +			base_addr &= PT64_LVL_ADDR_MASK(iterator.level);
> +			pseudo_gfn = base_addr >> PAGE_SHIFT;
>  			sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr,
>  					      iterator.level - 1,
>  					      1, ACC_ALL, iterator.sptep);

Looks good, please resend the whole patch.

  reply	other threads:[~2010-05-07 20:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-28 11:57 [PATCH] kvm mmu: reduce 50% memory usage Lai Jiangshan
2010-04-28 13:01 ` Avi Kivity
2010-04-28 18:05 ` Marcelo Tosatti
2010-04-29 18:09 ` Marcelo Tosatti
2010-04-29 18:43   ` Avi Kivity
     [not found]     ` <4BDA3F9B.8040708@cn.fujitsu.com>
2010-04-30  7:26       ` Avi Kivity
     [not found]         ` <4BDA9AAC.6060303@cn.fujitsu.com>
2010-04-30 10:00           ` Avi Kivity
2010-04-30 15:44     ` Marcelo Tosatti
2010-05-06  7:03       ` Lai Jiangshan
2010-05-06 19:04         ` Marcelo Tosatti
2010-05-07  8:25           ` Lai Jiangshan
2010-05-07 20:14             ` Marcelo Tosatti [this message]
2010-05-26  8:48           ` [RESEND PATCH 2/3] kvm, tdp: calculate correct base gfn for non-DIR level Lai Jiangshan
2010-05-26 10:15             ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100507201416.GA12974@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).