mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Dave Hansen <dave.hansen@intel.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Michael Roth <michael.roth@amd.com>,
	Ashish Kalra <ashish.kalra@amd.com>,
	Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH] x86/head/64: Switch to KERNEL_CS as soon as new GDT is installed
Date: Fri, 26 May 2023 08:07:44 -0500	[thread overview]
Message-ID: <8a250f71-bd21-a0a7-f1f8-5e6a3bffb18b@amd.com> (raw)
In-Reply-To: <57e7b3df-5ca3-b400-d99a-a430bcc35a7a@intel.com>

On 5/25/23 18:17, Dave Hansen wrote:
> On 5/17/23 09:26, Tom Lendacky wrote:
>> However, a recent patchset that looked to avoid using the legacy
>> decompressor during an EFI boot exposed this bug. At entry to startup_64,
>> the CS value is that of EFI and is not mapped in the new kernel GDT. So
>> when a #VC exception occurs, the CS value used by IRETQ is not valid and
>> the guest boot crashes.
> 
> This confused me a bit.  Nobody merged that patchset yet, right?  You
> just happened across this issue when debugging a crash in that *other* set?

Correct, it was Ard's EFI decompressor patchset series that he submitted, 
but has not yet been accepted, that I was testing:

[PATCH 0/6] efi/x86: Avoid legacy decompressor during EFI boot
   https://lore.kernel.org/lkml/20230424165726.2245548-1-ardb@kernel.org/

I reported the problem to Ard and submitted this patch before I realized 
that he also included a patch in his next version of the series:

https://lore.kernel.org/lkml/20230508070330.582131-16-ardb@kernel.org/

> 
>> Fix this issue by moving the block that switches to the KERNEL_CS value to
>> be done immediately after returning from startup_64_setup_env().
>>
>> Fixes: bcce82908333 ("x86/sev: Detect/setup SEV/SME features earlier in boot")
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> 
> Any thoughts on whether we want this in stable@?

It probably doesn't need to go to stable since the current decompressor 
code switches to a new GDT and uses the same kernel CS value that is being 
setup in arch/x86/kernel/head_64.S (which is why it hasn't been a problem).

> 
> I also wonder whether we need a comment in that little chunk of code
> something along the lines of:
> 
> 	/*
> 	 * Do not add anything which might take a fault or exception.
> 	 * IRET does not work here.
> 	 */
> 
> Michael, do you think you would have spotted something like this had it
> been in the code when you were patching it?

Let me know if you would like a v2 with that comment. I'm also fine if you 
  just want to add it as part of applying the patch, too.

Thanks,
Tom

      reply	other threads:[~2023-05-26 13:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 16:26 Tom Lendacky
2023-05-22 13:12 ` Joerg Roedel
2023-05-25 23:17 ` Dave Hansen
2023-05-26 13:07   ` Tom Lendacky [this message]

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=8a250f71-bd21-a0a7-f1f8-5e6a3bffb18b@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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

all inboxes | Powered by JetHome®