public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, Lai Jiangshan <laijs@linux.alibaba.com>,
	Joerg Roedel <joro@8bytes.org>, Borislav Petkov <bp@suse.de>
Subject: [patch 0/2] x86/idt: Consolidate IDT/TSS setup
Date: Fri, 07 May 2021 13:02:10 +0200	[thread overview]
Message-ID: <20210507110210.147106915@linutronix.de> (raw)

The IDT/TSS setup for the boot CPU on 64-bit is split into two parts:

  1) Setup IDT without IST before cpu_init()
  2) Setup IDT with IST after cpu_init()

Lai noticed [1] that the NMI setup in #1 is wrong because it uses the IST aware
entry point but if an NMI happens there it would run on the kernel stack
which can cause the IST aware code to malfunction.

That's not a real problem because a NMI hitting during early boot before
the IDT is fully set up is fatal anyway. The intermediate issue with the
split setup is just making that window marginally wider. Though the setup
logic is more convoluted than necessary.

There is another oddity regarding secondary CPUs. The recently added SEV
support requires #VC to be functional when invoking cpu_init() and
therefore added a separate function which initializes TSS before that.

Now cpu_init() itself does the same initialization again, which is
pointless and confusing at best.

Borislav posted a patch [2] which moves the TSS initialization to the start of
cpu_init(), but when looking at the boot CPU setup, this is not helpful.

So I kept the separate function and made use of it in trap_init() so that
the ordering is now TSS setup, IDT setup, cpu_init(). That allows to get
rid of the separate IST setup step and makes the overall code simpler.

Thanks,

	tglx

[1] https://lore.kernel.org/r/20210426230949.3561-3-jiangshanlai@gmail.com
[2] https://lore.kernel.org/r/20210504171745.2249-1-bp@alien8.de
---
 include/asm/desc.h      |    2 --
 include/asm/processor.h |    1 +
 kernel/cpu/common.c     |   24 +++++++++++-------------
 kernel/idt.c            |   40 ++++++++++++----------------------------
 kernel/traps.c          |    9 +++------
 5 files changed, 27 insertions(+), 49 deletions(-)





             reply	other threads:[~2021-05-07 15:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 11:02 Thomas Gleixner [this message]
2021-05-07 11:02 ` [patch 1/2] x86/cpu: Init exception handling from cpu_init_secondary() Thomas Gleixner
2021-05-08 23:40   ` Lai Jiangshan
2021-05-09 13:55     ` Thomas Gleixner
2021-05-10 21:29       ` [patch 1/2 v2] x86/cpu: Init AP " Thomas Gleixner
2021-05-11  9:25         ` Lai Jiangshan
2021-05-12  8:37           ` Peter Zijlstra
2021-05-12  8:49         ` Peter Zijlstra
2021-05-12  9:52           ` Thomas Gleixner
2021-05-18 12:40         ` [tip: x86/apic] x86_cpu_Init_AP_exception_handling_from_cpu_init_secondary_ tip-bot2 for Borislav Petkov
2021-05-18 12:52         ` [tip: x86/apic] x86/cpu: Init AP exception handling from cpu_init_secondary() tip-bot2 for Borislav Petkov
2021-05-07 11:02 ` [patch 2/2] x86/idt: Rework IDT setup for boot CPU Thomas Gleixner
2021-05-18 12:40   ` [tip: x86/apic] " tip-bot2 for Thomas Gleixner
2021-05-18 12:52   ` tip-bot2 for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507110210.147106915@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=bp@suse.de \
    --cc=joro@8bytes.org \
    --cc=laijs@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox