11 #ifndef __ARM64_KVM_SYS_REGS_LOCAL_H__
12 #define __ARM64_KVM_SYS_REGS_LOCAL_H__
14 #include <linux/bsearch.h>
16 #define reg_to_encoding(x) \
17 sys_reg((u32)(x)->Op0, (u32)(x)->Op1, \
18 (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2)
30 #define encoding_to_params(reg) \
31 ((struct sys_reg_params){ .Op0 = sys_reg_Op0(reg), \
32 .Op1 = sys_reg_Op1(reg), \
33 .CRn = sys_reg_CRn(reg), \
34 .CRm = sys_reg_CRm(reg), \
35 .Op2 = sys_reg_Op2(reg) })
37 #define esr_sys64_to_params(esr) \
38 ((struct sys_reg_params){ .Op0 = ((esr) >> 20) & 3, \
39 .Op1 = ((esr) >> 14) & 0x7, \
40 .CRn = ((esr) >> 10) & 0xf, \
41 .CRm = ((esr) >> 1) & 0xf, \
42 .Op2 = ((esr) >> 17) & 0x7, \
43 .is_write = !((esr) & 1) })
45 #define esr_cp1x_32_to_params(esr) \
46 ((struct sys_reg_params){ .Op1 = ((esr) >> 14) & 0x7, \
47 .CRn = ((esr) >> 10) & 0xf, \
48 .CRm = ((esr) >> 1) & 0xf, \
49 .Op2 = ((esr) >> 17) & 0x7, \
50 .is_write = !((esr) & 1) })
97 #define REG_HIDDEN (1 << 0)
98 #define REG_HIDDEN_USER (1 << 1)
99 #define REG_RAZ (1 << 2)
100 #define REG_USER_WI (1 << 3)
110 kvm_pr_unimpl(
"%pV { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
111 &(
struct va_format){
fmt, &va },
112 p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ?
"write" :
"read");
119 print_sys_reg_msg(p,
"%s",
"");
140 BUG_ON(r->
reg >= NR_SYS_REGS);
141 __vcpu_sys_reg(vcpu, r->
reg) = 0x1de7ec7edbadc0deULL;
142 return __vcpu_sys_reg(vcpu, r->
reg);
148 BUG_ON(r->
reg >= NR_SYS_REGS);
149 __vcpu_sys_reg(vcpu, r->
reg) = r->
val;
150 return __vcpu_sys_reg(vcpu, r->
reg);
210 const unsigned long pval = (
unsigned long)key;
222 return __inline_bsearch((
void *)pval, table, num,
sizeof(table[0]),
match_sys_reg);
236 #define AA32(_x) .aarch32_map = AA32_##_x
237 #define Op0(_x) .Op0 = _x
238 #define Op1(_x) .Op1 = _x
239 #define CRn(_x) .CRn = _x
240 #define CRm(_x) .CRm = _x
241 #define Op2(_x) .Op2 = _x
243 #define SYS_DESC(reg) \
245 Op0(sys_reg_Op0(reg)), Op1(sys_reg_Op1(reg)), \
246 CRn(sys_reg_CRn(reg)), CRm(sys_reg_CRm(reg)), \
247 Op2(sys_reg_Op2(reg))
bool(* access)(struct kvm_vcpu *, struct sys_reg_params *, const struct sys_reg_desc *)
enum sys_reg_desc::@9 aarch32_map
int(* set_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
unsigned int(* visibility)(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
int(* get_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
u64(* reset)(struct kvm_vcpu *, const struct sys_reg_desc *)
static bool sysreg_hidden(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
int kvm_sys_reg_get_user(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg, const struct sys_reg_desc table[], unsigned int num)
#define reg_to_encoding(x)
static char va_start(va, fmt)
static const struct sys_reg_desc * find_reg(const struct sys_reg_params *params, const struct sys_reg_desc table[], unsigned int num)
static __printf(2, 3) inline void print_sys_reg_msg(const struct sys_reg_params *p
int kvm_arm_sys_reg_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *)
static bool read_zero(struct kvm_vcpu *vcpu, struct sys_reg_params *p)
static bool ignore_write(struct kvm_vcpu *vcpu, const struct sys_reg_params *p)
static bool sysreg_user_write_ignore(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
static u64 reset_val(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
static u64 reset_unknown(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
static void print_sys_reg_instr(const struct sys_reg_params *p)
int kvm_sys_reg_set_user(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg, const struct sys_reg_desc table[], unsigned int num)
static int match_sys_reg(const void *key, const void *elt)
const struct sys_reg_desc * get_reg_by_id(u64 id, const struct sys_reg_desc table[], unsigned int num)
kvm_pr_unimpl("%pV { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n", &(struct va_format){ fmt, &va }, p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ? "write" :"read")
static bool sysreg_hidden_user(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
static int cmp_sys_reg(const struct sys_reg_desc *i1, const struct sys_reg_desc *i2)
static unsigned int sysreg_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
int kvm_arm_sys_reg_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *)
static bool sysreg_visible_as_raz(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)