linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Cc: linuxppc-dev@ozlabs.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 10/18] KVM: PPC: Book3S HV: Set process table for HPT guests on POWER9
Date: Mon, 23 Jan 2017 15:37:11 +1100	[thread overview]
Message-ID: <20170123043711.GB29357@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <1485139167.8172.3.camel@gmail.com>

On Mon, Jan 23, 2017 at 01:39:27PM +1100, Suraj Jitindar Singh wrote:
> On Thu, 2017-01-12 at 20:07 +1100, Paul Mackerras wrote:
> > This adds the implementation of the KVM_PPC_CONFIGURE_V3_MMU ioctl
> > for HPT guests on POWER9.  With this, we can return 1 for the
> > KVM_CAP_PPC_MMU_HASH_V3 capability.
> > 
> > Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
> > ---
> >  arch/powerpc/include/asm/kvm_host.h |  1 +
> >  arch/powerpc/kvm/book3s_hv.c        | 35
> > +++++++++++++++++++++++++++++++----
> >  arch/powerpc/kvm/powerpc.c          |  2 +-
> >  3 files changed, 33 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/powerpc/include/asm/kvm_host.h
> > b/arch/powerpc/include/asm/kvm_host.h
> > index e59b172..944532d 100644
> > --- a/arch/powerpc/include/asm/kvm_host.h
> > +++ b/arch/powerpc/include/asm/kvm_host.h
> > @@ -264,6 +264,7 @@ struct kvm_arch {
> >  	atomic_t hpte_mod_interest;
> >  	cpumask_t need_tlb_flush;
> >  	int hpt_cma_alloc;
> > +	u64 process_table;
> >  	struct dentry *debugfs_dir;
> >  	struct dentry *htab_dentry;
> >  #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> > diff --git a/arch/powerpc/kvm/book3s_hv.c
> > b/arch/powerpc/kvm/book3s_hv.c
> > index 1736f87..6bd0f4a 100644
> > --- a/arch/powerpc/kvm/book3s_hv.c
> > +++ b/arch/powerpc/kvm/book3s_hv.c
> > @@ -3092,8 +3092,8 @@ static void kvmppc_setup_partition_table(struct
> > kvm *kvm)
> >  	/* HTABSIZE and HTABORG fields */
> >  	dw0 |= kvm->arch.sdr1;
> >  
> > -	/* Second dword has GR=0; other fields are unused since
> > UPRT=0 */
> > -	dw1 = 0;
> > +	/* Second dword as set by userspace */
> > +	dw1 = kvm->arch.process_table;
> >  
> >  	mmu_partition_table_set_entry(kvm->arch.lpid, dw0, dw1);
> >  }
> > @@ -3658,10 +3658,37 @@ static void init_default_hcalls(void)
> >  	}
> >  }
> >  
> > -/* dummy implementations for now */
> >  static int kvmhv_configure_mmu(struct kvm *kvm, struct
> > kvm_ppc_mmuv3_cfg *cfg)
> >  {
> > -	return -EINVAL;
> > +	unsigned long lpcr;
> > +
> > +	/* If not on a POWER9, reject it */
> > +	if (!cpu_has_feature(CPU_FTR_ARCH_300))
> > +		return -ENODEV;
> > +
> > +	/* If any unknown flags set, reject it */
> > +	if (cfg->flags & ~(KVM_PPC_MMUV3_RADIX |
> > KVM_PPC_MMUV3_GTSE))
> > +		return -EINVAL;
> > +
> > +	/* We can't do radix yet */
> > +	if (cfg->flags & KVM_PPC_MMUV3_RADIX)
> > +		return -EINVAL;
> > +
> > +	/* GR (guest radix) bit in process_table field must match */
> > +	if (cfg->process_table & PATB_GR)
> > +		return -EINVAL;
> > +
> > +	/* Process table size field must be reasonable, i.e. <= 24
> > */
> > +	if ((cfg->process_table & PRTS_MASK) > 24)
> > +		return -EINVAL;
> > +
> > +	kvm->arch.process_table = cfg->process_table;
> > +	kvmppc_setup_partition_table(kvm);
> > +
> > +	lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0;
> > +	kvmppc_update_lpcr(kvm, lpcr, LPCR_GTSE);
> > +
> > +	return 0;
> >  }
> >  
> >  static int kvmhv_get_rmmu_info(struct kvm *kvm, struct
> > kvm_ppc_rmmu_info *info)
> > diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> > index 38c0d15..1476a48 100644
> > --- a/arch/powerpc/kvm/powerpc.c
> > +++ b/arch/powerpc/kvm/powerpc.c
> > @@ -569,7 +569,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm,
> > long ext)
> >  		r = !!(0 && hv_enabled && radix_enabled());
> >  		break;
> >  	case KVM_CAP_PPC_MMU_HASH_V3:
> > -		r = !!(0 && hv_enabled && !radix_enabled() &&
> > +		r = !!(hv_enabled && !radix_enabled() &&
> Just because we have radix enabled, is it correct to preclude a hash
> guest from running? Isn't it the case that we may have support for
> radix but a guest choose to run in hash mode (for what ever reason)?

At the moment it is correct, because we don't (yet) have the code to
switch to hash mode when entering a guest and switch back to radix
mode on exit.

Paul.

  reply	other threads:[~2017-01-23  4:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12  9:07 [PATCH 00/18] Support for radix guest and host on POWER9 Paul Mackerras
2017-01-12  9:07 ` [PATCH 01/18] powerpc/64: Don't try to use radix MMU under a hypervisor Paul Mackerras
2017-01-12 16:48   ` Balbir Singh
2017-01-12  9:07 ` [PATCH 02/18] powerpc/64: Fixes for the ibm, client-architecture-support options Paul Mackerras
2017-01-12  9:07 ` [PATCH 03/18] powerpc/64: Always enable radix support for 64-bit Book 3S kernels Paul Mackerras
2017-01-12  9:07 ` [PATCH 04/18] powerpc/64: Enable use of radix MMU under hypervisor on POWER9 Paul Mackerras
2017-01-22  2:17   ` kbuild test robot
2017-01-12  9:07 ` [PATCH 05/18] powerpc/64: More definitions for POWER9 Paul Mackerras
2017-01-12  9:07 ` [PATCH 06/18] powerpc/64: Export pgtable_cache and pgtable_cache_add for KVM Paul Mackerras
2017-01-12  9:07 ` [PATCH 07/18] powerpc/64: Make type of partition table flush depend on partition type Paul Mackerras
2017-01-12  9:07 ` [PATCH 08/18] KVM: PPC: Book3S HV: Don't try to signal cpu -1 Paul Mackerras
2017-01-12  9:07 ` [PATCH 09/18] KVM: PPC: Book3S HV: Add userspace interfaces for POWER9 MMU Paul Mackerras
2017-01-12  9:07 ` [PATCH 10/18] KVM: PPC: Book3S HV: Set process table for HPT guests on POWER9 Paul Mackerras
2017-01-23  2:39   ` Suraj Jitindar Singh
2017-01-23  4:37     ` Paul Mackerras [this message]
2017-01-12  9:07 ` [PATCH 11/18] KVM: PPC: Book3S HV: Add basic infrastructure for radix guests Paul Mackerras
2017-01-12  9:07 ` [PATCH 12/18] KVM: PPC: Book3S HV: Modify guest entry/exit paths to handle " Paul Mackerras
2017-01-12  9:07 ` [PATCH 13/18] KVM: PPC: Book3S HV: Page table construction and page faults for " Paul Mackerras
2017-01-23  3:17   ` Suraj Jitindar Singh
2017-01-23  4:38     ` Paul Mackerras
2017-01-12  9:07 ` [PATCH 14/18] KVM: PPC: Book3S HV: MMU notifier callbacks " Paul Mackerras
2017-01-23  3:21   ` Suraj Jitindar Singh
2017-01-12  9:07 ` [PATCH 15/18] KVM: PPC: Book3S HV: Implement dirty page logging " Paul Mackerras
2017-01-12  9:07 ` [PATCH 16/18] KVM: PPC: Book3S HV: Make HPT-specific hypercalls return error in radix mode Paul Mackerras
2017-01-12  9:07 ` [PATCH 17/18] KVM: PPC: Book3S HV: Enable radix guest support Paul Mackerras
2017-01-23  3:31   ` Suraj Jitindar Singh
2017-01-12  9:07 ` [PATCH 18/18] KVM: PPC: Book3S HV: Use ASDR for HPT guests on POWER9 Paul Mackerras

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=20170123043711.GB29357@fergus.ozlabs.ibm.com \
    --to=paulus@ozlabs.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=sjitindarsingh@gmail.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).