Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754670AbdIGHsn (ORCPT ); Thu, 7 Sep 2017 03:48:43 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37751 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754624AbdIGHsh (ORCPT ); Thu, 7 Sep 2017 03:48:37 -0400 X-Google-Smtp-Source: ADKCNb4lroHmvuc8ysVuJPaVzX3lgQckRB78+NfIChyhCFP5iSxdc9slY7M7inOrN2hZpS8DabNF9g== Date: Thu, 7 Sep 2017 09:48:34 +0200 From: Ingo Molnar To: Jiri Kosina Cc: Andy Lutomirski , X86 ML , Borislav Petkov , "linux-kernel@vger.kernel.org" , Linus Torvalds Subject: Re: [PATCH 1/2] x86/mm: Reinitialize TLB state on hotplug and resume Message-ID: <20170907074834.tmwo6vsvody2qrlg@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1326 Lines: 32 * Jiri Kosina wrote: > On Wed, 6 Sep 2017, Andy Lutomirski wrote: > > > When Linux brings a CPU down and back up, it switches to init_mm and then > > loads swapper_pg_dir into CR3. With PCID enabled, this has the side effect > > of masking off the ASID bits in CR3. > > > > This can result in some confusion in the TLB handling code. If we > > bring a CPU down and back up with any ASID other than 0, we end up > > with the wrong ASID active on the CPU after resume. This could > > cause our internal state to become corrupt, although major > > corruption is unlikely because init_mm doesn't have any user pages. > > More obviously, if CONFIG_DEBUG_VM=y, we'll trip over an assertion > > in the next context switch. The result of *that* is a failure to > > resume from suspend with probability 1 - 1/6^(cpus-1). > > > > Fix it by reinitializing cpu_tlbstate on resume and CPU bringup. > > > > Reported-by: Linus Torvalds > > Reported-by: Jiri Kosina > > Fixes: 10af6235e0d3 ("x86/mm: Implement PCID based optimization: try to preserve old TLB entries using PCID") > > Signed-off-by: Andy Lutomirski > > Tested-by: Jiri Kosina The fix should be upstream already, as of 1c9fe4409ce3 and later. Thanks, Ingo