Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbeAGSeO (ORCPT + 1 other); Sun, 7 Jan 2018 13:34:14 -0500 Received: from mga01.intel.com ([192.55.52.88]:51832 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754191AbeAGSeM (ORCPT ); Sun, 7 Jan 2018 13:34:12 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,327,1511856000"; d="scan'208";a="25164159" Subject: Re: [PATCH v2] x86/mm/pti: remove dead logic during user pagetable population To: Thomas Gleixner , Borislav Petkov References: <20180107103317.22613-1-albcamus@gmail.com> <20180107113655.zaovtpdfyjboccae@pd.tnic> Cc: Jike Song , linux-kernel@vger.kernel.org, David Woodhouse , Alan Cox , Jiri Koshina , Linus Torvalds , Tim Chen , Andi Lutomirski , Andi Kleen , Peter Zijlstra , Paul Turner , Tom Lendacky , Greg KH , Kees Cook , stable@vger.kernel.org From: Dave Hansen Message-ID: <58af26cd-dd39-a544-6449-e59d485bc551@intel.com> Date: Sun, 7 Jan 2018 10:34:11 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 01/07/2018 04:05 AM, Thomas Gleixner wrote: >> static DEFINE_SPINLOCK(shadow_table_allocation_lock); >> >> Now I have my suspicions why that's not needed anymore upstream but I'd >> let tglx explain better. > We got rid of all that runtime mapping stuff and the functions are only > called from pti_init(). So the locking and therefor the tests above are not > needed anymore. While at it we should mark all those function __init. Yes, the double-test was part of an optimization where we attempted to avoid using a global spinlock in the fork() path. We would check for unallocated mid-level page tables without the lock. The lock was only taken it when we needed to *make* an entry to avoid collisions. Now that it is all single-threaded, there is no chance of a collision, no need for a lock, and no need for the re-check. ^^ Just in case someone wants to include a bit more first-hand information about wtf that code was doing there.