KVM
Macros | Functions | Variables
sys_regs.c File Reference
#include <linux/bitfield.h>
#include <linux/bsearch.h>
#include <linux/cacheinfo.h>
#include <linux/kvm_host.h>
#include <linux/mm.h>
#include <linux/printk.h>
#include <linux/uaccess.h>
#include <asm/cacheflush.h>
#include <asm/cputype.h>
#include <asm/debug-monitors.h>
#include <asm/esr.h>
#include <asm/kvm_arm.h>
#include <asm/kvm_emulate.h>
#include <asm/kvm_hyp.h>
#include <asm/kvm_mmu.h>
#include <asm/kvm_nested.h>
#include <asm/perf_event.h>
#include <asm/sysreg.h>
#include <trace/events/kvm.h>
#include "sys_regs.h"
#include "trace.h"
Include dependency graph for sys_regs.c:

Go to the source code of this file.

Macros

#define PURE_EL2_SYSREG(el2)
 
#define MAPPED_EL2_SYSREG(el2, el1, fn)
 
#define CSSELR_MAX   14
 
#define DBG_BCR_BVR_WCR_WVR_EL1(n)
 
#define PMU_SYS_REG(name)
 
#define PMU_PMEVCNTR_EL0(n)
 
#define PMU_PMEVTYPER_EL0(n)
 
#define AMU_AMEVCNTR0_EL0(n)   { SYS_DESC(SYS_AMEVCNTR0_EL0(n)), undef_access }
 
#define AMU_AMEVTYPER0_EL0(n)   { SYS_DESC(SYS_AMEVTYPER0_EL0(n)), undef_access }
 
#define AMU_AMEVCNTR1_EL0(n)   { SYS_DESC(SYS_AMEVCNTR1_EL0(n)), undef_access }
 
#define AMU_AMEVTYPER1_EL0(n)   { SYS_DESC(SYS_AMEVTYPER1_EL0(n)), undef_access }
 
#define __PTRAUTH_KEY(k)
 
#define PTRAUTH_KEY(k)
 
#define ID_REG_LIMIT_FIELD_ENUM(val, reg, field, limit)
 
#define MTE_REG(name)
 
#define EL2_REG(name, acc, rst, v)
 
#define EL2_REG_VNCR(name, rst, v)   EL2_REG(name, bad_vncr_trap, rst, v)
 
#define EL2_REG_REDIR(name, rst, v)   EL2_REG(name, bad_redir_trap, rst, v)
 
#define EL12_REG(name, acc, rst, v)
 
#define ID_DESC(name)
 
#define ID_SANITISED(name)
 
#define AA32_ID_SANITISED(name)
 
#define ID_WRITABLE(name, mask)
 
#define ID_UNALLOCATED(crm, op2)
 
#define ID_HIDDEN(name)
 
#define DBG_BCR_BVR_WCR_WVR(n)
 
#define DBGBXVR(n)    { AA32(HI), Op1( 0), CRn( 1), CRm((n)), Op2( 1), trap_bvr, NULL, n }
 
#define CP15_PMU_SYS_REG(_map, _Op1, _CRn, _CRm, _Op2)
 
#define PMU_PMEVCNTR(n)
 
#define PMU_PMEVTYPER(n)
 
#define FUNCTION_INVARIANT(reg)
 
#define KVM_ARM_FEATURE_ID_RANGE_INDEX(r)
 

Functions

static u64 sys_reg_to_index (const struct sys_reg_desc *reg)
 
static int set_id_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static bool bad_trap (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r, const char *msg)
 
