Received: by 10.223.164.202 with SMTP id h10csp4471415wrb; Wed, 29 Nov 2017 06:57:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMaKF4zzjgDLj+yrfKG9gkCWJQ21/1pPeXGyCX42T+oYzFnyezMaXBMunLUqKe0pF0clRPvO X-Received: by 10.84.232.74 with SMTP id f10mr3050978pln.90.1511967447301; Wed, 29 Nov 2017 06:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511967447; cv=none; d=google.com; s=arc-20160816; b=VYQNYdRHcK+YdUwobmm01mdmR+bc4oWlWQhLETbaS5qEflG6z5ajSaU9ygEoFwmu97 wWGUdlFax4VTioNjMXQxGLEDI4GTqwK8DrWXKQYip1QVYLMhGLxHwi/6b/c81bt97vX6 JvqpCXcmja4GIUEWc0HvMdIR3sas6R2pvCqLnh4F5KPQVJFvs+QxYVTQJJEhvnbI4zcn p38ORLWtSrYsSh/MTlcNviLy4r9jP1U0IUGk8iZl9jbwpRpx4orieiT84fFr3kXIwCbC m/sckNTzWwLuRr6R0kCPzFXLVX3xaCo3CXRYjzrKV4RNUgVGcS5YdGwuB67/0wNNjA93 5fKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=D+lf8uDT7prRzei23DBNZHWoh/KyQ8TxaC9iSh4t9uU=; b=pvopIz2znsfcVapTMHedUJZl1tmADF3CwBSx42snkQTdCfE/mM7pR5AyIIHSIpwY9T rDo2SbGUMTqEb0hCDx6TvpGvlowjx2otAh8ufYXpVkVBWBP6iT+QcbHPuHSKhJwkcH1Q ncpBXkJzoEjugIodvSbOVc1STSigBy/ZVUVV4L2yMX9yDbILubgAn4StlU69iZE0g305 krBh7Tv9MwCZjp/V7oybKH+jc5UQLkqETFkvr9mKWBYia4AwlxORXD3eJTjvFmTUNu+J eSGdphxslgfQy6rjYBk7qeCn/ZfoezN5Kndm+M6mJsUJBka8SdbR3tXrXBdNXOr+WlWV UWrA== 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 ay8si1350419plb.215.2017.11.29.06.57.17; Wed, 29 Nov 2017 06:57:27 -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 S1755417AbdK2O4b convert rfc822-to-8bit (ORCPT + 69 others); Wed, 29 Nov 2017 09:56:31 -0500 Received: from smtp-out4.electric.net ([192.162.216.194]:51381 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751929AbdK2O43 (ORCPT ); Wed, 29 Nov 2017 09:56:29 -0500 Received: from 1eK3mf-0003ga-VW by out4a.electric.net with emc1-ok (Exim 4.87) (envelope-from ) id 1eK3mi-0003vo-W1; Wed, 29 Nov 2017 06:56:24 -0800 Received: by emcmailer; Wed, 29 Nov 2017 06:56:24 -0800 Received: from [156.67.243.126] (helo=AcuMS.aculab.com) by out4a.electric.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.87) (envelope-from ) id 1eK3mf-0003ga-VW; Wed, 29 Nov 2017 06:56:21 -0800 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 29 Nov 2017 14:56:43 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Wed, 29 Nov 2017 14:56:43 +0000 From: David Laight To: 'Andy Lutomirski' , Peter Zijlstra CC: Ingo Molnar , Jarkko Nikula , linux-kernel , Andy Lutomirski , Thomas Gleixner , Linus Torvalds , Borislav Petkov Subject: RE: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled Thread-Topic: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled Thread-Index: AQHTaR8fKskq+GLGsUC5ju1OFMHHkKMrb/rw Date: Wed, 29 Nov 2017 14:56:43 +0000 Message-ID: <4f2c1cf45fd04e83a7d360d0d602830e@AcuMS.aculab.com> References: <0fede9f9-88b0-a6e7-1027-dfb2019b8ef2@linux.intel.com> <20171129070951.hjjjpbyilzaak4ig@gmail.com> <20171129124711.slmq5emx4f26c4zp@hirez.programming.kicks-ass.net> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [fd9f:af1c:a25b:0:43c:695e:880f:8750] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 X-Virus-Status: Scanned by VirusSMART (c) X-Virus-Status: Scanned by VirusSMART (s) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Lutomirski > Sent: 29 November 2017 14:34 > > On Nov 29, 2017, at 4:47 AM, Peter Zijlstra wrote: > > > >> On Wed, Nov 29, 2017 at 08:09:51AM +0100, Ingo Molnar wrote: > >> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > >> index f81d50d7ceac..c0b52df8ee4f 100644 > >> --- a/arch/x86/entry/entry_64.S > >> +++ b/arch/x86/entry/entry_64.S > >> @@ -945,16 +945,16 @@ idtentry simd_coprocessor_error do_simd_coprocessor_error > has_error_code=0 > >> */ > >> ENTRY(native_load_gs_index) > >> FRAME_BEGIN > >> + SWAPGS /* switch from user GS to kernel GS */ > >> pushfq > >> DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI) > >> TRACE_IRQS_OFF > >> - SWAPGS > > > > I'm thinking those moves it too far back; we should at least have > > interrupts disabled when we do SWAPGS, no? Also, curse paravirt. > > > > I'll look in a few hours. > > But we definitely can't have irqs on when running with user gs. I can't remember what happens when swapgs itself faults. I'm pretty sure it can, restoring %ds %es and %fs can definitely fault (especially for 32 bit apps) if the restored values are invalid. With user LDT I think it is possible for a valid segment register to become invalid while a process is sleeping. The debugger (and possible a signal handler) can set the segment registers to arbitrary values - so loading them faults. I fixed NetBSD a few years ago so that all these faults were handled correctly. David From 1585404210277459895@xxx Wed Nov 29 12:41:16 +0000 2017 X-GM-THRID: 1585383480543829622 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread