Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754878AbeAMMI6 (ORCPT + 1 other); Sat, 13 Jan 2018 07:08:58 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:45277 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754820AbeAMMI4 (ORCPT ); Sat, 13 Jan 2018 07:08:56 -0500 Date: Sat, 13 Jan 2018 13:08:47 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Thomas Gleixner , Borislav Petkov , Laura Abbott , X86 ML , Linux Kernel Mailing List , stable Subject: Re: Yet another KPTI regression with 4.14.x series in a VM Message-ID: <20180113120847.GI3397@worktop> References: <9eb15489-da09-7a4c-0700-7b6eb99e6f7b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Fri, Jan 12, 2018 at 10:08:20PM -0800, Andy Lutomirski wrote: > Now this is quite a strange value to write to CR3. The 0x800 part > means that we're using the "user" variant of the address space that > would have ASID=0 and the 0x1000 bit being set corresponds to the user > pgdir, but this is nonsense, since the kernel never uses PCID 0 for > user mode. We always start at 1. The only exception is if > X86_FEATURE_PCID is off. But, if X86_FEATURE_PCID is off, then we > shouldn't be setting any PCID bits. My bad, I was under the impression the lower 12 bits would be ignored without PCID :/ > .Lwrcr3_\@: > /* Flip the PGD and ASID to the user version */ > orq $(PTI_SWITCH_MASK), \scratch_reg > mov \scratch_reg, %cr3 > .Lend_\@: > > That's bogus. PTI_SWITCH_MASK is 0x1800, which has PCID = 0x800. > This should probably use an alternative to select between 0x1000 and > 0x800 depending on X86_FEATURE_PCID or just use an entirely different > label for the !PCID case. ALTERNATIVE "orq $(PTI_SWITCH_PGTABLE_MASK), \scratch_reg", "orq $(PTI_SWITCH_MASK), \scratch_reg", X86_FEATURE_PCID Is not wanting to compile though; probably that whole alternative vs macro thing again :/