From nobody Tue Feb 10 05:45:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523949806655289.8865011135498; Tue, 17 Apr 2018 00:23:26 -0700 (PDT) Received: from localhost ([::1]:47930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8KxP-0007dh-Ak for importer@patchew.org; Tue, 17 Apr 2018 03:23:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8Krv-0003TI-EY for qemu-devel@nongnu.org; Tue, 17 Apr 2018 03:17:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8Krt-0008Vc-Kf for qemu-devel@nongnu.org; Tue, 17 Apr 2018 03:17:35 -0400 Received: from ozlabs.org ([203.11.71.1]:34081) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f8Krs-0008Td-U4; Tue, 17 Apr 2018 03:17:33 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 40QGm74Dwcz9s1t; Tue, 17 Apr 2018 17:17:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1523949447; bh=yHG4TY5EWQtcG/hbsOcMl2sNwUET9QG1KJgEQDcsTCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BOZ7XGI+XDTQmB4rz3Xvgvoyj+7B9ZV20VupDArXFXmGS6kiJlg5d8/Ng2YobiuuJ KvtxVa1UZ7Duoxpz4K4UQsxgctiIYSQK/wdQ96GZm5ir3wqFwc2poRmbVGonjYnyhY WTi6UmUtXTjcOHb/gvnMEsI0n5K+Mtpicrroqs0M= From: David Gibson To: groug@kaod.org Date: Tue, 17 Apr 2018 17:17:22 +1000 Message-Id: <20180417071722.9399-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180417071722.9399-1-david@gibson.dropbear.id.au> References: <20180417071722.9399-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PATCH for-2.13 10/10] spapr: Move PAPR specific cpu logic to pseries machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" cpu_ppc_set_papr() does three things: 1) it sets up the virtual hypervisor interface, 2) it prevents the cpu from ever entering hypervisor mode and 3) it tells KVM that we're emulating a cpu in PAPR mode. (1) & (2) make sense for any virtual hypervisor (if one ever exists). (3) belongs more properly in the machine type specific to a PAPR guest. While we're at it, remove an unnecessary test on kvm_enabled() by making kvmppc_set_papr() a safe no-op on non-KVM. Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr_cpu_core.c | 4 ++-- target/ppc/cpu.h | 2 +- target/ppc/kvm.c | 4 ++++ target/ppc/translate_init.c | 7 +------ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 8be0265d04..0a668b8954 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -94,8 +94,8 @@ static void spapr_cpu_init(sPAPRMachineState *spapr, Powe= rPCCPU *cpu, /* Set time-base frequency to 512 MHz */ cpu_ppc_tb_init(env, SPAPR_TIMEBASE_FREQ); =20 - /* Enable PAPR mode in TCG or KVM */ - cpu_ppc_set_papr(cpu, PPC_VIRTUAL_HYPERVISOR(spapr)); + cpu_ppc_set_vhyp(cpu, PPC_VIRTUAL_HYPERVISOR(spapr)); + kvmppc_set_papr(cpu); =20 qemu_register_reset(spapr_cpu_reset, cpu); } diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 8c9e03f54d..740939a085 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1331,7 +1331,7 @@ void store_booke_tcr (CPUPPCState *env, target_ulong = val); void store_booke_tsr (CPUPPCState *env, target_ulong val); void ppc_tlb_invalidate_all (CPUPPCState *env); void ppc_tlb_invalidate_one (CPUPPCState *env, target_ulong addr); -void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp); +void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp); #endif #endif =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 51177a8e00..e4341d6ff7 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2090,6 +2090,10 @@ void kvmppc_set_papr(PowerPCCPU *cpu) CPUState *cs =3D CPU(cpu); int ret; =20 + if (!kvm_enabled()) { + return; + } + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0); if (ret) { error_report("This vCPU type or KVM version does not support PAPR"= ); diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index bb5559d799..95e8dba97a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -8864,7 +8864,7 @@ POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) } =20 #if !defined(CONFIG_USER_ONLY) -void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) +void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) { CPUPPCState *env =3D &cpu->env; =20 @@ -8875,11 +8875,6 @@ void cpu_ppc_set_papr(PowerPCCPU *cpu, PPCVirtualHyp= ervisor *vhyp) * hypervisor mode itself */ env->msr_mask &=3D ~MSR_HVB; - - /* Tell KVM that we're in PAPR mode */ - if (kvm_enabled()) { - kvmppc_set_papr(cpu); - } } =20 #endif /* !defined(CONFIG_USER_ONLY) */ --=20 2.14.3