From: ewandevelop <ewandevelop@gmail.com>
To: seanjc@google.com
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-mm@kvack.org, avi@redhat.com, aarcange@redhat.com,
chrisw@redhat.com, riel@redhat.com, jeremy@goop.org,
mtosatti@redhat.com, hugh@veritas.com, corbet@lwn.net,
yaniv@redhat.com, dmonakhov@openvz.org
Subject: Re: [PATCH 0/3] kvm support for ksm
Date: Tue, 18 Oct 2022 11:31:59 +0800 [thread overview]
Message-ID: <9885be00-f12b-2019-2fa4-cfc5c8816e80@gmail.com> (raw)
In-Reply-To: <1238457604-7637-1-git-send-email-ieidus@redhat.com>
On 2009/3/31 08:00, Izik Eidus wrote:
> apply it against Avi git tree.
>
> Izik Eidus (3):
> kvm: dont hold pagecount reference for mapped sptes pages.
> kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes.
> kvm: add support for change_pte mmu notifiers
>
> arch/x86/include/asm/kvm_host.h | 1 +
> arch/x86/kvm/mmu.c | 89 ++++++++++++++++++++++++++++++++-------
> arch/x86/kvm/paging_tmpl.h | 16 ++++++-
> virt/kvm/kvm_main.c | 14 ++++++
> 4 files changed, 101 insertions(+), 19 deletions(-)
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
>
Hi, I'm learning kvm-mmu codes, when I was reading codes from this patch,
I can't understand why we need to do special process for "writable pte".
> +static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
> + unsigned long data)
> +{
> + int need_flush = 0;
> + u64 *spte, new_spte;
> + pte_t *ptep = (pte_t *)data;
> + pfn_t new_pfn;
> +
> + new_pfn = pte_pfn(ptep_val(ptep));
> + spte = rmap_next(kvm, rmapp, NULL);
> + while (spte) {
> + BUG_ON(!is_shadow_present_pte(*spte));
> + rmap_printk("kvm_set_pte_rmapp: spte %p %llx\n", spte, *spte);
> + need_flush = 1;
> + if (pte_write(ptep_val(ptep))) {
> + rmap_remove(kvm, spte);
> + set_shadow_pte(spte, shadow_trap_nonpresent_pte);
> + spte = rmap_next(kvm, rmapp, NULL);
> + } else {
> + new_spte = *spte &~ (PT64_BASE_ADDR_MASK);
> + new_spte |= new_pfn << PAGE_SHIFT;
> +
> + if (!pte_write(ptep_val(ptep))) {
> + new_spte &= ~PT_WRITABLE_MASK;
> + new_spte &= ~SPTE_HOST_WRITEABLE;
> + if (is_writeble_pte(*spte))
> + kvm_set_pfn_dirty(spte_to_pfn(*spte));
> + }
> + set_shadow_pte(spte, new_spte);
> + spte = rmap_next(kvm, rmapp, spte);
> + }
> + }
> + if (need_flush)
> + kvm_flush_remote_tlbs(kvm);
> +
> + return 0;
> +}
> +
In my opinion, we can just regard writable pte same as readable/executable,
all the corresponding sptes will be set as write-protect, and when guest
access them, an EPT-violation occurs and we do this #PF in kvm.
Shall anyone has some hint ?
prev parent reply other threads:[~2022-10-18 3:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 0:00 Izik Eidus
2009-03-31 0:00 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Izik Eidus
2009-03-31 0:00 ` [PATCH 2/3] kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes Izik Eidus
2009-03-31 0:00 ` [PATCH 3/3] kvm: add support for change_pte mmu notifiers Izik Eidus
2022-10-18 3:19 ` [PATCH 0/3] kvm support for ksm ewandevelop
2022-10-18 3:31 ` ewandevelop [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=9885be00-f12b-2019-2fa4-cfc5c8816e80@gmail.com \
--to=ewandevelop@gmail.com \
--cc=aarcange@redhat.com \
--cc=avi@redhat.com \
--cc=chrisw@redhat.com \
--cc=corbet@lwn.net \
--cc=dmonakhov@openvz.org \
--cc=hugh@veritas.com \
--cc=jeremy@goop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mtosatti@redhat.com \
--cc=riel@redhat.com \
--cc=seanjc@google.com \
--cc=yaniv@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