{ \
bool res; \
\
- res = vreg_emulate_sysreg64(regs, hsr, vreg_emulate_##reg); \
+ res = vreg_emulate_sysreg(regs, hsr, vreg_emulate_##reg); \
ASSERT(res); \
break; \
}
#define WRITE_SYSREG_SZ(sz, val, sysreg...) WRITE_SYSREG##sz(val, sysreg)
#endif
+/*
+ * type32_t is defined as register_t due to the vreg_emulate_cp32 and
+ * vreg_emulate_sysreg taking function pointer with register_t type used for
+ * passing register's value.
+ */
+typedef register_t type32_t;
+typedef uint64_t type64_t;
+
/* The name is passed from the upper macro to workaround macro expansion. */
#define TVM_REG(sz, func, reg...) \
-static bool func(struct cpu_user_regs *regs, uint##sz##_t *r, bool read) \
+static bool func(struct cpu_user_regs *regs, type##sz##_t *r, bool read) \
{ \
struct vcpu *v = current; \
bool cache_enabled = vcpu_has_cache_enabled(v); \
#else /* CONFIG_ARM_64 */
#define TVM_REG32_COMBINED(lowreg, hireg, xreg) \
-static bool vreg_emulate_##xreg(struct cpu_user_regs *regs, uint32_t *r, \
+static bool vreg_emulate_##xreg(struct cpu_user_regs *regs, register_t *r, \
bool read, bool hi) \
{ \
struct vcpu *v = current; \
return true; \
} \
\
-static bool vreg_emulate_##lowreg(struct cpu_user_regs *regs, uint32_t *r, \
+static bool vreg_emulate_##lowreg(struct cpu_user_regs *regs, register_t *r,\
bool read) \
{ \
return vreg_emulate_##xreg(regs, r, read, false); \
} \
\
-static bool vreg_emulate_##hireg(struct cpu_user_regs *regs, uint32_t *r, \
+static bool vreg_emulate_##hireg(struct cpu_user_regs *regs, register_t *r, \
bool read) \
{ \
return vreg_emulate_##xreg(regs, r, read, true); \
switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
{
case HSR_SYSREG_ICC_SGI1R_EL1:
- return vreg_emulate_sysreg64(regs, hsr, vgic_v3_emulate_sgi1r);
+ return vreg_emulate_sysreg(regs, hsr, vgic_v3_emulate_sgi1r);
default:
return false;
WRITE_SYSREG(v->arch.virt_timer.ctl, CNTV_CTL_EL0);
}
-static bool vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, bool read)
+static bool vtimer_cntp_ctl(struct cpu_user_regs *regs, register_t *r,
+ bool read)
{
struct vcpu *v = current;
s_time_t expires;
return true;
}
-static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r,
+static bool vtimer_cntp_tval(struct cpu_user_regs *regs, register_t *r,
bool read)
{
struct vcpu *v = current;
switch ( hsr.bits & HSR_SYSREG_REGS_MASK )
{
case HSR_SYSREG_CNTP_CTL_EL0:
- return vreg_emulate_sysreg32(regs, hsr, vtimer_cntp_ctl);
+ return vreg_emulate_sysreg(regs, hsr, vtimer_cntp_ctl);
case HSR_SYSREG_CNTP_TVAL_EL0:
- return vreg_emulate_sysreg32(regs, hsr, vtimer_cntp_tval);
+ return vreg_emulate_sysreg(regs, hsr, vtimer_cntp_tval);
case HSR_SYSREG_CNTP_CVAL_EL0:
- return vreg_emulate_sysreg64(regs, hsr, vtimer_cntp_cval);
+ return vreg_emulate_sysreg(regs, hsr, vtimer_cntp_cval);
default:
return false;
#define CNTKCTL_EL1_EL0PTEN (1u<<9) /* Expose phys timer registers to EL0 */
/* Timer control registers */
-#define CNTx_CTL_ENABLE (1u<<0) /* Enable timer */
+#define CNTx_CTL_ENABLE (1ul<<0) /* Enable timer */
#define CNTx_CTL_MASK (1ul<<1) /* Mask IRQ */
-#define CNTx_CTL_PENDING (1u<<2) /* IRQ pending */
+#define CNTx_CTL_PENDING (1ul<<2) /* IRQ pending */
/* Timer frequency mask */
#define CNTFRQ_MASK GENMASK(31, 0)
#ifndef __ASM_ARM_VREG__
#define __ASM_ARM_VREG__
-typedef bool (*vreg_reg32_fn_t)(struct cpu_user_regs *regs, uint32_t *r,
- bool read);
typedef bool (*vreg_reg64_fn_t)(struct cpu_user_regs *regs, uint64_t *r,
bool read);
+typedef bool (*vreg_reg_fn_t)(struct cpu_user_regs *regs, register_t *r,
+ bool read);
static inline bool vreg_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr,
- vreg_reg32_fn_t fn)
+ vreg_reg_fn_t fn)
{
struct hsr_cp32 cp32 = hsr.cp32;
/*
* implementation error in the emulation (such as not correctly
* setting r).
*/
- uint32_t r = 0;
+ register_t r = 0;
bool ret;
if ( !cp32.read )
}
#ifdef CONFIG_ARM_64
-static inline bool vreg_emulate_sysreg32(struct cpu_user_regs *regs, union hsr hsr,
- vreg_reg32_fn_t fn)
+static inline bool vreg_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr,
+ vreg_reg_fn_t fn)
{
struct hsr_sysreg sysreg = hsr.sysreg;
- uint32_t r = 0;
+ register_t r = 0;
bool ret;
if ( !sysreg.read )
return ret;
}
-
-static inline bool vreg_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr,
- vreg_reg64_fn_t fn)
-{
- struct hsr_sysreg sysreg = hsr.sysreg;
- /*
- * Initialize to zero to avoid leaking data if there is an
- * implementation error in the emulation (such as not correctly
- * setting x).
- */
- uint64_t x = 0;
- bool ret;
-
- if ( !sysreg.read )
- x = get_user_reg(regs, sysreg.reg);
-
- ret = fn(regs, &x, sysreg.read);
-
- if ( ret && sysreg.read )
- set_user_reg(regs, sysreg.reg, x);
-
- return ret;
-}
-
#endif
#define VREG_REG_MASK(size) ((~0UL) >> (BITS_PER_LONG - ((1 << (size)) * 8)))