mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
target/arm: Update get_a64_user_mem_index for VHE
The EL2&0 translation regime is affected by Load Register (unpriv). The code structure used here will facilitate later changes in this area for implementing UAO and NV. Tested-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20200206105448.4726-36-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
a7469a3c1e
commit
cc28fc30e3
4 changed files with 57 additions and 20 deletions
|
@ -3214,10 +3214,10 @@ typedef ARMCPU ArchCPU;
|
||||||
* | | | TBFLAG_A32 | |
|
* | | | TBFLAG_A32 | |
|
||||||
* | | +-----+----------+ TBFLAG_AM32 |
|
* | | +-----+----------+ TBFLAG_AM32 |
|
||||||
* | TBFLAG_ANY | |TBFLAG_M32| |
|
* | TBFLAG_ANY | |TBFLAG_M32| |
|
||||||
* | | +-------------------------|
|
* | | +-+----------+--------------|
|
||||||
* | | | TBFLAG_A64 |
|
* | | | TBFLAG_A64 |
|
||||||
* +--------------+-----------+-------------------------+
|
* +--------------+---------+---------------------------+
|
||||||
* 31 20 14 0
|
* 31 20 15 0
|
||||||
*
|
*
|
||||||
* Unless otherwise noted, these bits are cached in env->hflags.
|
* Unless otherwise noted, these bits are cached in env->hflags.
|
||||||
*/
|
*/
|
||||||
|
@ -3283,6 +3283,7 @@ FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1)
|
||||||
FIELD(TBFLAG_A64, BT, 9, 1)
|
FIELD(TBFLAG_A64, BT, 9, 1)
|
||||||
FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */
|
FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */
|
||||||
FIELD(TBFLAG_A64, TBID, 12, 2)
|
FIELD(TBFLAG_A64, TBID, 12, 2)
|
||||||
|
FIELD(TBFLAG_A64, UNPRIV, 14, 1)
|
||||||
|
|
||||||
static inline bool bswap_code(bool sctlr_b)
|
static inline bool bswap_code(bool sctlr_b)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12011,6 +12011,28 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Compute the condition for using AccType_UNPRIV for LDTR et al. */
|
||||||
|
/* TODO: ARMv8.2-UAO */
|
||||||
|
switch (mmu_idx) {
|
||||||
|
case ARMMMUIdx_E10_1:
|
||||||
|
case ARMMMUIdx_SE10_1:
|
||||||
|
/* TODO: ARMv8.3-NV */
|
||||||
|
flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1);
|
||||||
|
break;
|
||||||
|
case ARMMMUIdx_E20_2:
|
||||||
|
/* TODO: ARMv8.4-SecEL2 */
|
||||||
|
/*
|
||||||
|
* Note that E20_2 is gated by HCR_EL2.E2H == 1, but E20_0 is
|
||||||
|
* gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR.
|
||||||
|
*/
|
||||||
|
if (env->cp15.hcr_el2 & HCR_TGE) {
|
||||||
|
flags = FIELD_DP32(flags, TBFLAG_A64, UNPRIV, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
|
return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,25 +105,36 @@ void a64_translate_init(void)
|
||||||
offsetof(CPUARMState, exclusive_high), "exclusive_high");
|
offsetof(CPUARMState, exclusive_high), "exclusive_high");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_a64_user_mem_index(DisasContext *s)
|
/*
|
||||||
|
* Return the core mmu_idx to use for A64 "unprivileged load/store" insns
|
||||||
|
*/
|
||||||
|
static int get_a64_user_mem_index(DisasContext *s)
|
||||||
{
|
{
|
||||||
/* Return the core mmu_idx to use for A64 "unprivileged load/store" insns:
|
/*
|
||||||
* if EL1, access as if EL0; otherwise access at current EL
|
* If AccType_UNPRIV is not used, the insn uses AccType_NORMAL,
|
||||||
|
* which is the usual mmu_idx for this cpu state.
|
||||||
*/
|
*/
|
||||||
ARMMMUIdx useridx;
|
ARMMMUIdx useridx = s->mmu_idx;
|
||||||
|
|
||||||
switch (s->mmu_idx) {
|
if (s->unpriv) {
|
||||||
case ARMMMUIdx_E10_1:
|
/*
|
||||||
useridx = ARMMMUIdx_E10_0;
|
* We have pre-computed the condition for AccType_UNPRIV.
|
||||||
break;
|
* Therefore we should never get here with a mmu_idx for
|
||||||
case ARMMMUIdx_SE10_1:
|
* which we do not know the corresponding user mmu_idx.
|
||||||
useridx = ARMMMUIdx_SE10_0;
|
*/
|
||||||
break;
|
switch (useridx) {
|
||||||
case ARMMMUIdx_Stage2:
|
case ARMMMUIdx_E10_1:
|
||||||
g_assert_not_reached();
|
useridx = ARMMMUIdx_E10_0;
|
||||||
default:
|
break;
|
||||||
useridx = s->mmu_idx;
|
case ARMMMUIdx_E20_2:
|
||||||
break;
|
useridx = ARMMMUIdx_E20_0;
|
||||||
|
break;
|
||||||
|
case ARMMMUIdx_SE10_1:
|
||||||
|
useridx = ARMMMUIdx_SE10_0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return arm_to_core_mmu_idx(useridx);
|
return arm_to_core_mmu_idx(useridx);
|
||||||
}
|
}
|
||||||
|
@ -14171,6 +14182,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
|
||||||
dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE);
|
dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE);
|
||||||
dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT);
|
dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT);
|
||||||
dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE);
|
dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE);
|
||||||
|
dc->unpriv = FIELD_EX32(tb_flags, TBFLAG_A64, UNPRIV);
|
||||||
dc->vec_len = 0;
|
dc->vec_len = 0;
|
||||||
dc->vec_stride = 0;
|
dc->vec_stride = 0;
|
||||||
dc->cp_regs = arm_cpu->cp_regs;
|
dc->cp_regs = arm_cpu->cp_regs;
|
||||||
|
|
|
@ -73,6 +73,8 @@ typedef struct DisasContext {
|
||||||
* ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*.
|
* ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*.
|
||||||
*/
|
*/
|
||||||
bool is_ldex;
|
bool is_ldex;
|
||||||
|
/* True if AccType_UNPRIV should be used for LDTR et al */
|
||||||
|
bool unpriv;
|
||||||
/* True if v8.3-PAuth is active. */
|
/* True if v8.3-PAuth is active. */
|
||||||
bool pauth_active;
|
bool pauth_active;
|
||||||
/* True with v8.5-BTI and SCTLR_ELx.BT* set. */
|
/* True with v8.5-BTI and SCTLR_ELx.BT* set. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue