From patchwork Wed May 30 10:09:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Mackerras X-Patchwork-Id: 922688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="k0KoBAY+"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40wmZT5J5Qz9s1w for ; Wed, 30 May 2018 20:10:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750967AbeE3KK4 (ORCPT ); Wed, 30 May 2018 06:10:56 -0400 Received: from ozlabs.org ([203.11.71.1]:43825 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbeE3KKz (ORCPT ); Wed, 30 May 2018 06:10:55 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 40wmZP3WqPz9s1d; Wed, 30 May 2018 20:10:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527675053; bh=ozTjJLJRJ8gF7dWMMoTS1fgmI+HpqZuiMzkfXUrSQuw=; h=Date:From:To:Cc:Subject:From; b=k0KoBAY+VSxKBjRZGzpq6z6njxSFxP+kSbjzK+n5Y9S5HOfsFQVdECtc647sStWmM WSVm6G1HAJe5yb723biSHthBs22rni+HV/NqTydBreSutVW53v06CQn7a900+VaCu3 R62KGgirIlfJS0fTp/rWGa/EszrPJpv55slUgh1TMz2YLZ9Xt3CqCl2dRaz7wyKYV+ QhtSncDxoz7LOVYub9rwWo4y9c4VNAw3p4oqq9SOwM8s1p8KC2uTWVCmto9zx24mbK Gb4qskNHPPjzNaomdNEI3B1WBAMC4cQ+HBMkWxiOW50ssLCXpiL3boDBmc7Ku7AjA2 r6oRn4virVbJQ== Date: Wed, 30 May 2018 20:09:46 +1000 From: Paul Mackerras To: kvm@vger.kernel.org Cc: kvm-ppc@vger.kernel.org, Greg Kurz Subject: [PATCH] KVM: PPC: Book3S PR: Allow KVM_PPC_CONFIGURE_V3_MMU to succeed Message-ID: <20180530100946.GA6466@fergus.ozlabs.ibm.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Currently, PR KVM does not implement the configure_mmu operation, and so the KVM_PPC_CONFIGURE_V3_MMU ioctl always fails with an EINVAL error. This causes recent kernels to fail to boot as a PR KVM guest on POWER9, since recent kernels booted in HPT mode do the H_REGISTER_PROC_TBL hypercall, which causes userspace (QEMU) to do KVM_PPC_CONFIGURE_V3_MMU, which fails. This implements a minimal configure_mmu operation for PR KVM. It succeeds only if the MMU is being configured for HPT mode and no process table is being registered. This is enough to get recent kernels to boot as a PR KVM guest. Signed-off-by: Paul Mackerras Reviewed-by: Greg Kurz Tested-by: Greg Kurz --- arch/powerpc/kvm/book3s_pr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index c74a8885427d..b1aff9f83ed0 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -1687,6 +1687,17 @@ static int kvm_vm_ioctl_get_smmu_info_pr(struct kvm *kvm, return 0; } + +static int kvm_configure_mmu_pr(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg) +{ + if (!cpu_has_feature(CPU_FTR_ARCH_300)) + return -ENODEV; + /* Require flags and process table base and size to all be zero. */ + if (cfg->flags || cfg->process_table) + return -EINVAL; + return 0; +} + #else static int kvm_vm_ioctl_get_smmu_info_pr(struct kvm *kvm, struct kvm_ppc_smmu_info *info) @@ -1788,6 +1799,7 @@ static struct kvmppc_ops kvm_ops_pr = { .arch_vm_ioctl = kvm_arch_vm_ioctl_pr, #ifdef CONFIG_PPC_BOOK3S_64 .hcall_implemented = kvmppc_hcall_impl_pr, + .configure_mmu = kvm_configure_mmu_pr, #endif .giveup_ext = kvmppc_giveup_ext, };