Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4090101pxk; Tue, 8 Sep 2020 10:23:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvjf+MuuZRxfSOGFF92cBSJgTBQETm3dFnZyP5JvbmlDLY4A8Eonxmxnyy0RU0a18oIU4P X-Received: by 2002:a17:906:3f89:: with SMTP id b9mr18474806ejj.463.1599585787335; Tue, 08 Sep 2020 10:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599585787; cv=none; d=google.com; s=arc-20160816; b=tos/NxgIsWjcLA0GkrFSr69x5XHgY7pDln9nbQq821OjmuR85uKXp8WNzjF5X4e8Pf 1+x08RqUU9gBFPeTmstJu/H/8E8apkxWqG6DYMpaib+Vv3NfZ4C2q2KljDNmYzTP/ol4 UbWLdS6702Sfp/cOUfP4uwdO6HZ3siomHPRcqPZPCWQbWRDPLEXGlu3p4xdEiYQS6iuG Yp2u4jEKoBHqVxZGv9nj/8xmsR2D00rWMkqyaMJvfg1/x2sSdBLealXbZTS9cxjEOlsj ilFkux7HZEUwzxs0q+rbf0fsEA34PQBtxUWc1EOfAYs/cJLN2R3ruA2AdSYlPDKFET41 Kwpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=LmUlHAGcDfQUhA9DUzYK7oqYD6W3gPvxbkj2WBXLliI=; b=HBPPDtSimlHDKCoAVasju1+UYFN08m85XLHEWszUUGbYUXo4FVZvXkS2A/ob7I4LGQ 1DXbNOABoSAYgmE0fnRZNCvXyhY8VzqXLx8JZtqVZZDUqtDfom9UPmmr6zifN6EteurQ 8RPdy5FRSBVso9xLRYsEpVfC4emeukylSL/PNMorYWsAIBh1TGXGkXZmGWiAlEsf2BjK 3BfqDobqAYsMGIf9KAfGZLYLhi0LluvSP68MXq/4fjsqY8YPgKLXnOA131Nkphhja1wH uI3CfAQ/MrueUT9+sUTvPKUiiAnWj1GIJd+gF7Xn/HKlhmL/Z2XQB3wPIQuY6QzBmdNB qAtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=NT+D1his; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n13si12072503ejz.621.2020.09.08.10.22.44; Tue, 08 Sep 2020 10:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=NT+D1his; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731681AbgIHRWF (ORCPT + 99 others); Tue, 8 Sep 2020 13:22:05 -0400 Received: from mail.skyhub.de ([5.9.137.197]:58316 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbgIHRUw (ORCPT ); Tue, 8 Sep 2020 13:20:52 -0400 Received: from zn.tnic (p200300ec2f10bf0070b09dfd4356f225.dip0.t-ipconnect.de [IPv6:2003:ec:2f10:bf00:70b0:9dfd:4356:f225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 6016C1EC0493; Tue, 8 Sep 2020 19:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1599585648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=LmUlHAGcDfQUhA9DUzYK7oqYD6W3gPvxbkj2WBXLliI=; b=NT+D1hisw4b0wW+6D7Ney6pv8pqgOWkQiIpZMVJFpu03DYUr3koV1ACECWUSItIFaW0klI 6lQvPBJz1xfNqiAypVEEPioZLzJhxPHQWnPMBFkqcSx5eFSdpW4Hse7mx++L7Y6j3zJfOv V2b1QESn48gtV8CN2wkTeDHRDEKrGvo= Date: Tue, 8 Sep 2020 19:20:42 +0200 From: Borislav Petkov To: Joerg Roedel Cc: x86@kernel.org, Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v7 67/72] x86/smpboot: Load TSS and getcpu GDT entry before loading IDT Message-ID: <20200908172042.GF25236@zn.tnic> References: <20200907131613.12703-1-joro@8bytes.org> <20200907131613.12703-68-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200907131613.12703-68-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 07, 2020 at 03:16:08PM +0200, Joerg Roedel wrote: > From: Joerg Roedel > > The IDT on 64bit contains vectors which use paranoid_entry() and/or IST > stacks. To make these vectors work the TSS and the getcpu GDT entry need > to be set up before the IDT is loaded. > > Signed-off-by: Joerg Roedel > --- > arch/x86/include/asm/processor.h | 1 + > arch/x86/kernel/cpu/common.c | 23 +++++++++++++++++++++++ > arch/x86/kernel/smpboot.c | 2 +- > 3 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h > index d8a82e650810..5ac507586769 100644 > --- a/arch/x86/include/asm/processor.h > +++ b/arch/x86/include/asm/processor.h > @@ -696,6 +696,7 @@ extern void load_direct_gdt(int); > extern void load_fixmap_gdt(int); > extern void load_percpu_segment(int); > extern void cpu_init(void); > +extern void cpu_init_exception_handling(void); > extern void cr4_init(void); > > static inline unsigned long get_debugctlmsr(void) > diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c > index 1d65365363a1..a9527c0c38fb 100644 > --- a/arch/x86/kernel/cpu/common.c > +++ b/arch/x86/kernel/cpu/common.c > @@ -1854,6 +1854,29 @@ static inline void tss_setup_io_bitmap(struct tss_struct *tss) > #endif > } > > +/* > + * Setup everything needed to handle exceptions from the IDT, including the IST > + * exceptions which use paranoid_entry() > + */ > +void cpu_init_exception_handling(void) > +{ > + struct tss_struct *tss = this_cpu_ptr(&cpu_tss_rw); > + int cpu = raw_smp_processor_id(); > + > + /* paranoid_entry() gets the CPU number from the GDT */ > + setup_getcpu(cpu); > + > + /* IST vectors need TSS to be set up. */ > + tss_setup_ist(tss); > + tss_setup_io_bitmap(tss); > + set_tss_desc(cpu, &get_cpu_entry_area(cpu)->tss.x86_tss); > + > + load_TR_desc(); Aha, this is what you mean here in your 0th message. I'm guessing it is ok to do those things twice in start_secondary... -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette