2008-12-16 11:43:58 +01:00
|
|
|
/*
|
|
|
|
* 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__
|
|
|
|
|
2013-01-06 09:31:30 +01:00
|
|
|
#define TYPE_HOST_POWERPC_CPU "host-" TYPE_POWERPC_CPU
|
|
|
|
|
2008-12-16 11:43:58 +01:00
|
|
|
void kvmppc_init(void);
|
|
|
|
|
2011-07-21 02:54:51 +02:00
|
|
|
#ifdef CONFIG_KVM
|
|
|
|
|
2010-02-09 17:37:05 +01:00
|
|
|
uint32_t kvmppc_get_tbfreq(void);
|
2011-07-21 02:29:15 +02:00
|
|
|
uint64_t kvmppc_get_clockfreq(void);
|
pseries: Add device tree properties for VMX/VSX and DFP under kvm
Sufficiently recent PAPR specifications define properties "ibm,vmx"
and "ibm,dfp" on the CPU node which advertise whether the VMX vector
extensions (or the later VSX version) and/or the Decimal Floating
Point operations from IBM's recent POWER CPUs are available.
Currently we do not put these in the guest device tree and the guest
kernel will consequently assume they are not available. This is good,
because they are not supported under TCG. VMX is similar enough to
Altivec that it might be trivial to support, but VSX and DFP would
both require significant work to support in TCG.
However, when running under kvm on a host which supports these
instructions, there's no reason not to let the guest use them. This
patch, therefore, checks for the relevant support on the host CPU
and, if present, advertises them to the guest as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-10-10 20:31:01 +02:00
|
|
|
uint32_t kvmppc_get_vmx(void);
|
|
|
|
uint32_t kvmppc_get_dfp(void);
|
2013-01-03 13:37:02 +01:00
|
|
|
int kvmppc_get_hasidle(CPUPPCState *env);
|
2012-03-14 01:38:22 +01:00
|
|
|
int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
|
2012-10-31 06:06:49 +01:00
|
|
|
int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
|
|
|
|
void kvmppc_set_papr(PowerPCCPU *cpu);
|
2013-01-17 11:54:38 +01:00
|
|
|
void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
|
2011-09-29 23:39:10 +02:00
|
|
|
int kvmppc_smt_threads(void);
|
2013-02-24 19:16:21 +01:00
|
|
|
int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
|
|
|
|
int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
|
|
|
|
int kvmppc_set_tcr(PowerPCCPU *cpu);
|
|
|
|
int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
|
2011-10-23 19:25:04 +02:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2011-09-29 23:39:11 +02:00
|
|
|
off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
|
2011-09-29 23:39:12 +02:00
|
|
|
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);
|
2012-09-12 18:57:12 +02:00
|
|
|
int kvmppc_reset_htab(int shift_hint);
|
|
|
|
uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift);
|
2011-10-23 19:25:04 +02:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
2013-03-30 07:40:49 +01:00
|
|
|
bool kvmppc_has_cap_epr(void);
|
2013-09-26 08:18:35 +02:00
|
|
|
int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
|
2014-02-20 18:52:24 +01:00
|
|
|
bool kvmppc_has_cap_htab_fd(void);
|
2013-07-18 21:33:03 +02:00
|
|
|
int kvmppc_get_htab_fd(bool write);
|
|
|
|
int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns);
|
|
|
|
int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
|
|
|
|
uint16_t n_valid, uint16_t n_invalid);
|
2014-02-20 18:52:24 +01:00
|
|
|
uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu, target_ulong pte_index);
|
|
|
|
void kvmppc_hash64_free_pteg(uint64_t token);
|
2010-08-30 13:49:15 +02:00
|
|
|
|
2014-02-20 18:52:38 +01:00
|
|
|
void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index,
|
|
|
|
target_ulong pte0, target_ulong pte1);
|
|
|
|
|
2011-07-21 02:54:51 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
static inline uint32_t kvmppc_get_tbfreq(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t kvmppc_get_clockfreq(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
pseries: Add device tree properties for VMX/VSX and DFP under kvm
Sufficiently recent PAPR specifications define properties "ibm,vmx"
and "ibm,dfp" on the CPU node which advertise whether the VMX vector
extensions (or the later VSX version) and/or the Decimal Floating
Point operations from IBM's recent POWER CPUs are available.
Currently we do not put these in the guest device tree and the guest
kernel will consequently assume they are not available. This is good,
because they are not supported under TCG. VMX is similar enough to
Altivec that it might be trivial to support, but VSX and DFP would
both require significant work to support in TCG.
However, when running under kvm on a host which supports these
instructions, there's no reason not to let the guest use them. This
patch, therefore, checks for the relevant support on the host CPU
and, if present, advertises them to the guest as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-10-10 20:31:01 +02:00
|
|
|
static inline uint32_t kvmppc_get_vmx(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t kvmppc_get_dfp(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-03 13:37:02 +01:00
|
|
|
static inline int kvmppc_get_hasidle(CPUPPCState *env)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-14 01:38:22 +01:00
|
|
|
static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
|
2011-07-21 02:54:51 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
ppc64: Rudimentary Support for extra page sizes on server CPUs
More recent Power server chips (i.e. based on the 64 bit hash MMU)
support more than just the traditional 4k and 16M page sizes. This
can get quite complicated, because which page sizes are supported,
which combinations are supported within an MMU segment and how these
page sizes are encoded both in the SLB entry and the hash PTE can vary
depending on the CPU model (they are not specified by the
architecture). In addition the firmware or hypervisor may not permit
use of certain page sizes, for various reasons. Whether various page
sizes are supported on KVM, for example, depends on whether the PR or
HV variant of KVM is in use, and on the page size of the memory
backing the guest's RAM.
This patch adds information to the CPUState and cpu defs to describe
the supported page sizes and encodings. Since TCG does not yet
support any extended page sizes, we just set this to NULL in the
static CPU definitions, expanding this to the default 4k and 16M page
sizes when we initialize the cpu state. When using KVM, however, we
instead determine available page sizes using the new
KVM_PPC_GET_SMMU_INFO call. For old kernels without that call, we use
some defaults, with some guesswork which should do the right thing for
existing HV and PR implementations. The fallback might not be correct
for future versions, but that's ok, because they'll have
KVM_PPC_GET_SMMU_INFO.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2012-06-18 21:56:25 +02:00
|
|
|
static inline int kvmppc_read_segment_page_sizes(uint32_t *prop, int maxcells)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-31 06:06:49 +01:00
|
|
|
static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
|
2011-07-21 02:54:51 +02:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-31 06:06:49 +01:00
|
|
|
static inline void kvmppc_set_papr(PowerPCCPU *cpu)
|
2011-08-09 17:57:37 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-17 11:54:38 +01:00
|
|
|
static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 23:39:10 +02:00
|
|
|
static inline int kvmppc_smt_threads(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-02-24 19:16:21 +01:00
|
|
|
static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_set_tcr(PowerPCCPU *cpu)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-10-23 19:25:04 +02:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2011-09-29 23:39:11 +02:00
|
|
|
static inline off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 23:39:12 +02:00
|
|
|
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;
|
|
|
|
}
|
2012-09-12 18:57:12 +02:00
|
|
|
|
|
|
|
static inline int kvmppc_reset_htab(int shift_hint)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64_t kvmppc_rma_size(uint64_t current_size,
|
|
|
|
unsigned int hash_shift)
|
|
|
|
{
|
|
|
|
return ram_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_update_sdr1(CPUPPCState *env)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-23 19:25:04 +02:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
2011-09-29 23:39:12 +02:00
|
|
|
|
2013-03-30 07:40:49 +01:00
|
|
|
static inline bool kvmppc_has_cap_epr(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-07-18 21:33:03 +02:00
|
|
|
|
2013-09-26 08:18:35 +02:00
|
|
|
static inline int kvmppc_define_rtas_kernel_token(uint32_t token,
|
|
|
|
const char *function)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-02-20 18:52:24 +01:00
|
|
|
static inline bool kvmppc_has_cap_htab_fd(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-18 21:33:03 +02:00
|
|
|
static inline int kvmppc_get_htab_fd(bool write)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize,
|
|
|
|
int64_t max_ns)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
|
|
|
|
uint16_t n_valid, uint16_t n_invalid)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2014-02-20 18:52:24 +01:00
|
|
|
static inline uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu,
|
|
|
|
target_ulong pte_index)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvmppc_hash64_free_pteg(uint64_t token)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2014-02-20 18:52:38 +01:00
|
|
|
static inline void kvmppc_hash64_write_pte(CPUPPCState *env,
|
|
|
|
target_ulong pte_index,
|
|
|
|
target_ulong pte0, target_ulong pte1)
|
|
|
|
{
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2011-07-21 02:54:51 +02:00
|
|
|
#endif
|
|
|
|
|
2011-04-01 06:15:30 +02:00
|
|
|
#ifndef CONFIG_KVM
|
|
|
|
#define kvmppc_eieio() do { } while (0)
|
|
|
|
#else
|
|
|
|
#define kvmppc_eieio() \
|
|
|
|
do { \
|
|
|
|
if (kvm_enabled()) { \
|
|
|
|
asm volatile("eieio" : : : "memory"); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2010-08-30 13:49:15 +02:00
|
|
|
#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
|
2010-02-09 17:37:05 +01:00
|
|
|
|
2008-12-16 11:43:58 +01:00
|
|
|
#endif /* __KVM_PPC_H__ */
|