0f5cb2989f
The pseries machine of qemu implements the TCE mechanism used as a virtual IOMMU for the PAPR defined virtual IO devices. Because the PAPR spec only defines a small DMA address space, the guest VIO drivers need to update TCE mappings very frequently - the virtual network device is particularly bad. This means many slow exits to qemu to emulate the H_PUT_TCE hypercall. Sufficiently recent kernels allow this to be mitigated by implementing H_PUT_TCE in the host kernel. To make use of this, however, qemu needs to initialize the necessary TCE tables, and map them into itself so that the VIO device implementations can retrieve the mappings when they access guest memory (which is treated as a virtual DMA operation). This patch adds the necessary calls to use the KVM TCE acceleration. If the kernel does not support acceleration, or there is some other error creating the accelerated TCE table, then it will still fall back to full userspace TCE implementation. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Alexander Graf <agraf@suse.de>
102 lines
2.1 KiB
C
102 lines
2.1 KiB
C
/*
|
|
* Copyright 2008 IBM Corporation.
|
|
* Authors: Hollis Blanchard <hollisb@us.ibm.com>
|
|
*
|
|
* This work is licensed under the GNU GPL license version 2 or later.
|
|
*
|
|
*/
|
|
|
|
#ifndef __KVM_PPC_H__
|
|
#define __KVM_PPC_H__
|
|
|
|
#include "memory.h"
|
|
|
|
void kvmppc_init(void);
|
|
|
|
#ifdef CONFIG_KVM
|
|
|
|
uint32_t kvmppc_get_tbfreq(void);
|
|
uint64_t kvmppc_get_clockfreq(void);
|
|
int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len);
|
|
int kvmppc_set_interrupt(CPUState *env, int irq, int level);
|
|
void kvmppc_set_papr(CPUState *env);
|
|
int kvmppc_smt_threads(void);
|
|
off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
|
|
void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd);
|
|
int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
|
|
|
|
#else
|
|
|
|
static inline uint32_t kvmppc_get_tbfreq(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline uint64_t kvmppc_get_clockfreq(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline int kvmppc_set_interrupt(CPUState *env, int irq, int level)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline void kvmppc_set_papr(CPUState *env)
|
|
{
|
|
}
|
|
|
|
static inline int kvmppc_smt_threads(void)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
static inline off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void *kvmppc_create_spapr_tce(uint32_t liobn,
|
|
uint32_t window_size, int *fd)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline int kvmppc_remove_spapr_tce(void *table, int pfd,
|
|
uint32_t window_size)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_KVM
|
|
#define kvmppc_eieio() do { } while (0)
|
|
#else
|
|
#define kvmppc_eieio() \
|
|
do { \
|
|
if (kvm_enabled()) { \
|
|
asm volatile("eieio" : : : "memory"); \
|
|
} \
|
|
} while (0)
|
|
#endif
|
|
|
|
#ifndef KVM_INTERRUPT_SET
|
|
#define KVM_INTERRUPT_SET -1
|
|
#endif
|
|
|
|
#ifndef KVM_INTERRUPT_UNSET
|
|
#define KVM_INTERRUPT_UNSET -2
|
|
#endif
|
|
|
|
#ifndef KVM_INTERRUPT_SET_LEVEL
|
|
#define KVM_INTERRUPT_SET_LEVEL -3
|
|
#endif
|
|
|
|
#endif /* __KVM_PPC_H__ */
|