All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled
@ 2015-05-05 10:01 Razvan Cojocaru
  2015-05-05 10:08 ` Razvan Cojocaru
  2015-05-05 10:23 ` Jan Beulich
  0 siblings, 2 replies; 4+ messages in thread
From: Razvan Cojocaru @ 2015-05-05 10:01 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.cooper3, keir, Razvan Cojocaru, jbeulich

The mem_access client might want to use hvm_emulate_one_no_write(),
in which case the RAM-to-RAM copy code in hvmemul_rep_movs() would
lead to an unwanted (and unexpected) write operation.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
---
 xen/arch/x86/hvm/emulate.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 40de776..4cc7e01 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -951,6 +951,14 @@ static int hvmemul_rep_movs(
         return hvmemul_do_mmio(
             dgpa, reps, bytes_per_rep, sgpa, IOREQ_WRITE, df, NULL);
 
+    /*
+     * The mem_access client might want to call hvm_emulate_one_no_write(),
+     * in which case going ahead would lead to an unwanted write.
+     * Fall back to slow emulation instead.
+     */
+    if ( unlikely(current->domain->arch.mem_access_emulate_enabled) )
+        return X86EMUL_UNHANDLEABLE;
+
     /* RAM-to-RAM copy: emulate as equivalent of memmove(dgpa, sgpa, bytes). */
     bytes = *reps * bytes_per_rep;
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled
  2015-05-05 10:01 [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled Razvan Cojocaru
@ 2015-05-05 10:08 ` Razvan Cojocaru
  2015-05-05 10:23 ` Jan Beulich
  1 sibling, 0 replies; 4+ messages in thread
From: Razvan Cojocaru @ 2015-05-05 10:08 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.cooper3, keir, jbeulich

On 05/05/2015 01:01 PM, Razvan Cojocaru wrote:
> The mem_access client might want to use hvm_emulate_one_no_write(),
> in which case the RAM-to-RAM copy code in hvmemul_rep_movs() would
> lead to an unwanted (and unexpected) write operation.

This patch requires Tamas' last series, which is now in staging.


Thanks,
Razvan Cojocaru

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled
  2015-05-05 10:01 [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled Razvan Cojocaru
  2015-05-05 10:08 ` Razvan Cojocaru
@ 2015-05-05 10:23 ` Jan Beulich
  2015-05-05 11:27   ` Razvan Cojocaru
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2015-05-05 10:23 UTC (permalink / raw)
  To: Razvan Cojocaru; +Cc: andrew.cooper3, keir, xen-devel

>>> On 05.05.15 at 12:01, <rcojocaru@bitdefender.com> wrote:
> The mem_access client might want to use hvm_emulate_one_no_write(),
> in which case the RAM-to-RAM copy code in hvmemul_rep_movs() would
> lead to an unwanted (and unexpected) write operation.

I don't follow: hvm_emulate_one_no_write() uses
hvm_emulate_ops_no_write, which in turn uses
hvmemul_rep_movs_discard(). What unwanted writes are you
talking about? And if it was needed, why would
hvmemul_rep_stos() not require a similar tweak?

Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled
  2015-05-05 10:23 ` Jan Beulich
@ 2015-05-05 11:27   ` Razvan Cojocaru
  0 siblings, 0 replies; 4+ messages in thread
From: Razvan Cojocaru @ 2015-05-05 11:27 UTC (permalink / raw)
  To: Jan Beulich; +Cc: andrew.cooper3, keir, xen-devel

On 05/05/2015 01:23 PM, Jan Beulich wrote:
>>>> On 05.05.15 at 12:01, <rcojocaru@bitdefender.com> wrote:
>> The mem_access client might want to use hvm_emulate_one_no_write(),
>> in which case the RAM-to-RAM copy code in hvmemul_rep_movs() would
>> lead to an unwanted (and unexpected) write operation.
> 
> I don't follow: hvm_emulate_one_no_write() uses
> hvm_emulate_ops_no_write, which in turn uses
> hvmemul_rep_movs_discard(). What unwanted writes are you
> talking about? And if it was needed, why would
> hvmemul_rep_stos() not require a similar tweak?

You're right, my mistake. I'm testing a few patches meant for the a new
series, and one of them introduces a third kind of emulation, and the
problem is only there - the nowrite case is fine, as you rightly pointed
out. Sorry for the false alarm.

On the bright side, this just saved a bit of back-and-forth when the
series is submitted.


Thanks,
Razvan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-05 11:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-05 10:01 [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled Razvan Cojocaru
2015-05-05 10:08 ` Razvan Cojocaru
2015-05-05 10:23 ` Jan Beulich
2015-05-05 11:27   ` Razvan Cojocaru

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.