From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752218AbdK2VZP (ORCPT ); Wed, 29 Nov 2017 16:25:15 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:38803 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbdK2VZM (ORCPT ); Wed, 29 Nov 2017 16:25:12 -0500 X-Google-Smtp-Source: AGs4zMZNb3GRFX+Z0xFpqhoqg2xxlAnaPl21QdDoPk97snHmSdpBlBb3GWfPqQqpK0oLa7Arj33rKQ== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled From: Andy Lutomirski X-Mailer: iPhone Mail (15B202) In-Reply-To: Date: Wed, 29 Nov 2017 13:25:09 -0800 Cc: Andy Lutomirski , Ingo Molnar , Jarkko Nikula , linux-kernel , Thomas Gleixner , Peter Zijlstra , Borislav Petkov Message-Id: <31643632-8A3F-46AC-95AB-27FC94ED79A3@amacapital.net> References: <0fede9f9-88b0-a6e7-1027-dfb2019b8ef2@linux.intel.com> <20171129070951.hjjjpbyilzaak4ig@gmail.com> To: Linus Torvalds Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vATLPIuX024459 > On Nov 29, 2017, at 12:58 PM, Linus Torvalds wrote: > >> On Wed, Nov 29, 2017 at 10:12 AM, Andy Lutomirski wrote: >> >> Jarkko, can you try the attached patch? If it survives resume, can >> you see if the log contains anything interesting? > > I'm not Jarkko, but I'm not a huge fan of that patch. > > If this was the cause of the problem (and it looks likely), wouldn't > it be nicer to instead make sure that __restore_processor_state() is > made to use only low-level code and easy to verify? > > That function is already marked "notrace" because it is so fragile, > and it does the segment register reloads manually with inline asms. I completely agree, and I think it might be better to move more of that crap to asm. Also, it looks quite buggy -- it restores segment registers before it loads the LDT, so they had better not be user registers. Or we could load fixed values into the segment regs if they're not user values. > > Could we make it use "native_load_gs_index()" instead? Or even go all > the way and make it do that user-space %gs load internally with inline > asm, the way it already does the kernel space %gs? Dunno. If we need the exception handling, it can't be inlined. Anyway, this wasn't meant to be an upstreamable fix. It was meant to make sure the problem I'm fixing is the right problem. > > (Maybe "native_wrmsrl()" too?) > > Or is this actually all supposed to work even under PV? That sounds really iffy. > > Linus