From: Bharat Bhushan <r65777@freescale.com>
To: <benh@kernel.crashing.org>, <agraf@suse.de>, <paulus@samba.org>,
<kvm@vger.kernel.org>, <kvm-ppc@vger.kernel.org>,
<linuxppc-dev@lists.ozlabs.org>, <scottwood@freescale.com>
Cc: Bharat Bhushan <bharat.bhushan@freescale.com>
Subject: [PATCH 5/6 v5] kvm: booke: clear host tlb reference flag on guest tlb invalidation
Date: Thu, 19 Sep 2013 11:32:45 +0530 [thread overview]
Message-ID: <1379570566-3715-6-git-send-email-Bharat.Bhushan@freescale.com> (raw)
In-Reply-To: <1379570566-3715-1-git-send-email-Bharat.Bhushan@freescale.com>
On booke, "struct tlbe_ref" contains host tlb mapping information
(pfn: for guest-pfn to pfn, flags: attribute associated with this mapping)
for a guest tlb entry. So when a guest creates a TLB entry then
"struct tlbe_ref" is set to point to valid "pfn" and set attributes in
"flags" field of the above said structure. When a guest TLB entry is
invalidated then flags field of corresponding "struct tlbe_ref" is
updated to point that this is no more valid, also we selectively clear
some other attribute bits, example: if E500_TLB_BITMAP was set then we clear
E500_TLB_BITMAP, if E500_TLB_TLB0 is set then we clear this.
Ideally we should clear complete "flags" as this entry is invalid and does not
have anything to re-used. The other part of the problem is that when we use
the same entry again then also we do not clear (started doing or-ing etc).
So far it was working because the selectively clearing mentioned above
actually clears "flags" what was set during TLB mapping. But the problem
starts coming when we add more attributes to this then we need to selectively
clear them and which is not needed.
This patch we do both
- Clear "flags" when invalidating;
- Clear "flags" when reusing same entry later
Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
---
v3-> v5
- New patch (found this issue when doing vfio-pci development)
arch/powerpc/kvm/e500_mmu_host.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 1c6a9d7..60f5a3c 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -217,7 +217,8 @@ void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
}
mb();
vcpu_e500->g2h_tlb1_map[esel] = 0;
- ref->flags &= ~(E500_TLB_BITMAP | E500_TLB_VALID);
+ /* Clear flags as TLB is not backed by the host anymore */
+ ref->flags = 0;
local_irq_restore(flags);
}
@@ -227,7 +228,8 @@ void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
* rarely and is not worth optimizing. Invalidate everything.
*/
kvmppc_e500_tlbil_all(vcpu_e500);
- ref->flags &= ~(E500_TLB_TLB0 | E500_TLB_VALID);
+ /* Clear flags as TLB is not backed by the host anymore */
+ ref->flags = 0;
}
/* Already invalidated in between */
@@ -237,8 +239,8 @@ void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
/* Guest tlbe is backed by at most one host tlbe per shadow pid. */
kvmppc_e500_tlbil_one(vcpu_e500, gtlbe);
- /* Mark the TLB as not backed by the host anymore */
- ref->flags &= ~E500_TLB_VALID;
+ /* Clear flags as TLB is not backed by the host anymore */
+ ref->flags = 0;
}
static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe)
@@ -251,7 +253,7 @@ static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref,
pfn_t pfn)
{
ref->pfn = pfn;
- ref->flags |= E500_TLB_VALID;
+ ref->flags = E500_TLB_VALID;
if (tlbe_is_writable(gtlbe))
kvm_set_pfn_dirty(pfn);
--
1.7.0.4
next prev parent reply other threads:[~2013-09-19 6:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 6:02 [PATCH 0/6 v5] kvm: powerpc: use cache attributes from linux pte Bharat Bhushan
2013-09-19 6:02 ` [PATCH 1/6 v5] powerpc: book3e: _PAGE_LENDIAN must be _PAGE_ENDIAN Bharat Bhushan
2013-09-19 6:02 ` [PATCH 2/6 v5] kvm: powerpc: allow guest control "E" attribute in mas2 Bharat Bhushan
2013-09-19 6:02 ` [PATCH 3/6 v5] kvm: powerpc: allow guest control "G" " Bharat Bhushan
2013-09-19 6:02 ` [PATCH 4/6 v5] kvm: powerpc: keep only pte search logic in lookup_linux_pte Bharat Bhushan
2013-10-04 13:27 ` Alexander Graf
2013-10-04 13:44 ` Bhushan Bharat-R65777
2013-09-19 6:02 ` Bharat Bhushan [this message]
2013-09-19 21:07 ` [PATCH 5/6 v5] kvm: booke: clear host tlb reference flag on guest tlb invalidation Scott Wood
2013-09-20 4:19 ` Bhushan Bharat-R65777
2013-09-20 16:18 ` Scott Wood
2013-09-20 18:04 ` Bhushan Bharat-R65777
2013-09-20 18:08 ` Scott Wood
2013-09-20 18:11 ` Bhushan Bharat-R65777
2013-09-19 6:02 ` [PATCH 6/6 v5] kvm: powerpc: use caching attributes as per linux pte Bharat Bhushan
2013-10-04 14:03 ` [PATCH 0/6 v5] kvm: powerpc: use cache attributes from " Alexander Graf
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=1379570566-3715-6-git-send-email-Bharat.Bhushan@freescale.com \
--to=r65777@freescale.com \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=bharat.bhushan@freescale.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=scottwood@freescale.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).