From nobody Sat May 4 00:59:01 2024 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.zoho.com; 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490592229961560.5707219021933; Sun, 26 Mar 2017 22:23:49 -0700 (PDT) Received: from localhost ([::1]:44403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csN87-0000zu-VY for importer@patchew.org; Mon, 27 Mar 2017 01:23:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csN7K-0000hc-LZ for qemu-devel@nongnu.org; Mon, 27 Mar 2017 01:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csN7H-0007yM-Jb for qemu-devel@nongnu.org; Mon, 27 Mar 2017 01:22:58 -0400 Received: from ozlabs.ru ([107.173.13.209]:54124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csN7H-0007y3-Cy; Mon, 27 Mar 2017 01:22:55 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 64E103A6042A; Mon, 27 Mar 2017 01:22:27 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Mon, 27 Mar 2017 16:22:19 +1100 Message-Id: <20170327052219.33110-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu] target-ppc/kvm: Enable in-kernel TCE acceleration for multi-tce 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: Alexey Kardashevskiy , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enables in-kernel handling of H_PUT_TCE_INDIRECT and H_STUFF_TCE hypercalls. The host kernel support is there since v4.6, in particular d3695aa4f452 ("KVM: PPC: Add support for multiple-TCE hcalls"). H_PUT_TCE is already accelerated and does not need any special enablement. Signed-off-by: Alexey Kardashevskiy --- target/ppc/kvm_ppc.h | 6 ++++++ hw/ppc/spapr.c | 4 +++- target/ppc/kvm.c | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 4b2fd9a609..f48243d13f 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -39,6 +39,7 @@ target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, #ifndef CONFIG_USER_ONLY off_t kvmppc_alloc_rma(void **rma); bool kvmppc_spapr_use_multitce(void); +int kvmppc_spapr_enable_inkernel_multitce(void); void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, uint64_t bus_offset, uint32_t nb_table, int *pfd, bool need_vfio); @@ -180,6 +181,11 @@ static inline bool kvmppc_spapr_use_multitce(void) return false; } =20 +static inline int kvmppc_spapr_enable_inkernel_multitce(void) +{ + return -1; +} + static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_= shift, uint64_t bus_offset, uint32_t nb_table, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0e1c29bcf8..8027716f73 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2360,10 +2360,12 @@ static void ppc_spapr_init(MachineState *machine) =20 qemu_register_boot_set(spapr_boot_set, spapr); =20 - /* to stop and start vmclock */ if (kvm_enabled()) { + /* to stop and start vmclock */ qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change, &spapr->tb); + + kvmppc_spapr_enable_inkernel_multitce(); } } =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 6dc39623e5..560ce655c7 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2194,6 +2194,20 @@ bool kvmppc_spapr_use_multitce(void) return cap_spapr_multitce; } =20 +int kvmppc_spapr_enable_inkernel_multitce(void) +{ + int ret; + + ret =3D kvm_vm_enable_cap(kvm_state, KVM_CAP_PPC_ENABLE_HCALL, 0, + H_PUT_TCE_INDIRECT, 1); + if (!ret) { + ret =3D kvm_vm_enable_cap(kvm_state, KVM_CAP_PPC_ENABLE_HCALL, 0, + H_STUFF_TCE, 1); + } + + return ret; +} + void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift, uint64_t bus_offset, uint32_t nb_table, int *pfd, bool need_vfio) --=20 2.11.0