From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Bharat Bhushan <r65777@freescale.com>,
agraf@suse.de, scottwood@freescale.com,
stuart.yoder@freescale.com, kvm@vger.kernel.org,
kvm-ppc@vger.kernel.org, paulus@samba.org
Cc: Bharat Bhushan <Bharat.Bhushan@freescale.com>,
Bharat Bhushan <bharat.bhushan@freescale.com>
Subject: Re: [PATCH 3/4] kvm: powerpc: define a linux pte lookup function
Date: Tue, 15 Oct 2013 05:17:23 +0000 [thread overview]
Message-ID: <871u3n15v0.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1381212212-29641-4-git-send-email-Bharat.Bhushan@freescale.com>
Bharat Bhushan <r65777@freescale.com> writes:
> We need to search linux "pte" to get "pte" attributes for
> setting TLB in KVM.
> This patch defines a linux_pte_lookup() function for same.
>
> Signed-off-by: Bharat Bhushan <bharat.bhushan@freescale.com>
> ---
> arch/powerpc/include/asm/pgtable.h | 35 +++++++++++++++++++++++++++++++++++
> 1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
> index 7d6eacf..fd26c04 100644
> --- a/arch/powerpc/include/asm/pgtable.h
> +++ b/arch/powerpc/include/asm/pgtable.h
> @@ -223,6 +223,41 @@ extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
> #endif
> pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
> unsigned *shift);
> +
> +static inline pte_t lookup_linux_pte(pgd_t *pgdir, unsigned long hva,
> + unsigned long *pte_sizep)
> +{
> + pte_t *ptep;
> + pte_t pte;
> + unsigned long ps = *pte_sizep;
> + unsigned int shift;
> +
> + ptep = find_linux_pte_or_hugepte(pgdir, hva, &shift);
> + if (!ptep)
> + return __pte(0);
> + if (shift)
> + *pte_sizep = 1ul << shift;
> + else
> + *pte_sizep = PAGE_SIZE;
> +
> + if (ps > *pte_sizep)
> + return __pte(0);
> +
> + /* wait until _PAGE_BUSY is clear */
> + while (1) {
> + pte = pte_val(*ptep);
> + if (unlikely(pte & _PAGE_BUSY)) {
> + cpu_relax();
> + continue;
> + }
What if we find a THP page that is splitting ? Older function returned
__pte(0) in that case.
> + }
> +
> + /* If pte is not present return None */
> + if (unlikely(!(pte & _PAGE_PRESENT)))
> + return __pte(0);
> +
> + return pte;
> +}
> #endif /* __ASSEMBLY__ */
>
> #endif /* __KERNEL__ */
> --
-aneesh
next prev parent reply other threads:[~2013-10-15 5:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 6:15 [PATCH 0/4] kvm: powerpc: use cache attributes from linux pte Bharat Bhushan
2013-10-08 6:15 ` [PATCH 1/4] kvm: booke: clear host tlb reference flag on guest tlb invalidation Bharat Bhushan
2013-10-08 6:15 ` [PATCH 2/4] kvm: book3s: rename lookup_linux_pte() to lookup_linux_pte_and_update() Bharat Bhushan
2013-10-08 6:15 ` [PATCH 3/4] kvm: powerpc: define a linux pte lookup function Bharat Bhushan
2013-10-08 21:36 ` Scott Wood
2013-10-09 8:48 ` Bhushan Bharat-R65777
2013-10-09 17:47 ` Scott Wood
2013-10-10 10:35 ` Paul Mackerras
2013-10-10 10:44 ` Bhushan Bharat-R65777
2013-10-10 10:52 ` Paul Mackerras
2013-10-15 5:19 ` Aneesh Kumar K.V
2013-10-10 10:33 ` Paul Mackerras
2013-10-15 5:17 ` Aneesh Kumar K.V [this message]
2013-10-08 6:15 ` [PATCH 4/4] kvm: powerpc: use caching attributes as per linux pte Bharat Bhushan
2013-10-28 10:36 ` [PATCH 0/4] kvm: powerpc: use cache attributes from " Bharat Bhushan
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=871u3n15v0.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=Bharat.Bhushan@freescale.com \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=paulus@samba.org \
--cc=r65777@freescale.com \
--cc=scottwood@freescale.com \
--cc=stuart.yoder@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