2019-05-29 22:12:40 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2010-04-16 06:11:40 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright SUSE Linux Products GmbH 2010
|
|
|
|
*
|
|
|
|
* Authors: Alexander Graf <agraf@suse.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_KVM_BOOKE_H__
|
|
|
|
#define __ASM_KVM_BOOKE_H__
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
|
2014-09-01 17:01:58 +08:00
|
|
|
/*
|
|
|
|
* Number of available lpids. Only the low-order 6 bits of LPID rgister are
|
|
|
|
* implemented on e500mc+ cores.
|
|
|
|
*/
|
2011-12-20 23:34:20 +08:00
|
|
|
#define KVMPPC_NR_LPIDS 64
|
|
|
|
|
2013-07-04 14:57:45 +08:00
|
|
|
#define KVMPPC_INST_EHPRIV 0x7c00021c
|
|
|
|
#define EHPRIV_OC_SHIFT 11
|
|
|
|
/* "ehpriv 1" : ehpriv with OC = 1 is used for debug emulation */
|
|
|
|
#define EHPRIV_OC_DEBUG 1
|
2013-03-21 04:24:58 +08:00
|
|
|
|
2010-04-16 06:11:40 +08:00
|
|
|
static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
|
|
|
|
{
|
2018-05-07 14:20:07 +08:00
|
|
|
vcpu->arch.regs.gpr[num] = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
|
|
|
|
{
|
2018-05-07 14:20:07 +08:00
|
|
|
return vcpu->arch.regs.gpr[num];
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
|
|
|
|
{
|
2018-10-08 13:30:58 +08:00
|
|
|
vcpu->arch.regs.ccr = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2018-10-08 13:30:58 +08:00
|
|
|
return vcpu->arch.regs.ccr;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
2015-05-27 07:56:57 +08:00
|
|
|
static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
|
2010-04-16 06:11:40 +08:00
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
vcpu->arch.regs.xer = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
2015-05-27 07:56:57 +08:00
|
|
|
static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
|
2010-04-16 06:11:40 +08:00
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
return vcpu->arch.regs.xer;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
2014-01-09 18:51:16 +08:00
|
|
|
static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
/* XXX Would need to check TLB entry */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-04-16 06:11:40 +08:00
|
|
|
static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
vcpu->arch.regs.ctr = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
return vcpu->arch.regs.ctr;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
vcpu->arch.regs.link = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
return vcpu->arch.regs.link;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
vcpu->arch.regs.nip = val;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
2018-05-07 14:20:08 +08:00
|
|
|
return vcpu->arch.regs.nip;
|
2010-04-16 06:11:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
return vcpu->arch.fault_dear;
|
|
|
|
}
|
2014-06-20 20:43:36 +08:00
|
|
|
|
|
|
|
static inline bool kvmppc_supports_magic_page(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
/* Magic page is only supported on e500v2 */
|
|
|
|
#ifdef CONFIG_KVM_E500V2
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2010-04-16 06:11:40 +08:00
|
|
|
#endif /* __ASM_KVM_BOOKE_H__ */
|