* Re: [PATCH] x86/HVM: never retain emulated insn cache when exiting back to guest
[not found] <5AD9F6F102000078001BD0C8@suse.com>
@ 2018-04-20 14:21 ` Juergen Gross
0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2018-04-20 14:21 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Andrew Cooper, Paul Durrant
On 20/04/18 16:19, Jan Beulich wrote:
> 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>
Release-acked-by: Juergen Gross <jgross@suse.com>
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/HVM: never retain emulated insn cache when exiting back to guest
2018-04-20 14:19 Jan Beulich
@ 2018-04-20 14:25 ` Paul Durrant
0 siblings, 0 replies; 3+ messages in thread
From: Paul Durrant @ 2018-04-20 14:25 UTC (permalink / raw)
To: 'Jan Beulich', xen-devel; +Cc: Juergen Gross, Andrew Cooper
> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 20 April 2018 15:19
> To: xen-devel <xen-devel@lists.xenproject.org>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>; Juergen Gross <jgross@suse.com>
> Subject: [PATCH] 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>
>
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c
> @@ -2266,22 +2266,20 @@ static int _hvm_emulate_one(struct hvm_e
>
> 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 )
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] x86/HVM: never retain emulated insn cache when exiting back to guest
@ 2018-04-20 14:19 Jan Beulich
2018-04-20 14:25 ` Paul Durrant
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2018-04-20 14:19 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, Andrew Cooper, Paul Durrant
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>
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2266,22 +2266,20 @@ static int _hvm_emulate_one(struct hvm_e
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 )
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-20 14:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <5AD9F6F102000078001BD0C8@suse.com>
2018-04-20 14:21 ` [PATCH] x86/HVM: never retain emulated insn cache when exiting back to guest Juergen Gross
2018-04-20 14:19 Jan Beulich
2018-04-20 14:25 ` Paul Durrant
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.