All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hu Yaohui <loki2441@gmail.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: Nested EPT Write Protection
Date: Mon, 22 Jun 2015 15:59:33 +0200	[thread overview]
Message-ID: <558814C5.6050804@redhat.com> (raw)
In-Reply-To: <CAHqbYQsXfmQfBGva2t_VSFMQj3dnwUUcFPBbvnQDN_tR0y3i8g@mail.gmail.com>



On 22/06/2015 15:28, Hu Yaohui wrote:
> 
> */2504             pseudo_gfn = base_addr >> PAGE_SHIFT;
> 2505             sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr,
> 2506                           iterator.level - 1,
> 2507                           1, ACC_ALL, iterator.sptep);/*
> 2508             if (!sp) {
> 2509                 pgprintk("nonpaging_map: ENOMEM\n");
> 2510                 kvm_release_pfn_clean(pfn);
> 2511                 return -ENOMEM;
> 2512             }
>                                    .........
> 
> </code>
> it will get a pseudo_gfn to allocate a kvm_mmu_page. What if a
> pseudo_gfn itself causes a tdp_page_fault?
> Will it make the corresponding EPT page table entry marked as readonly also?

If tdp_page_fault is used (meaning non-nested KVM: nested KVM uses
ept_page_fault instead), sp->unsync is always true:

	/* in kvm_mmu_get_page - __direct_map passes direct == true */
        if (!direct) {
                if (rmap_write_protect(vcpu, gfn))
                        kvm_flush_remote_tlbs(vcpu->kvm);
                if (level > PT_PAGE_TABLE_LEVEL && need_sync)
                        kvm_sync_pages(vcpu, gfn);

                account_shadowed(vcpu->kvm, sp);
        }

so mmu_need_write_protect always returns false.

Note that higher in kvm_mmu_get_page there is another conditional:

                if (!need_sync && sp->unsync)
                        need_sync = true;

but it only applies to the !direct case.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in

      parent reply	other threads:[~2015-06-22 13:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19  1:52 Nested EPT Write Protection Hu Yaohui
2015-06-19  6:27 ` Paolo Bonzini
2015-06-19 12:44   ` Hu Yaohui
2015-06-19 15:23     ` Paolo Bonzini
2015-06-19 18:57       ` Hu Yaohui
2015-06-22 11:26         ` Paolo Bonzini
     [not found]           ` <CAHqbYQsXfmQfBGva2t_VSFMQj3dnwUUcFPBbvnQDN_tR0y3i8g@mail.gmail.com>
2015-06-22 13:59             ` Paolo Bonzini [this message]

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=558814C5.6050804@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=loki2441@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.