kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: avi.kivity@gmail.com, mtosatti@redhat.com, pbonzini@redhat.com,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v3 4/6] KVM: MMU: fast invalidate all mmio sptes
Date: Thu, 27 Jun 2013 17:50:08 +0800	[thread overview]
Message-ID: <51CC0AD0.3080003@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130627092152.GB10758@redhat.com>

On 06/27/2013 05:21 PM, Gleb Natapov wrote:
> On Thu, Jun 27, 2013 at 12:14:24PM +0300, Gleb Natapov wrote:
>> On Thu, Jun 27, 2013 at 12:01:10PM +0300, Gleb Natapov wrote:
>>> On Thu, Jun 27, 2013 at 11:29:00AM +0300, Gleb Natapov wrote:
>>>> On Fri, Jun 07, 2013 at 04:51:26PM +0800, Xiao Guangrong wrote:
>>>>> This patch tries to introduce a very simple and scale way to invalidate
>>>>> all mmio sptes - it need not walk any shadow pages and hold mmu-lock
>>>>>
>>>>> KVM maintains a global mmio valid generation-number which is stored in
>>>>> kvm->memslots.generation and every mmio spte stores the current global
>>>>> generation-number into his available bits when it is created
>>>>>
>>>>> When KVM need zap all mmio sptes, it just simply increase the global
>>>>> generation-number. When guests do mmio access, KVM intercepts a MMIO #PF
>>>>> then it walks the shadow page table and get the mmio spte. If the
>>>>> generation-number on the spte does not equal the global generation-number,
>>>>> it will go to the normal #PF handler to update the mmio spte
>>>>>
>>>>> Since 19 bits are used to store generation-number on mmio spte, we zap all
>>>>> mmio sptes when the number is round
>>>>>
>>>> So this commit makes Fedora 9 32 bit reboot during boot, Fedora 9 64
>>>> fails too, but I haven't checked what happens exactly.
>>>>
>>> Something wrong with gfn calculation during mmio:
>>>
>>> qemu-system-x86-17003 [000]  3962.625103: handle_mmio_page_fault: addr:c00ba6c0 gfn 100000000ba access a92
>>> qemu-system-x86-17003 [000]  3962.774862: handle_mmio_page_fault: addr:ffffb170 gfn 100000fee00 access a92
>>>
>> Hmm, so I wounder why get_mmio_spte_gfn() does not clear gen bits.
>>
> Hmm, something like patch below fixes it. Will test more.
> 
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index 1fd2c05..aec9c05 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -260,7 +260,8 @@ static bool is_mmio_spte(u64 spte)
> 
>  static gfn_t get_mmio_spte_gfn(u64 spte)
>  {
> -	return (spte & ~shadow_mmio_mask) >> PAGE_SHIFT;
> +	u64 mask = generation_mmio_spte_mask(MMIO_MAX_GEN) | shadow_mmio_mask;
> +	return (spte & ~mask) >> PAGE_SHIFT;
>  }

Looks nice.

Gleb, thank you very much for investigating the bug and fixing my mistake.
I will be more careful in the further developments.

  reply	other threads:[~2013-06-27  9:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07  8:51 [PATCH v3 0/6] KVM: MMU: fast invalidate all mmio sptes Xiao Guangrong
2013-06-07  8:51 ` [PATCH v3 1/6] KVM: MMU: retain more available bits on mmio spte Xiao Guangrong
2013-06-07  8:51 ` [PATCH v3 2/6] KVM: MMU: store generation-number into " Xiao Guangrong
2013-06-07  8:51 ` [PATCH v3 3/6] KVM: MMU: make return value of mmio page fault handler more readable Xiao Guangrong
2013-06-10  7:57   ` Gleb Natapov
2013-06-10  8:45     ` Xiao Guangrong
2013-06-10 13:16     ` Takuya Yoshikawa
2013-06-11  9:18       ` Gleb Natapov
2013-06-07  8:51 ` [PATCH v3 4/6] KVM: MMU: fast invalidate all mmio sptes Xiao Guangrong
2013-06-27  8:29   ` Gleb Natapov
2013-06-27  9:01     ` Gleb Natapov
2013-06-27  9:14       ` Gleb Natapov
2013-06-27  9:21         ` Gleb Natapov
2013-06-27  9:50           ` Xiao Guangrong [this message]
2013-06-27 10:19             ` Gleb Natapov
2013-06-27 11:05               ` Xiao Guangrong
2013-06-27 11:10                 ` Gleb Natapov
2013-06-07  8:51 ` [PATCH v3 5/6] KVM: MMU: add tracepoint for check_mmio_spte Xiao Guangrong
2013-06-07  8:51 ` [PATCH v3 6/6] KVM: MMU: init kvm generation close to mmio wrap-around value Xiao Guangrong
2013-06-10  7:56 ` [PATCH v3 0/6] KVM: MMU: fast invalidate all mmio sptes Gleb Natapov
2013-06-10  8:39   ` Xiao Guangrong
2013-06-10 13:43     ` Takuya Yoshikawa
2013-06-10 17:03       ` Gleb Natapov
2013-06-19 11:08         ` Paolo Bonzini
2013-06-19 11:27           ` Xiao Guangrong
2013-06-14  0:08 ` Marcelo Tosatti
2013-06-15  2:22   ` Takuya Yoshikawa
2013-06-17 11:59     ` Xiao Guangrong
2013-06-18 22:21       ` Marcelo Tosatti
2013-06-18 14:26 ` Paolo Bonzini
2013-06-19  2:47   ` Xiao Guangrong
2013-06-19 17:40 ` Paolo Bonzini

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=51CC0AD0.3080003@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=avi.kivity@gmail.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    /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).