[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: Roger Pau Monne <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 2 May 2023 10:43:13 +0100
  • 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=y/ohsvz7RMYZ/9dWDuDSvtZTZRcuZhJhikCKGjbfp9M=; b=ijOuBBMk0c71m43wZbFuuiKP8ae9/PULpH2zcthzKUVxQdCVhjfmMx8BiebxI/s+4Bu/aDa1v/OlQ1Od6SZ4lwnV+uV87f1AvT2KYwMfIJdGmKZwD5ZWoU8n++X+bDOn0yrPFRsstChtGb+Ls09/lGsWt/Uwj7NQSWHH5icsKwtFMox6uPFIj0IA4HpgQ7fsSk2ocsxCPJ81tET4/pV7nof5ziuF0XaytSDHwpTLp35vH7+yFeMnWRfCncj6904M2ULMl0T+II33VnS5HxJH9raMKT1pAXth3/0hLCKCNdC+IBqpe5UhRbadgaPXYz6OllAZzZddm71/HsyfOWbqbQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vcn2R3zHW7Yk7eCf2+geCobSmlIBLWoztBjE51PVNQGH1okYj3h2698Iu3mRk+GPhpT7BFkhuoKoEL2p6BZQWNezUHyVs7dvmMQ35QwCeq6a4i+FbtUvLEsawiExBqt1xmoNc5yQb85XVM+yxoM0KY3ZOosCUKxcBEv5gwSKDfE5y+dEoAcyNrvxDkPAVeSm0gUkF3BBzZdUFzG668nYUDe47qCo/BahMGHV5sqwux2IAI6eos56Hf99J27Im+jpAeBuO7lkBnWJ1O1msJNBANek1T4XLo5DhnGeeTVqwv9m+ZTts1a1ixnxRrj5qC0NRkzICa0JwyTey+BnPJnWag==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 02 May 2023 09:43:37 +0000
  • Ironport-data: A9a23:iZ+TGKysO+xm+jKOPJZ6t+caxyrEfRIJ4+MujC+fZmUNrF6WrkVTm 2JLXDuPOazeY2L2ctF2PIyw8k8A75+BnINhGlM4qyAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UIHUMja4mtC5QRjPaoT5TcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KT1B+ tdGDxkgVRyGg92nxoOdW9J0ott2eaEHPKtH0p1h5RfwKK9+BLrlHODN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvDCVlVQpuFTuGIO9ltiibMNZhEuH4 EnB+Hz0GEoyP92D0zuVtHmrg4cjmAuiANxCS+LgpqACbFu75F0sCTsGeEWAotKGh0+jauAGd F1Kw397xUQ13AnxJjXnZDWorXjBshMCVt54F+wh9BrL2qfS+xyeBGUPUnhGctNOnM08SCEu1 1SJt8j0HjEpu7qQIVqC8p+EoDX0PjIaRVLufgcBRAoBptPl/4c6i0uXSs45SfbtyNroBTv33 jaG6jAkgKkehtIK0KP9+k3bhzWrpd7CSQtdChjrY19JJzhRPOaND7FEI3CChRqcBO51lmW8g UU=
  • Ironport-hdrordr: A9a23:+gkPba3ShLyJWOJP9nScEQqjBfdxeYIsimQD101hICG9Lfbo6f xGzc5rqiMc1gxhJE3I+erwSJVoj0msvKKdkrNhSotKOzOW9FdATbsSoLcKpgeQahEWmdQtp5 uITZIOcOEYYWIKxvoSpTPIWerJ7rG8gcaVbM3lvhJQpTgDUdAG0++SYjzra3GePTM2YabRd6 DsqPavxQDQCkj/Nf7LfUXtNtKrz7an+P2JAH52ZCLPqjP+xQ9Ax4SKaSRwtS1uJw+nr41Sh1 Qt3zaJk5lKcpmAu33hPzi51eUYpDKt8KoEOOW8zugTNjHmjEKJSe1aKsC/lQFwhNvqxEchkd HKrRtlF8Nv60nJdmXwhRf2wQHv3Bsn9nenkDaj8CPeiP28YAh/J9tKhIpffBecw008vOtk2K YO+26CrZJYAT7JgSy4zdnVUBNBkFayvBMZ4Lcupk0adbFbRK5arIQZ8k8QOJAcHBji4IRiK+ VqBNG03ocSTXqqK1Ti+kV/yt2lWXo+Wj2cRFIZh8CT2z9K2Fhk0kox3qUk7ys93aN4b6MBy/ XPM6xumr0LZNQRd7hBCOAIRtbyInDRQCjLLHmZLT3cZfw60kr22sDKCYgOlbCXkMRi9upjpH 2BaiIDiYcKQTOwNSXUt6c7oSwkQw2GLHbQI49llspEU4bHNfnW2B24ORETevSb0rUi6+3gKr KO0cFtcrjexC3VaN109jy7fYVOJnwXV89Qnt46XlaHpavwQLHXig==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

>
> 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.

The important point here is that we want to shed all pre-trampoline
state, and unexpectedly being on the wrong GDT alias certainly
complicated debugging this...


> +
>          cmpb    $0,bootsym_rel(skip_realmode,5)
>          jnz     .Lskip_realmode
>  




 


Rackspace

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