mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
target/i386: Restrict SoftMMU mmu_index() to TCG
Move x86_cpu_mmu_index() to tcg-cpu.c, convert CPUClass::mmu_index() to TCGCPUOps::mmu_index(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250401080938.32278-10-philmd@linaro.org>
This commit is contained in:
committed by
Richard Henderson
parent
611c34a745
commit
8480f7c745
@@ -8664,23 +8664,6 @@ static bool x86_cpu_has_work(CPUState *cs)
|
||||
}
|
||||
#endif /* !CONFIG_USER_ONLY */
|
||||
|
||||
int x86_mmu_index_pl(CPUX86State *env, unsigned pl)
|
||||
{
|
||||
int mmu_index_32 = (env->hflags & HF_CS64_MASK) ? 0 : 1;
|
||||
int mmu_index_base =
|
||||
pl == 3 ? MMU_USER64_IDX :
|
||||
!(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP64_IDX :
|
||||
(env->eflags & AC_MASK) ? MMU_KNOSMAP64_IDX : MMU_KSMAP64_IDX;
|
||||
|
||||
return mmu_index_base + mmu_index_32;
|
||||
}
|
||||
|
||||
static int x86_cpu_mmu_index(CPUState *cs, bool ifetch)
|
||||
{
|
||||
CPUX86State *env = cpu_env(cs);
|
||||
return x86_mmu_index_pl(env, env->hflags & HF_CPL_MASK);
|
||||
}
|
||||
|
||||
static void x86_disas_set_info(CPUState *cs, disassemble_info *info)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
@@ -8922,7 +8905,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
|
||||
|
||||
cc->class_by_name = x86_cpu_class_by_name;
|
||||
cc->parse_features = x86_cpu_parse_featurestr;
|
||||
cc->mmu_index = x86_cpu_mmu_index;
|
||||
cc->dump_state = x86_cpu_dump_state;
|
||||
cc->set_pc = x86_cpu_set_pc;
|
||||
cc->get_pc = x86_cpu_get_pc;
|
||||
|
||||
@@ -2597,8 +2597,6 @@ static inline bool is_mmu_index_32(int mmu_index)
|
||||
return mmu_index & 1;
|
||||
}
|
||||
|
||||
int x86_mmu_index_pl(CPUX86State *env, unsigned pl);
|
||||
|
||||
#define CC_DST (env->cc_dst)
|
||||
#define CC_SRC (env->cc_src)
|
||||
#define CC_SRC2 (env->cc_src2)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "helper-tcg.h"
|
||||
#include "seg_helper.h"
|
||||
#include "access.h"
|
||||
#include "tcg-cpu.h"
|
||||
|
||||
#ifdef TARGET_X86_64
|
||||
#define SET_ESP(val, sp_mask) \
|
||||
|
||||
@@ -94,6 +94,23 @@ static void x86_restore_state_to_opc(CPUState *cs,
|
||||
}
|
||||
}
|
||||
|
||||
int x86_mmu_index_pl(CPUX86State *env, unsigned pl)
|
||||
{
|
||||
int mmu_index_32 = (env->hflags & HF_CS64_MASK) ? 0 : 1;
|
||||
int mmu_index_base =
|
||||
pl == 3 ? MMU_USER64_IDX :
|
||||
!(env->hflags & HF_SMAP_MASK) ? MMU_KNOSMAP64_IDX :
|
||||
(env->eflags & AC_MASK) ? MMU_KNOSMAP64_IDX : MMU_KSMAP64_IDX;
|
||||
|
||||
return mmu_index_base + mmu_index_32;
|
||||
}
|
||||
|
||||
static int x86_cpu_mmu_index(CPUState *cs, bool ifetch)
|
||||
{
|
||||
CPUX86State *env = cpu_env(cs);
|
||||
return x86_mmu_index_pl(env, env->hflags & HF_CPL_MASK);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
static bool x86_debug_check_breakpoint(CPUState *cs)
|
||||
{
|
||||
@@ -112,6 +129,7 @@ static const TCGCPUOps x86_tcg_ops = {
|
||||
.translate_code = x86_translate_code,
|
||||
.synchronize_from_tb = x86_cpu_synchronize_from_tb,
|
||||
.restore_state_to_opc = x86_restore_state_to_opc,
|
||||
.mmu_index = x86_cpu_mmu_index,
|
||||
.cpu_exec_enter = x86_cpu_exec_enter,
|
||||
.cpu_exec_exit = x86_cpu_exec_exit,
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
|
||||
@@ -78,4 +78,6 @@ QEMU_BUILD_BUG_ON(offsetof(X86XSaveArea, pkru_state) != XSAVE_PKRU_OFFSET);
|
||||
|
||||
bool tcg_cpu_realizefn(CPUState *cs, Error **errp);
|
||||
|
||||
int x86_mmu_index_pl(CPUX86State *env, unsigned pl);
|
||||
|
||||
#endif /* TCG_CPU_H */
|
||||
|
||||
Reference in New Issue
Block a user