From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 09/13] KVM: PPC: e500: enable magic page
Date: Thu, 19 May 2011 10:43:21 +0000 [thread overview]
Message-ID: <4DD4F449.907@suse.de> (raw)
In-Reply-To: <20110517234234.GG3580@schlenkerla.am.freescale.net>
On 05/18/2011 01:42 AM, Scott Wood wrote:
> This is a shared page used for paravirtualization. It is always present
> in the guest kernel's effective address space at the address indicated
> by the hypercall that enables it.
>
> The physical address specified by the hypercall is not used, as
> e500 does not have real mode.
This also requires a documentation change.
> Signed-off-by: Scott Wood<scottwood@freescale.com>
> ---
> arch/powerpc/include/asm/kvm_ppc.h | 1 +
> arch/powerpc/kvm/booke.c | 11 +++++++++++
> arch/powerpc/kvm/e500_tlb.c | 22 +++++++++++++++++++++-
> arch/powerpc/kvm/powerpc.c | 9 +++++----
> 4 files changed, 38 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index 9345238..c662f14 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -109,6 +109,7 @@ extern void kvmppc_booke_exit(void);
>
> extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu);
> extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu);
> +extern void kvmppc_map_magic(struct kvm_vcpu *vcpu);
>
> /*
> * Cuts out inst bits with ordering according to spec.
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index 85b9391..036625e 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -472,6 +472,17 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
> gpa_t gpaddr;
> gfn_t gfn;
>
> +#ifdef CONFIG_KVM_E500
> + if (!(vcpu->arch.shared->msr& MSR_PR)&&
> + (eaddr& PAGE_MASK) = vcpu->arch.magic_page_ea) {
> + kvmppc_map_magic(vcpu);
> + kvmppc_account_exit(vcpu, DTLB_VIRT_MISS_EXITS);
> + r = RESUME_GUEST;
> +
> + break;
> + }
> +#endif
> +
> /* Check the guest TLB. */
> gtlb_index = kvmppc_mmu_dtlb_index(vcpu, eaddr);
> if (gtlb_index< 0) {
> diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
> index 7f808c5..c09e642 100644
> --- a/arch/powerpc/kvm/e500_tlb.c
> +++ b/arch/powerpc/kvm/e500_tlb.c
> @@ -76,7 +76,8 @@ static inline unsigned int tlb0_get_next_victim(
>
> static inline unsigned int tlb1_max_shadow_size(void)
> {
> - return tlb1_entry_num - tlbcam_index;
> + /* reserve one entry for magic page */
> + return tlb1_entry_num - tlbcam_index - 1;
> }
>
> static inline int tlbe_is_writable(struct tlbe *tlbe)
> @@ -142,6 +143,25 @@ static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
> }
> }
>
> +void kvmppc_map_magic(struct kvm_vcpu *vcpu)
> +{
> + struct tlbe magic;
> + ulong shared_page = ((ulong)vcpu->arch.shared)& PAGE_MASK;
> + pfn_t pfn;
> +
> + pfn = (pfn_t)virt_to_phys((void *)shared_page)>> PAGE_SHIFT;
> + get_page(pfn_to_page(pfn));
> +
> + magic.mas1 = MAS1_VALID | MAS1_TS |
> + MAS1_TSIZE(BOOK3E_PAGESZ_4K);
> + magic.mas2 = vcpu->arch.magic_page_ea | MAS2_M;
> + magic.mas3 = (pfn<< PAGE_SHIFT) |
> + MAS3_SW | MAS3_SR | MAS3_UW | MAS3_UR;
> + magic.mas7 = pfn>> (32 - PAGE_SHIFT);
> +
> + __write_host_tlbe(&magic, MAS0_TLBSEL(1) | MAS0_ESEL(tlbcam_index));
It's a 4k page, so why use TLB1? Also, you add this as PID0 mapping, no?
Shouldn't it be restricted to the guest's kernel?
Alex
next prev parent reply other threads:[~2011-05-19 10:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 23:42 [PATCH 09/13] KVM: PPC: e500: enable magic page Scott Wood
2011-05-19 10:43 ` Alexander Graf [this message]
2011-05-19 16:37 ` Scott Wood
2011-05-21 16:39 ` Alexander Graf
2011-05-23 15:45 ` Scott Wood
2011-05-27 23:03 ` Alexander Graf
2011-06-02 23:17 ` Scott Wood
2011-06-14 9:55 ` Alexander Graf
2011-06-14 18:52 ` Scott Wood
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=4DD4F449.907@suse.de \
--to=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
/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.