[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/8] target/i386: svm: do not discard high 32 bits of EXITINFO1
From: |
Paolo Bonzini |
Subject: |
[PULL 4/8] target/i386: svm: do not discard high 32 bits of EXITINFO1 |
Date: |
Fri, 19 Mar 2021 10:39:20 -0400 |
env->error_code is only 32-bits wide, so the high 32 bits of EXITINFO1
are being lost. However, even though saving guest state and restoring
host state must be delayed to do_vmexit, because they might take tb_lock,
it is always possible to write to the VMCB. So do this for the exit
code and EXITINFO1, just like it is already being done for EXITINFO2.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/tcg/helper-tcg.h | 2 +-
target/i386/tcg/seg_helper.c | 4 ++--
target/i386/tcg/svm_helper.c | 15 +++++++--------
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h
index ef60e2e04b..bcdfca06f6 100644
--- a/target/i386/tcg/helper-tcg.h
+++ b/target/i386/tcg/helper-tcg.h
@@ -80,7 +80,7 @@ void cpu_load_eflags(CPUX86State *env, int eflags, int
update_mask);
/* svm_helper.c */
void QEMU_NORETURN cpu_vmexit(CPUX86State *nenv, uint32_t exit_code,
uint64_t exit_info_1, uintptr_t retaddr);
-void do_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1);
+void do_vmexit(CPUX86State *env);
/* seg_helper.c */
void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw);
diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c
index 180d47f0e9..d180a381d1 100644
--- a/target/i386/tcg/seg_helper.c
+++ b/target/i386/tcg/seg_helper.c
@@ -1305,9 +1305,9 @@ void x86_cpu_do_interrupt(CPUState *cs)
/* successfully delivered */
env->old_exception = -1;
#else
- if (cs->exception_index >= EXCP_VMEXIT) {
+ if (cs->exception_index == EXCP_VMEXIT) {
assert(env->old_exception == -1);
- do_vmexit(env, cs->exception_index - EXCP_VMEXIT, env->error_code);
+ do_vmexit(env);
} else {
do_interrupt_all(cpu, cs->exception_index,
env->exception_is_int,
diff --git a/target/i386/tcg/svm_helper.c b/target/i386/tcg/svm_helper.c
index 097bb9b83d..0145afceae 100644
--- a/target/i386/tcg/svm_helper.c
+++ b/target/i386/tcg/svm_helper.c
@@ -621,15 +621,19 @@ void cpu_vmexit(CPUX86State *env, uint32_t exit_code,
uint64_t exit_info_1,
control.exit_info_2)),
env->eip);
- cs->exception_index = EXCP_VMEXIT + exit_code;
- env->error_code = exit_info_1;
+ cs->exception_index = EXCP_VMEXIT;
+ x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_code),
+ exit_code);
+
+ x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb,
+ control.exit_info_1),
exit_info_1),
/* remove any pending exception */
env->old_exception = -1;
cpu_loop_exit(cs);
}
-void do_vmexit(CPUX86State *env, uint32_t exit_code, uint64_t exit_info_1)
+void do_vmexit(CPUX86State *env)
{
CPUState *cs = env_cpu(env);
uint32_t int_ctl;
@@ -762,11 +766,6 @@ void do_vmexit(CPUX86State *env, uint32_t exit_code,
uint64_t exit_info_1)
env->vm_hsave + offsetof(struct vmcb, save.dr7));
/* other setups */
- x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_code),
- exit_code);
- x86_stq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_1),
- exit_info_1);
-
x86_stl_phys(cs,
env->vm_vmcb + offsetof(struct vmcb, control.exit_int_info),
x86_ldl_phys(cs, env->vm_vmcb + offsetof(struct vmcb,
--
2.26.2
- [PULL 0/8] Misc bugfixes for QEMU soft freeze, Paolo Bonzini, 2021/03/19
- [PULL 1/8] qom: use qemu_printf to print help for user-creatable objects, Paolo Bonzini, 2021/03/19
- [PULL 3/8] target/i386: fail if toggling LA57 in 64-bit mode, Paolo Bonzini, 2021/03/19
- [PULL 2/8] target/i386: allow modifying TCG phys-addr-bits, Paolo Bonzini, 2021/03/19
- [PULL 8/8] tests/qtest: cleanup the testcase for bug 1878642, Paolo Bonzini, 2021/03/19
- [PULL 6/8] i386: Make migration fail when Hyper-V reenlightenment was enabled but 'user_tsc_khz' is unset, Paolo Bonzini, 2021/03/19
- [PULL 7/8] hw/intc/i8259: Refactor pic_read_irq() to avoid uninitialized variable, Paolo Bonzini, 2021/03/19
- [PULL 4/8] target/i386: svm: do not discard high 32 bits of EXITINFO1,
Paolo Bonzini <=
- [PULL 5/8] i386: Fix 'hypercall_hypercall' typo, Paolo Bonzini, 2021/03/19
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, no-reply, 2021/03/19
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, Peter Maydell, 2021/03/20
- Re: [PULL 0/8] Misc bugfixes for QEMU soft freeze, Thomas Huth, 2021/03/22