static bool read_from_write_only (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
 
static bool write_to_read_only (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
 
static bool get_el2_to_el1_mapping (unsigned int reg, unsigned int *el1r, u64(**xlate)(u64))
 
u64 vcpu_read_sys_reg (const struct kvm_vcpu *vcpu, int reg)
 
void vcpu_write_sys_reg (struct kvm_vcpu *vcpu, u64 val, int reg)
 
static u8 get_min_cache_line_size (bool icache)
 
static u32 get_ccsidr (struct kvm_vcpu *vcpu, u32 csselr)
 
static int set_ccsidr (struct kvm_vcpu *vcpu, u32 csselr, u32 val)
 
static bool access_rw (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_dcsw (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_dcgsw (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static void get_access_mask (const struct sys_reg_desc *r, u64 *mask, u64 *shift)
 
static bool access_vm_reg (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_actlr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_gic_sgi (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_gic_sre (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_raz_wi (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_undef (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_loregion (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_oslar_el1 (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_oslsr_el1 (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static int set_oslsr_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static bool trap_dbgauthstatus_el1 (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_debug_regs (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static void reg_to_dbg (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd, u64 *dbg_reg)
 
static void dbg_to_reg (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd, u64 *dbg_reg)
 
static bool trap_bvr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
 
static int set_bvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static int get_bvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static u64 reset_bvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool trap_bcr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
 
static int set_bcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static int get_bcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static u64 reset_bcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool trap_wvr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
 
static int set_wvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static int get_wvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static u64 reset_wvr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool trap_wcr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
 
static int set_wcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static int get_wcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static u64 reset_wcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static u64 reset_amair_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_actlr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_mpidr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static unsigned int pmu_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_pmu_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_pmevcntr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_pmevtyper (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_pmselr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 reset_pmcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static bool check_pmu_access_disabled (struct kvm_vcpu *vcpu, u64 flags)
 
static bool pmu_access_el0_disabled (struct kvm_vcpu *vcpu)
 
static bool pmu_write_swinc_el0_disabled (struct kvm_vcpu *vcpu)
 
static bool pmu_access_cycle_counter_el0_disabled (struct kvm_vcpu *vcpu)
 
static bool pmu_access_event_counter_el0_disabled (struct kvm_vcpu *vcpu)
 
static bool access_pmcr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmselr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmceid (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool pmu_counter_idx_valid (struct kvm_vcpu *vcpu, u64 idx)
 
static int get_pmu_evcntr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 *val)
 
static bool access_pmu_evcntr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmu_evtyper (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static int set_pmreg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 val)
 
static int get_pmreg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 *val)
 
static bool access_pmcnten (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pminten (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmovs (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmswinc (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_pmuserenr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static int get_pmcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 *val)
 
static int set_pmcr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 val)
 
static bool undef_access (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static unsigned int ptrauth_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool access_arch_timer (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static s64 kvm_arm64_ftr_safe_value (u32 id, const struct arm64_ftr_bits *ftrp, s64 new, s64 cur)
 
static int arm64_check_features (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static u8 pmuver_to_perfmon (u8 pmuver)
 
static u64 __kvm_read_sanitised_id_reg (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 kvm_read_sanitised_id_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static u64 read_id_reg (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static bool is_id_reg (u32 id)
 
static bool is_aa32_id_reg (u32 id)
 
static unsigned int id_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static unsigned int aa32_id_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static unsigned int raz_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static bool access_id_reg (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static unsigned int sve_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static u64 read_sanitised_id_aa64pfr0_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static u64 read_sanitised_id_aa64dfr0_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static int set_id_aa64dfr0_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static u64 read_sanitised_id_dfr0_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static int set_id_dfr0_el1 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static int get_id_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static int get_raz_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
 
static int set_wi_reg (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static bool access_ctr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_clidr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static u64 reset_clidr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 
static int set_clidr (struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
 
static bool access_csselr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_ccsidr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static unsigned int mte_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static unsigned int el2_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool bad_vncr_trap (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool bad_redir_trap (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static unsigned int hidden_user_visibility (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
 
static bool access_sp_el1 (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_elr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool access_spsr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool trap_dbgdidr (struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
 
static bool check_sysreg_table (const struct sys_reg_desc *table, unsigned int n, bool is_32)
 
int kvm_handle_cp14_load_store (struct kvm_vcpu *vcpu)
 
static void perform_access (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
 
static bool emulate_cp (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *table, size_t num)
 
static void unhandled_cp_access (struct kvm_vcpu *vcpu, struct sys_reg_params *params)
 
static int kvm_handle_cp_64 (struct kvm_vcpu *vcpu, const struct sys_reg_desc *global, size_t nr_global)
 
static bool emulate_sys_reg (struct kvm_vcpu *vcpu, struct sys_reg_params *params)
 
static bool kvm_esr_cp10_id_to_sys64 (u64 esr, struct sys_reg_params *params)
 
int kvm_handle_cp10_id (struct kvm_vcpu *vcpu)
 
static int kvm_emulate_cp15_id_reg (struct kvm_vcpu *vcpu, struct sys_reg_params *params)
 
static int kvm_handle_cp_32 (struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *global, size_t nr_global)
 
int kvm_handle_cp15_64 (struct kvm_vcpu *vcpu)
 
int kvm_handle_cp15_32 (struct kvm_vcpu *vcpu)
 
int kvm_handle_cp14_64 (struct kvm_vcpu *vcpu)
 
int kvm_handle_cp14_32 (struct kvm_vcpu *vcpu)
 
static bool is_imp_def_sys_reg (struct sys_reg_params *params)
 
static void kvm_reset_id_regs (struct kvm_vcpu *vcpu)
 
void kvm_reset_sys_regs (struct kvm_vcpu *vcpu)
 
int kvm_handle_sys_reg (struct kvm_vcpu *vcpu)
 
static bool index_to_params (u64 id, struct sys_reg_params *params)
 
const struct sys_reg_descget_reg_by_id (u64 id, const struct sys_reg_desc table[], unsigned int num)
 
static const struct sys_reg_descid_to_sys_reg_desc (struct kvm_vcpu *vcpu, u64 id, const struct sys_reg_desc table[], unsigned int num)
 
static u64 get_ctr_el0 (struct kvm_vcpu *v, const struct sys_reg_desc *r)
 
static int get_invariant_sys_reg (u64 id, u64 __user *uaddr)
 
static int set_invariant_sys_reg (u64 id, u64 __user *uaddr)
 
static int demux_c15_get (struct kvm_vcpu *vcpu, u64 id, void __user *uaddr)
 
static int demux_c15_set (struct kvm_vcpu *vcpu, u64 id, void __user *uaddr)
 
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)
 
int kvm_arm_sys_reg_get_reg (struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
 
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)
 
int kvm_arm_sys_reg_set_reg (struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
 
static unsigned int num_demux_regs (void)
 
static int write_demux_regids (u64 __user *uindices)
 
static bool copy_reg_to_user (const struct sys_reg_desc *reg, u64 __user **uind)
 
static int walk_one_sys_reg (const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 __user **uind, unsigned int *total)
 
static int walk_sys_regs (struct kvm_vcpu *vcpu, u64 __user *uind)
 
unsigned long kvm_arm_num_sys_reg_descs (struct kvm_vcpu *vcpu)
 
int kvm_arm_copy_sys_reg_indices (struct kvm_vcpu *vcpu, u64 __user *uindices)
 
static bool is_feature_id_reg (u32 encoding)
 
int kvm_vm_ioctl_get_reg_writable_masks (struct kvm *kvm, struct reg_mask_range *range)
 
int __init kvm_sys_reg_table_init (void)
 

Variables

static const struct sys_reg_desc sys_reg_descs []
 
static const struct sys_reg_descfirst_idreg
 
static const struct sys_reg_desc cp14_regs []
 
static const struct sys_reg_desc cp14_64_regs []
 
static const struct sys_reg_desc cp15_regs []
 
static const struct sys_reg_desc cp15_64_regs []
 
static struct sys_reg_desc invariant_sys_regs[] __ro_after_init
 

Macro Definition Documentation

◆ __PTRAUTH_KEY

#define __PTRAUTH_KEY (   k)
Value:
{ SYS_DESC(SYS_## k), undef_access, reset_unknown, k, \
.visibility = ptrauth_visibility}
static bool undef_access(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:1334
static unsigned int ptrauth_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:1348
#define SYS_DESC(reg)
Definition: sys_regs.h:243
static u64 reset_unknown(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.h:136

Definition at line 1360 of file sys_regs.c.

◆ AA32_ID_SANITISED

#define AA32_ID_SANITISED (   name)
Value:
{ \
ID_DESC(name), \
.set_user = set_id_reg, \
.visibility = aa32_id_visibility, \
.val = 0, \
}
static unsigned int aa32_id_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1604
static u64 kvm_read_sanitised_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1560
static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:1815

Definition at line 2096 of file sys_regs.c.

◆ AMU_AMEVCNTR0_EL0

#define AMU_AMEVCNTR0_EL0 (   n)    { SYS_DESC(SYS_AMEVCNTR0_EL0(n)), undef_access }

Definition at line 1343 of file sys_regs.c.

◆ AMU_AMEVCNTR1_EL0

#define AMU_AMEVCNTR1_EL0 (   n)    { SYS_DESC(SYS_AMEVCNTR1_EL0(n)), undef_access }

Definition at line 1345 of file sys_regs.c.

◆ AMU_AMEVTYPER0_EL0

#define AMU_AMEVTYPER0_EL0 (   n)    { SYS_DESC(SYS_AMEVTYPER0_EL0(n)), undef_access }

Definition at line 1344 of file sys_regs.c.

◆ AMU_AMEVTYPER1_EL0

#define AMU_AMEVTYPER1_EL0 (   n)    { SYS_DESC(SYS_AMEVTYPER1_EL0(n)), undef_access }

Definition at line 1346 of file sys_regs.c.

◆ CP15_PMU_SYS_REG

#define CP15_PMU_SYS_REG (   _map,
  _Op1,
  _CRn,
  _CRm,
  _Op2 
)
Value:
AA32(_map), \
Op1(_Op1), CRn(_CRn), CRm(_CRm), Op2(_Op2), \
.visibility = pmu_visibility
static unsigned int pmu_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:837
#define CRm(_x)
Definition: sys_regs.h:240
#define Op2(_x)
Definition: sys_regs.h:241
#define AA32(_x)
Definition: sys_regs.h:236
#define CRn(_x)
Definition: sys_regs.h:239

Definition at line 2872 of file sys_regs.c.

◆ CSSELR_MAX

#define CSSELR_MAX   14

Definition at line 215 of file sys_regs.c.

◆ DBG_BCR_BVR_WCR_WVR

#define DBG_BCR_BVR_WCR_WVR (   n)
Value:
/* DBGBVRn */ \
{ AA32(LO), Op1( 0), CRn( 0), CRm((n)), Op2( 4), trap_bvr, NULL, n }, \
/* DBGBCRn */ \
{ Op1( 0), CRn( 0), CRm((n)), Op2( 5), trap_bcr, NULL, n }, \
/* DBGWVRn */ \
{ Op1( 0), CRn( 0), CRm((n)), Op2( 6), trap_wvr, NULL, n }, \
/* DBGWCRn */ \
{ Op1( 0), CRn( 0), CRm((n)), Op2( 7), trap_wcr, NULL, n }
static bool trap_bcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
Definition: sys_regs.c:691
static bool trap_bvr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
Definition: sys_regs.c:654
static bool trap_wcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
Definition: sys_regs.c:766
static bool trap_wvr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd)
Definition: sys_regs.c:728
#define Op1(_x)
Definition: sys_regs.h:238

Definition at line 2761 of file sys_regs.c.

◆ DBG_BCR_BVR_WCR_WVR_EL1

#define DBG_BCR_BVR_WCR_WVR_EL1 (   n)
Value:
{ SYS_DESC(SYS_DBGBVRn_EL1(n)), \
trap_bvr, reset_bvr, 0, 0, get_bvr, set_bvr }, \
{ SYS_DESC(SYS_DBGBCRn_EL1(n)), \
trap_bcr, reset_bcr, 0, 0, get_bcr, set_bcr }, \
{ SYS_DESC(SYS_DBGWVRn_EL1(n)), \
trap_wvr, reset_wvr, 0, 0, get_wvr, set_wvr }, \
{ SYS_DESC(SYS_DBGWCRn_EL1(n)), \
trap_wcr, reset_wcr, 0, 0, get_wcr, set_wcr }
static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:782
static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.c:789
static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.c:677
static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.c:714
static u64 reset_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:759
static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:670
static u64 reset_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:721
static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.c:752
static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:707
static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:745
static u64 reset_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:684
static u64 reset_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:796

Definition at line 1308 of file sys_regs.c.

◆ DBGBXVR

#define DBGBXVR (   n)     { AA32(HI), Op1( 0), CRn( 1), CRm((n)), Op2( 1), trap_bvr, NULL, n }

Definition at line 2771 of file sys_regs.c.

◆ EL12_REG

#define EL12_REG (   name,
  acc,
  rst,
 
)
Value:
{ \
SYS_DESC(SYS_##name##_EL12), \
.access = acc, \
.reset = rst, \
.reg = name##_EL1, \
.val = v, \
.visibility = hidden_user_visibility, \
}
static unsigned int hidden_user_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:2055

Definition at line 2061 of file sys_regs.c.

◆ EL2_REG

#define EL2_REG (   name,
  acc,
  rst,
 
)
Value:
{ \
SYS_DESC(SYS_##name), \
.access = acc, \
.reset = rst, \
.reg = name, \
.visibility = el2_visibility, \
.val = v, \
}
static unsigned int el2_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:2003

Definition at line 2038 of file sys_regs.c.

◆ EL2_REG_REDIR

#define EL2_REG_REDIR (   name,
  rst,
 
)    EL2_REG(name, bad_redir_trap, rst, v)

Definition at line 2048 of file sys_regs.c.

◆ EL2_REG_VNCR

#define EL2_REG_VNCR (   name,
  rst,
 
)    EL2_REG(name, bad_vncr_trap, rst, v)

Definition at line 2047 of file sys_regs.c.

◆ FUNCTION_INVARIANT

#define FUNCTION_INVARIANT (   reg)
Value:
static u64 get_##reg(struct kvm_vcpu *v, \
const struct sys_reg_desc *r) \
{ \
((struct sys_reg_desc *)r)->val = read_sysreg(reg); \
return ((struct sys_reg_desc *)r)->val; \
}

Definition at line 3569 of file sys_regs.c.

◆ ID_DESC

#define ID_DESC (   name)
Value:
SYS_DESC(SYS_##name), \
.access = access_id_reg, \
.get_user = get_id_reg \
static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.c:1796
static bool access_id_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:1626

Definition at line 2081 of file sys_regs.c.

◆ ID_HIDDEN

#define ID_HIDDEN (   name)
Value:
{ \
ID_DESC(name), \
.set_user = set_id_reg, \
.visibility = raz_visibility, \
.val = 0, \
}
static unsigned int raz_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1618

Definition at line 2133 of file sys_regs.c.

◆ ID_REG_LIMIT_FIELD_ENUM

#define ID_REG_LIMIT_FIELD_ENUM (   val,
  reg,
  field,
  limit 
)
Value:
({ \
u64 __f_val = FIELD_GET(reg##_##field##_MASK, val); \
(val) &= ~reg##_##field##_MASK; \
(val) |= FIELD_PREP(reg##_##field##_MASK, \
min(__f_val, (u64)reg##_##field##_##limit)); \
(val); \
})

Definition at line 1683 of file sys_regs.c.

◆ ID_SANITISED

#define ID_SANITISED (   name)
Value:
{ \
ID_DESC(name), \
.set_user = set_id_reg, \
.visibility = id_visibility, \
.val = 0, \
}
static unsigned int id_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1589

Definition at line 2087 of file sys_regs.c.

◆ ID_UNALLOCATED

#define ID_UNALLOCATED (   crm,
  op2 
)
Value:
{ \
Op0(3), Op1(0), CRn(0), CRm(crm), Op2(op2), \
.access = access_id_reg, \
.get_user = get_id_reg, \
.set_user = set_id_reg, \
.visibility = raz_visibility, \
.val = 0, \
}

Definition at line 2118 of file sys_regs.c.

◆ ID_WRITABLE

#define ID_WRITABLE (   name,
  mask 
)
Value:
{ \
ID_DESC(name), \
.set_user = set_id_reg, \
.visibility = id_visibility, \
.val = mask, \
}

Definition at line 2105 of file sys_regs.c.

◆ KVM_ARM_FEATURE_ID_RANGE_INDEX

#define KVM_ARM_FEATURE_ID_RANGE_INDEX (   r)
Value:
KVM_ARM_FEATURE_ID_RANGE_IDX(sys_reg_Op0(r), \
sys_reg_Op1(r), \
sys_reg_CRn(r), \
sys_reg_CRm(r), \
sys_reg_Op2(r))

Definition at line 3874 of file sys_regs.c.

◆ MAPPED_EL2_SYSREG

#define MAPPED_EL2_SYSREG (   el2,
  el1,
  fn 
)
Value:
case el2: { \
*xlate = fn; \
*el1r = el1; \
return true; \
}

Definition at line 81 of file sys_regs.c.

◆ MTE_REG

#define MTE_REG (   name)
Value:
{ \
SYS_DESC(SYS_##name), \
.access = undef_access, \
.reset = reset_unknown, \
.reg = name, \
.visibility = mte_visibility, \
}
static unsigned int mte_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd)
Definition: sys_regs.c:1986

Definition at line 1995 of file sys_regs.c.

◆ PMU_PMEVCNTR

#define PMU_PMEVCNTR (   n)
Value:
{ CP15_PMU_SYS_REG(DIRECT, 0, 0b1110, \
(0b1000 | (((n) >> 3) & 0x3)), ((n) & 0x7)), \
.access = access_pmu_evcntr }
static bool access_pmu_evcntr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:1031
#define CP15_PMU_SYS_REG(_map, _Op1, _CRn, _CRm, _Op2)
Definition: sys_regs.c:2872

Definition at line 2878 of file sys_regs.c.

◆ PMU_PMEVCNTR_EL0

#define PMU_PMEVCNTR_EL0 (   n)
Value:
{ PMU_SYS_REG(PMEVCNTRn_EL0(n)), \
.reset = reset_pmevcntr, .get_user = get_pmu_evcntr, \
.access = access_pmu_evcntr, .reg = (PMEVCNTR0_EL0 + n), }
static int get_pmu_evcntr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r, u64 *val)
Definition: sys_regs.c:1015
#define PMU_SYS_REG(name)
Definition: sys_regs.c:1318
static u64 reset_pmevcntr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:860

Definition at line 1323 of file sys_regs.c.

◆ PMU_PMEVTYPER

#define PMU_PMEVTYPER (   n)
Value:
{ CP15_PMU_SYS_REG(DIRECT, 0, 0b1110, \
(0b1100 | (((n) >> 3) & 0x3)), ((n) & 0x7)), \
.access = access_pmu_evtyper }
static bool access_pmu_evtyper(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:1084

Definition at line 2884 of file sys_regs.c.

◆ PMU_PMEVTYPER_EL0

#define PMU_PMEVTYPER_EL0 (   n)
Value:
{ PMU_SYS_REG(PMEVTYPERn_EL0(n)), \
.reset = reset_pmevtyper, \
.access = access_pmu_evtyper, .reg = (PMEVTYPER0_EL0 + n), }
static u64 reset_pmevtyper(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:868

Definition at line 1329 of file sys_regs.c.

◆ PMU_SYS_REG

#define PMU_SYS_REG (   name)
Value:
SYS_DESC(SYS_##name), .reset = reset_pmu_reg, \
.visibility = pmu_visibility
static u64 reset_pmu_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:846

Definition at line 1318 of file sys_regs.c.

◆ PTRAUTH_KEY

#define PTRAUTH_KEY (   k)
Value:
__PTRAUTH_KEY(k ## KEYLO_EL1), \
__PTRAUTH_KEY(k ## KEYHI_EL1)
#define __PTRAUTH_KEY(k)
Definition: sys_regs.c:1360

Definition at line 1364 of file sys_regs.c.

◆ PURE_EL2_SYSREG

#define PURE_EL2_SYSREG (   el2)
Value:
case el2: { \
*el1r = el2; \
return true; \
}

Definition at line 75 of file sys_regs.c.

Function Documentation

◆ __kvm_read_sanitised_id_reg()

static u64 __kvm_read_sanitised_id_reg ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1517 of file sys_regs.c.

1519 {
1520  u32 id = reg_to_encoding(r);
1521  u64 val;
1522 
1523  if (sysreg_visible_as_raz(vcpu, r))
1524  return 0;
1525 
1526  val = read_sanitised_ftr_reg(id);
1527 
1528  switch (id) {
1529  case SYS_ID_AA64PFR1_EL1:
1530  if (!kvm_has_mte(vcpu->kvm))
1531  val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MTE);
1532 
1533  val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_SME);
1534  break;
1535  case SYS_ID_AA64ISAR1_EL1:
1536  if (!vcpu_has_ptrauth(vcpu))
1537  val &= ~(ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_APA) |
1538  ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_API) |
1539  ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_GPA) |
1540  ARM64_FEATURE_MASK(ID_AA64ISAR1_EL1_GPI));
1541  break;
1542  case SYS_ID_AA64ISAR2_EL1:
1543  if (!vcpu_has_ptrauth(vcpu))
1544  val &= ~(ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_APA3) |
1545  ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_GPA3));
1546  if (!cpus_have_final_cap(ARM64_HAS_WFXT))
1547  val &= ~ARM64_FEATURE_MASK(ID_AA64ISAR2_EL1_WFxT);
1548  break;
1549  case SYS_ID_AA64MMFR2_EL1:
1550  val &= ~ID_AA64MMFR2_EL1_CCIDX_MASK;
1551  break;
1552  case SYS_ID_MMFR4_EL1:
1553  val &= ~ARM64_FEATURE_MASK(ID_MMFR4_EL1_CCIDX);
1554  break;
1555  }
1556 
1557  return val;
1558 }
#define reg_to_encoding(x)
Definition: sys_regs.h:16
static bool sysreg_visible_as_raz(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.h:177
Here is the call graph for this function:
Here is the caller graph for this function:

◆ aa32_id_visibility()

static unsigned int aa32_id_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1604 of file sys_regs.c.

1606 {
1607  /*
1608  * AArch32 ID registers are UNKNOWN if AArch32 isn't implemented at any
1609  * EL. Promote to RAZ/WI in order to guarantee consistency between
1610  * systems.
1611  */
1612  if (!kvm_supports_32bit_el0())
1613  return REG_RAZ | REG_USER_WI;
1614 
1615  return id_visibility(vcpu, r);
1616 }
#define REG_RAZ
Definition: sys_regs.h:99
#define REG_USER_WI
Definition: sys_regs.h:100
Here is the call graph for this function:

◆ access_actlr()

static bool access_actlr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 403 of file sys_regs.c.

406 {
407  u64 mask, shift;
408 
409  if (p->is_write)
410  return ignore_write(vcpu, p);
411 
412  get_access_mask(r, &mask, &shift);
413  p->regval = (vcpu_read_sys_reg(vcpu, r->reg) & mask) >> shift;
414 
415  return true;
416 }
bool is_write
Definition: sys_regs.h:27
u64 vcpu_read_sys_reg(const struct kvm_vcpu *vcpu, int reg)
Definition: sys_regs.c:128
static void get_access_mask(const struct sys_reg_desc *r, u64 *mask, u64 *shift)
Definition: sys_regs.c:355
static bool ignore_write(struct kvm_vcpu *vcpu, const struct sys_reg_params *p)
Definition: sys_regs.h:122
Here is the call graph for this function:

◆ access_arch_timer()

static bool access_arch_timer ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1368 of file sys_regs.c.

1371 {
1372  enum kvm_arch_timers tmr;
1373  enum kvm_arch_timer_regs treg;
1374  u64 reg = reg_to_encoding(r);
1375 
1376  switch (reg) {
1377  case SYS_CNTP_TVAL_EL0:
1378  case SYS_AARCH32_CNTP_TVAL:
1379  tmr = TIMER_PTIMER;
1380  treg = TIMER_REG_TVAL;
1381  break;
1382  case SYS_CNTP_CTL_EL0:
1383  case SYS_AARCH32_CNTP_CTL:
1384  tmr = TIMER_PTIMER;
1385  treg = TIMER_REG_CTL;
1386  break;
1387  case SYS_CNTP_CVAL_EL0:
1388  case SYS_AARCH32_CNTP_CVAL:
1389  tmr = TIMER_PTIMER;
1390  treg = TIMER_REG_CVAL;
1391  break;
1392  case SYS_CNTPCT_EL0:
1393  case SYS_CNTPCTSS_EL0:
1394  case SYS_AARCH32_CNTPCT:
1395  tmr = TIMER_PTIMER;
1396  treg = TIMER_REG_CNT;
1397  break;
1398  default:
1399  print_sys_reg_msg(p, "%s", "Unhandled trapped timer register");
1400  kvm_inject_undefined(vcpu);
1401  return false;
1402  }
1403 
1404  if (p->is_write)
1405  kvm_arm_timer_write_sysreg(vcpu, tmr, treg, p->regval);
1406  else
1407  p->regval = kvm_arm_timer_read_sysreg(vcpu, tmr, treg);
1408 
1409  return true;
1410 }
void kvm_arm_timer_write_sysreg(struct kvm_vcpu *vcpu, enum kvm_arch_timers tmr, enum kvm_arch_timer_regs treg, u64 val)
Definition: arch_timer.c:1219
u64 kvm_arm_timer_read_sysreg(struct kvm_vcpu *vcpu, enum kvm_arch_timers tmr, enum kvm_arch_timer_regs treg)
Definition: arch_timer.c:1167
kvm_arch_timers
@ TIMER_PTIMER
kvm_arch_timer_regs
@ TIMER_REG_CTL
@ TIMER_REG_TVAL
@ TIMER_REG_CNT
@ TIMER_REG_CVAL
void kvm_inject_undefined(struct kvm_vcpu *vcpu)
Definition: inject_fault.c:225
Here is the call graph for this function:

◆ access_ccsidr()

static bool access_ccsidr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1970 of file sys_regs.c.

1972 {
1973  u32 csselr;
1974 
1975  if (p->is_write)
1976  return write_to_read_only(vcpu, p, r);
1977 
1978  csselr = vcpu_read_sys_reg(vcpu, CSSELR_EL1);
1979  csselr &= CSSELR_EL1_Level | CSSELR_EL1_InD;
1980  if (csselr < CSSELR_MAX)
1981  p->regval = get_ccsidr(vcpu, csselr);
1982 
1983  return true;
1984 }
static u32 get_ccsidr(struct kvm_vcpu *vcpu, u32 csselr)
Definition: sys_regs.c:243
#define CSSELR_MAX
Definition: sys_regs.c:215
static bool write_to_read_only(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
Definition: sys_regs.c:67
Here is the call graph for this function:

◆ access_clidr()

static bool access_clidr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1878 of file sys_regs.c.

1880 {
1881  if (p->is_write)
1882  return write_to_read_only(vcpu, p, r);
1883 
1884  p->regval = __vcpu_sys_reg(vcpu, r->reg);
1885  return true;
1886 }
Here is the call graph for this function:

◆ access_csselr()

static bool access_csselr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1958 of file sys_regs.c.

1960 {
1961  int reg = r->reg;
1962 
1963  if (p->is_write)
1964  vcpu_write_sys_reg(vcpu, p->regval, reg);
1965  else
1966  p->regval = vcpu_read_sys_reg(vcpu, reg);
1967  return true;
1968 }
void vcpu_write_sys_reg(struct kvm_vcpu *vcpu, u64 val, int reg)
Definition: sys_regs.c:172
Here is the call graph for this function:

◆ access_ctr()

static bool access_ctr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1868 of file sys_regs.c.

1870 {
1871  if (p->is_write)
1872  return write_to_read_only(vcpu, p, r);
1873 
1874  p->regval = read_sanitised_ftr_reg(SYS_CTR_EL0);
1875  return true;
1876 }
Here is the call graph for this function:

◆ access_dcgsw()

static bool access_dcgsw ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 342 of file sys_regs.c.

345 {
346  if (!kvm_has_mte(vcpu->kvm)) {
347  kvm_inject_undefined(vcpu);
348  return false;
349  }
350 
351  /* Treat MTE S/W ops as we treat the classic ones: with contempt */
352  return access_dcsw(vcpu, p, r);
353 }
static bool access_dcsw(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:322
Here is the call graph for this function:

◆ access_dcsw()

static bool access_dcsw ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 322 of file sys_regs.c.

325 {
326  if (!p->is_write)
327  return read_from_write_only(vcpu, p, r);
328 
329  /*
330  * Only track S/W ops if we don't have FWB. It still indicates
331  * that the guest is a bit broken (S/W operations should only
332  * be done by firmware, knowing that there is only a single
333  * CPU left in the system, and certainly not from non-secure
334  * software).
335  */
336  if (!cpus_have_final_cap(ARM64_HAS_STAGE2_FWB))
337  kvm_set_way_flush(vcpu);
338 
339  return true;
340 }
void kvm_set_way_flush(struct kvm_vcpu *vcpu)
Definition: mmu.c:2102
static bool read_from_write_only(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
Definition: sys_regs.c:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ access_elr()

static bool access_elr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2153 of file sys_regs.c.

2156 {
2157  if (p->is_write)
2158  vcpu_write_sys_reg(vcpu, p->regval, ELR_EL1);
2159  else
2160  p->regval = vcpu_read_sys_reg(vcpu, ELR_EL1);
2161 
2162  return true;
2163 }
Here is the call graph for this function:

◆ access_gic_sgi()

static bool access_gic_sgi ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 424 of file sys_regs.c.

427 {
428  bool g1;
429 
430  if (!p->is_write)
431  return read_from_write_only(vcpu, p, r);
432 
433  /*
434  * In a system where GICD_CTLR.DS=1, a ICC_SGI0R_EL1 access generates
435  * Group0 SGIs only, while ICC_SGI1R_EL1 can generate either group,
436  * depending on the SGI configuration. ICC_ASGI1R_EL1 is effectively
437  * equivalent to ICC_SGI0R_EL1, as there is no "alternative" secure
438  * group.
439  */
440  if (p->Op0 == 0) { /* AArch32 */
441  switch (p->Op1) {
442  default: /* Keep GCC quiet */
443  case 0: /* ICC_SGI1R */
444  g1 = true;
445  break;
446  case 1: /* ICC_ASGI1R */
447  case 2: /* ICC_SGI0R */
448  g1 = false;
449  break;
450  }
451  } else { /* AArch64 */
452  switch (p->Op2) {
453  default: /* Keep GCC quiet */
454  case 5: /* ICC_SGI1R_EL1 */
455  g1 = true;
456  break;
457  case 6: /* ICC_ASGI1R_EL1 */
458  case 7: /* ICC_SGI0R_EL1 */
459  g1 = false;
460  break;
461  }
462  }
463 
464  vgic_v3_dispatch_sgi(vcpu, p->regval, g1);
465 
466  return true;
467 }
void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1)
Here is the call graph for this function:

◆ access_gic_sre()

static bool access_gic_sre ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 469 of file sys_regs.c.

472 {
473  if (p->is_write)
474  return ignore_write(vcpu, p);
475 
476  p->regval = vcpu->arch.vgic_cpu.vgic_v3.vgic_sre;
477  return true;
478 }
Here is the call graph for this function:

◆ access_id_reg()

static bool access_id_reg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1626 of file sys_regs.c.

1629 {
1630  if (p->is_write)
1631  return write_to_read_only(vcpu, p, r);
1632 
1633  p->regval = read_id_reg(vcpu, r);
1634 
1635  return true;
1636 }
static u64 read_id_reg(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1566
Here is the call graph for this function:

◆ access_pmceid()

static bool access_pmceid ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 980 of file sys_regs.c.

982 {
983  u64 pmceid, mask, shift;
984 
985  BUG_ON(p->is_write);
986 
987  if (pmu_access_el0_disabled(vcpu))
988  return false;
989 
990  get_access_mask(r, &mask, &shift);
991 
992  pmceid = kvm_pmu_get_pmceid(vcpu, (p->Op2 & 1));
993  pmceid &= mask;
994  pmceid >>= shift;
995 
996  p->regval = pmceid;
997 
998  return true;
999 }
u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1)
Definition: pmu-emul.c:760
static bool pmu_access_el0_disabled(struct kvm_vcpu *vcpu)
Definition: sys_regs.c:915
Here is the call graph for this function:

◆ access_pmcnten()

static bool access_pmcnten ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1153 of file sys_regs.c.

1155 {
1156  u64 val, mask;
1157 
1158  if (pmu_access_el0_disabled(vcpu))
1159  return false;
1160 
1161  mask = kvm_pmu_valid_counter_mask(vcpu);
1162  if (p->is_write) {
1163  val = p->regval & mask;
1164  if (r->Op2 & 0x1) {
1165  /* accessing PMCNTENSET_EL0 */
1166  __vcpu_sys_reg(vcpu, PMCNTENSET_EL0) |= val;
1167  kvm_pmu_enable_counter_mask(vcpu, val);
1169  } else {
1170  /* accessing PMCNTENCLR_EL0 */
1171  __vcpu_sys_reg(vcpu, PMCNTENSET_EL0) &= ~val;
1172  kvm_pmu_disable_counter_mask(vcpu, val);
1173  }
1174  } else {
1175  p->regval = __vcpu_sys_reg(vcpu, PMCNTENSET_EL0);
1176  }
1177 
1178  return true;
1179 }
u64 kvm_pmu_valid_counter_mask(struct kvm_vcpu *vcpu)
Definition: pmu-emul.c:268
void kvm_pmu_disable_counter_mask(struct kvm_vcpu *vcpu, u64 val)
Definition: pmu-emul.c:319
void kvm_pmu_enable_counter_mask(struct kvm_vcpu *vcpu, u64 val)
Definition: pmu-emul.c:285
void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu)
Definition: pmu.c:176
Here is the call graph for this function:

◆ access_pmcr()

static bool access_pmcr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 935 of file sys_regs.c.

937 {
938  u64 val;
939 
940  if (pmu_access_el0_disabled(vcpu))
941  return false;
942 
943  if (p->is_write) {
944  /*
945  * Only update writeable bits of PMCR (continuing into
946  * kvm_pmu_handle_pmcr() as well)
947  */
948  val = kvm_vcpu_read_pmcr(vcpu);
949  val &= ~ARMV8_PMU_PMCR_MASK;
950  val |= p->regval & ARMV8_PMU_PMCR_MASK;
951  if (!kvm_supports_32bit_el0())
952  val |= ARMV8_PMU_PMCR_LC;
953  kvm_pmu_handle_pmcr(vcpu, val);
954  } else {
955  /* PMCR.P & PMCR.C are RAZ */
956  val = kvm_vcpu_read_pmcr(vcpu)
957  & ~(ARMV8_PMU_PMCR_P | ARMV8_PMU_PMCR_C);
958  p->regval = val;
959  }
960 
961  return true;
962 }
void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
Definition: pmu-emul.c:551
u64 kvm_vcpu_read_pmcr(struct kvm_vcpu *vcpu)
Definition: pmu-emul.c:1136
Here is the call graph for this function:

◆ access_pminten()

static bool access_pminten ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1181 of file sys_regs.c.

1183 {
1184  u64 mask = kvm_pmu_valid_counter_mask(vcpu);
1185 
1186  if (check_pmu_access_disabled(vcpu, 0))
1187  return false;
1188 
1189  if (p->is_write) {
1190  u64 val = p->regval & mask;
1191 
1192  if (r->Op2 & 0x1)
1193  /* accessing PMINTENSET_EL1 */
1194  __vcpu_sys_reg(vcpu, PMINTENSET_EL1) |= val;
1195  else
1196  /* accessing PMINTENCLR_EL1 */
1197  __vcpu_sys_reg(vcpu, PMINTENSET_EL1) &= ~val;
1198  } else {
1199  p->regval = __vcpu_sys_reg(vcpu, PMINTENSET_EL1);
1200  }
1201 
1202  return true;
1203 }
static bool check_pmu_access_disabled(struct kvm_vcpu *vcpu, u64 flags)
Definition: sys_regs.c:904
Here is the call graph for this function:

◆ access_pmovs()

static bool access_pmovs ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1205 of file sys_regs.c.

1207 {
1208  u64 mask = kvm_pmu_valid_counter_mask(vcpu);
1209 
1210  if (pmu_access_el0_disabled(vcpu))
1211  return false;
1212 
1213  if (p->is_write) {
1214  if (r->CRm & 0x2)
1215  /* accessing PMOVSSET_EL0 */
1216  __vcpu_sys_reg(vcpu, PMOVSSET_EL0) |= (p->regval & mask);
1217  else
1218  /* accessing PMOVSCLR_EL0 */
1219  __vcpu_sys_reg(vcpu, PMOVSSET_EL0) &= ~(p->regval & mask);
1220  } else {
1221  p->regval = __vcpu_sys_reg(vcpu, PMOVSSET_EL0);
1222  }
1223 
1224  return true;
1225 }
Here is the call graph for this function:

◆ access_pmselr()

static bool access_pmselr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 964 of file sys_regs.c.

966 {
968  return false;
969 
970  if (p->is_write)
971  __vcpu_sys_reg(vcpu, PMSELR_EL0) = p->regval;
972  else
973  /* return PMSELR.SEL field */
974  p->regval = __vcpu_sys_reg(vcpu, PMSELR_EL0)
975  & ARMV8_PMU_COUNTER_MASK;
976 
977  return true;
978 }
static bool pmu_access_event_counter_el0_disabled(struct kvm_vcpu *vcpu)
Definition: sys_regs.c:930
Here is the call graph for this function:

◆ access_pmswinc()

static bool access_pmswinc ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1227 of file sys_regs.c.

1229 {
1230  u64 mask;
1231 
1232  if (!p->is_write)
1233  return read_from_write_only(vcpu, p, r);
1234 
1235  if (pmu_write_swinc_el0_disabled(vcpu))
1236  return false;
1237 
1238  mask = kvm_pmu_valid_counter_mask(vcpu);
1239  kvm_pmu_software_increment(vcpu, p->regval & mask);
1240  return true;
1241 }
void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val)
Definition: pmu-emul.c:541
static bool pmu_write_swinc_el0_disabled(struct kvm_vcpu *vcpu)
Definition: sys_regs.c:920
Here is the call graph for this function:

◆ access_pmu_evcntr()

static bool access_pmu_evcntr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1031 of file sys_regs.c.

1034 {
1035  u64 idx = ~0UL;
1036 
1037  if (r->CRn == 9 && r->CRm == 13) {
1038  if (r->Op2 == 2) {
1039  /* PMXEVCNTR_EL0 */
1041  return false;
1042 
1043  idx = __vcpu_sys_reg(vcpu, PMSELR_EL0)
1044  & ARMV8_PMU_COUNTER_MASK;
1045  } else if (r->Op2 == 0) {
1046  /* PMCCNTR_EL0 */
1048  return false;
1049 
1050  idx = ARMV8_PMU_CYCLE_IDX;
1051  }
1052  } else if (r->CRn == 0 && r->CRm == 9) {
1053  /* PMCCNTR */
1055  return false;
1056 
1057  idx = ARMV8_PMU_CYCLE_IDX;
1058  } else if (r->CRn == 14 && (r->CRm & 12) == 8) {
1059  /* PMEVCNTRn_EL0 */
1061  return false;
1062 
1063  idx = ((r->CRm & 3) << 3) | (r->Op2 & 7);
1064  }
1065 
1066  /* Catch any decoding mistake */
1067  WARN_ON(idx == ~0UL);
1068 
1069  if (!pmu_counter_idx_valid(vcpu, idx))
1070  return false;
1071 
1072  if (p->is_write) {
1073  if (pmu_access_el0_disabled(vcpu))
1074  return false;
1075 
1076  kvm_pmu_set_counter_value(vcpu, idx, p->regval);
1077  } else {
1078  p->regval = kvm_pmu_get_counter_value(vcpu, idx);
1079  }
1080 
1081  return true;
1082 }
#define ARMV8_PMU_CYCLE_IDX
Definition: arm_pmu.h:13
u64 kvm_pmu_get_counter_value(struct kvm_vcpu *vcpu, u64 select_idx)
Definition: pmu-emul.c:141
void kvm_pmu_set_counter_value(struct kvm_vcpu *vcpu, u64 select_idx, u64 val)
Definition: pmu-emul.c:182
static bool pmu_access_cycle_counter_el0_disabled(struct kvm_vcpu *vcpu)
Definition: sys_regs.c:925
static bool pmu_counter_idx_valid(struct kvm_vcpu *vcpu, u64 idx)
Definition: sys_regs.c:1001
Here is the call graph for this function:

◆ access_pmu_evtyper()

static bool access_pmu_evtyper ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1084 of file sys_regs.c.

1086 {
1087  u64 idx, reg;
1088 
1089  if (pmu_access_el0_disabled(vcpu))
1090  return false;
1091 
1092  if (r->CRn == 9 && r->CRm == 13 && r->Op2 == 1) {
1093  /* PMXEVTYPER_EL0 */
1094  idx = __vcpu_sys_reg(vcpu, PMSELR_EL0) & ARMV8_PMU_COUNTER_MASK;
1095  reg = PMEVTYPER0_EL0 + idx;
1096  } else if (r->CRn == 14 && (r->CRm & 12) == 12) {
1097  idx = ((r->CRm & 3) << 3) | (r->Op2 & 7);
1098  if (idx == ARMV8_PMU_CYCLE_IDX)
1099  reg = PMCCFILTR_EL0;
1100  else
1101  /* PMEVTYPERn_EL0 */
1102  reg = PMEVTYPER0_EL0 + idx;
1103  } else {
1104  BUG();
1105  }
1106 
1107  if (!pmu_counter_idx_valid(vcpu, idx))
1108  return false;
1109 
1110  if (p->is_write) {
1111  kvm_pmu_set_counter_event_type(vcpu, p->regval, idx);
1113  } else {
1114  p->regval = __vcpu_sys_reg(vcpu, reg);
1115  }
1116 
1117  return true;
1118 }
void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data, u64 select_idx)
Definition: pmu-emul.c:678
Here is the call graph for this function:

◆ access_pmuserenr()

static bool access_pmuserenr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1243 of file sys_regs.c.

1245 {
1246  if (p->is_write) {
1247  if (!vcpu_mode_priv(vcpu)) {
1248  kvm_inject_undefined(vcpu);
1249  return false;
1250  }
1251 
1252  __vcpu_sys_reg(vcpu, PMUSERENR_EL0) =
1253  p->regval & ARMV8_PMU_USERENR_MASK;
1254  } else {
1255  p->regval = __vcpu_sys_reg(vcpu, PMUSERENR_EL0)
1256  & ARMV8_PMU_USERENR_MASK;
1257  }
1258 
1259  return true;
1260 }
Here is the call graph for this function:

◆ access_rw()

static bool access_rw ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 307 of file sys_regs.c.

310 {
311  if (p->is_write)
312  vcpu_write_sys_reg(vcpu, p->regval, r->reg);
313  else
314  p->regval = vcpu_read_sys_reg(vcpu, r->reg);
315 
316  return true;
317 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ access_sp_el1()

static bool access_sp_el1 ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2141 of file sys_regs.c.

2144 {
2145  if (p->is_write)
2146  __vcpu_sys_reg(vcpu, SP_EL1) = p->regval;
2147  else
2148  p->regval = __vcpu_sys_reg(vcpu, SP_EL1);
2149 
2150  return true;
2151 }

◆ access_spsr()

static bool access_spsr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2165 of file sys_regs.c.

2168 {
2169  if (p->is_write)
2170  __vcpu_sys_reg(vcpu, SPSR_EL1) = p->regval;
2171  else
2172  p->regval = __vcpu_sys_reg(vcpu, SPSR_EL1);
2173 
2174  return true;
2175 }

◆ access_vm_reg()

static bool access_vm_reg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 378 of file sys_regs.c.

381 {
382  bool was_enabled = vcpu_has_cache_enabled(vcpu);
383  u64 val, mask, shift;
384 
385  BUG_ON(!p->is_write);
386 
387  get_access_mask(r, &mask, &shift);
388 
389  if (~mask) {
390  val = vcpu_read_sys_reg(vcpu, r->reg);
391  val &= ~mask;
392  } else {
393  val = 0;
394  }
395 
396  val |= (p->regval & (mask >> shift)) << shift;
397  vcpu_write_sys_reg(vcpu, val, r->reg);
398 
399  kvm_toggle_cache(vcpu, was_enabled);
400  return true;
401 }
void kvm_toggle_cache(struct kvm_vcpu *vcpu, bool was_enabled)
Definition: mmu.c:2123
Here is the call graph for this function:

◆ arm64_check_features()

static int arm64_check_features ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1450 of file sys_regs.c.

1453 {
1454  const struct arm64_ftr_reg *ftr_reg;
1455  const struct arm64_ftr_bits *ftrp = NULL;
1456  u32 id = reg_to_encoding(rd);
1457  u64 writable_mask = rd->val;
1458  u64 limit = rd->reset(vcpu, rd);
1459  u64 mask = 0;
1460 
1461  /*
1462  * Hidden and unallocated ID registers may not have a corresponding
1463  * struct arm64_ftr_reg. Of course, if the register is RAZ we know the
1464  * only safe value is 0.
1465  */
1466  if (sysreg_visible_as_raz(vcpu, rd))
1467  return val ? -E2BIG : 0;
1468 
1469  ftr_reg = get_arm64_ftr_reg(id);
1470  if (!ftr_reg)
1471  return -EINVAL;
1472 
1473  ftrp = ftr_reg->ftr_bits;
1474 
1475  for (; ftrp && ftrp->width; ftrp++) {
1476  s64 f_val, f_lim, safe_val;
1477  u64 ftr_mask;
1478 
1479  ftr_mask = arm64_ftr_mask(ftrp);
1480  if ((ftr_mask & writable_mask) != ftr_mask)
1481  continue;
1482 
1483  f_val = arm64_ftr_value(ftrp, val);
1484  f_lim = arm64_ftr_value(ftrp, limit);
1485  mask |= ftr_mask;
1486 
1487  if (f_val == f_lim)
1488  safe_val = f_val;
1489  else
1490  safe_val = kvm_arm64_ftr_safe_value(id, ftrp, f_val, f_lim);
1491 
1492  if (safe_val != f_val)
1493  return -E2BIG;
1494  }
1495 
1496  /* For fields that are not writable, values in limit are the safe values. */
1497  if ((val & ~mask) != (limit & ~mask))
1498  return -E2BIG;
1499 
1500  return 0;
1501 }
u64(* reset)(struct kvm_vcpu *, const struct sys_reg_desc *)
Definition: sys_regs.h:78
static s64 kvm_arm64_ftr_safe_value(u32 id, const struct arm64_ftr_bits *ftrp, s64 new, s64 cur)
Definition: sys_regs.c:1412
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bad_redir_trap()

static bool bad_redir_trap ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2025 of file sys_regs.c.

2028 {
2029  /*
2030  * We really shouldn't be here, and this is likely the result
2031  * of a misconfigured trap, as this register should target the
2032  * corresponding EL1, and nothing else.
2033  */
2034  return bad_trap(vcpu, p, r,
2035  "trap of EL2 register redirected to EL1");
2036 }
static bool bad_trap(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r, const char *msg)
Definition: sys_regs.c:48
Here is the call graph for this function:

◆ bad_trap()

static bool bad_trap ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc r,
const char *  msg 
)
static

Definition at line 48 of file sys_regs.c.

52 {
53  WARN_ONCE(1, "Unexpected %s\n", msg);
54  print_sys_reg_instr(params);
56  return false;
57 }
static void print_sys_reg_instr(const struct sys_reg_params *p)
Definition: sys_regs.h:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bad_vncr_trap()

static bool bad_vncr_trap ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2012 of file sys_regs.c.

2015 {
2016  /*
2017  * We really shouldn't be here, and this is likely the result
2018  * of a misconfigured trap, as this register should target the
2019  * VNCR page, and nothing else.
2020  */
2021  return bad_trap(vcpu, p, r,
2022  "trap of VNCR-backed register");
2023 }
Here is the call graph for this function:

◆ check_pmu_access_disabled()

static bool check_pmu_access_disabled ( struct kvm_vcpu *  vcpu,
u64  flags 
)
static

Definition at line 904 of file sys_regs.c.

905 {
906  u64 reg = __vcpu_sys_reg(vcpu, PMUSERENR_EL0);
907  bool enabled = (reg & flags) || vcpu_mode_priv(vcpu);
908 
909  if (!enabled)
910  kvm_inject_undefined(vcpu);
911 
912  return !enabled;
913 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_sysreg_table()

static bool check_sysreg_table ( const struct sys_reg_desc table,
unsigned int  n,
bool  is_32 
)
static

Definition at line 3053 of file sys_regs.c.

3055 {
3056  unsigned int i;
3057 
3058  for (i = 0; i < n; i++) {
3059  if (!is_32 && table[i].reg && !table[i].reset) {
3060  kvm_err("sys_reg table %pS entry %d lacks reset\n", &table[i], i);
3061  return false;
3062  }
3063 
3064  if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
3065  kvm_err("sys_reg table %pS entry %d out of order\n", &table[i - 1], i - 1);
3066  return false;
3067  }
3068  }
3069 
3070  return true;
3071 }
static int cmp_sys_reg(const struct sys_reg_desc *i1, const struct sys_reg_desc *i2)
Definition: sys_regs.h:189
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_reg_to_user()

static bool copy_reg_to_user ( const struct sys_reg_desc reg,
u64 __user **  uind 
)
static

Definition at line 3795 of file sys_regs.c.

3796 {
3797  if (!*uind)
3798  return true;
3799 
3800  if (put_user(sys_reg_to_index(reg), *uind))
3801  return false;
3802 
3803  (*uind)++;
3804  return true;
3805 }
static u64 sys_reg_to_index(const struct sys_reg_desc *reg)
Definition: sys_regs.c:3784
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dbg_to_reg()

static void dbg_to_reg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd,
u64 *  dbg_reg 
)
static

Definition at line 643 of file sys_regs.c.

647 {
648  u64 mask, shift;
649 
650  get_access_mask(rd, &mask, &shift);
651  p->regval = (*dbg_reg & mask) >> shift;
652 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ demux_c15_get()

static int demux_c15_get ( struct kvm_vcpu *  vcpu,
u64  id,
void __user *  uaddr 
)
static

Definition at line 3627 of file sys_regs.c.

3628 {
3629  u32 val;
3630  u32 __user *uval = uaddr;
3631 
3632  /* Fail if we have unknown bits set. */
3633  if (id & ~(KVM_REG_ARCH_MASK|KVM_REG_SIZE_MASK|KVM_REG_ARM_COPROC_MASK
3634  | ((1 << KVM_REG_ARM_COPROC_SHIFT)-1)))
3635  return -ENOENT;
3636 
3637  switch (id & KVM_REG_ARM_DEMUX_ID_MASK) {
3638  case KVM_REG_ARM_DEMUX_ID_CCSIDR:
3639  if (KVM_REG_SIZE(id) != 4)
3640  return -ENOENT;
3641  val = (id & KVM_REG_ARM_DEMUX_VAL_MASK)
3642  >> KVM_REG_ARM_DEMUX_VAL_SHIFT;
3643  if (val >= CSSELR_MAX)
3644  return -ENOENT;
3645 
3646  return put_user(get_ccsidr(vcpu, val), uval);
3647  default:
3648  return -ENOENT;
3649  }
3650 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ demux_c15_set()

static int demux_c15_set ( struct kvm_vcpu *  vcpu,
u64  id,
void __user *  uaddr 
)
static

Definition at line 3652 of file sys_regs.c.

3653 {
3654  u32 val, newval;
3655  u32 __user *uval = uaddr;
3656 
3657  /* Fail if we have unknown bits set. */
3658  if (id & ~(KVM_REG_ARCH_MASK|KVM_REG_SIZE_MASK|KVM_REG_ARM_COPROC_MASK
3659  | ((1 << KVM_REG_ARM_COPROC_SHIFT)-1)))
3660  return -ENOENT;
3661 
3662  switch (id & KVM_REG_ARM_DEMUX_ID_MASK) {
3663  case KVM_REG_ARM_DEMUX_ID_CCSIDR:
3664  if (KVM_REG_SIZE(id) != 4)
3665  return -ENOENT;
3666  val = (id & KVM_REG_ARM_DEMUX_VAL_MASK)
3667  >> KVM_REG_ARM_DEMUX_VAL_SHIFT;
3668  if (val >= CSSELR_MAX)
3669  return -ENOENT;
3670 
3671  if (get_user(newval, uval))
3672  return -EFAULT;
3673 
3674  return set_ccsidr(vcpu, val, newval);
3675  default:
3676  return -ENOENT;
3677  }
3678 }
static int set_ccsidr(struct kvm_vcpu *vcpu, u32 csselr, u32 val)
Definition: sys_regs.c:278
Here is the call graph for this function:
Here is the caller graph for this function:

◆ el2_visibility()

static unsigned int el2_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 2003 of file sys_regs.c.

2005 {
2006  if (vcpu_has_nv(vcpu))
2007  return 0;
2008 
2009  return REG_HIDDEN;
2010 }
#define REG_HIDDEN
Definition: sys_regs.h:97

◆ emulate_cp()

static bool emulate_cp ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc table,
size_t  num 
)
static

Definition at line 3113 of file sys_regs.c.

3117 {
3118  const struct sys_reg_desc *r;
3119 
3120  if (!table)
3121  return false; /* Not handled */
3122 
3123  r = find_reg(params, table, num);
3124 
3125  if (r) {
3126  perform_access(vcpu, params, r);
3127  return true;
3128  }
3129 
3130  /* Not handled */
3131  return false;
3132 }
static void perform_access(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *r)
Definition: sys_regs.c:3079
static const struct sys_reg_desc * find_reg(const struct sys_reg_params *params, const struct sys_reg_desc table[], unsigned int num)
Definition: sys_regs.h:217
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emulate_sys_reg()

static bool emulate_sys_reg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params 
)
static

emulate_sys_reg - Emulate a guest access to an AArch64 system register @vcpu: The VCPU pointer @params: Decoded system register parameters

Return: true if the system register access was successful, false otherwise.

Definition at line 3400 of file sys_regs.c.

3402 {
3403  const struct sys_reg_desc *r;
3404 
3405  r = find_reg(params, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
3406 
3407  if (likely(r)) {
3408  perform_access(vcpu, params, r);
3409  return true;
3410  }
3411 
3412  if (is_imp_def_sys_reg(params)) {
3413  kvm_inject_undefined(vcpu);
3414  } else {
3415  print_sys_reg_msg(params,
3416  "Unsupported guest sys_reg access at: %lx [%08lx]\n",
3417  *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
3418  kvm_inject_undefined(vcpu);
3419  }
3420  return false;
3421 }
static const struct sys_reg_desc sys_reg_descs[]
Definition: sys_regs.c:2188
static bool is_imp_def_sys_reg(struct sys_reg_params *params)
Definition: sys_regs.c:3387
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_access_mask()

static void get_access_mask ( const struct sys_reg_desc r,
u64 *  mask,
u64 *  shift 
)
static

Definition at line 355 of file sys_regs.c.

356 {
357  switch (r->aarch32_map) {
358  case AA32_LO:
359  *mask = GENMASK_ULL(31, 0);
360  *shift = 0;
361  break;
362  case AA32_HI:
363  *mask = GENMASK_ULL(63, 32);
364  *shift = 32;
365  break;
366  default:
367  *mask = GENMASK_ULL(63, 0);
368  *shift = 0;
369  break;
370  }
371 }
enum sys_reg_desc::@9 aarch32_map
Here is the caller graph for this function:

◆ get_bcr()

static int get_bcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 714 of file sys_regs.c.

716 {
717  *val = vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
718  return 0;
719 }

◆ get_bvr()

static int get_bvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 677 of file sys_regs.c.

679 {
680  *val = vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
681  return 0;
682 }

◆ get_ccsidr()

static u32 get_ccsidr ( struct kvm_vcpu *  vcpu,
u32  csselr 
)
static

Definition at line 243 of file sys_regs.c.

244 {
245  u8 line_size;
246 
247  if (vcpu->arch.ccsidr)
248  return vcpu->arch.ccsidr[csselr];
249 
250  line_size = get_min_cache_line_size(csselr & CSSELR_EL1_InD);
251 
252  /*
253  * Fabricate a CCSIDR value as the overriding value does not exist.
254  * The real CCSIDR value will not be used as it can vary by the
255  * physical CPU which the vcpu currently resides in.
256  *
257  * The line size is determined with get_min_cache_line_size(), which
258  * should be valid for all CPUs even if they have different cache
259  * configuration.
260  *
261  * The associativity bits are cleared, meaning the geometry of all data
262  * and unified caches (which are guaranteed to be PIPT and thus
263  * non-aliasing) are 1 set and 1 way.
264  * Guests should not be doing cache operations by set/way at all, and
265  * for this reason, we trap them and attempt to infer the intent, so
266  * that we can flush the entire guest's address space at the appropriate
267  * time. The exposed geometry minimizes the number of the traps.
268  * [If guests should attempt to infer aliasing properties from the
269  * geometry (which is not permitted by the architecture), they would
270  * only do so for virtually indexed caches.]
271  *
272  * We don't check if the cache level exists as it is allowed to return
273  * an UNKNOWN value if not.
274  */
275  return SYS_FIELD_PREP(CCSIDR_EL1, LineSize, line_size - 4);
276 }
static u8 get_min_cache_line_size(bool icache)
Definition: sys_regs.c:221
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ctr_el0()

static u64 get_ctr_el0 ( struct kvm_vcpu *  v,
const struct sys_reg_desc r 
)
static

Definition at line 3581 of file sys_regs.c.

3582 {
3583  ((struct sys_reg_desc *)r)->val = read_sanitised_ftr_reg(SYS_CTR_EL0);
3584  return ((struct sys_reg_desc *)r)->val;
3585 }

◆ get_el2_to_el1_mapping()

static bool get_el2_to_el1_mapping ( unsigned int  reg,
unsigned int *  el1r,
u64(**)(u64)  xlate 
)
static

Definition at line 88 of file sys_regs.c.

90 {
91  switch (reg) {
92  PURE_EL2_SYSREG( VPIDR_EL2 );
93  PURE_EL2_SYSREG( VMPIDR_EL2 );
94  PURE_EL2_SYSREG( ACTLR_EL2 );
95  PURE_EL2_SYSREG( HCR_EL2 );
96  PURE_EL2_SYSREG( MDCR_EL2 );
97  PURE_EL2_SYSREG( HSTR_EL2 );
98  PURE_EL2_SYSREG( HACR_EL2 );
99  PURE_EL2_SYSREG( VTTBR_EL2 );
100  PURE_EL2_SYSREG( VTCR_EL2 );
101  PURE_EL2_SYSREG( RVBAR_EL2 );
102  PURE_EL2_SYSREG( TPIDR_EL2 );
103  PURE_EL2_SYSREG( HPFAR_EL2 );
104  PURE_EL2_SYSREG( CNTHCTL_EL2 );
105  MAPPED_EL2_SYSREG(SCTLR_EL2, SCTLR_EL1,
106  translate_sctlr_el2_to_sctlr_el1 );
107  MAPPED_EL2_SYSREG(CPTR_EL2, CPACR_EL1,
108  translate_cptr_el2_to_cpacr_el1 );
109  MAPPED_EL2_SYSREG(TTBR0_EL2, TTBR0_EL1,
110  translate_ttbr0_el2_to_ttbr0_el1 );
111  MAPPED_EL2_SYSREG(TTBR1_EL2, TTBR1_EL1, NULL );
112  MAPPED_EL2_SYSREG(TCR_EL2, TCR_EL1,
113  translate_tcr_el2_to_tcr_el1 );
114  MAPPED_EL2_SYSREG(VBAR_EL2, VBAR_EL1, NULL );
115  MAPPED_EL2_SYSREG(AFSR0_EL2, AFSR0_EL1, NULL );
116  MAPPED_EL2_SYSREG(AFSR1_EL2, AFSR1_EL1, NULL );
117  MAPPED_EL2_SYSREG(ESR_EL2, ESR_EL1, NULL );
118  MAPPED_EL2_SYSREG(FAR_EL2, FAR_EL1, NULL );
119  MAPPED_EL2_SYSREG(MAIR_EL2, MAIR_EL1, NULL );
120  MAPPED_EL2_SYSREG(AMAIR_EL2, AMAIR_EL1, NULL );
121  MAPPED_EL2_SYSREG(ELR_EL2, ELR_EL1, NULL );
122  MAPPED_EL2_SYSREG(SPSR_EL2, SPSR_EL1, NULL );
123  default:
124  return false;
125  }
126 }
#define MAPPED_EL2_SYSREG(el2, el1, fn)
Definition: sys_regs.c:81
#define PURE_EL2_SYSREG(el2)
Definition: sys_regs.c:75
Here is the caller graph for this function:

◆ get_id_reg()

static int get_id_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 1796 of file sys_regs.c.

1798 {
1799  /*
1800  * Avoid locking if the VM has already started, as the ID registers are
1801  * guaranteed to be invariant at that point.
1802  */
1803  if (kvm_vm_has_ran_once(vcpu->kvm)) {
1804  *val = read_id_reg(vcpu, rd);
1805  return 0;
1806  }
1807 
1808  mutex_lock(&vcpu->kvm->arch.config_lock);
1809  *val = read_id_reg(vcpu, rd);
1810  mutex_unlock(&vcpu->kvm->arch.config_lock);
1811 
1812  return 0;
1813 }
Here is the call graph for this function:

◆ get_invariant_sys_reg()

static int get_invariant_sys_reg ( u64  id,
u64 __user *  uaddr 
)
static

Definition at line 3595 of file sys_regs.c.

3596 {
3597  const struct sys_reg_desc *r;
3598 
3599  r = get_reg_by_id(id, invariant_sys_regs,
3600  ARRAY_SIZE(invariant_sys_regs));
3601  if (!r)
3602  return -ENOENT;
3603 
3604  return put_user(r->val, uaddr);
3605 }
const struct sys_reg_desc * get_reg_by_id(u64 id, const struct sys_reg_desc table[], unsigned int num)
Definition: sys_regs.c:3528
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_min_cache_line_size()

static u8 get_min_cache_line_size ( bool  icache)
static

Definition at line 221 of file sys_regs.c.

222 {
223  u64 ctr = read_sanitised_ftr_reg(SYS_CTR_EL0);
224  u8 field;
225 
226  if (icache)
227  field = SYS_FIELD_GET(CTR_EL0, IminLine, ctr);
228  else
229  field = SYS_FIELD_GET(CTR_EL0, DminLine, ctr);
230 
231  /*
232  * Cache line size is represented as Log2(words) in CTR_EL0.
233  * Log2(bytes) can be derived with the following:
234  *
235  * Log2(words) + 2 = Log2(bytes / 4) + 2
236  * = Log2(bytes) - 2 + 2
237  * = Log2(bytes)
238  */
239  return field + 2;
240 }
Here is the caller graph for this function:

◆ get_pmcr()

static int get_pmcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r,
u64 *  val 
)
static

Definition at line 1262 of file sys_regs.c.

1264 {
1265  *val = kvm_vcpu_read_pmcr(vcpu);
1266  return 0;
1267 }
Here is the call graph for this function:

◆ get_pmreg()

static int get_pmreg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r,
u64 *  val 
)
static

Definition at line 1145 of file sys_regs.c.

1146 {
1147  u64 mask = kvm_pmu_valid_counter_mask(vcpu);
1148 
1149  *val = __vcpu_sys_reg(vcpu, r->reg) & mask;
1150  return 0;
1151 }
Here is the call graph for this function:

◆ get_pmu_evcntr()

static int get_pmu_evcntr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r,
u64 *  val 
)
static

Definition at line 1015 of file sys_regs.c.

1017 {
1018  u64 idx;
1019 
1020  if (r->CRn == 9 && r->CRm == 13 && r->Op2 == 0)
1021  /* PMCCNTR_EL0 */
1022  idx = ARMV8_PMU_CYCLE_IDX;
1023  else
1024  /* PMEVCNTRn_EL0 */
1025  idx = ((r->CRm & 3) << 3) | (r->Op2 & 7);
1026 
1027  *val = kvm_pmu_get_counter_value(vcpu, idx);
1028  return 0;
1029 }
Here is the call graph for this function:

◆ get_raz_reg()

static int get_raz_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 1855 of file sys_regs.c.

1857 {
1858  *val = 0;
1859  return 0;
1860 }

◆ get_reg_by_id()

const struct sys_reg_desc* get_reg_by_id ( u64  id,
const struct sys_reg_desc  table[],
unsigned int  num 
)

Definition at line 3528 of file sys_regs.c.

3531 {
3532  struct sys_reg_params params;
3533 
3534  if (!index_to_params(id, &params))
3535  return NULL;
3536 
3537  return find_reg(&params, table, num);
3538 }
static bool index_to_params(u64 id, struct sys_reg_params *params)
Definition: sys_regs.c:3499
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_wcr()

static int get_wcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 789 of file sys_regs.c.

791 {
792  *val = vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
793  return 0;
794 }

◆ get_wvr()

static int get_wvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 *  val 
)
static

Definition at line 752 of file sys_regs.c.

754 {
755  *val = vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
756  return 0;
757 }

◆ hidden_user_visibility()

static unsigned int hidden_user_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 2055 of file sys_regs.c.

2057 {
2058  return REG_HIDDEN_USER;
2059 }
#define REG_HIDDEN_USER
Definition: sys_regs.h:98

◆ id_to_sys_reg_desc()

static const struct sys_reg_desc* id_to_sys_reg_desc ( struct kvm_vcpu *  vcpu,
u64  id,
const struct sys_reg_desc  table[],
unsigned int  num 
)
static

Definition at line 3542 of file sys_regs.c.

3545 {
3546  const struct sys_reg_desc *r;
3547 
3548  /* We only do sys_reg for now. */
3549  if ((id & KVM_REG_ARM_COPROC_MASK) != KVM_REG_ARM64_SYSREG)
3550  return NULL;
3551 
3552  r = get_reg_by_id(id, table, num);
3553 
3554  /* Not saved in the sys_reg array and not otherwise accessible? */
3555  if (r && (!(r->reg || r->get_user) || sysreg_hidden(vcpu, r)))
3556  r = NULL;
3557 
3558  return r;
3559 }
int(* get_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 *val)
Definition: sys_regs.h:87
static bool sysreg_hidden(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.h:162
Here is the call graph for this function:
Here is the caller graph for this function:

◆ id_visibility()

static unsigned int id_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1589 of file sys_regs.c.

1591 {
1592  u32 id = reg_to_encoding(r);
1593 
1594  switch (id) {
1595  case SYS_ID_AA64ZFR0_EL1:
1596  if (!vcpu_has_sve(vcpu))
1597  return REG_RAZ;
1598  break;
1599  }
1600 
1601  return 0;
1602 }
Here is the caller graph for this function:

◆ index_to_params()

static bool index_to_params ( u64  id,
struct sys_reg_params params 
)
static

Definition at line 3499 of file sys_regs.c.

3500 {
3501  switch (id & KVM_REG_SIZE_MASK) {
3502  case KVM_REG_SIZE_U64:
3503  /* Any unused index bits means it's not valid. */
3504  if (id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK
3505  | KVM_REG_ARM_COPROC_MASK
3506  | KVM_REG_ARM64_SYSREG_OP0_MASK
3507  | KVM_REG_ARM64_SYSREG_OP1_MASK
3508  | KVM_REG_ARM64_SYSREG_CRN_MASK
3509  | KVM_REG_ARM64_SYSREG_CRM_MASK
3510  | KVM_REG_ARM64_SYSREG_OP2_MASK))
3511  return false;
3512  params->Op0 = ((id & KVM_REG_ARM64_SYSREG_OP0_MASK)
3513  >> KVM_REG_ARM64_SYSREG_OP0_SHIFT);
3514  params->Op1 = ((id & KVM_REG_ARM64_SYSREG_OP1_MASK)
3515  >> KVM_REG_ARM64_SYSREG_OP1_SHIFT);
3516  params->CRn = ((id & KVM_REG_ARM64_SYSREG_CRN_MASK)
3517  >> KVM_REG_ARM64_SYSREG_CRN_SHIFT);
3518  params->CRm = ((id & KVM_REG_ARM64_SYSREG_CRM_MASK)
3519  >> KVM_REG_ARM64_SYSREG_CRM_SHIFT);
3520  params->Op2 = ((id & KVM_REG_ARM64_SYSREG_OP2_MASK)
3521  >> KVM_REG_ARM64_SYSREG_OP2_SHIFT);
3522  return true;
3523  default:
3524  return false;
3525  }
3526 }
Here is the caller graph for this function:

◆ is_aa32_id_reg()

static bool is_aa32_id_reg ( u32  id)
inlinestatic

Definition at line 1582 of file sys_regs.c.

1583 {
1584  return (sys_reg_Op0(id) == 3 && sys_reg_Op1(id) == 0 &&
1585  sys_reg_CRn(id) == 0 && sys_reg_CRm(id) >= 1 &&
1586  sys_reg_CRm(id) <= 3);
1587 }
Here is the caller graph for this function:

◆ is_feature_id_reg()

static bool is_feature_id_reg ( u32  encoding)
static

Definition at line 3881 of file sys_regs.c.

3882 {
3883  return (sys_reg_Op0(encoding) == 3 &&
3884  (sys_reg_Op1(encoding) < 2 || sys_reg_Op1(encoding) == 3) &&
3885  sys_reg_CRn(encoding) == 0 &&
3886  sys_reg_CRm(encoding) <= 7);
3887 }
Here is the caller graph for this function:

◆ is_id_reg()

static bool is_id_reg ( u32  id)
inlinestatic

Definition at line 1575 of file sys_regs.c.

1576 {
1577  return (sys_reg_Op0(id) == 3 && sys_reg_Op1(id) == 0 &&
1578  sys_reg_CRn(id) == 0 && sys_reg_CRm(id) >= 1 &&
1579  sys_reg_CRm(id) < 8);
1580 }
Here is the caller graph for this function:

◆ is_imp_def_sys_reg()

static bool is_imp_def_sys_reg ( struct sys_reg_params params)
static

Definition at line 3387 of file sys_regs.c.

3388 {
3389  // See ARM DDI 0487E.a, section D12.3.2
3390  return params->Op0 == 3 && (params->CRn & 0b1011) == 0b1011;
3391 }
Here is the caller graph for this function:

◆ kvm_arm64_ftr_safe_value()

static s64 kvm_arm64_ftr_safe_value ( u32  id,
const struct arm64_ftr_bits *  ftrp,
s64  new,
s64  cur 
)
static

Definition at line 1412 of file sys_regs.c.

1414 {
1415  struct arm64_ftr_bits kvm_ftr = *ftrp;
1416 
1417  /* Some features have different safe value type in KVM than host features */
1418  switch (id) {
1419  case SYS_ID_AA64DFR0_EL1:
1420  switch (kvm_ftr.shift) {
1421  case ID_AA64DFR0_EL1_PMUVer_SHIFT:
1422  kvm_ftr.type = FTR_LOWER_SAFE;
1423  break;
1424  case ID_AA64DFR0_EL1_DebugVer_SHIFT:
1425  kvm_ftr.type = FTR_LOWER_SAFE;
1426  break;
1427  }
1428  break;
1429  case SYS_ID_DFR0_EL1:
1430  if (kvm_ftr.shift == ID_DFR0_EL1_PerfMon_SHIFT)
1431  kvm_ftr.type = FTR_LOWER_SAFE;
1432  break;
1433  }
1434 
1435  return arm64_ftr_safe_value(&kvm_ftr, new, cur);
1436 }
static unsigned long cur
Definition: early_alloc.c:17
Here is the caller graph for this function:

◆ kvm_arm_copy_sys_reg_indices()

int kvm_arm_copy_sys_reg_indices ( struct kvm_vcpu *  vcpu,
u64 __user *  uindices 
)

Definition at line 3854 of file sys_regs.c.

3855 {
3856  unsigned int i;
3857  int err;
3858 
3859  /* Then give them all the invariant registers' indices. */
3860  for (i = 0; i < ARRAY_SIZE(invariant_sys_regs); i++) {
3861  if (put_user(sys_reg_to_index(&invariant_sys_regs[i]), uindices))
3862  return -EFAULT;
3863  uindices++;
3864  }
3865 
3866  err = walk_sys_regs(vcpu, uindices);
3867  if (err < 0)
3868  return err;
3869  uindices += err;
3870 
3871  return write_demux_regids(uindices);
3872 }
static int write_demux_regids(u64 __user *uindices)
Definition: sys_regs.c:3770
static int walk_sys_regs(struct kvm_vcpu *vcpu, u64 __user *uind)
Definition: sys_regs.c:3830
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_arm_num_sys_reg_descs()

unsigned long kvm_arm_num_sys_reg_descs ( struct kvm_vcpu *  vcpu)

Definition at line 3847 of file sys_regs.c.

3848 {
3849  return ARRAY_SIZE(invariant_sys_regs)
3850  + num_demux_regs()
3851  + walk_sys_regs(vcpu, (u64 __user *)NULL);
3852 }
static unsigned int num_demux_regs(void)
Definition: sys_regs.c:3765
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_arm_sys_reg_get_reg()

int kvm_arm_sys_reg_get_reg ( struct kvm_vcpu *  vcpu,
const struct kvm_one_reg *  reg 
)

Definition at line 3705 of file sys_regs.c.

3706 {
3707  void __user *uaddr = (void __user *)(unsigned long)reg->addr;
3708  int err;
3709 
3710  if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_DEMUX)
3711  return demux_c15_get(vcpu, reg->id, uaddr);
3712 
3713  err = get_invariant_sys_reg(reg->id, uaddr);
3714  if (err != -ENOENT)
3715  return err;
3716 
3717  return kvm_sys_reg_get_user(vcpu, reg,
3718  sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
3719 }
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)
Definition: sys_regs.c:3680
static int get_invariant_sys_reg(u64 id, u64 __user *uaddr)
Definition: sys_regs.c:3595
static int demux_c15_get(struct kvm_vcpu *vcpu, u64 id, void __user *uaddr)
Definition: sys_regs.c:3627
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_arm_sys_reg_set_reg()

int kvm_arm_sys_reg_set_reg ( struct kvm_vcpu *  vcpu,
const struct kvm_one_reg *  reg 
)

Definition at line 3749 of file sys_regs.c.

3750 {
3751  void __user *uaddr = (void __user *)(unsigned long)reg->addr;
3752  int err;
3753 
3754  if ((reg->id & KVM_REG_ARM_COPROC_MASK) == KVM_REG_ARM_DEMUX)
3755  return demux_c15_set(vcpu, reg->id, uaddr);
3756 
3757  err = set_invariant_sys_reg(reg->id, uaddr);
3758  if (err != -ENOENT)
3759  return err;
3760 
3761  return kvm_sys_reg_set_user(vcpu, reg,
3762  sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
3763 }
static int set_invariant_sys_reg(u64 id, u64 __user *uaddr)
Definition: sys_regs.c:3607
static int demux_c15_set(struct kvm_vcpu *vcpu, u64 id, void __user *uaddr)
Definition: sys_regs.c:3652
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)
Definition: sys_regs.c:3721
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_emulate_cp15_id_reg()

static int kvm_emulate_cp15_id_reg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params 
)
static

kvm_emulate_cp15_id_reg() - Handles an MRC trap on a guest CP15 access where CRn=0, which corresponds to the AArch32 feature registers. @vcpu: the vCPU pointer @params: the system register access parameters.

Our cp15 system register tables do not enumerate the AArch32 feature registers. Conveniently, our AArch64 table does, and the AArch32 system register encoding can be trivially remapped into the AArch64 for the feature registers: Append op0=3, leaving op1, CRn, CRm, and op2 the same.

According to DDI0487G.b G7.3.1, paragraph "Behavior of VMSAv8-32 32-bit System registers with (coproc=0b1111, CRn==c0)", read accesses from this range are either UNKNOWN or RES0. Rerouting remains architectural as we treat undefined registers in this range as RAZ.

Definition at line 3299 of file sys_regs.c.

3301 {
3302  int Rt = kvm_vcpu_sys_get_rt(vcpu);
3303 
3304  /* Treat impossible writes to RO registers as UNDEFINED */
3305  if (params->is_write) {
3306  unhandled_cp_access(vcpu, params);
3307  return 1;
3308  }
3309 
3310  params->Op0 = 3;
3311 
3312  /*
3313  * All registers where CRm > 3 are known to be UNKNOWN/RAZ from AArch32.
3314  * Avoid conflicting with future expansion of AArch64 feature registers
3315  * and simply treat them as RAZ here.
3316  */
3317  if (params->CRm > 3)
3318  params->regval = 0;
3319  else if (!emulate_sys_reg(vcpu, params))
3320  return 1;
3321 
3322  vcpu_set_reg(vcpu, Rt, params->regval);
3323  return 1;
3324 }
static void unhandled_cp_access(struct kvm_vcpu *vcpu, struct sys_reg_params *params)
Definition: sys_regs.c:3134
static bool emulate_sys_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *params)
Definition: sys_regs.c:3400
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_esr_cp10_id_to_sys64()

static bool kvm_esr_cp10_id_to_sys64 ( u64  esr,
struct sys_reg_params params 
)
static

Definition at line 3216 of file sys_regs.c.

3217 {
3218  u8 reg_id = (esr >> 10) & 0xf;
3219  bool valid;
3220 
3221  params->is_write = ((esr & 1) == 0);
3222  params->Op0 = 3;
3223  params->Op1 = 0;
3224  params->CRn = 0;
3225  params->CRm = 3;
3226 
3227  /* CP10 ID registers are read-only */
3228  valid = !params->is_write;
3229 
3230  switch (reg_id) {
3231  /* MVFR0 */
3232  case 0b0111:
3233  params->Op2 = 0;
3234  break;
3235  /* MVFR1 */
3236  case 0b0110:
3237  params->Op2 = 1;
3238  break;
3239  /* MVFR2 */
3240  case 0b0101:
3241  params->Op2 = 2;
3242  break;
3243  default:
3244  valid = false;
3245  }
3246 
3247  if (valid)
3248  return true;
3249 
3250  kvm_pr_unimpl("Unhandled cp10 register %s: %u\n",
3251  params->is_write ? "write" : "read", reg_id);
3252  return false;
3253 }
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")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_handle_cp10_id()

int kvm_handle_cp10_id ( struct kvm_vcpu *  vcpu)

kvm_handle_cp10_id() - Handles a VMRS trap on guest access to a 'Media and VFP Register' from AArch32. @vcpu: The vCPU pointer

MVFR{0-2} are architecturally mapped to the AArch64 MVFR{0-2}_EL1 registers. Work out the correct AArch64 system register encoding and reroute to the AArch64 system register emulation.

Definition at line 3264 of file sys_regs.c.

3265 {
3266  int Rt = kvm_vcpu_sys_get_rt(vcpu);
3267  u64 esr = kvm_vcpu_get_esr(vcpu);
3268  struct sys_reg_params params;
3269 
3270  /* UNDEF on any unhandled register access */
3271  if (!kvm_esr_cp10_id_to_sys64(esr, &params)) {
3272  kvm_inject_undefined(vcpu);
3273  return 1;
3274  }
3275 
3276  if (emulate_sys_reg(vcpu, &params))
3277  vcpu_set_reg(vcpu, Rt, params.regval);
3278 
3279  return 1;
3280 }
static bool kvm_esr_cp10_id_to_sys64(u64 esr, struct sys_reg_params *params)
Definition: sys_regs.c:3216
Here is the call graph for this function:

◆ kvm_handle_cp14_32()

int kvm_handle_cp14_32 ( struct kvm_vcpu *  vcpu)

Definition at line 3378 of file sys_regs.c.

3379 {
3380  struct sys_reg_params params;
3381 
3382  params = esr_cp1x_32_to_params(kvm_vcpu_get_esr(vcpu));
3383 
3384  return kvm_handle_cp_32(vcpu, &params, cp14_regs, ARRAY_SIZE(cp14_regs));
3385 }
static int kvm_handle_cp_32(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *global, size_t nr_global)
Definition: sys_regs.c:3331
static const struct sys_reg_desc cp14_regs[]
Definition: sys_regs.c:2779
#define esr_cp1x_32_to_params(esr)
Definition: sys_regs.h:45
Here is the call graph for this function:

◆ kvm_handle_cp14_64()

int kvm_handle_cp14_64 ( struct kvm_vcpu *  vcpu)

Definition at line 3373 of file sys_regs.c.

3374 {
3375  return kvm_handle_cp_64(vcpu, cp14_64_regs, ARRAY_SIZE(cp14_64_regs));
3376 }
static int kvm_handle_cp_64(struct kvm_vcpu *vcpu, const struct sys_reg_desc *global, size_t nr_global)
Definition: sys_regs.c:3164
static const struct sys_reg_desc cp14_64_regs[]
Definition: sys_regs.c:2864
Here is the call graph for this function:

◆ kvm_handle_cp14_load_store()

int kvm_handle_cp14_load_store ( struct kvm_vcpu *  vcpu)

Definition at line 3073 of file sys_regs.c.

3074 {
3075  kvm_inject_undefined(vcpu);
3076  return 1;
3077 }
Here is the call graph for this function:

◆ kvm_handle_cp15_32()

int kvm_handle_cp15_32 ( struct kvm_vcpu *  vcpu)

Definition at line 3355 of file sys_regs.c.

3356 {
3357  struct sys_reg_params params;
3358 
3359  params = esr_cp1x_32_to_params(kvm_vcpu_get_esr(vcpu));
3360 
3361  /*
3362  * Certain AArch32 ID registers are handled by rerouting to the AArch64
3363  * system register table. Registers in the ID range where CRm=0 are
3364  * excluded from this scheme as they do not trivially map into AArch64
3365  * system register encodings.
3366  */
3367  if (params.Op1 == 0 && params.CRn == 0 && params.CRm)
3368  return kvm_emulate_cp15_id_reg(vcpu, &params);
3369 
3370  return kvm_handle_cp_32(vcpu, &params, cp15_regs, ARRAY_SIZE(cp15_regs));
3371 }
static int kvm_emulate_cp15_id_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *params)
Definition: sys_regs.c:3299
static const struct sys_reg_desc cp15_regs[]
Definition: sys_regs.c:2893
Here is the call graph for this function:

◆ kvm_handle_cp15_64()

int kvm_handle_cp15_64 ( struct kvm_vcpu *  vcpu)

Definition at line 3350 of file sys_regs.c.

3351 {
3352  return kvm_handle_cp_64(vcpu, cp15_64_regs, ARRAY_SIZE(cp15_64_regs));
3353 }
static const struct sys_reg_desc cp15_64_regs[]
Definition: sys_regs.c:3041
Here is the call graph for this function:

◆ kvm_handle_cp_32()

static int kvm_handle_cp_32 ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc global,
size_t  nr_global 
)
static

kvm_handle_cp_32 – handles a mrc/mcr trap on a guest CP14/CP15 access @vcpu: The VCPU pointer @run: The kvm_run struct

Definition at line 3331 of file sys_regs.c.

3335 {
3336  int Rt = kvm_vcpu_sys_get_rt(vcpu);
3337 
3338  params->regval = vcpu_get_reg(vcpu, Rt);
3339 
3340  if (emulate_cp(vcpu, params, global, nr_global)) {
3341  if (!params->is_write)
3342  vcpu_set_reg(vcpu, Rt, params->regval);
3343  return 1;
3344  }
3345 
3346  unhandled_cp_access(vcpu, params);
3347  return 1;
3348 }
static bool emulate_cp(struct kvm_vcpu *vcpu, struct sys_reg_params *params, const struct sys_reg_desc *table, size_t num)
Definition: sys_regs.c:3113
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_handle_cp_64()

static int kvm_handle_cp_64 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc global,
size_t  nr_global 
)
static

kvm_handle_cp_64 – handles a mrrc/mcrr trap on a guest CP14/CP15 access @vcpu: The VCPU pointer @run: The kvm_run struct

Definition at line 3164 of file sys_regs.c.

3167 {
3168  struct sys_reg_params params;
3169  u64 esr = kvm_vcpu_get_esr(vcpu);
3170  int Rt = kvm_vcpu_sys_get_rt(vcpu);
3171  int Rt2 = (esr >> 10) & 0x1f;
3172 
3173  params.CRm = (esr >> 1) & 0xf;
3174  params.is_write = ((esr & 1) == 0);
3175 
3176  params.Op0 = 0;
3177  params.Op1 = (esr >> 16) & 0xf;
3178  params.Op2 = 0;
3179  params.CRn = 0;
3180 
3181  /*
3182  * Make a 64-bit value out of Rt and Rt2. As we use the same trap
3183  * backends between AArch32 and AArch64, we get away with it.
3184  */
3185  if (params.is_write) {
3186  params.regval = vcpu_get_reg(vcpu, Rt) & 0xffffffff;
3187  params.regval |= vcpu_get_reg(vcpu, Rt2) << 32;
3188  }
3189 
3190  /*
3191  * If the table contains a handler, handle the
3192  * potential register operation in the case of a read and return
3193  * with success.
3194  */
3195  if (emulate_cp(vcpu, &params, global, nr_global)) {
3196  /* Split up the value between registers for the read side */
3197  if (!params.is_write) {
3198  vcpu_set_reg(vcpu, Rt, lower_32_bits(params.regval));
3199  vcpu_set_reg(vcpu, Rt2, upper_32_bits(params.regval));
3200  }
3201 
3202  return 1;
3203  }
3204 
3205  unhandled_cp_access(vcpu, &params);
3206  return 1;
3207 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_handle_sys_reg()

int kvm_handle_sys_reg ( struct kvm_vcpu *  vcpu)

kvm_handle_sys_reg – handles a mrs/msr trap on a guest sys_reg access @vcpu: The VCPU pointer

Definition at line 3473 of file sys_regs.c.

3474 {
3475  struct sys_reg_params params;
3476  unsigned long esr = kvm_vcpu_get_esr(vcpu);
3477  int Rt = kvm_vcpu_sys_get_rt(vcpu);
3478 
3479  trace_kvm_handle_sys_reg(esr);
3480 
3481  if (__check_nv_sr_forward(vcpu))
3482  return 1;
3483 
3484  params = esr_sys64_to_params(esr);
3485  params.regval = vcpu_get_reg(vcpu, Rt);
3486 
3487  if (!emulate_sys_reg(vcpu, &params))
3488  return 1;
3489 
3490  if (!params.is_write)
3491  vcpu_set_reg(vcpu, Rt, params.regval);
3492  return 1;
3493 }
bool __check_nv_sr_forward(struct kvm_vcpu *vcpu)
#define esr_sys64_to_params(esr)
Definition: sys_regs.h:37
Here is the call graph for this function:

◆ kvm_read_sanitised_id_reg()

static u64 kvm_read_sanitised_id_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1560 of file sys_regs.c.

1562 {
1563  return __kvm_read_sanitised_id_reg(vcpu, r);
1564 }
static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.c:1517
Here is the call graph for this function:

◆ kvm_reset_id_regs()

static void kvm_reset_id_regs ( struct kvm_vcpu *  vcpu)
static

Definition at line 3423 of file sys_regs.c.

3424 {
3425  const struct sys_reg_desc *idreg = first_idreg;
3426  u32 id = reg_to_encoding(idreg);
3427  struct kvm *kvm = vcpu->kvm;
3428 
3429  if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
3430  return;
3431 
3432  lockdep_assert_held(&kvm->arch.config_lock);
3433 
3434  /* Initialize all idregs */
3435  while (is_id_reg(id)) {
3436  IDREG(kvm, id) = idreg->reset(vcpu, idreg);
3437 
3438  idreg++;
3439  id = reg_to_encoding(idreg);
3440  }
3441 
3442  set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
3443 }
static const struct sys_reg_desc * first_idreg
Definition: sys_regs.c:2730
static bool is_id_reg(u32 id)
Definition: sys_regs.c:1575
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_reset_sys_regs()

void kvm_reset_sys_regs ( struct kvm_vcpu *  vcpu)

kvm_reset_sys_regs - sets system registers to reset value @vcpu: The VCPU pointer

This function finds the right table above and sets the registers on the virtual CPU struct to their architecturally defined reset values.

Definition at line 3452 of file sys_regs.c.

3453 {
3454  unsigned long i;
3455 
3456  kvm_reset_id_regs(vcpu);
3457 
3458  for (i = 0; i < ARRAY_SIZE(sys_reg_descs); i++) {
3459  const struct sys_reg_desc *r = &sys_reg_descs[i];
3460 
3461  if (is_id_reg(reg_to_encoding(r)))
3462  continue;
3463 
3464  if (r->reset)
3465  r->reset(vcpu, r);
3466  }
3467 }
static void kvm_reset_id_regs(struct kvm_vcpu *vcpu)
Definition: sys_regs.c:3423
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_sys_reg_get_user()

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 
)

Definition at line 3680 of file sys_regs.c.

3682 {
3683  u64 __user *uaddr = (u64 __user *)(unsigned long)reg->addr;
3684  const struct sys_reg_desc *r;
3685  u64 val;
3686  int ret;
3687 
3688  r = id_to_sys_reg_desc(vcpu, reg->id, table, num);
3689  if (!r || sysreg_hidden_user(vcpu, r))
3690  return -ENOENT;
3691 
3692  if (r->get_user) {
3693  ret = (r->get_user)(vcpu, r, &val);
3694  } else {
3695  val = __vcpu_sys_reg(vcpu, r->reg);
3696  ret = 0;
3697  }
3698 
3699  if (!ret)
3700  ret = put_user(val, uaddr);
3701 
3702  return ret;
3703 }
static const struct sys_reg_desc * id_to_sys_reg_desc(struct kvm_vcpu *vcpu, u64 id, const struct sys_reg_desc table[], unsigned int num)
Definition: sys_regs.c:3542
static bool sysreg_hidden_user(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.h:168
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_sys_reg_set_user()

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 
)

Definition at line 3721 of file sys_regs.c.

3723 {
3724  u64 __user *uaddr = (u64 __user *)(unsigned long)reg->addr;
3725  const struct sys_reg_desc *r;
3726  u64 val;
3727  int ret;
3728 
3729  if (get_user(val, uaddr))
3730  return -EFAULT;
3731 
3732  r = id_to_sys_reg_desc(vcpu, reg->id, table, num);
3733  if (!r || sysreg_hidden_user(vcpu, r))
3734  return -ENOENT;
3735 
3736  if (sysreg_user_write_ignore(vcpu, r))
3737  return 0;
3738 
3739  if (r->set_user) {
3740  ret = (r->set_user)(vcpu, r, val);
3741  } else {
3742  __vcpu_sys_reg(vcpu, r->reg) = val;
3743  ret = 0;
3744  }
3745 
3746  return ret;
3747 }
int(* set_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.h:89
static bool sysreg_user_write_ignore(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
Definition: sys_regs.h:183
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_sys_reg_table_init()

int __init kvm_sys_reg_table_init ( void  )

Definition at line 3933 of file sys_regs.c.

3934 {
3935  struct sys_reg_params params;
3936  bool valid = true;
3937  unsigned int i;
3938 
3939  /* Make sure tables are unique and in order. */
3940  valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
3941  valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
3942  valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
3943  valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
3944  valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
3945  valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
3946 
3947  if (!valid)
3948  return -EINVAL;
3949 
3950  /* We abuse the reset function to overwrite the table itself. */
3951  for (i = 0; i < ARRAY_SIZE(invariant_sys_regs); i++)
3952  invariant_sys_regs[i].reset(NULL, &invariant_sys_regs[i]);
3953 
3954  /* Find the first idreg (SYS_ID_PFR0_EL1) in sys_reg_descs. */
3955  params = encoding_to_params(SYS_ID_PFR0_EL1);
3956  first_idreg = find_reg(&params, sys_reg_descs, ARRAY_SIZE(sys_reg_descs));
3957  if (!first_idreg)
3958  return -EINVAL;
3959 
3960  if (kvm_get_mode() == KVM_MODE_NV)
3961  return populate_nv_trap_config();
3962 
3963  return 0;
3964 }
enum kvm_mode kvm_get_mode(void)
Definition: arm.c:2657
int __init populate_nv_trap_config(void)
static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n, bool is_32)
Definition: sys_regs.c:3053
#define encoding_to_params(reg)
Definition: sys_regs.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvm_vm_ioctl_get_reg_writable_masks()

int kvm_vm_ioctl_get_reg_writable_masks ( struct kvm *  kvm,
struct reg_mask_range *  range 
)

Definition at line 3889 of file sys_regs.c.

3890 {
3891  const void *zero_page = page_to_virt(ZERO_PAGE(0));
3892  u64 __user *masks = (u64 __user *)range->addr;
3893 
3894  /* Only feature id range is supported, reserved[13] must be zero. */
3895  if (range->range ||
3896  memcmp(range->reserved, zero_page, sizeof(range->reserved)))
3897  return -EINVAL;
3898 
3899  /* Wipe the whole thing first */
3900  if (clear_user(masks, KVM_ARM_FEATURE_ID_RANGE_SIZE * sizeof(__u64)))
3901  return -EFAULT;
3902 
3903  for (int i = 0; i < ARRAY_SIZE(sys_reg_descs); i++) {
3904  const struct sys_reg_desc *reg = &sys_reg_descs[i];
3905  u32 encoding = reg_to_encoding(reg);
3906  u64 val;
3907 
3908  if (!is_feature_id_reg(encoding) || !reg->set_user)
3909  continue;
3910 
3911  /*
3912  * For ID registers, we return the writable mask. Other feature
3913  * registers return a full 64bit mask. That's not necessary
3914  * compliant with a given revision of the architecture, but the
3915  * RES0/RES1 definitions allow us to do that.
3916  */
3917  if (is_id_reg(encoding)) {
3918  if (!reg->val ||
3919  (is_aa32_id_reg(encoding) && !kvm_supports_32bit_el0()))
3920  continue;
3921  val = reg->val;
3922  } else {
3923  val = ~0UL;
3924  }
3925 
3926  if (put_user(val, (masks + KVM_ARM_FEATURE_ID_RANGE_INDEX(encoding))))
3927  return -EFAULT;
3928  }
3929 
3930  return 0;
3931 }
#define KVM_ARM_FEATURE_ID_RANGE_INDEX(r)
Definition: sys_regs.c:3874
static bool is_feature_id_reg(u32 encoding)
Definition: sys_regs.c:3881
static bool is_aa32_id_reg(u32 id)
Definition: sys_regs.c:1582
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mte_visibility()

static unsigned int mte_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1986 of file sys_regs.c.

1988 {
1989  if (kvm_has_mte(vcpu->kvm))
1990  return 0;
1991 
1992  return REG_HIDDEN;
1993 }

◆ num_demux_regs()

static unsigned int num_demux_regs ( void  )
static

Definition at line 3765 of file sys_regs.c.

3766 {
3767  return CSSELR_MAX;
3768 }
Here is the caller graph for this function:

◆ perform_access()

static void perform_access ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc r 
)
static

Definition at line 3079 of file sys_regs.c.

3082 {
3083  trace_kvm_sys_access(*vcpu_pc(vcpu), params, r);
3084 
3085  /* Check for regs disabled by runtime config */
3086  if (sysreg_hidden(vcpu, r)) {
3087  kvm_inject_undefined(vcpu);
3088  return;
3089  }
3090 
3091  /*
3092  * Not having an accessor means that we have configured a trap
3093  * that we don't know how to handle. This certainly qualifies
3094  * as a gross bug that should be fixed right away.
3095  */
3096  BUG_ON(!r->access);
3097 
3098  /* Skip instruction if instructed so */
3099  if (likely(r->access(vcpu, params, r)))
3100  kvm_incr_pc(vcpu);
3101 }
bool(* access)(struct kvm_vcpu *, struct sys_reg_params *, const struct sys_reg_desc *)
Definition: sys_regs.h:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmu_access_cycle_counter_el0_disabled()

static bool pmu_access_cycle_counter_el0_disabled ( struct kvm_vcpu *  vcpu)
static

Definition at line 925 of file sys_regs.c.

926 {
927  return check_pmu_access_disabled(vcpu, ARMV8_PMU_USERENR_CR | ARMV8_PMU_USERENR_EN);
928 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmu_access_el0_disabled()

static bool pmu_access_el0_disabled ( struct kvm_vcpu *  vcpu)
static

Definition at line 915 of file sys_regs.c.

916 {
917  return check_pmu_access_disabled(vcpu, ARMV8_PMU_USERENR_EN);
918 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmu_access_event_counter_el0_disabled()

static bool pmu_access_event_counter_el0_disabled ( struct kvm_vcpu *  vcpu)
static

Definition at line 930 of file sys_regs.c.

931 {
932  return check_pmu_access_disabled(vcpu, ARMV8_PMU_USERENR_ER | ARMV8_PMU_USERENR_EN);
933 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmu_counter_idx_valid()

static bool pmu_counter_idx_valid ( struct kvm_vcpu *  vcpu,
u64  idx 
)
static

Definition at line 1001 of file sys_regs.c.

1002 {
1003  u64 pmcr, val;
1004 
1005  pmcr = kvm_vcpu_read_pmcr(vcpu);
1006  val = FIELD_GET(ARMV8_PMU_PMCR_N, pmcr);
1007  if (idx >= val && idx != ARMV8_PMU_CYCLE_IDX) {
1008  kvm_inject_undefined(vcpu);
1009  return false;
1010  }
1011 
1012  return true;
1013 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmu_visibility()

static unsigned int pmu_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 837 of file sys_regs.c.

839 {
840  if (kvm_vcpu_has_pmu(vcpu))
841  return 0;
842 
843  return REG_HIDDEN;
844 }
#define kvm_vcpu_has_pmu(vcpu)
Definition: arm_pmu.h:170

◆ pmu_write_swinc_el0_disabled()

static bool pmu_write_swinc_el0_disabled ( struct kvm_vcpu *  vcpu)
static

Definition at line 920 of file sys_regs.c.

921 {
922  return check_pmu_access_disabled(vcpu, ARMV8_PMU_USERENR_SW | ARMV8_PMU_USERENR_EN);
923 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmuver_to_perfmon()

static u8 pmuver_to_perfmon ( u8  pmuver)
static

Definition at line 1503 of file sys_regs.c.

1504 {
1505  switch (pmuver) {
1506  case ID_AA64DFR0_EL1_PMUVer_IMP:
1507  return ID_DFR0_EL1_PerfMon_PMUv3;
1508  case ID_AA64DFR0_EL1_PMUVer_IMP_DEF:
1509  return ID_DFR0_EL1_PerfMon_IMPDEF;
1510  default:
1511  /* Anything ARMv8.1+ and NI have the same value. For now. */
1512  return pmuver;
1513  }
1514 }
Here is the caller graph for this function:

◆ ptrauth_visibility()

static unsigned int ptrauth_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1348 of file sys_regs.c.

1350 {
1351  return vcpu_has_ptrauth(vcpu) ? 0 : REG_HIDDEN;
1352 }

◆ raz_visibility()

static unsigned int raz_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1618 of file sys_regs.c.

1620 {
1621  return REG_RAZ;
1622 }

◆ read_from_write_only()

static bool read_from_write_only ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc r 
)
static

Definition at line 59 of file sys_regs.c.

62 {
63  return bad_trap(vcpu, params, r,
64  "sys_reg read to write-only register");
65 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_id_reg()

static u64 read_id_reg ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1566 of file sys_regs.c.

1567 {
1568  return IDREG(vcpu->kvm, reg_to_encoding(r));
1569 }
Here is the caller graph for this function:

◆ read_sanitised_id_aa64dfr0_el1()

static u64 read_sanitised_id_aa64dfr0_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1692 of file sys_regs.c.

1694 {
1695  u64 val = read_sanitised_ftr_reg(SYS_ID_AA64DFR0_EL1);
1696 
1697  val = ID_REG_LIMIT_FIELD_ENUM(val, ID_AA64DFR0_EL1, DebugVer, V8P8);
1698 
1699  /*
1700  * Only initialize the PMU version if the vCPU was configured with one.
1701  */
1702  val &= ~ID_AA64DFR0_EL1_PMUVer_MASK;
1703  if (kvm_vcpu_has_pmu(vcpu))
1704  val |= SYS_FIELD_PREP(ID_AA64DFR0_EL1, PMUVer,
1706 
1707  /* Hide SPE from guests */
1708  val &= ~ID_AA64DFR0_EL1_PMSVer_MASK;
1709 
1710  return val;
1711 }
u8 kvm_arm_pmu_get_pmuver_limit(void)
Definition: pmu-emul.c:1121
#define ID_REG_LIMIT_FIELD_ENUM(val, reg, field, limit)
Definition: sys_regs.c:1683
Here is the call graph for this function:

◆ read_sanitised_id_aa64pfr0_el1()

static u64 read_sanitised_id_aa64pfr0_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1648 of file sys_regs.c.

1650 {
1651  u64 val = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);
1652 
1653  if (!vcpu_has_sve(vcpu))
1654  val &= ~ID_AA64PFR0_EL1_SVE_MASK;
1655 
1656  /*
1657  * The default is to expose CSV2 == 1 if the HW isn't affected.
1658  * Although this is a per-CPU feature, we make it global because
1659  * asymmetric systems are just a nuisance.
1660  *
1661  * Userspace can override this as long as it doesn't promise
1662  * the impossible.
1663  */
1664  if (arm64_get_spectre_v2_state() == SPECTRE_UNAFFECTED) {
1665  val &= ~ID_AA64PFR0_EL1_CSV2_MASK;
1666  val |= SYS_FIELD_PREP_ENUM(ID_AA64PFR0_EL1, CSV2, IMP);
1667  }
1668  if (arm64_get_meltdown_state() == SPECTRE_UNAFFECTED) {
1669  val &= ~ID_AA64PFR0_EL1_CSV3_MASK;
1670  val |= SYS_FIELD_PREP_ENUM(ID_AA64PFR0_EL1, CSV3, IMP);
1671  }
1672 
1674  val &= ~ID_AA64PFR0_EL1_GIC_MASK;
1675  val |= SYS_FIELD_PREP_ENUM(ID_AA64PFR0_EL1, GIC, IMP);
1676  }
1677 
1678  val &= ~ID_AA64PFR0_EL1_AMU_MASK;
1679 
1680  return val;
1681 }
struct vgic_global kvm_vgic_global_state
@ VGIC_V3
Definition: arm_vgic.h:40
enum vgic_type type
Definition: arm_vgic.h:46

◆ read_sanitised_id_dfr0_el1()

static u64 read_sanitised_id_dfr0_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1747 of file sys_regs.c.

1749 {
1751  u64 val = read_sanitised_ftr_reg(SYS_ID_DFR0_EL1);
1752 
1753  val &= ~ID_DFR0_EL1_PerfMon_MASK;
1754  if (kvm_vcpu_has_pmu(vcpu))
1755  val |= SYS_FIELD_PREP(ID_DFR0_EL1, PerfMon, perfmon);
1756 
1757  val = ID_REG_LIMIT_FIELD_ENUM(val, ID_DFR0_EL1, CopDbg, Debugv8p8);
1758 
1759  return val;
1760 }
static u8 pmuver_to_perfmon(u8 pmuver)
Definition: sys_regs.c:1503
Here is the call graph for this function:

◆ reg_to_dbg()

static void reg_to_dbg ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd,
u64 *  dbg_reg 
)
static

Definition at line 626 of file sys_regs.c.

630 {
631  u64 mask, shift, val;
632 
633  get_access_mask(rd, &mask, &shift);
634 
635  val = *dbg_reg;
636  val &= ~mask;
637  val |= (p->regval & (mask >> shift)) << shift;
638  *dbg_reg = val;
639 
640  vcpu_set_flag(vcpu, DEBUG_DIRTY);
641 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_actlr()

static u64 reset_actlr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 810 of file sys_regs.c.

811 {
812  u64 actlr = read_sysreg(actlr_el1);
813  vcpu_write_sys_reg(vcpu, actlr, ACTLR_EL1);
814  return actlr;
815 }
Here is the call graph for this function:

◆ reset_amair_el1()

static u64 reset_amair_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 803 of file sys_regs.c.

804 {
805  u64 amair = read_sysreg(amair_el1);
806  vcpu_write_sys_reg(vcpu, amair, AMAIR_EL1);
807  return amair;
808 }
Here is the call graph for this function:

◆ reset_bcr()

static u64 reset_bcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 721 of file sys_regs.c.

723 {
724  vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm] = rd->val;
725  return rd->val;
726 }

◆ reset_bvr()

static u64 reset_bvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 684 of file sys_regs.c.

686 {
687  vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm] = rd->val;
688  return rd->val;
689 }

◆ reset_clidr()

static u64 reset_clidr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 1892 of file sys_regs.c.

1893 {
1894  u64 ctr_el0 = read_sanitised_ftr_reg(SYS_CTR_EL0);
1895  u64 clidr;
1896  u8 loc;
1897 
1898  if ((ctr_el0 & CTR_EL0_IDC)) {
1899  /*
1900  * Data cache clean to the PoU is not required so LoUU and LoUIS
1901  * will not be set and a unified cache, which will be marked as
1902  * LoC, will be added.
1903  *
1904  * If not DIC, let the unified cache L2 so that an instruction
1905  * cache can be added as L1 later.
1906  */
1907  loc = (ctr_el0 & CTR_EL0_DIC) ? 1 : 2;
1908  clidr = CACHE_TYPE_UNIFIED << CLIDR_CTYPE_SHIFT(loc);
1909  } else {
1910  /*
1911  * Data cache clean to the PoU is required so let L1 have a data
1912  * cache and mark it as LoUU and LoUIS. As L1 has a data cache,
1913  * it can be marked as LoC too.
1914  */
1915  loc = 1;
1916  clidr = 1 << CLIDR_LOUU_SHIFT;
1917  clidr |= 1 << CLIDR_LOUIS_SHIFT;
1918  clidr |= CACHE_TYPE_DATA << CLIDR_CTYPE_SHIFT(1);
1919  }
1920 
1921  /*
1922  * Instruction cache invalidation to the PoU is required so let L1 have
1923  * an instruction cache. If L1 already has a data cache, it will be
1924  * CACHE_TYPE_SEPARATE.
1925  */
1926  if (!(ctr_el0 & CTR_EL0_DIC))
1927  clidr |= CACHE_TYPE_INST << CLIDR_CTYPE_SHIFT(1);
1928 
1929  clidr |= loc << CLIDR_LOC_SHIFT;
1930 
1931  /*
1932  * Add tag cache unified to data cache. Allocation tags and data are
1933  * unified in a cache line so that it looks valid even if there is only
1934  * one cache line.
1935  */
1936  if (kvm_has_mte(vcpu->kvm))
1937  clidr |= 2 << CLIDR_TTYPE_SHIFT(loc);
1938 
1939  __vcpu_sys_reg(vcpu, r->reg) = clidr;
1940 
1941  return __vcpu_sys_reg(vcpu, r->reg);
1942 }

◆ reset_mpidr()

static u64 reset_mpidr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 817 of file sys_regs.c.

818 {
819  u64 mpidr;
820 
821  /*
822  * Map the vcpu_id into the first three affinity level fields of
823  * the MPIDR. We limit the number of VCPUs in level 0 due to a
824  * limitation to 16 CPUs in that level in the ICC_SGIxR registers
825  * of the GICv3 to be able to address each CPU directly when
826  * sending IPIs.
827  */
828  mpidr = (vcpu->vcpu_id & 0x0f) << MPIDR_LEVEL_SHIFT(0);
829  mpidr |= ((vcpu->vcpu_id >> 4) & 0xff) << MPIDR_LEVEL_SHIFT(1);
830  mpidr |= ((vcpu->vcpu_id >> 12) & 0xff) << MPIDR_LEVEL_SHIFT(2);
831  mpidr |= (1ULL << 31);
832  vcpu_write_sys_reg(vcpu, mpidr, MPIDR_EL1);
833 
834  return mpidr;
835 }
Here is the call graph for this function:

◆ reset_pmcr()

static u64 reset_pmcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 888 of file sys_regs.c.

889 {
890  u64 pmcr = 0;
891 
892  if (!kvm_supports_32bit_el0())
893  pmcr |= ARMV8_PMU_PMCR_LC;
894 
895  /*
896  * The value of PMCR.N field is included when the
897  * vCPU register is read via kvm_vcpu_read_pmcr().
898  */
899  __vcpu_sys_reg(vcpu, r->reg) = pmcr;
900 
901  return __vcpu_sys_reg(vcpu, r->reg);
902 }

◆ reset_pmevcntr()

static u64 reset_pmevcntr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 860 of file sys_regs.c.

861 {
862  reset_unknown(vcpu, r);
863  __vcpu_sys_reg(vcpu, r->reg) &= GENMASK(31, 0);
864 
865  return __vcpu_sys_reg(vcpu, r->reg);
866 }
Here is the call graph for this function:

◆ reset_pmevtyper()

static u64 reset_pmevtyper ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 868 of file sys_regs.c.

869 {
870  /* This thing will UNDEF, who cares about the reset value? */
871  if (!kvm_vcpu_has_pmu(vcpu))
872  return 0;
873 
874  reset_unknown(vcpu, r);
875  __vcpu_sys_reg(vcpu, r->reg) &= kvm_pmu_evtyper_mask(vcpu->kvm);
876 
877  return __vcpu_sys_reg(vcpu, r->reg);
878 }
u64 kvm_pmu_evtyper_mask(struct kvm *kvm)
Definition: pmu-emul.c:63
Here is the call graph for this function:

◆ reset_pmselr()

static u64 reset_pmselr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 880 of file sys_regs.c.

881 {
882  reset_unknown(vcpu, r);
883  __vcpu_sys_reg(vcpu, r->reg) &= ARMV8_PMU_COUNTER_MASK;
884 
885  return __vcpu_sys_reg(vcpu, r->reg);
886 }
Here is the call graph for this function:

◆ reset_pmu_reg()

static u64 reset_pmu_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r 
)
static

Definition at line 846 of file sys_regs.c.

847 {
848  u64 mask = BIT(ARMV8_PMU_CYCLE_IDX);
849  u8 n = vcpu->kvm->arch.pmcr_n;
850 
851  if (n)
852  mask |= GENMASK(n - 1, 0);
853 
854  reset_unknown(vcpu, r);
855  __vcpu_sys_reg(vcpu, r->reg) &= mask;
856 
857  return __vcpu_sys_reg(vcpu, r->reg);
858 }
Here is the call graph for this function:

◆ reset_wcr()

static u64 reset_wcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 796 of file sys_regs.c.

798 {
799  vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm] = rd->val;
800  return rd->val;
801 }

◆ reset_wvr()

static u64 reset_wvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 759 of file sys_regs.c.

761 {
762  vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm] = rd->val;
763  return rd->val;
764 }

◆ set_bcr()

static int set_bcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 707 of file sys_regs.c.

709 {
710  vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm] = val;
711  return 0;
712 }

◆ set_bvr()

static int set_bvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 670 of file sys_regs.c.

672 {
673  vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm] = val;
674  return 0;
675 }

◆ set_ccsidr()

static int set_ccsidr ( struct kvm_vcpu *  vcpu,
u32  csselr,
u32  val 
)
static

Definition at line 278 of file sys_regs.c.

279 {
280  u8 line_size = FIELD_GET(CCSIDR_EL1_LineSize, val) + 4;
281  u32 *ccsidr = vcpu->arch.ccsidr;
282  u32 i;
283 
284  if ((val & CCSIDR_EL1_RES0) ||
285  line_size < get_min_cache_line_size(csselr & CSSELR_EL1_InD))
286  return -EINVAL;
287 
288  if (!ccsidr) {
289  if (val == get_ccsidr(vcpu, csselr))
290  return 0;
291 
292  ccsidr = kmalloc_array(CSSELR_MAX, sizeof(u32), GFP_KERNEL_ACCOUNT);
293  if (!ccsidr)
294  return -ENOMEM;
295 
296  for (i = 0; i < CSSELR_MAX; i++)
297  ccsidr[i] = get_ccsidr(vcpu, i);
298 
299  vcpu->arch.ccsidr = ccsidr;
300  }
301 
302  ccsidr[csselr] = val;
303 
304  return 0;
305 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_clidr()

static int set_clidr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1944 of file sys_regs.c.

1946 {
1947  u64 ctr_el0 = read_sanitised_ftr_reg(SYS_CTR_EL0);
1948  u64 idc = !CLIDR_LOC(val) || (!CLIDR_LOUIS(val) && !CLIDR_LOUU(val));
1949 
1950  if ((val & CLIDR_EL1_RES0) || (!(ctr_el0 & CTR_EL0_IDC) && idc))
1951  return -EINVAL;
1952 
1953  __vcpu_sys_reg(vcpu, rd->reg) = val;
1954 
1955  return 0;
1956 }

◆ set_id_aa64dfr0_el1()

static int set_id_aa64dfr0_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1713 of file sys_regs.c.

1716 {
1717  u8 debugver = SYS_FIELD_GET(ID_AA64DFR0_EL1, DebugVer, val);
1718  u8 pmuver = SYS_FIELD_GET(ID_AA64DFR0_EL1, PMUVer, val);
1719 
1720  /*
1721  * Prior to commit 3d0dba5764b9 ("KVM: arm64: PMU: Move the
1722  * ID_AA64DFR0_EL1.PMUver limit to VM creation"), KVM erroneously
1723  * exposed an IMP_DEF PMU to userspace and the guest on systems w/
1724  * non-architectural PMUs. Of course, PMUv3 is the only game in town for
1725  * PMU virtualization, so the IMP_DEF value was rather user-hostile.
1726  *
1727  * At minimum, we're on the hook to allow values that were given to
1728  * userspace by KVM. Cover our tracks here and replace the IMP_DEF value
1729  * with a more sensible NI. The value of an ID register changing under
1730  * the nose of the guest is unfortunate, but is certainly no more
1731  * surprising than an ill-guided PMU driver poking at impdef system
1732  * registers that end in an UNDEF...
1733  */
1734  if (pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
1735  val &= ~ID_AA64DFR0_EL1_PMUVer_MASK;
1736 
1737  /*
1738  * ID_AA64DFR0_EL1.DebugVer is one of those awkward fields with a
1739  * nonzero minimum safe value.
1740  */
1741  if (debugver < ID_AA64DFR0_EL1_DebugVer_IMP)
1742  return -EINVAL;
1743 
1744  return set_id_reg(vcpu, rd, val);
1745 }
Here is the call graph for this function:

◆ set_id_dfr0_el1()

static int set_id_dfr0_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1762 of file sys_regs.c.

1765 {
1766  u8 perfmon = SYS_FIELD_GET(ID_DFR0_EL1, PerfMon, val);
1767  u8 copdbg = SYS_FIELD_GET(ID_DFR0_EL1, CopDbg, val);
1768 
1769  if (perfmon == ID_DFR0_EL1_PerfMon_IMPDEF) {
1770  val &= ~ID_DFR0_EL1_PerfMon_MASK;
1771  perfmon = 0;
1772  }
1773 
1774  /*
1775  * Allow DFR0_EL1.PerfMon to be set from userspace as long as
1776  * it doesn't promise more than what the HW gives us on the
1777  * AArch64 side (as everything is emulated with that), and
1778  * that this is a PMUv3.
1779  */
1780  if (perfmon != 0 && perfmon < ID_DFR0_EL1_PerfMon_PMUv3)
1781  return -EINVAL;
1782 
1783  if (copdbg < ID_DFR0_EL1_CopDbg_Armv8)
1784  return -EINVAL;
1785 
1786  return set_id_reg(vcpu, rd, val);
1787 }
Here is the call graph for this function:

◆ set_id_reg()

static int set_id_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1815 of file sys_regs.c.

1817 {
1818  u32 id = reg_to_encoding(rd);
1819  int ret;
1820 
1821  mutex_lock(&vcpu->kvm->arch.config_lock);
1822 
1823  /*
1824  * Once the VM has started the ID registers are immutable. Reject any
1825  * write that does not match the final register value.
1826  */
1827  if (kvm_vm_has_ran_once(vcpu->kvm)) {
1828  if (val != read_id_reg(vcpu, rd))
1829  ret = -EBUSY;
1830  else
1831  ret = 0;
1832 
1833  mutex_unlock(&vcpu->kvm->arch.config_lock);
1834  return ret;
1835  }
1836 
1837  ret = arm64_check_features(vcpu, rd, val);
1838  if (!ret)
1839  IDREG(vcpu->kvm, id) = val;
1840 
1841  mutex_unlock(&vcpu->kvm->arch.config_lock);
1842 
1843  /*
1844  * arm64_check_features() returns -E2BIG to indicate the register's
1845  * feature set is a superset of the maximally-allowed register value.
1846  * While it would be nice to precisely describe this to userspace, the
1847  * existing UAPI for KVM_SET_ONE_REG has it that invalid register
1848  * writes return -EINVAL.
1849  */
1850  if (ret == -E2BIG)
1851  ret = -EINVAL;
1852  return ret;
1853 }
static int arm64_check_features(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 val)
Definition: sys_regs.c:1450
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_invariant_sys_reg()

static int set_invariant_sys_reg ( u64  id,
u64 __user *  uaddr 
)
static

Definition at line 3607 of file sys_regs.c.

3608 {
3609  const struct sys_reg_desc *r;
3610  u64 val;
3611 
3612  r = get_reg_by_id(id, invariant_sys_regs,
3613  ARRAY_SIZE(invariant_sys_regs));
3614  if (!r)
3615  return -ENOENT;
3616 
3617  if (get_user(val, uaddr))
3618  return -EFAULT;
3619 
3620  /* This is what we mean by invariant: you can't change it. */
3621  if (r->val != val)
3622  return -EINVAL;
3623 
3624  return 0;
3625 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_oslsr_el1()

static int set_oslsr_el1 ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 551 of file sys_regs.c.

553 {
554  /*
555  * The only modifiable bit is the OSLK bit. Refuse the write if
556  * userspace attempts to change any other bit in the register.
557  */
558  if ((val ^ rd->val) & ~OSLSR_EL1_OSLK)
559  return -EINVAL;
560 
561  __vcpu_sys_reg(vcpu, rd->reg) = val;
562  return 0;
563 }

◆ set_pmcr()

static int set_pmcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r,
u64  val 
)
static

Definition at line 1269 of file sys_regs.c.

1271 {
1272  u8 new_n = FIELD_GET(ARMV8_PMU_PMCR_N, val);
1273  struct kvm *kvm = vcpu->kvm;
1274 
1275  mutex_lock(&kvm->arch.config_lock);
1276 
1277  /*
1278  * The vCPU can't have more counters than the PMU hardware
1279  * implements. Ignore this error to maintain compatibility
1280  * with the existing KVM behavior.
1281  */
1282  if (!kvm_vm_has_ran_once(kvm) &&
1283  new_n <= kvm_arm_pmu_get_max_counters(kvm))
1284  kvm->arch.pmcr_n = new_n;
1285 
1286  mutex_unlock(&kvm->arch.config_lock);
1287 
1288  /*
1289  * Ignore writes to RES0 bits, read only bits that are cleared on
1290  * vCPU reset, and writable bits that KVM doesn't support yet.
1291  * (i.e. only PMCR.N and bits [7:0] are mutable from userspace)
1292  * The LP bit is RES0 when FEAT_PMUv3p5 is not supported on the vCPU.
1293  * But, we leave the bit as it is here, as the vCPU's PMUver might
1294  * be changed later (NOTE: the bit will be cleared on first vCPU run
1295  * if necessary).
1296  */
1297  val &= ARMV8_PMU_PMCR_MASK;
1298 
1299  /* The LC bit is RES1 when AArch32 is not supported */
1300  if (!kvm_supports_32bit_el0())
1301  val |= ARMV8_PMU_PMCR_LC;
1302 
1303  __vcpu_sys_reg(vcpu, r->reg) = val;
1304  return 0;
1305 }
u8 kvm_arm_pmu_get_max_counters(struct kvm *kvm)
Definition: pmu-emul.c:908
Here is the call graph for this function:

◆ set_pmreg()

static int set_pmreg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc r,
u64  val 
)
static

Definition at line 1120 of file sys_regs.c.

1121 {
1122  bool set;
1123 
1124  val &= kvm_pmu_valid_counter_mask(vcpu);
1125 
1126  switch (r->reg) {
1127  case PMOVSSET_EL0:
1128  /* CRm[1] being set indicates a SET register, and CLR otherwise */
1129  set = r->CRm & 2;
1130  break;
1131  default:
1132  /* Op2[0] being set indicates a SET register, and CLR otherwise */
1133  set = r->Op2 & 1;
1134  break;
1135  }
1136 
1137  if (set)
1138  __vcpu_sys_reg(vcpu, r->reg) |= val;
1139  else
1140  __vcpu_sys_reg(vcpu, r->reg) &= ~val;
1141 
1142  return 0;
1143 }
Here is the call graph for this function:

◆ set_wcr()

static int set_wcr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 782 of file sys_regs.c.

784 {
785  vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm] = val;
786  return 0;
787 }

◆ set_wi_reg()

static int set_wi_reg ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 1862 of file sys_regs.c.

1864 {
1865  return 0;
1866 }

◆ set_wvr()

static int set_wvr ( struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64  val 
)
static

Definition at line 745 of file sys_regs.c.

747 {
748  vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm] = val;
749  return 0;
750 }

◆ sve_visibility()

static unsigned int sve_visibility ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd 
)
static

Definition at line 1639 of file sys_regs.c.

1641 {
1642  if (vcpu_has_sve(vcpu))
1643  return 0;
1644 
1645  return REG_HIDDEN;
1646 }

◆ sys_reg_to_index()

static u64 sys_reg_to_index ( const struct sys_reg_desc reg)
static

Definition at line 3784 of file sys_regs.c.

3785 {
3786  return (KVM_REG_ARM64 | KVM_REG_SIZE_U64 |
3787  KVM_REG_ARM64_SYSREG |
3788  (reg->Op0 << KVM_REG_ARM64_SYSREG_OP0_SHIFT) |
3789  (reg->Op1 << KVM_REG_ARM64_SYSREG_OP1_SHIFT) |
3790  (reg->CRn << KVM_REG_ARM64_SYSREG_CRN_SHIFT) |
3791  (reg->CRm << KVM_REG_ARM64_SYSREG_CRM_SHIFT) |
3792  (reg->Op2 << KVM_REG_ARM64_SYSREG_OP2_SHIFT));
3793 }
Here is the caller graph for this function:

◆ trap_bcr()

static bool trap_bcr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd 
)
static

Definition at line 691 of file sys_regs.c.

694 {
695  u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->CRm];
696 
697  if (p->is_write)
698  reg_to_dbg(vcpu, p, rd, dbg_reg);
699  else
700  dbg_to_reg(vcpu, p, rd, dbg_reg);
701 
702  trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
703 
704  return true;
705 }
static void reg_to_dbg(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd, u64 *dbg_reg)
Definition: sys_regs.c:626
static void dbg_to_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *rd, u64 *dbg_reg)
Definition: sys_regs.c:643
Here is the call graph for this function:

◆ trap_bvr()

static bool trap_bvr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd 
)
static

Definition at line 654 of file sys_regs.c.

657 {
658  u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->CRm];
659 
660  if (p->is_write)
661  reg_to_dbg(vcpu, p, rd, dbg_reg);
662  else
663  dbg_to_reg(vcpu, p, rd, dbg_reg);
664 
665  trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
666 
667  return true;
668 }
Here is the call graph for this function:

◆ trap_dbgauthstatus_el1()

static bool trap_dbgauthstatus_el1 ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 565 of file sys_regs.c.

568 {
569  if (p->is_write) {
570  return ignore_write(vcpu, p);
571  } else {
572  p->regval = read_sysreg(dbgauthstatus_el1);
573  return true;
574  }
575 }
Here is the call graph for this function:

◆ trap_dbgdidr()

static bool trap_dbgdidr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 2732 of file sys_regs.c.

2735 {
2736  if (p->is_write) {
2737  return ignore_write(vcpu, p);
2738  } else {
2739  u64 dfr = IDREG(vcpu->kvm, SYS_ID_AA64DFR0_EL1);
2740  u64 pfr = IDREG(vcpu->kvm, SYS_ID_AA64PFR0_EL1);
2741  u32 el3 = !!SYS_FIELD_GET(ID_AA64PFR0_EL1, EL3, pfr);
2742 
2743  p->regval = ((SYS_FIELD_GET(ID_AA64DFR0_EL1, WRPs, dfr) << 28) |
2744  (SYS_FIELD_GET(ID_AA64DFR0_EL1, BRPs, dfr) << 24) |
2745  (SYS_FIELD_GET(ID_AA64DFR0_EL1, CTX_CMPs, dfr) << 20) |
2746  (SYS_FIELD_GET(ID_AA64DFR0_EL1, DebugVer, dfr) << 16) |
2747  (1 << 15) | (el3 << 14) | (el3 << 12));
2748  return true;
2749  }
2750 }

◆ trap_debug_regs()

static bool trap_debug_regs ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 604 of file sys_regs.c.

607 {
608  access_rw(vcpu, p, r);
609  if (p->is_write)
610  vcpu_set_flag(vcpu, DEBUG_DIRTY);
611 
612  trace_trap_reg(__func__, r->reg, p->is_write, p->regval);
613 
614  return true;
615 }
static bool access_rw(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:307
Here is the call graph for this function:

◆ trap_loregion()

static bool trap_loregion ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 504 of file sys_regs.c.

507 {
508  u64 val = IDREG(vcpu->kvm, SYS_ID_AA64MMFR1_EL1);
509  u32 sr = reg_to_encoding(r);
510 
511  if (!(val & (0xfUL << ID_AA64MMFR1_EL1_LO_SHIFT))) {
512  kvm_inject_undefined(vcpu);
513  return false;
514  }
515 
516  if (p->is_write && sr == SYS_LORID_EL1)
517  return write_to_read_only(vcpu, p, r);
518 
519  return trap_raz_wi(vcpu, p, r);
520 }
static bool trap_raz_wi(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:480
Here is the call graph for this function:

◆ trap_oslar_el1()

static bool trap_oslar_el1 ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 522 of file sys_regs.c.

525 {
526  u64 oslsr;
527 
528  if (!p->is_write)
529  return read_from_write_only(vcpu, p, r);
530 
531  /* Forward the OSLK bit to OSLSR */
532  oslsr = __vcpu_sys_reg(vcpu, OSLSR_EL1) & ~OSLSR_EL1_OSLK;
533  if (p->regval & OSLAR_EL1_OSLK)
534  oslsr |= OSLSR_EL1_OSLK;
535 
536  __vcpu_sys_reg(vcpu, OSLSR_EL1) = oslsr;
537  return true;
538 }
Here is the call graph for this function:

◆ trap_oslsr_el1()

static bool trap_oslsr_el1 ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 540 of file sys_regs.c.

543 {
544  if (p->is_write)
545  return write_to_read_only(vcpu, p, r);
546 
547  p->regval = __vcpu_sys_reg(vcpu, r->reg);
548  return true;
549 }
Here is the call graph for this function:

◆ trap_raz_wi()

static bool trap_raz_wi ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 480 of file sys_regs.c.

483 {
484  if (p->is_write)
485  return ignore_write(vcpu, p);
486  else
487  return read_zero(vcpu, p);
488 }
static bool read_zero(struct kvm_vcpu *vcpu, struct sys_reg_params *p)
Definition: sys_regs.h:128
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trap_undef()

static bool trap_undef ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 490 of file sys_regs.c.

493 {
494  kvm_inject_undefined(vcpu);
495  return false;
496 }
Here is the call graph for this function:

◆ trap_wcr()

static bool trap_wcr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd 
)
static

Definition at line 766 of file sys_regs.c.

769 {
770  u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->CRm];
771 
772  if (p->is_write)
773  reg_to_dbg(vcpu, p, rd, dbg_reg);
774  else
775  dbg_to_reg(vcpu, p, rd, dbg_reg);
776 
777  trace_trap_reg(__func__, rd->CRm, p->is_write, *dbg_reg);
778 
779  return true;
780 }
Here is the call graph for this function:

◆ trap_wvr()

static bool trap_wvr ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc rd 
)
static

Definition at line 728 of file sys_regs.c.

731 {
732  u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm];
733 
734  if (p->is_write)
735  reg_to_dbg(vcpu, p, rd, dbg_reg);
736  else
737  dbg_to_reg(vcpu, p, rd, dbg_reg);
738 
739  trace_trap_reg(__func__, rd->CRm, p->is_write,
740  vcpu->arch.vcpu_debug_state.dbg_wvr[rd->CRm]);
741 
742  return true;
743 }
Here is the call graph for this function:

◆ undef_access()

static bool undef_access ( struct kvm_vcpu *  vcpu,
struct sys_reg_params p,
const struct sys_reg_desc r 
)
static

Definition at line 1334 of file sys_regs.c.

1336 {
1337  kvm_inject_undefined(vcpu);
1338 
1339  return false;
1340 }
Here is the call graph for this function:

◆ unhandled_cp_access()

static void unhandled_cp_access ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params 
)
static

Definition at line 3134 of file sys_regs.c.

3136 {
3137  u8 esr_ec = kvm_vcpu_trap_get_class(vcpu);
3138  int cp = -1;
3139 
3140  switch (esr_ec) {
3141  case ESR_ELx_EC_CP15_32:
3142  case ESR_ELx_EC_CP15_64:
3143  cp = 15;
3144  break;
3145  case ESR_ELx_EC_CP14_MR:
3146  case ESR_ELx_EC_CP14_64:
3147  cp = 14;
3148  break;
3149  default:
3150  WARN_ON(1);
3151  }
3152 
3153  print_sys_reg_msg(params,
3154  "Unsupported guest CP%d access at: %08lx [%08lx]\n",
3155  cp, *vcpu_pc(vcpu), *vcpu_cpsr(vcpu));
3156  kvm_inject_undefined(vcpu);
3157 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcpu_read_sys_reg()

u64 vcpu_read_sys_reg ( const struct kvm_vcpu *  vcpu,
int  reg 
)

Definition at line 128 of file sys_regs.c.

129 {
130  u64 val = 0x8badf00d8badf00d;
131  u64 (*xlate)(u64) = NULL;
132  unsigned int el1r;
133 
134  if (!vcpu_get_flag(vcpu, SYSREGS_ON_CPU))
135  goto memory_read;
136 
137  if (unlikely(get_el2_to_el1_mapping(reg, &el1r, &xlate))) {
138  if (!is_hyp_ctxt(vcpu))
139  goto memory_read;
140 
141  /*
142  * If this register does not have an EL1 counterpart,
143  * then read the stored EL2 version.
144  */
145  if (reg == el1r)
146  goto memory_read;
147 
148  /*
149  * If we have a non-VHE guest and that the sysreg
150  * requires translation to be used at EL1, use the
151  * in-memory copy instead.
152  */
153  if (!vcpu_el2_e2h_is_set(vcpu) && xlate)
154  goto memory_read;
155 
156  /* Get the current version of the EL1 counterpart. */
157  WARN_ON(!__vcpu_read_sys_reg_from_cpu(el1r, &val));
158  return val;
159  }
160 
161  /* EL1 register can't be on the CPU if the guest is in vEL2. */
162  if (unlikely(is_hyp_ctxt(vcpu)))
163  goto memory_read;
164 
165  if (__vcpu_read_sys_reg_from_cpu(reg, &val))
166  return val;
167 
168 memory_read:
169  return __vcpu_sys_reg(vcpu, reg);
170 }
static bool get_el2_to_el1_mapping(unsigned int reg, unsigned int *el1r, u64(**xlate)(u64))
Definition: sys_regs.c:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vcpu_write_sys_reg()

void vcpu_write_sys_reg ( struct kvm_vcpu *  vcpu,
u64  val,
int  reg 
)

Definition at line 172 of file sys_regs.c.

173 {
174  u64 (*xlate)(u64) = NULL;
175  unsigned int el1r;
176 
177  if (!vcpu_get_flag(vcpu, SYSREGS_ON_CPU))
178  goto memory_write;
179 
180  if (unlikely(get_el2_to_el1_mapping(reg, &el1r, &xlate))) {
181  if (!is_hyp_ctxt(vcpu))
182  goto memory_write;
183 
184  /*
185  * Always store a copy of the write to memory to avoid having
186  * to reverse-translate virtual EL2 system registers for a
187  * non-VHE guest hypervisor.
188  */
189  __vcpu_sys_reg(vcpu, reg) = val;
190 
191  /* No EL1 counterpart? We're done here.? */
192  if (reg == el1r)
193  return;
194 
195  if (!vcpu_el2_e2h_is_set(vcpu) && xlate)
196  val = xlate(val);
197 
198  /* Redirect this to the EL1 version of the register. */
199  WARN_ON(!__vcpu_write_sys_reg_to_cpu(val, el1r));
200  return;
201  }
202 
203  /* EL1 register can't be on the CPU if the guest is in vEL2. */
204  if (unlikely(is_hyp_ctxt(vcpu)))
205  goto memory_write;
206 
207  if (__vcpu_write_sys_reg_to_cpu(val, reg))
208  return;
209 
210 memory_write:
211  __vcpu_sys_reg(vcpu, reg) = val;
212 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ walk_one_sys_reg()

static int walk_one_sys_reg ( const struct kvm_vcpu *  vcpu,
const struct sys_reg_desc rd,
u64 __user **  uind,
unsigned int *  total 
)
static

Definition at line 3807 of file sys_regs.c.

3811 {
3812  /*
3813  * Ignore registers we trap but don't save,
3814  * and for which no custom user accessor is provided.
3815  */
3816  if (!(rd->reg || rd->get_user))
3817  return 0;
3818 
3819  if (sysreg_hidden_user(vcpu, rd))
3820  return 0;
3821 
3822  if (!copy_reg_to_user(rd, uind))
3823  return -EFAULT;
3824 
3825  (*total)++;
3826  return 0;
3827 }
static bool copy_reg_to_user(const struct sys_reg_desc *reg, u64 __user **uind)
Definition: sys_regs.c:3795
Here is the call graph for this function:
Here is the caller graph for this function:

◆ walk_sys_regs()

static int walk_sys_regs ( struct kvm_vcpu *  vcpu,
u64 __user *  uind 
)
static

Definition at line 3830 of file sys_regs.c.

3831 {
3832  const struct sys_reg_desc *i2, *end2;
3833  unsigned int total = 0;
3834  int err;
3835 
3836  i2 = sys_reg_descs;
3837  end2 = sys_reg_descs + ARRAY_SIZE(sys_reg_descs);
3838 
3839  while (i2 != end2) {
3840  err = walk_one_sys_reg(vcpu, i2++, &uind, &total);
3841  if (err)
3842  return err;
3843  }
3844  return total;
3845 }
static int walk_one_sys_reg(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, u64 __user **uind, unsigned int *total)
Definition: sys_regs.c:3807
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_demux_regids()

static int write_demux_regids ( u64 __user *  uindices)
static

Definition at line 3770 of file sys_regs.c.

3771 {
3772  u64 val = KVM_REG_ARM64 | KVM_REG_SIZE_U32 | KVM_REG_ARM_DEMUX;
3773  unsigned int i;
3774 
3775  val |= KVM_REG_ARM_DEMUX_ID_CCSIDR;
3776  for (i = 0; i < CSSELR_MAX; i++) {
3777  if (put_user(val | i, uindices))
3778  return -EFAULT;
3779  uindices++;
3780  }
3781  return 0;
3782 }
Here is the caller graph for this function:

◆ write_to_read_only()

static bool write_to_read_only ( struct kvm_vcpu *  vcpu,
struct sys_reg_params params,
const struct sys_reg_desc r 
)
static

Definition at line 67 of file sys_regs.c.

70 {
71  return bad_trap(vcpu, params, r,
72  "sys_reg write to read-only register");
73 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ __ro_after_init

struct sys_reg_desc invariant_sys_regs [] __ro_after_init
static
Initial value:
= {
{ SYS_DESC(SYS_MIDR_EL1), NULL, get_midr_el1 },
{ SYS_DESC(SYS_REVIDR_EL1), NULL, get_revidr_el1 },
{ SYS_DESC(SYS_AIDR_EL1), NULL, get_aidr_el1 },
{ SYS_DESC(SYS_CTR_EL0), NULL, get_ctr_el0 },
}
static u64 get_ctr_el0(struct kvm_vcpu *v, const struct sys_reg_desc *r)
Definition: sys_regs.c:3581

Definition at line 3588 of file sys_regs.c.

◆ cp14_64_regs

const struct sys_reg_desc cp14_64_regs[]
static
Initial value:
= {
{ Op1( 0), CRm( 1), .access = trap_raz_wi },
{ Op1( 0), CRm( 2), .access = trap_raz_wi },
}

Definition at line 2732 of file sys_regs.c.

◆ cp14_regs

const struct sys_reg_desc cp14_regs[]
static

Definition at line 2732 of file sys_regs.c.

◆ cp15_64_regs

const struct sys_reg_desc cp15_64_regs[]
static
Initial value:
= {
{ Op1( 0), CRn( 0), CRm( 2), Op2( 0), access_vm_reg, NULL, TTBR0_EL1 },
{ CP15_PMU_SYS_REG(DIRECT, 0, 0, 9, 0), .access = access_pmu_evcntr },
{ Op1( 0), CRn( 0), CRm(12), Op2( 0), access_gic_sgi },
{ SYS_DESC(SYS_AARCH32_CNTPCT), access_arch_timer },
{ Op1( 1), CRn( 0), CRm( 2), Op2( 0), access_vm_reg, NULL, TTBR1_EL1 },
{ Op1( 1), CRn( 0), CRm(12), Op2( 0), access_gic_sgi },
{ Op1( 2), CRn( 0), CRm(12), Op2( 0), access_gic_sgi },
{ SYS_DESC(SYS_AARCH32_CNTP_CVAL), access_arch_timer },
{ SYS_DESC(SYS_AARCH32_CNTPCTSS), access_arch_timer },
}
static bool access_vm_reg(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:378
static bool access_arch_timer(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:1368
static bool access_gic_sgi(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r)
Definition: sys_regs.c:424

Definition at line 2732 of file sys_regs.c.

◆ cp15_regs

const struct sys_reg_desc cp15_regs[]
static

Definition at line 2732 of file sys_regs.c.

◆ first_idreg

const struct sys_reg_desc* first_idreg
static

Definition at line 2730 of file sys_regs.c.

◆ sys_reg_descs

const struct sys_reg_desc sys_reg_descs[]
static

Definition at line 2165 of file sys_regs.c.