mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
4656e1f012
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>
134 lines
2.7 KiB
C
134 lines
2.7 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);
|
|
uint32_t kvmppc_get_vmx(void);
|
|
uint32_t kvmppc_get_dfp(void);
|
|
int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
|
|
int kvmppc_set_interrupt(CPUPPCState *env, int irq, int level);
|
|
void kvmppc_set_papr(CPUPPCState *env);
|
|
int kvmppc_smt_threads(void);
|
|
#ifndef CONFIG_USER_ONLY
|
|
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);
|
|
#endif /* !CONFIG_USER_ONLY */
|
|
const ppc_def_t *kvmppc_host_cpu_def(void);
|
|
int kvmppc_fixup_cpu(CPUPPCState *env);
|
|
|
|
#else
|
|
|
|
static inline uint32_t kvmppc_get_tbfreq(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline uint64_t kvmppc_get_clockfreq(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t kvmppc_get_vmx(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline uint32_t kvmppc_get_dfp(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline int kvmppc_read_segment_page_sizes(uint32_t *prop, int maxcells)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline int kvmppc_set_interrupt(CPUPPCState *env, int irq, int level)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static inline void kvmppc_set_papr(CPUPPCState *env)
|
|
{
|
|
}
|
|
|
|
static inline int kvmppc_smt_threads(void)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
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 /* !CONFIG_USER_ONLY */
|
|
|
|
static inline const ppc_def_t *kvmppc_host_cpu_def(void)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline int kvmppc_fixup_cpu(CPUPPCState *env)
|
|
{
|
|
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__ */
|