From patchwork Thu Apr 2 02:01:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yang" X-Patchwork-Id: 15823 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3225JSd002350 for ; Thu, 2 Apr 2009 02:05:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757874AbZDBCFI (ORCPT ); Wed, 1 Apr 2009 22:05:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756183AbZDBCFI (ORCPT ); Wed, 1 Apr 2009 22:05:08 -0400 Received: from mga01.intel.com ([192.55.52.88]:29334 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581AbZDBCFF (ORCPT ); Wed, 1 Apr 2009 22:05:05 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 01 Apr 2009 18:56:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.39,310,1235980800"; d="scan'208,223";a="678014029" Received: from pgsmsx602.gar.corp.intel.com ([10.221.43.81]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2009 19:08:46 -0700 Received: from pdsmsx602.ccr.corp.intel.com (172.16.12.184) by pgsmsx602.gar.corp.intel.com (10.221.43.81) with Microsoft SMTP Server (TLS) id 8.1.340.0; Thu, 2 Apr 2009 10:03:36 +0800 Received: from pdsmsx502.ccr.corp.intel.com ([172.16.12.96]) by pdsmsx602.ccr.corp.intel.com ([172.16.12.184]) with mapi; Thu, 2 Apr 2009 10:03:25 +0800 From: "Zhang, Yang" To: "kvm-ia64@vger.kernel.org" CC: "kvm@vger.kernel.org" , Avi Kivity , "Zhang, Xiantao" Date: Thu, 2 Apr 2009 10:01:42 +0800 Subject: [PATCH] KVM: Qemu: Flush i-cache after ide-dma operation in IA64 Thread-Topic: [PATCH] KVM: Qemu: Flush i-cache after ide-dma operation in IA64 Thread-Index: AcmzNveCty5nPy/TSWqYAY+pWatSkw== Message-ID: <10C63FAD690C13458F0B32BCED571F140F98ED4B@pdsmsx502.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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. Signed-off-by: Xiantao Zhang Signed-off-by: Yang Zhang 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;;"); +} #else +static inline void qemu_sync_idcache(unsigned long start, unsigned long stop) +#endif + #define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) #endif diff --git a/qemu/cutils.c b/qemu/cutils.c index 5b36cc6..7b57173 100644 --- a/qemu/cutils.c +++ b/qemu/cutils.c @@ -23,6 +23,7 @@ */ #include "qemu-common.h" #include "host-utils.h" +#include "cache-utils.h" #include 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; }