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

Re: [PATCH 2/2] x86/trampoline: load the GDT located in the trampoline page


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 2 May 2023 12:34:01 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GK3S7p7ZYgG72MlZtaCx995FesgjOzg2erqZCRG44lw=; b=mrjz97AG4hdLpm59q4PGDRgL5ds7J3vhwV3KQLwZbqUeBx6RiN6Hwh7XLF/lD7RaXSvz0D1P7B+dYV5yEgs3vgkTffPNHzYk9HlEnpR8itOggtbmkvVs181OJEe41Oj+a8694/81j/mH8SDP469bbZUjCOEYSVFcxVn/QahRJg5SYGd0C/ruvDaIEgH6cZGh/4FzXHbO3HT/A7ZsSIjNvfrC8c8BEunUll0wNT/96qHf/ngQVQCbsVxBPMq88gc4E9Jxo/CF/JcQUxAvBYkR3TH3c5aaXHjARNVyN/3OhhPtomBeer3w5rZEOaiOMcfpdRl++DATL6sd1yhGIHF8Ow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NTiSQy2ZHdqcfQ/c6tg012pHRl5DY5hbab5ef6EPVhV5OsD6mO3qE7M6bt5bg3Y+ihPG0rOtydkH1cqfbEf/ZjxRxflGdFawe4pURq7bNstaNHcH1wO7CfKMwRpfBe7/dj3xHwkVw9nEWshXDNR4ngnQojRlzNqMutMLIVhJyhIH674+8esJ1BDANx3/ijJYX/3RXmLrzblLIoUrlg7L7F7FD/E3E2my7AhbXXOr/CiHlPMxc54/Wd8IFdbG/DNwQrZ6ArBBTaBMeBEmxOrMcUjIur00PDlvq877kLdXNWBawehYGQiRUswKD4jJAGf+5qIpiL6vhS3EXR75scDrkw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 02 May 2023 10:34:39 +0000
  • Ironport-data: A9a23:zTYqtKvdXjajRR6hFyO7FWVJOefnVHBfMUV32f8akzHdYApBsoF/q tZmKWiBM/aNYmekc4x0PoS+8h8O7JKGzd5jHQM/+yo2ECgS+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg3HVQ+IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4bKj6Vv0gnRkPaoQ5AKGzSFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwEiEudDGmubOK6ZW9YO5q3McRCJfpBdZK0p1g5Wmx4fcOZ7nmG/mPwOACmTA6i4ZJAOrUY NcfZXx3dhPcbhZTO1ARTpUjgOOvgXq5eDpdwL6XjfNvvy6Pk0oui/60b4G9lt+iHK25mm6Co W3L5SLhCwwyP92D0zuVtHmrg4cjmAuiANxCROfgr64CbFu7/jAXUzQMZACCnNK0003uWsBZD 30Uw397xUQ13AnxJjXnZDWorXjBshMCVt54F+wh9BrL2qfS+xyeBGUPUnhGctNOnM08SCEu1 1SJt8j0HjEpu7qQIVqC8p+EoDX0PjIaRVLufgcBRAoBptz8+oc6i0qTSs45SfHuyNroBTv33 jaG6jAkgKkehtIK0KP9+k3bhzWrpd7CSQtdChjrY19JJzhRPOaND7FEI3CBhRqcBO51lmW8g UU=
  • Ironport-hdrordr: A9a23:ZJ2NkaCVUp9mEd3lHemW55DYdb4zR+YMi2TDtnoBKiC9F/byqy nAppgmPHPP5wr5O0tBpTnjAse9qBrnnPYejLX5Vo3CYOCJghrOEKhSqafk3j38C2nf24dmpM FdmnFFebjN5I5B/KLHCaKDYrQd/OU=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, May 02, 2023 at 10:43:13AM +0100, Andrew Cooper wrote:
> On 02/05/2023 10:22 am, Roger Pau Monne wrote:
> > When booting the BSP the portion of the code executed from the
> > trampoline page will be using the GDT located in the hypervisor
> > .text.head section rather than the GDT located in the trampoline page.
> 
> It's more subtle than this.
> 
> gdt_boot_descr references the trampoline GDT, but by it's position in
> the main Xen image.

Right, gdt_boot_descr GDTR references gdt_48, but the instance on the
Xen .text section, not the trampoline.

I've tried to explain this in the commit message, but maybe I've
failed to do so.

> >
> > If skip_realmode is not set the GDT located in the trampoline page
> > will be loaded after having executed the BIOS call, otherwise the GDT
> > from .text.head will be used for all the protected mode trampoline
> > code execution.
> >
> > Note that both gdt_boot_descr and gdt_48 contain the same entries, but
> > the former is located inside the hypervisor .text section, while the
> > later lives in the relocated trampoline page.
> >
> > This is not harmful as-is, as both GDTs contain the same entries, but
> > for consistency with the APs switch the BSP trampoline code to also
> > use the GDT on the trampoline page.
> >
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, although ...
> 
> > ---
> >  xen/arch/x86/boot/trampoline.S | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
> > index cdecf949b410..e4b4b9091d0c 100644
> > --- a/xen/arch/x86/boot/trampoline.S
> > +++ b/xen/arch/x86/boot/trampoline.S
> > @@ -164,6 +164,12 @@ GLOBAL(trampoline_cpu_started)
> >  
> >          .code32
> >  trampoline_boot_cpu_entry:
> > +        /*
> > +         * Load the GDT from the relocated trampoline page rather than the
> > +         * hypervisor .text section.
> > +         */
> > +        lgdt    bootsym_rel(gdt_48, 4)
> 
> ... I'd suggest rewording this to simply /* Switch to trampoline GDT */,
> or perhaps with an "alias" in there somewhere.

"Switch to the relocated trampoline GDT." maybe?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.