From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbdK2Usn (ORCPT ); Wed, 29 Nov 2017 15:48:43 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:35536 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751980AbdK2Usk (ORCPT ); Wed, 29 Nov 2017 15:48:40 -0500 X-Google-Smtp-Source: AGs4zMb7OBX0lMaCG1CteGZVFVlLtQT1hqMfGPAbvxJSD1Ehd7zJCViRf8+KqmNlVG0RP3MO8ZNVZgMq9I2s2/Dl3Uc= MIME-Version: 1.0 In-Reply-To: References: <0fede9f9-88b0-a6e7-1027-dfb2019b8ef2@linux.intel.com> <20171129070951.hjjjpbyilzaak4ig@gmail.com> <20171129124711.slmq5emx4f26c4zp@hirez.programming.kicks-ass.net> <4f2c1cf45fd04e83a7d360d0d602830e@AcuMS.aculab.com> From: Linus Torvalds Date: Wed, 29 Nov 2017 12:48:39 -0800 X-Google-Sender-Auth: IT8gudG4wcMplrZuU3BjZed8KeY Message-ID: Subject: Re: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled To: David Laight Cc: Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Jarkko Nikula , linux-kernel , Thomas Gleixner , Borislav Petkov Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 29, 2017 at 8:51 AM, David Laight wrote: > > SWAPGS is a PITA. The hardware designers should have tried to write > all the interrupt handling code. That's actually my biggest beef with x86-64. The kernel entry/exit is completely misdesigned. That was actually better in the original i386, which handles nesting ok (modulo the NMI disable flag and the STI shadow bit which doesn't save/restore properly). Yes, the 386 model of infinite indirection through IDT/GDT/TSS is broken and should have had a mode bit to just replace with a simple "use this stack and address for kernel entry" MSR register - but that simplified kernel entry/exit should have saved/restored _more_ info, not less (eg "save/restore segment shadow state rather than the descriptor number that needs the insane indirection" etc) The problem was never the few push/pop instructions that kernel entry involved. The entry/exit garbage admittedly started before x86-64 itself - all those 'syscall' variants are equally broken. Not saving/restoring state properly is just unbelievable sh*t. x86-64 then made things worse with SWAPGS etc. A lot of people hate x86 because of instruction decoding. No, if you need a reason to dislike x86, it's because of exception handling and iret. Rant over. Linus