From: Razvan Cojocaru Subject: [PATCH] xen: Disable RAM-to-RAM copy in hvmemul_rep_movs() when mem_access_emulate_enabled Date: Tue, 5 May 2015 13:01:22 +0300 Message-ID: <1430820082-15790-1-git-send-email-rcojocaru@bitdefender.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: andrew.cooper3@citrix.com, keir@xen.org, Razvan Cojocaru , jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org 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 --- 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