Re: [PATCH v6 13/76] x86/boot/compressed/64: Add IDT Infrastructure

From: Joerg Roedel
Date: Fri Aug 28 2020 - 08:12:56 EST


Hi Arvind,

On Thu, Aug 27, 2020 at 11:26:57AM -0400, Arvind Sankar wrote:
> On Mon, Aug 24, 2020 at 10:54:08AM +0200, Joerg Roedel wrote:
> > + pushq %rsi
> > + call load_stage1_idt
> > + popq %rsi
> > +
>
> Do we need the functions later in the series or could this just use lidt
> directly?

The function also sets up the actual IDT entries in the table before
doing the lidt, so this needs to be a call to a C function. Setting up
IDT entries in assembly does not result in readable code.

> Is there any risk of exceptions getting triggered during the move of the
> compressed kernel, before the stage2 reload?

No, that would be a bug in either the UEFI BIOS or in the boot code.
When the kernel image is moved to the end of the decompression buffer it
still runs on the EFI page-table.

With the changes in this patch-set there will be page-faults when the
kernel is actually decompressed. But that happens after the stage2-idt
is loaded.

> > +SYM_DATA_START(boot_idt_desc)
> > + .word boot_idt_end - boot_idt
>
> I think this should be boot_idt_end - boot_idt - 1, right?
> The limit value is expressed in bytes and is added to the base address
> to get the address of the last valid byte. A limit value of 0 results
> in exactly 1 valid byte. Because IDT entries are always eight bytes
> long, the limit should always be one less than an integral multiple of
> eight (that is, 8N – 1).

You are right, I will fix that, thanks.

Regards,

Joerg