Received: by 10.223.185.116 with SMTP id b49csp2347034wrg; Thu, 15 Feb 2018 10:10:23 -0800 (PST) X-Google-Smtp-Source: AH8x227RfjkgkEF+veNdCclWZCEA79aeKY/bzbXeyunsoEJeqYVKrgW6ofjetwtdbDWrrPH3CT6X X-Received: by 10.98.174.26 with SMTP id q26mr3399133pff.92.1518718223420; Thu, 15 Feb 2018 10:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518718223; cv=none; d=google.com; s=arc-20160816; b=i3li2bUV9myXBQFD+78IRWFQ8igBMVW1/wk9lmKoGfI76EjJXWOckzCa1Kesxx9cjs OBaZlSqba1yoPPdqGqzaYv/lc8gixGIhujKLXK1ilknFKBKXcUW8FqDzdgbUdp+ZE1F/ Zj1TWoFfFlL1fvSaxJV1eXr5iePQsmyRak2MaullQkckzmAZ35ObDf+5Lbe70JadWwZB ICccEqC37nQ7X0mnY+msc0LpOtwdu1NbClYL1XSI4qyfn/ww8DiT4sL6svi+iGM0D7ub HWGTBn9UcNDWIoTCn8w+iQmIpF612pkXbYZBkx28dV8qQ/JPmWi/j+IVLt8DTFVopMy0 ddVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=yqUy7UBg6/SH2h1o7TpJXJjJH0nwbRKppE44U6FcmZs=; b=OpMrO9u7sYmcjxPOFqGvj9crv7l4Js7DH3iFOcD1Y4M4u/j62m30G9KPm1p1JiYmv/ QG6U4Lq7Mn7lDeQIXXzGC5T0SvSWhOYfeUBNanGktrHg+85nWcRjkTMXDmqGOAFMU/dM YH1TLoXnTJ5hrBVxJpF2+KzwYgtUbugI9LYGE9/RGyCleg9eLmm2hxz4Hi7+k5XB/7AW MxWi1UoMDUbBsv5cHi65+HyVnUGsCA1DGSwJRLt1skniW/WvrD8buAvsy6X1Z5ivGkW8 351MJKrk9PEnf9d5kUlxvQu5gjzrT3xusxhfAGYVv0iuGJfsvJntzS9qcYdFtbHx2qfp SI9A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4-v6si4868705pln.121.2018.02.15.10.10.08; Thu, 15 Feb 2018 10:10:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166082AbeBOSIu (ORCPT + 99 others); Thu, 15 Feb 2018 13:08:50 -0500 Received: from mga04.intel.com ([192.55.52.120]:54428 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163994AbeBOSIs (ORCPT ); Thu, 15 Feb 2018 13:08:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Feb 2018 10:08:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,517,1511856000"; d="scan'208";a="18780963" Received: from makhan1-mobl.amr.corp.intel.com (HELO [10.254.69.204]) ([10.254.69.204]) by orsmga006.jf.intel.com with ESMTP; 15 Feb 2018 10:08:47 -0800 Subject: Re: [PATCH RFC v2 5/6] x86: Use global pages when PTI is disabled To: Nadav Amit References: <20180215163602.61162-1-namit@vmware.com> <20180215163602.61162-6-namit@vmware.com> <10c21933-fe93-ccad-b315-2a7ca1e917a4@linux.intel.com> Cc: Ingo Molnar , Thomas Gleixner , Andy Lutomirski , Peter Zijlstra , Willy Tarreau , "x86@kernel.org" , "linux-kernel@vger.kernel.org" From: Dave Hansen Message-ID: <7b48990b-0a56-a26d-5d98-fe305331caec@linux.intel.com> Date: Thu, 15 Feb 2018 10:08:47 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/15/2018 09:47 AM, Nadav Amit wrote: > Dave Hansen wrote: >>> diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c >>> index c67ef3fb4f35..979c7ec6baab 100644 >>> --- a/arch/x86/mm/tlb.c >>> +++ b/arch/x86/mm/tlb.c >>> @@ -74,7 +74,8 @@ static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen, >>> return; >>> } >>> >>> - if (this_cpu_read(cpu_tlbstate.invalidate_other)) >>> + if (this_cpu_read(cpu_tlbstate.invalidate_other) && >>> + !mm_pti_disable(next)) >>> clear_asid_other(); >> >> This isn't obviously correct. Don't we still need to invalidate other >> user asids? > > I forgot to regard this question: When you reenable PTI (after switching back > to 64-bit process), you flush the global pages, so no kernel mappings for the > 32-bit process are left. Can you please write up a proper description for this? It's horribly complicated, intertwined with global pages, and sets up a dependency that *ALL* TLB entries invalidated via __flush_tlb_one_kernel() must be _PAGE_GLOBAL. How about you actually clear cpu_tlbstate.invalidate_other when you do the CR4.PGE switching? That seems a much more direct way and is much more self-documenting. That brings up another point: these patches rather ignore cpu_tlbstate. That leads to confusing code (this) and the double-flushing on context switch I brought up earlier. Was this intentional, or is it something you can reconsider going forward?