7 #include <linux/irqchip/arm-gic-v3.h>
9 #include <asm/kvm_asm.h>
10 #include <asm/kvm_mmu.h>
16 #include "../../sys_regs.h"
37 u64 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT);
39 *vcpu_pc(vcpu) = read_sysreg_el2(SYS_ELR);
40 *vcpu_cpsr(vcpu) = read_sysreg_el2(SYS_SPSR);
42 kvm_pend_exception(vcpu, EXCEPT_AA64_EL1_SYNC);
46 write_sysreg_el1(esr, SYS_ESR);
47 write_sysreg_el1(read_sysreg_el2(SYS_ELR), SYS_ELR);
48 write_sysreg_el2(*vcpu_pc(vcpu), SYS_ELR);
49 write_sysreg_el2(*vcpu_cpsr(vcpu), SYS_SPSR);
62 u64 mask = GENMASK_ULL(ARM64_FEATURE_FIELD_BITS - 1, 0);
71 while (sys_reg_val && restrict_fields) {
72 value |= min(sys_reg_val & mask, restrict_fields & mask);
74 restrict_fields &= ~mask;
75 mask <<= ARM64_FEATURE_FIELD_BITS;
99 const struct kvm *kvm = (
const struct kvm *)kern_hyp_va(vcpu->kvm);
102 if (!kvm_has_mte(kvm))
103 allow_mask &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE);
167 if (!vcpu_has_ptrauth(vcpu))
168 allow_mask &= ~(ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_APA) |
169 ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_API) |
170 ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_GPA) |
171 ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_GPI));
180 if (!vcpu_has_ptrauth(vcpu))
181 allow_mask &= ~(ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3) |
182 ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_GPA3));
211 case SYS_ID_AA64PFR0_EL1:
213 case SYS_ID_AA64PFR1_EL1:
215 case SYS_ID_AA64ZFR0_EL1:
217 case SYS_ID_AA64DFR0_EL1:
219 case SYS_ID_AA64DFR1_EL1:
221 case SYS_ID_AA64AFR0_EL1:
223 case SYS_ID_AA64AFR1_EL1:
225 case SYS_ID_AA64ISAR0_EL1:
227 case SYS_ID_AA64ISAR1_EL1:
229 case SYS_ID_AA64ISAR2_EL1:
231 case SYS_ID_AA64MMFR0_EL1:
233 case SYS_ID_AA64MMFR1_EL1:
235 case SYS_ID_AA64MMFR2_EL1:
278 BUILD_BUG_ON(FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_EL1),
310 p->
regval = ICC_SRE_EL1_DIB | ICC_SRE_EL1_DFB | ICC_SRE_EL1_SRE;
316 #define AARCH32(REG) { SYS_DESC(REG), .access = pvm_access_id_aarch32 }
319 #define AARCH64(REG) { SYS_DESC(REG), .access = pvm_access_id_aarch64 }
326 #define ID_UNALLOCATED(crm, op2) { \
327 Op0(3), Op1(0), CRn(0), CRm(crm), Op2(op2), \
328 .access = pvm_access_id_aarch64, \
332 #define RAZ_WI(REG) { SYS_DESC(REG), .access = pvm_access_raz_wi }
335 #define HOST_HANDLED(REG) { SYS_DESC(REG), .access = NULL }
421 RAZ_WI(SYS_ERXSTATUS_EL1),
478 unsigned long esr = kvm_vcpu_get_esr(vcpu);
479 int Rt = kvm_vcpu_sys_get_rt(vcpu);
482 params.
regval = vcpu_get_reg(vcpu, Rt);
497 if (r->
access(vcpu, ¶ms, r))
501 vcpu_set_reg(vcpu, Rt, params.
regval);
static void __kvm_skip_instr(struct kvm_vcpu *vcpu)
void __kvm_adjust_pc(struct kvm_vcpu *vcpu)
#define PVM_ID_AA64MMFR1_ALLOW
#define PVM_ID_AA64AFR1_ALLOW
#define PVM_ID_AA64MMFR2_ALLOW
#define PVM_ID_AA64ISAR0_ALLOW
#define PVM_ID_AA64AFR0_ALLOW
#define PVM_ID_AA64MMFR0_RESTRICT_UNSIGNED
#define PVM_ID_AA64ISAR1_ALLOW
#define PVM_ID_AA64DFR1_ALLOW
#define PVM_ID_AA64PFR1_ALLOW
#define PVM_ID_AA64ISAR2_ALLOW
#define PVM_ID_AA64DFR0_ALLOW
#define PVM_ID_AA64ZFR0_ALLOW
#define PVM_ID_AA64MMFR0_ALLOW
#define PVM_ID_AA64PFR0_ALLOW
#define PVM_ID_AA64PFR0_RESTRICT_UNSIGNED
u64 id_aa64isar2_el1_sys_val
static u64 get_pvm_id_aa64mmfr1(const struct kvm_vcpu *vcpu)
u64 id_aa64pfr0_el1_sys_val
static u64 get_pvm_id_aa64afr0(const struct kvm_vcpu *vcpu)
static u64 get_pvm_id_aa64dfr1(const struct kvm_vcpu *vcpu)
static u64 get_pvm_id_aa64dfr0(const struct kvm_vcpu *vcpu)
bool kvm_handle_pvm_sysreg(struct kvm_vcpu *vcpu, u64 *exit_code)
static u64 get_pvm_id_aa64isar1(const struct kvm_vcpu *vcpu)
static bool pvm_access_id_aarch64(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
static u64 get_pvm_id_aa64afr1(const struct kvm_vcpu *vcpu)
static u64 get_pvm_id_aa64zfr0(const struct kvm_vcpu *vcpu)
#define ID_UNALLOCATED(crm, op2)
static u64 get_pvm_id_aa64mmfr0(const struct kvm_vcpu *vcpu)
u64 id_aa64pfr1_el1_sys_val
static u64 get_pvm_id_aa64isar0(const struct kvm_vcpu *vcpu)
int kvm_check_pvm_sysreg_table(void)
static u64 get_pvm_id_aa64mmfr2(const struct kvm_vcpu *vcpu)
bool kvm_handle_pvm_restricted(struct kvm_vcpu *vcpu, u64 *exit_code)
u64 id_aa64mmfr0_el1_sys_val
static bool pvm_access_id_aarch32(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
static const struct sys_reg_desc pvm_sys_reg_descs[]
static void inject_undef64(struct kvm_vcpu *vcpu)
u64 id_aa64mmfr2_el1_sys_val
static u64 get_restricted_features_unsigned(u64 sys_reg_val, u64 restrict_fields)
static bool pvm_gic_read_sre(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
static bool pvm_access_raz_wi(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
static u64 read_id_reg(const struct kvm_vcpu *vcpu, struct sys_reg_desc const *r)
u64 id_aa64mmfr1_el1_sys_val
u64 id_aa64isar1_el1_sys_val
u64 id_aa64isar0_el1_sys_val
static u64 get_pvm_id_aa64pfr0(const struct kvm_vcpu *vcpu)
u64 id_aa64smfr0_el1_sys_val
u64 pvm_read_id_reg(const struct kvm_vcpu *vcpu, u32 id)
static u64 get_pvm_id_aa64isar2(const struct kvm_vcpu *vcpu)
static u64 get_pvm_id_aa64pfr1(const struct kvm_vcpu *vcpu)
#define HOST_HANDLED(REG)
bool(* access)(struct kvm_vcpu *, struct sys_reg_params *, const struct sys_reg_desc *)
#define reg_to_encoding(x)
#define esr_sys64_to_params(esr)
static const struct sys_reg_desc * find_reg(const struct sys_reg_params *params, const struct sys_reg_desc table[], unsigned int num)
static int cmp_sys_reg(const struct sys_reg_desc *i1, const struct sys_reg_desc *i2)