Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793AbdL0Cy6 (ORCPT ); Tue, 26 Dec 2017 21:54:58 -0500 Received: from mail-it0-f49.google.com ([209.85.214.49]:43703 "EHLO mail-it0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbdL0Cy5 (ORCPT ); Tue, 26 Dec 2017 21:54:57 -0500 X-Google-Smtp-Source: ACJfBotsylxshvSxKqSTZFnlOrvt65BBGXgZEx+jqGhJSOtzNq31X1fl5M9cGoSJx9nzhWXkX4xbOg0bUKVeT09wd30= MIME-Version: 1.0 In-Reply-To: References: <20171224014415.GA5663@chirva-void> <20171225212934.GA1410@arch-chirva.localdomain> <20171226231900.GB1410@arch-chirva.localdomain> From: Linus Torvalds Date: Tue, 26 Dec 2017 18:54:55 -0800 X-Google-Sender-Auth: pJLA8OWpdBShs-zeSYqPP6KF6zU Message-ID: Subject: Re: PROBLEM: consolidated IDT invalidation causes kexec to reboot To: Peter Anvin Cc: Alexandru Chirvasitu , Andy Lutomirski , Thomas Gleixner , kernel list , Borislav Petkov , Brian Gerst , Denys Vlasenko , Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1397 Lines: 29 On Tue, Dec 26, 2017 at 6:25 PM, wrote: > > This is why I personally prefer to see these kinds of terminal stubs written in assembly explicitly: the C compiler simply doesn't have all the information needed to do the right thing. > > I'm personally very sceptical to nuking the GDT unless we're in real mode. There seems to be no point, and just opens up failure modes. Agreed, but I think it was originally probably done for that exact reason: to explicitly trigger issues if somebody did something odd. That said, this time it's actually the "load_segments()" that causes the real problem, and the GDT and IDT invalidation shouldn't have actually done anything at all, since we shouldn't actually be taking faults or loading segments. And historically that segment reset didn't matter either, because apparently we don't do any percpu stuff either. And the stack canary use for %gs is actually fairly recent (well, "recent" is relative: the stack protector code goes back to 2006, but the load_segments() use predates that. So I think we should actually fix "load_segments()" to not load fs/gs with __KERNEL_DS, but with __KERNEL_PERCPU and __KERNEL_STACK_CANARY respectively. ... and yes, we should also look at the idt/gdt invalidation, but I wonder if the paravirt code might want to trigger there for people. Do people do kexec under paravirt? Linus