mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-28 20:41:52 -06:00
target/i386: Refactored intercept checks into cpu_svm_has_intercept
Added cpu_svm_has_intercept to reduce duplication when checking the corresponding intercept bit outside of cpu_svm_check_intercept_param Signed-off-by: Lara Lazier <laramglazier@gmail.com> Message-Id: <20210616123907.17765-2-laramglazier@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
f8bb7e1c25
commit
813c6459ee
2 changed files with 76 additions and 61 deletions
|
@ -2149,9 +2149,13 @@ static inline void
|
||||||
cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type,
|
cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type,
|
||||||
uint64_t param, uintptr_t retaddr)
|
uint64_t param, uintptr_t retaddr)
|
||||||
{ /* no-op */ }
|
{ /* no-op */ }
|
||||||
|
static inline bool
|
||||||
|
cpu_svm_has_intercept(CPUX86State *env, uint32_t type)
|
||||||
|
{ return false; }
|
||||||
#else
|
#else
|
||||||
void cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type,
|
void cpu_svm_check_intercept_param(CPUX86State *env1, uint32_t type,
|
||||||
uint64_t param, uintptr_t retaddr);
|
uint64_t param, uintptr_t retaddr);
|
||||||
|
bool cpu_svm_has_intercept(CPUX86State *env, uint32_t type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* apic.c */
|
/* apic.c */
|
||||||
|
|
|
@ -412,6 +412,43 @@ void helper_clgi(CPUX86State *env)
|
||||||
env->hflags2 &= ~HF2_GIF_MASK;
|
env->hflags2 &= ~HF2_GIF_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cpu_svm_has_intercept(CPUX86State *env, uint32_t type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR0 + 8:
|
||||||
|
if (env->intercept_cr_read & (1 << (type - SVM_EXIT_READ_CR0))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SVM_EXIT_WRITE_CR0 ... SVM_EXIT_WRITE_CR0 + 8:
|
||||||
|
if (env->intercept_cr_write & (1 << (type - SVM_EXIT_WRITE_CR0))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SVM_EXIT_READ_DR0 ... SVM_EXIT_READ_DR0 + 7:
|
||||||
|
if (env->intercept_dr_read & (1 << (type - SVM_EXIT_READ_DR0))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SVM_EXIT_WRITE_DR0 ... SVM_EXIT_WRITE_DR0 + 7:
|
||||||
|
if (env->intercept_dr_write & (1 << (type - SVM_EXIT_WRITE_DR0))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SVM_EXIT_EXCP_BASE ... SVM_EXIT_EXCP_BASE + 31:
|
||||||
|
if (env->intercept_exceptions & (1 << (type - SVM_EXIT_EXCP_BASE))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (env->intercept & (1ULL << (type - SVM_EXIT_INTR))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type,
|
void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type,
|
||||||
uint64_t param, uintptr_t retaddr)
|
uint64_t param, uintptr_t retaddr)
|
||||||
{
|
{
|
||||||
|
@ -420,34 +457,12 @@ void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type,
|
||||||
if (likely(!(env->hflags & HF_GUEST_MASK))) {
|
if (likely(!(env->hflags & HF_GUEST_MASK))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
|
||||||
case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR0 + 8:
|
if (!cpu_svm_has_intercept(env, type)) {
|
||||||
if (env->intercept_cr_read & (1 << (type - SVM_EXIT_READ_CR0))) {
|
return;
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case SVM_EXIT_WRITE_CR0 ... SVM_EXIT_WRITE_CR0 + 8:
|
if (type == SVM_EXIT_MSR) {
|
||||||
if (env->intercept_cr_write & (1 << (type - SVM_EXIT_WRITE_CR0))) {
|
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SVM_EXIT_READ_DR0 ... SVM_EXIT_READ_DR0 + 7:
|
|
||||||
if (env->intercept_dr_read & (1 << (type - SVM_EXIT_READ_DR0))) {
|
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SVM_EXIT_WRITE_DR0 ... SVM_EXIT_WRITE_DR0 + 7:
|
|
||||||
if (env->intercept_dr_write & (1 << (type - SVM_EXIT_WRITE_DR0))) {
|
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SVM_EXIT_EXCP_BASE ... SVM_EXIT_EXCP_BASE + 31:
|
|
||||||
if (env->intercept_exceptions & (1 << (type - SVM_EXIT_EXCP_BASE))) {
|
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SVM_EXIT_MSR:
|
|
||||||
if (env->intercept & (1ULL << (SVM_EXIT_MSR - SVM_EXIT_INTR))) {
|
|
||||||
/* FIXME: this should be read in at vmrun (faster this way?) */
|
/* FIXME: this should be read in at vmrun (faster this way?) */
|
||||||
uint64_t addr = x86_ldq_phys(cs, env->vm_vmcb +
|
uint64_t addr = x86_ldq_phys(cs, env->vm_vmcb +
|
||||||
offsetof(struct vmcb,
|
offsetof(struct vmcb,
|
||||||
|
@ -478,14 +493,10 @@ void cpu_svm_check_intercept_param(CPUX86State *env, uint32_t type,
|
||||||
if (x86_ldub_phys(cs, addr + t1) & ((1 << param) << t0)) {
|
if (x86_ldub_phys(cs, addr + t1) & ((1 << param) << t0)) {
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
cpu_vmexit(env, type, param, retaddr);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (env->intercept & (1ULL << (type - SVM_EXIT_INTR))) {
|
|
||||||
cpu_vmexit(env, type, param, retaddr);
|
cpu_vmexit(env, type, param, retaddr);
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void helper_svm_check_intercept(CPUX86State *env, uint32_t type)
|
void helper_svm_check_intercept(CPUX86State *env, uint32_t type)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue