Re: [kvm-unit-tests PATCH v2 06/17] x86 UEFI: Load GDT and TSS after UEFI boot up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 20, 2021 at 6:26 PM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> On 27/08/21 05:12, Zixuan Wang wrote:
> > +.globl gdt64
> > +gdt64:
> > +     .quad 0
> > +     .quad 0x00af9b000000ffff /* 64-bit code segment */
> > +     .quad 0x00cf93000000ffff /* 32/64-bit data segment */
> > +     .quad 0x00af1b000000ffff /* 64-bit code segment, not present */
> > +     .quad 0x00cf9b000000ffff /* 32-bit code segment */
> > +     .quad 0x008f9b000000FFFF /* 16-bit code segment */
> > +     .quad 0x008f93000000FFFF /* 16-bit data segment */
> > +     .quad 0x00cffb000000ffff /* 32-bit code segment (user) */
> > +     .quad 0x00cff3000000ffff /* 32/64-bit data segment (user) */
> > +     .quad 0x00affb000000ffff /* 64-bit code segment (user) */
> > +
> > +     .quad 0                  /* 6 spare selectors */
> > +     .quad 0
> > +     .quad 0
> > +     .quad 0
> > +     .quad 0
> > +     .quad 0
> > +
> > +tss_descr:
> > +     .rept max_cpus
> > +     .quad 0x000089000000ffff /* 64-bit avail tss */
> > +     .quad 0                  /* tss high addr */
> > +     .endr
> > +gdt64_end:
> >
> > +.globl tss
> > +tss:
> > +     .rept max_cpus
> > +     .long 0
> > +     .quad 0
> > +     .quad 0, 0
> > +     .quad 0, 0, 0, 0, 0, 0, 0, 0
> > +     .long 0, 0, 0
> > +     .endr
> > +tss_end:
> > +
>
> Please place the IDT (from the previous patch), GDT and TSS in a common
> source file for both UEFI and multiboot.  It could in fact be
> lib/x86/desc.c even.
>
> Duplicating the descriptors is fine, since they're only referred from
> the startup code.
>
> Paolo
>

I will make this update in the next version.

I think placing descriptors in lib/x86/desc.c is also a good idea. In
this way, compilers can automatically generate position-independent
code (PIC) for data structures written in C, and the following
descriptor address setup code can be removed.

> + /* Set GDT runtime address */
> + lea gdt64(%rip), %rax
> + mov %rax, gdt64_desc+2(%rip)

Best regards,
Zixuan



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux