target-ppc/kvm: Enable in-kernel TCE acceleration for multi-tce

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 <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Alexey Kardashevskiy 2017-03-27 16:22:19 +11:00 committed by David Gibson
parent e957f6a9b9
commit 3dc410ae83
3 changed files with 23 additions and 1 deletions

View File

@ -2361,10 +2361,12 @@ static void ppc_spapr_init(MachineState *machine)
qemu_register_boot_set(spapr_boot_set, spapr); qemu_register_boot_set(spapr_boot_set, spapr);
/* to stop and start vmclock */
if (kvm_enabled()) { if (kvm_enabled()) {
/* to stop and start vmclock */
qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change, qemu_add_vm_change_state_handler(cpu_ppc_clock_vm_state_change,
&spapr->tb); &spapr->tb);
kvmppc_spapr_enable_inkernel_multitce();
} }
} }

View File

@ -2198,6 +2198,20 @@ bool kvmppc_spapr_use_multitce(void)
return cap_spapr_multitce; return cap_spapr_multitce;
} }
int kvmppc_spapr_enable_inkernel_multitce(void)
{
int ret;
ret = kvm_vm_enable_cap(kvm_state, KVM_CAP_PPC_ENABLE_HCALL, 0,
H_PUT_TCE_INDIRECT, 1);
if (!ret) {
ret = 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, void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
uint64_t bus_offset, uint32_t nb_table, uint64_t bus_offset, uint32_t nb_table,
int *pfd, bool need_vfio) int *pfd, bool need_vfio)

View File

@ -39,6 +39,7 @@ target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu,
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
off_t kvmppc_alloc_rma(void **rma); off_t kvmppc_alloc_rma(void **rma);
bool kvmppc_spapr_use_multitce(void); 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, void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
uint64_t bus_offset, uint32_t nb_table, uint64_t bus_offset, uint32_t nb_table,
int *pfd, bool need_vfio); int *pfd, bool need_vfio);
@ -180,6 +181,11 @@ static inline bool kvmppc_spapr_use_multitce(void)
return false; return false;
} }
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, static inline void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t page_shift,
uint64_t bus_offset, uint64_t bus_offset,
uint32_t nb_table, uint32_t nb_table,