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: 10438323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93B79601E9 for ; Wed, 30 May 2018 10:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 784202893A for ; Wed, 30 May 2018 10:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F432892D; Wed, 30 May 2018 10:11:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 827E32892D for ; Wed, 30 May 2018 10:10:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751168AbeE3KK5 (ORCPT ); Wed, 30 May 2018 06:10:57 -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-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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, };