From: Joerg Roedel <joro@8bytes.org>
To: David Laight <David.Laight@aculab.com>
Cc: 'Ard Biesheuvel' <ardb@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"hpa@zytor.com" <hpa@zytor.com>, Joerg Roedel <jroedel@suse.de>,
Kees Cook <keescook@chromium.org>,
Andy Lutomirski <luto@kernel.org>,
Uros Bizjak <ubizjak@gmail.com>,
Arvind Sankar <nivedita@alum.mit.edu>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Fabio Aiuto <fabioaiuto83@gmail.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] x86/efi: Restore Firmware IDT in before ExitBootServices()
Date: Fri, 20 Aug 2021 18:04:18 +0200 [thread overview]
Message-ID: <YR/SgrOiBLs53SJ5@8bytes.org> (raw)
In-Reply-To: <cdd7869a14ad4021acfacffa3918981c@AcuMS.aculab.com>
On Fri, Aug 20, 2021 at 03:46:11PM +0000, David Laight wrote:
> So load a temporary IDT so that you can detect invalid instructions
> and restore the UEFI IDT immediately afterwards?
Going forward with SEV-SNP, the IDT is not only needed for special
instructions, but also to detect when the hypervisor is doing fishy
things with the guests memory, which could happen at _any_ instruction
boundary.
> I'm guessing the GDT is changed in order to access all of physical
> memory (well enough to load the kernel).
The kernels GDT is needed to switch from 32-bit protected mode to long
mode, where it calls ExitBootServices().
I think the reason is to avoid compiling a 64-bit and a 32-bit EFI
library into the decompressor stub. With a 32-bit library the kernel
could call ExitBootServices() right away before it jumps to startup_32.
But it only has the 64-bit library, so it has to switch to long-mode
first before it make subsequent EFI calls.
> Could that be done using the LDT?
> It is unlikely that the UEFI cares about that?
Well, I guess it could work via the LDT too, but the current GDT
switching code if proven to work on exiting BIOSes and I'd rather not
change it to something less proven when there is no serious problem with
it.
> Is this 32bit non-paged code?
> Running that with a physical memory offset made my head hurt.
Yes, 32-bit EFI launches the kernel in 32-bit protected mode, paging
disabled. I think that it also has to use a flat segmentation model
without offsets. But someone who knows the EFI spec better than me can
correct me here :)
Regards,
Joerg
next prev parent reply other threads:[~2021-08-20 16:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 7:34 [PATCH] x86/efi: Restore Firmware IDT in before ExitBootServices() Joerg Roedel
2021-08-20 7:41 ` Ard Biesheuvel
2021-08-20 8:01 ` Joerg Roedel
2021-08-20 8:43 ` David Laight
2021-08-20 8:52 ` 'Joerg Roedel'
2021-08-20 9:02 ` David Laight
2021-08-20 10:19 ` 'Joerg Roedel'
2021-08-20 11:31 ` Ard Biesheuvel
2021-08-20 11:51 ` Joerg Roedel
2021-08-20 15:46 ` David Laight
2021-08-20 16:04 ` Joerg Roedel [this message]
2021-08-20 9:26 ` Borislav Petkov
2021-08-20 11:24 ` Borislav Petkov
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=YR/SgrOiBLs53SJ5@8bytes.org \
--to=joro@8bytes.org \
--cc=David.Laight@aculab.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=fabioaiuto83@gmail.com \
--cc=hpa@zytor.com \
--cc=jroedel@suse.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nivedita@alum.mit.edu \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=ubizjak@gmail.com \
--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