From: "Jan Beulich" Subject: [PATCH] x86: don't use VA for cache flush when also flushing TLB Date: Mon, 26 May 2014 11:17:51 +0100 Message-ID: <538330EF0200007800015B4B@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part7341AEDF.0__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Woryd-00028k-UX for xen-devel@lists.xenproject.org; Mon, 26 May 2014 10:17:56 +0000 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 Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part7341AEDF.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Doing both flushes at once is a strong indication for the address mapping to either having got dropped (in which case the cache flush, when done via INVLPG, would fault) or its physical address having changed (in which case the cache flush would end up being done on the wrong address range). There is no adverse effect (other than the obvious performance one) using WBINVD in this case regardless of the range's size; only map_pages_to_xen() uses combined flushes at present. This problem was observed with the 2nd try backport of d6cb14b3 ("VT-d: suppress UR signaling for desktop chipsets") to 4.2 (where ioremap() needs to be replaced with set_fixmap_nocache(); the now commented out __set_fixmap(, 0, 0) there to undo the mapping resulted in the first of the above two scenarios). Signed-off-by: Jan Beulich --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -152,7 +152,8 @@ void flush_area_local(const void *va, un if ( order < (BITS_PER_LONG - PAGE_SHIFT) ) sz =3D 1UL << (order + PAGE_SHIFT); =20 - if ( c->x86_clflush_size && c->x86_cache_size && sz && + if ( !(flags & (FLUSH_TLB|FLUSH_TLB_GLOBAL)) && + c->x86_clflush_size && c->x86_cache_size && sz && ((sz >> 10) < c->x86_cache_size) ) { va =3D (const void *)((unsigned long)va & ~(sz - 1)); --=__Part7341AEDF.0__= Content-Type: text/plain; name="x86-flush-mixed.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-flush-mixed.patch" x86: don't use VA for cache flush when also flushing TLB=0A=0ADoing both = flushes at once is a strong indication for the address=0Amapping to either = having got dropped (in which case the cache flush,=0Awhen done via INVLPG, = would fault) or its physical address having=0Achanged (in which case the = cache flush would end up being done on the=0Awrong address range). There = is no adverse effect (other than the=0Aobvious performance one) using = WBINVD in this case regardless of the=0Arange's size; only map_pages_to_xen= () uses combined flushes at present.=0A=0AThis problem was observed with = the 2nd try backport of d6cb14b3 ("VT-d:=0Asuppress UR signaling for = desktop chipsets") to 4.2 (where ioremap()=0Aneeds to be replaced with = set_fixmap_nocache(); the now commented out=0A__set_fixmap(, 0, 0) there = to undo the mapping resulted in the first of=0Athe above two scenarios).=0A= =0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/f= lushtlb.c=0A+++ b/xen/arch/x86/flushtlb.c=0A@@ -152,7 +152,8 @@ void = flush_area_local(const void *va, un=0A if ( order < (BITS_PER_LONG = - PAGE_SHIFT) )=0A sz =3D 1UL << (order + PAGE_SHIFT);=0A =0A- = if ( c->x86_clflush_size && c->x86_cache_size && sz &&=0A+ = if ( !(flags & (FLUSH_TLB|FLUSH_TLB_GLOBAL)) &&=0A+ c->x86_clfl= ush_size && c->x86_cache_size && sz &&=0A ((sz >> 10) < = c->x86_cache_size) )=0A {=0A va =3D (const void = *)((unsigned long)va & ~(sz - 1));=0A --=__Part7341AEDF.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part7341AEDF.0__=--