From patchwork Wed Feb 10 12:57:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8271471 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4ECD3BEEE5 for ; Wed, 10 Feb 2016 12:59:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6738E2038F for ; Wed, 10 Feb 2016 12:59:48 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D9A720381 for ; Wed, 10 Feb 2016 12:59:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTUKh-0006l3-Ty; Wed, 10 Feb 2016 12:57:23 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTUKg-0006kv-RW for xen-devel@lists.xenproject.org; Wed, 10 Feb 2016 12:57:22 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id AB/30-08977-2B33BB65; Wed, 10 Feb 2016 12:57:22 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1455109040!13373282!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51709 invoked from network); 10 Feb 2016 12:57:21 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Feb 2016 12:57:21 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 10 Feb 2016 05:57:19 -0700 Message-Id: <56BB41BC02000078000D08AD@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 10 Feb 2016 05:57:16 -0700 From: "Jan Beulich" To: "xen-devel" References: <56BB3DE902000078000D087A@prv-mh.provo.novell.com> In-Reply-To: <56BB3DE902000078000D087A@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper , Keir Fraser Subject: [Xen-devel] [PATCH 2/3] x86: use CLFLUSHOPT when available X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Also drop an unnecessary va adjustment in the code being touched. Signed-off-by: Jan Beulich x86: use CLFLUSHOPT when available Also drop an unnecessary va adjustment in the code being touched. Signed-off-by: Jan Beulich --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -139,10 +139,12 @@ unsigned int flush_area_local(const void c->x86_clflush_size && c->x86_cache_size && sz && ((sz >> 10) < c->x86_cache_size) ) { - va = (const void *)((unsigned long)va & ~(sz - 1)); + alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT); for ( i = 0; i < sz; i += c->x86_clflush_size ) - asm volatile ( "clflush %0" - : : "m" (((const char *)va)[i]) ); + alternative_input("rex clflush %0", + "data16 clflush %0", + X86_FEATURE_CLFLUSHOPT, + "m" (((const char *)va)[i])); } else { --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -163,6 +163,7 @@ #define X86_FEATURE_ADX (7*32+19) /* ADCX, ADOX instructions */ #define X86_FEATURE_SMAP (7*32+20) /* Supervisor Mode Access Prevention */ #define X86_FEATURE_PCOMMIT (7*32+22) /* PCOMMIT instruction */ +#define X86_FEATURE_CLFLUSHOPT (7*32+23) /* CLFLUSHOPT instruction */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 8 */ #define X86_FEATURE_PKU (8*32+ 3) /* Protection Keys for Userspace */ Reviewed-by: Andrew Cooper --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -139,10 +139,12 @@ unsigned int flush_area_local(const void c->x86_clflush_size && c->x86_cache_size && sz && ((sz >> 10) < c->x86_cache_size) ) { - va = (const void *)((unsigned long)va & ~(sz - 1)); + alternative(ASM_NOP3, "sfence", X86_FEATURE_CLFLUSHOPT); for ( i = 0; i < sz; i += c->x86_clflush_size ) - asm volatile ( "clflush %0" - : : "m" (((const char *)va)[i]) ); + alternative_input("rex clflush %0", + "data16 clflush %0", + X86_FEATURE_CLFLUSHOPT, + "m" (((const char *)va)[i])); } else { --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -163,6 +163,7 @@ #define X86_FEATURE_ADX (7*32+19) /* ADCX, ADOX instructions */ #define X86_FEATURE_SMAP (7*32+20) /* Supervisor Mode Access Prevention */ #define X86_FEATURE_PCOMMIT (7*32+22) /* PCOMMIT instruction */ +#define X86_FEATURE_CLFLUSHOPT (7*32+23) /* CLFLUSHOPT instruction */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 8 */ #define X86_FEATURE_PKU (8*32+ 3) /* Protection Keys for Userspace */