From: Alexander Graf <agraf@suse.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v2] kvm/book3s: Make kernel emulated H_PUT_TCE available for "PR" KVM
Date: Wed, 02 May 2012 15:32:30 +0200 [thread overview]
Message-ID: <4FA1376E.2030606@suse.de> (raw)
In-Reply-To: <1331884714.3105.166.camel@pasglop>
On 03/16/2012 08:58 AM, Benjamin Herrenschmidt wrote:
> There is nothing in the code for emulating TCE tables in the kernel
> that prevents it from working on "PR" KVM... other than ifdef's and
> location of the code.
>
> This renames book3s_64_vio_hv.c to book3s_64_vio.c and moves the
> bulk of the code there.
>
> This speeds things up a bit on my G5.
> ---
>
> v2. Changed the ifdef as per discussion with Alex. I still didn't
> manage to get git to figure out the rename but that's no big deal,
> the old file had only one small function in it. There's no code
> change, you can trust me on that one, It's really just moving
> things around :-)
>
> arch/powerpc/include/asm/kvm_host.h | 4 +-
> arch/powerpc/include/asm/kvm_ppc.h | 2 +
> arch/powerpc/kvm/Makefile | 3 +-
> arch/powerpc/kvm/book3s_64_vio.c | 187 +++++++++++++++++++++++++++++++++++
> arch/powerpc/kvm/book3s_64_vio_hv.c | 73 --------------
> arch/powerpc/kvm/book3s_hv.c | 109 --------------------
> arch/powerpc/kvm/book3s_pr.c | 3 +
> arch/powerpc/kvm/book3s_pr_papr.c | 18 ++++
> arch/powerpc/kvm/powerpc.c | 8 +-
> 9 files changed, 221 insertions(+), 186 deletions(-)
> create mode 100644 arch/powerpc/kvm/book3s_64_vio.c
> delete mode 100644 arch/powerpc/kvm/book3s_64_vio_hv.c
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 42a527e..d848cdc 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -237,7 +237,6 @@ struct kvm_arch {
> unsigned long vrma_slb_v;
> int rma_setup_done;
> int using_mmu_notifiers;
> - struct list_head spapr_tce_tables;
> spinlock_t slot_phys_lock;
> unsigned long *slot_phys[KVM_MEM_SLOTS_NUM];
> int slot_npages[KVM_MEM_SLOTS_NUM];
> @@ -245,6 +244,9 @@ struct kvm_arch {
> struct kvmppc_vcore *vcores[KVM_MAX_VCORES];
> struct kvmppc_linear_info *hpt_li;
> #endif /* CONFIG_KVM_BOOK3S_64_HV */
> +#ifdef CONFIG_PPC_BOOK3S_64
> + struct list_head spapr_tce_tables;
> +#endif
> };
>
> /*
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index 7f0a3da..c1069f6 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -126,6 +126,8 @@ extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu,
> extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu);
> extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
> struct kvm_create_spapr_tce *args);
> +extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
> + unsigned long ioba, unsigned long tce);
> extern long kvm_vm_ioctl_allocate_rma(struct kvm *kvm,
> struct kvm_allocate_rma *rma);
> extern struct kvmppc_linear_info *kvm_alloc_rma(void);
> diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
> index 25225ae..8c95def 100644
> --- a/arch/powerpc/kvm/Makefile
> +++ b/arch/powerpc/kvm/Makefile
> @@ -54,6 +54,7 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_PR) := \
> book3s_paired_singles.o \
> book3s_pr.o \
> book3s_pr_papr.o \
> + book3s_64_vio.o \
> book3s_emulate.o \
> book3s_interrupts.o \
> book3s_mmu_hpte.o \
> @@ -70,7 +71,7 @@ kvm-book3s_64-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \
> kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HV) := \
> book3s_hv_rmhandlers.o \
> book3s_hv_rm_mmu.o \
> - book3s_64_vio_hv.o \
> + book3s_64_vio.o \
> book3s_hv_builtin.o
>
> kvm-book3s_64-module-objs := \
> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> new file mode 100644
> index 0000000..193ba68
> --- /dev/null
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -0,0 +1,187 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License, version 2, as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> + *
> + * Copyright 2010 Paul Mackerras, IBM Corp.<paulus@au1.ibm.com>
> + * Copyright 2011 David Gibson, IBM Corporation<dwg@au1.ibm.com>
> + */
> +
> +#include<linux/types.h>
> +#include<linux/string.h>
> +#include<linux/kvm.h>
> +#include<linux/kvm_host.h>
> +#include<linux/highmem.h>
> +#include<linux/gfp.h>
> +#include<linux/slab.h>
> +#include<linux/hugetlb.h>
> +#include<linux/list.h>
> +#include<linux/anon_inodes.h>
> +
> +#include<asm/tlbflush.h>
> +#include<asm/kvm_ppc.h>
> +#include<asm/kvm_book3s.h>
> +#include<asm/mmu-hash64.h>
> +#include<asm/hvcall.h>
> +#include<asm/synch.h>
> +#include<asm/ppc-opcode.h>
> +#include<asm/kvm_host.h>
> +#include<asm/udbg.h>
> +
> +#define TCES_PER_PAGE (PAGE_SIZE / sizeof(u64))
> +
> +/* WARNING: This will be called in real-mode on HV KVM and virtual
> + * mode on PR KVM
> + */
> +long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
> + unsigned long ioba, unsigned long tce)
> +{
> + struct kvm *kvm = vcpu->kvm;
> + struct kvmppc_spapr_tce_table *stt;
> +
> + /* udbg_printf("H_PUT_TCE(): liobn=0x%lx ioba=0x%lx, tce=0x%lx\n", */
> + /* liobn, ioba, tce); */
> +
> + list_for_each_entry(stt,&kvm->arch.spapr_tce_tables, list) {
> + if (stt->liobn == liobn) {
> + unsigned long idx = ioba>> SPAPR_TCE_SHIFT;
> + struct page *page;
> + u64 *tbl;
> +
> + /* udbg_printf("H_PUT_TCE: liobn 0x%lx => stt=%p window_size=0x%x\n", */
> + /* liobn, stt, stt->window_size); */
> + if (ioba>= stt->window_size)
> + return H_PARAMETER;
> +
> + page = stt->pages[idx / TCES_PER_PAGE];
> + tbl = (u64 *)page_address(page);
> +
> + /* FIXME: Need to validate the TCE itself */
> + /* udbg_printf("tce @ %p\n",&tbl[idx % TCES_PER_PAGE]); */
> + tbl[idx % TCES_PER_PAGE] = tce;
> + return H_SUCCESS;
> + }
> + }
> +
> + /* Didn't find the liobn, punt it to userspace */
> + return H_TOO_HARD;
> +}
This function needs to be available in real mode on HV, but the ones
below must be on module code when kvm is compiled as a module, because
they call kvm infrastructure which lives in module code.
Alex
next prev parent reply other threads:[~2012-05-02 13:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-16 7:58 [PATCH v2] kvm/book3s: Make kernel emulated H_PUT_TCE available for "PR" KVM Benjamin Herrenschmidt
2012-04-26 11:24 ` Alexander Graf
2012-04-26 11:24 ` Alexander Graf
2012-05-02 13:32 ` Alexander Graf [this message]
2012-05-02 21:17 ` Benjamin Herrenschmidt
2012-05-02 21:21 ` Alexander Graf
2012-05-02 21:53 ` Benjamin Herrenschmidt
2012-05-02 22:32 ` [PATCH] " 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=4FA1376E.2030606@suse.de \
--to=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox