Received: by 10.223.185.116 with SMTP id b49csp3206678wrg; Mon, 5 Mar 2018 16:32:14 -0800 (PST) X-Google-Smtp-Source: AG47ELsYbvKoe/LpDYGK5NR/dCk40FgmN5+CNMt5wjV7vmYTp+x5lZk/rc2sy/GMHBR4DfxqXCLW X-Received: by 10.101.71.202 with SMTP id f10mr13343198pgs.91.1520296334399; Mon, 05 Mar 2018 16:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296334; cv=none; d=google.com; s=arc-20160816; b=JTKHhCFxsCVGMnAtZw5mlZbf5tfEJ+784W5dgZNjbDY6MoVuRivbi/8cEA9qoqY//l 164EvniQjqVvREQkvzG86BZTfKPZTZQ6KWkm+47T2lPQ3Wn7tIet1mGXaXJZxaItWbLm IUH5l45BNjsR0c/s2AzEd/khWk8KmD2miivccFiSLiRLxveFHO/ZwTNFU92ZHGbviF/E 5QrmuXIWfO8WqU+yvMvN9eZQ3RY0J9dZZabvgrQLMXRt2bVaD24SpHkdctXUIKHmhxz1 NQWsgafTpKY+vw529u7XtQqXNp7jFDux2TOEGJZLxrXO5ytVVSDkriwRsr1Gx9GbDzzS JT0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=DFQokVOoASB6/suVkhTq8r2ZrRph+1QQQs2yZDhN2k0=; b=QfBu3mDF5vOiPl8+SqRQp9RudSkEa3HjVflWuxRYaXnbnP3+XKU5Nt7ZLIxu+qy9EN YLB6+zlcm2eBb//QTi5sEIZUHUJneU9y3DsIM7a4WRwzqbG12J214SgVmbNA8L+XqqS9 VPYLBc+OA/vl3XwMNR7IbfK69dL1MQ+VJNEen7yh6UlV6Ea1K1zNlSptAEo3rcFY6R1f 0rFcsfCIZNcsXR8jL5KHMWdosKkpZlbjyDLM1nqafPtLd2t82AjR8pBNo9tO45s0FLnM HIhCEGrvbjNw7sFCrXCZFGHPAFGLDNwrDgLVqkR4X0fqm7iVjHgyvt4XdrCkrzLErTh6 e6NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=dYzhe7H8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si9012950pgp.542.2018.03.05.16.31.59; Mon, 05 Mar 2018 16:32:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=dYzhe7H8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933590AbeCFA3t (ORCPT + 99 others); Mon, 5 Mar 2018 19:29:49 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:43078 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933498AbeCFA0y (ORCPT ); Mon, 5 Mar 2018 19:26:54 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260MvNc075031; Tue, 6 Mar 2018 00:26:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=DFQokVOoASB6/suVkhTq8r2ZrRph+1QQQs2yZDhN2k0=; b=dYzhe7H8Va/MSdRvjKhrOpJCmbAQqK1zjuzQeL46hkGzxhyzMH+pShe/sRLwggvNDTM4 TxNaY6dr3ia4EHrgxlzFTyx5vCqTYA8P3dh5Vb+eWwD0MS6KFnTxbHrd2f5uVBpTsgN+ aT11aUI/dRw5xfZsrVT2IjwXvnOHxtLO7Q0QttLkeU5fa7Z+3PhnYsHcwerSAmf5I5f5 f1gn8XFP+XjNqx03UO3/63ymbkhre0CZ9U5nXH9MUZOeL/F2QivWPdMakqxtS45WGMT5 SOn2W7FWWbX3/MntWIqaOPBIZsrLc8QO7SrBuPIi4YkwE1EWLMi57NaS3iJAU5zcW9FE Xw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2ghe5xgf1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:49 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w260Qmgq031281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:48 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w260QmpZ000540; Tue, 6 Mar 2018 00:26:48 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:48 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 55/65] kaiser: asm/tlbflush.h handle noPGE at lower level Date: Mon, 5 Mar 2018 19:25:28 -0500 Message-Id: <20180306002538.1761-56-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=573 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hugh Dickins I found asm/tlbflush.h too twisty, and think it safer not to avoid __native_flush_tlb_global_irq_disabled() in the kaiser_enabled case, but instead let it handle kaiser_enabled along with cr3: it can just use __native_flush_tlb() for that, no harm in re-disabling preemption. (This is not the same change as Kirill and Dave have suggested for upstream, flipping PGE in cr4: that's neat, but needs a cpu_has_pge check; cr3 is enough for kaiser, and thought to be cheaper than cr4.) Also delete the X86_FEATURE_INVPCID invpcid_flush_all_nonglobals() preference from __native_flush_tlb(): unlike the invpcid_flush_all() preference in __native_flush_tlb_global(), it's not seen in upstream 4.14, and was recently reported to be surprisingly slow. Signed-off-by: Hugh Dickins Acked-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 0651b3ad99dd59269e2ec883338ab8fba617e203) Signed-off-by: Pavel Tatashin --- arch/x86/include/asm/tlbflush.h | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index b376095a1fd9..6fdc8c399601 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -151,14 +151,6 @@ static inline void kaiser_flush_tlb_on_return_to_user(void) static inline void __native_flush_tlb(void) { - if (this_cpu_has(X86_FEATURE_INVPCID)) { - /* - * Note, this works with CR4.PCIDE=0 or 1. - */ - invpcid_flush_all_nonglobals(); - return; - } - /* * If current->mm == NULL then we borrow a mm which may change during a * task switch and therefore we must not be preempted while we write CR3 @@ -182,11 +174,8 @@ static inline void __native_flush_tlb_global_irq_disabled(void) /* restore PGE as it was before */ native_write_cr4(cr4); } else { - /* - * x86_64 microcode update comes this way when CR4.PGE is not - * enabled, and it's safer for all callers to allow this case. - */ - native_write_cr3(native_read_cr3()); + /* do it with cr3, letting kaiser flush user PCID */ + __native_flush_tlb(); } } @@ -194,12 +183,6 @@ static inline void __native_flush_tlb_global(void) { unsigned long flags; - if (kaiser_enabled) { - /* Globals are not used at all */ - __native_flush_tlb(); - return; - } - if (this_cpu_has(X86_FEATURE_INVPCID)) { /* * Using INVPCID is considerably faster than a pair of writes @@ -255,11 +238,7 @@ static inline void __native_flush_tlb_single(unsigned long addr) static inline void __flush_tlb_all(void) { - if (cpu_has_pge) - __flush_tlb_global(); - else - __flush_tlb(); - + __flush_tlb_global(); /* * Note: if we somehow had PCID but not PGE, then this wouldn't work -- * we'd end up flushing kernel translations for the current ASID but -- 2.16.2