From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: Qemu: Flush i-cache after ide-dma operation in IA64 Date: Thu, 02 Apr 2009 11:55:27 +0300 Message-ID: <49D47D7F.2040904@redhat.com> References: <10C63FAD690C13458F0B32BCED571F140F98ED4B@pdsmsx502.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "kvm-ia64@vger.kernel.org" , "kvm@vger.kernel.org" , "Zhang, Xiantao" To: "Zhang, Yang" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:56140 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755568AbZDBIzb (ORCPT ); Thu, 2 Apr 2009 04:55:31 -0400 In-Reply-To: <10C63FAD690C13458F0B32BCED571F140F98ED4B@pdsmsx502.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Zhang, Yang wrote: > The data from dma will include instructions. In order to exeuting the right > instruction, we should to flush the i-cache to ensure those data can be see > by cpu. > > > > diff --git a/qemu/cache-utils.h b/qemu/cache-utils.h > index b45fde4..5e11d12 100644 > --- a/qemu/cache-utils.h > +++ b/qemu/cache-utils.h > @@ -33,8 +33,22 @@ static inline void flush_icache_range(unsigned long start, unsigned long stop) > asm volatile ("sync" : : : "memory"); > asm volatile ("isync" : : : "memory"); > } > +#define qemu_sync_idcache flush_icache_range > +#else > > +#ifdef __ia64__ > +static inline void qemu_sync_idcache(unsigned long start, unsigned long stop) > +{ > + while (start < stop) { > + asm volatile ("fc %0" :: "r"(start)); > + start += 32; > + } > + asm volatile (";;sync.i;;srlz.i;;"); > +} > What about smp? I'm surprised the guest doesn't do this by itself? > > void pstrcpy(char *buf, int buf_size, const char *str) > @@ -215,6 +216,8 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count) > if (copy > qiov->iov[i].iov_len) > copy = qiov->iov[i].iov_len; > memcpy(qiov->iov[i].iov_base, p, copy); > + qemu_sync_idcache((unsigned long)qiov->iov[i].iov_base, > + (unsigned long)(qiov->iov[i].iov_base + copy)); > p += copy; > count -= copy; > } > This is the wrong place to put this. Once we stop bouncing scatter/gather DMA, we will no longer call this function. The correct place is either in the device code itself, or in the dma api (dma-helpers.c). -- error compiling committee.c: too many arguments to function