From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: [PATCH 10/11] KVM: MMU: fix detecting misaligned accessed
Date: Tue, 16 Aug 2011 14:46:15 +0800 [thread overview]
Message-ID: <4E4A1237.6060609@cn.fujitsu.com> (raw)
In-Reply-To: <4E4A10E8.5090705@cn.fujitsu.com>
Sometimes, we only modify the last one byte of a pte to update status bit,
for example, clear_bit is used to clear r/w bit in linux kernel and 'andb'
instruction is used in this function, in this case, kvm_mmu_pte_write will
treat it as misaligned access, and the shadow page table is zapped
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
arch/x86/kvm/mmu.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index cfe24fe..adaa160 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3601,6 +3601,14 @@ static bool detect_write_misaligned(struct kvm_mmu_page *sp, gpa_t gpa,
offset = offset_in_page(gpa);
pte_size = sp->role.cr4_pae ? 8 : 4;
+
+ /*
+ * Sometimes, the OS only writes the last one bytes to update status
+ * bits, for example, in linux, andb instruction is used in clear_bit().
+ */
+ if (!(offset & (pte_size - 1)) && bytes == 1)
+ return false;
+
misaligned = (offset ^ (offset + bytes - 1)) & ~(pte_size - 1);
misaligned |= bytes < 4;
--
1.7.5.4
next prev parent reply other threads:[~2011-08-16 6:44 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-16 6:40 [PATCH 01/11] KVM: MMU: avoid pte_list_desc running out in kvm_mmu_pte_write Xiao Guangrong
2011-08-16 6:41 ` [PATCH 02/11] KVM: x86: tag the instructions which are used to write page table Xiao Guangrong
2011-08-22 14:32 ` Marcelo Tosatti
2011-08-22 14:36 ` Avi Kivity
2011-08-16 6:42 ` [PATCH 03/11] KVM: x86: retry non-page-table writing instruction Xiao Guangrong
2011-08-22 19:59 ` Marcelo Tosatti
2011-08-22 20:21 ` Xiao Guangrong
2011-08-22 20:42 ` Marcelo Tosatti
2011-08-16 6:42 ` [PATCH 04/11] KVM: x86: cleanup port-in/port-out emulated Xiao Guangrong
2011-08-16 6:43 ` [PATCH 05/11] KVM: MMU: do not mark access bit on pte write path Xiao Guangrong
2011-08-16 6:44 ` [PATCH 06/11] KVM: MMU: cleanup FNAME(invlpg) Xiao Guangrong
2011-08-16 6:44 ` [PATCH 07/11] KVM: MMU: fast prefetch spte on invlpg path Xiao Guangrong
2011-08-22 22:28 ` Marcelo Tosatti
2011-08-23 1:50 ` Xiao Guangrong
2011-08-16 6:45 ` [PATCH 08/11] KVM: MMU: remove unnecessary kvm_mmu_free_some_pages Xiao Guangrong
2011-08-16 6:45 ` [PATCH 09/11] KVM: MMU: split kvm_mmu_pte_write function Xiao Guangrong
2011-08-16 6:46 ` Xiao Guangrong [this message]
2011-08-16 6:46 ` [PATCH 11/11] KVM: MMU: improve write flooding detected Xiao Guangrong
2011-08-23 8:00 ` Marcelo Tosatti
2011-08-23 10:55 ` Xiao Guangrong
2011-08-23 12:38 ` Marcelo Tosatti
2011-08-23 16:32 ` Xiao Guangrong
2011-08-23 19:09 ` Marcelo Tosatti
2011-08-23 20:16 ` Xiao Guangrong
2011-08-24 20:05 ` Marcelo Tosatti
2011-08-25 2:04 ` Marcelo Tosatti
2011-08-25 4:42 ` Avi Kivity
2011-08-25 13:21 ` Marcelo Tosatti
2011-08-25 14:06 ` Avi Kivity
2011-08-25 14:07 ` Avi Kivity
2011-08-25 7:40 ` Xiao Guangrong
2011-08-25 7:57 ` Xiao Guangrong
2011-08-25 13:47 ` Marcelo Tosatti
2011-08-26 3:18 ` Xiao Guangrong
2011-08-26 10:53 ` Marcelo Tosatti
2011-08-26 14:24 ` Xiao Guangrong
-- strict thread matches above, loose matches on Subject: below --
2011-07-26 11:24 [PATCH 0/11] KVM: x86: optimize for guest page written Xiao Guangrong
2011-07-26 11:31 ` [PATCH 10/11] KVM: MMU: fix detecting misaligned accessed Xiao Guangrong
2011-07-27 9:15 ` Avi Kivity
2011-07-27 10:10 ` Xiao Guangrong
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=4E4A1237.6060609@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@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 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.