mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86/HVM: never retain emulated insn cache when exiting back to guest
Commit 5fcb26e69e ("x86/HVM: don't retain emulated insn cache when
exiting back to guest") didn't go quite far enough: The insn emulator
may itself decide to return X86EMUL_RETRY (currently for certain
CMPXCHG failures and AVX2 gather insns), in which case we'd also exit
back to guest context. Tie the caching to whether we have an I/O
completion pending, instead of x86_emulate()'s return value.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
1 parent
8c02a19230
commit
25b0dad541
1 file changed
+8
-10
@@ -2266,22 +2266,20 @@ static int _hvm_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt,
|
||||
|
||||
vio->mmio_retry = 0;
|
||||
|
||||
switch ( rc = x86_emulate(&hvmemul_ctxt->ctxt, ops) )
|
||||
rc = x86_emulate(&hvmemul_ctxt->ctxt, ops);
|
||||
if ( rc == X86EMUL_OKAY && vio->mmio_retry )
|
||||
rc = X86EMUL_RETRY;
|
||||
|
||||
if ( !hvm_vcpu_io_need_completion(vio) )
|
||||
{
|
||||
case X86EMUL_OKAY:
|
||||
if ( vio->mmio_retry )
|
||||
rc = X86EMUL_RETRY;
|
||||
/* fall through */
|
||||
default:
|
||||
vio->mmio_cache_count = 0;
|
||||
vio->mmio_insn_bytes = 0;
|
||||
break;
|
||||
|
||||
case X86EMUL_RETRY:
|
||||
}
|
||||
else
|
||||
{
|
||||
BUILD_BUG_ON(sizeof(vio->mmio_insn) < sizeof(hvmemul_ctxt->insn_buf));
|
||||
vio->mmio_insn_bytes = hvmemul_ctxt->insn_buf_bytes;
|
||||
memcpy(vio->mmio_insn, hvmemul_ctxt->insn_buf, vio->mmio_insn_bytes);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( hvmemul_ctxt->ctxt.retire.singlestep )
|
||||
|
||||