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

Re: [PATCH] x86: Use low memory size directly from Multiboot


  • To: dinhngoc.tu@xxxxxxx
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 9 Feb 2022 12:25:07 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=LUPm9P7Soho4UbNgVOVbXKJ0UODsyWCejIETI+XeZvQ=; b=TwXU3UIxK/BB3qakySqbdnnDFvYz2ZUKnX+sjI5OsKLONktZQYLHj1MIPQFA5HXcZI+FUNOHBJuEb72/sJ27COP0nfOTV+dvDZqjCB/PACRCVkV/KZJCnL9JIwtLezilioRwethAOvpAw8hKoPADiemItnAcqUdZW+u8UgofGlox56VWqnwIif762ZC/uUtpGJBycL1/6HLV9sO89PDmar2c1KYqw13H80kYUwBKuv0JLuDnMQPV73OoTqj/JKosWDJvD6Dyduf6NcoyknUWx8jH0jNRicwVGzngv1XcAZSXpYdM7A5hi7uLc0scGGn4oXi/lnzY+y9UdttxF5gL3g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kb5B3CTNnDc0ClWFkSKaEJz+chOdK2F7KzPFi/FVahsNAa7ItL+AxicKtdvhYfo0IA74y/LoLgLuQswI2EBwdEHM7vMNH1YJwR9DMCOZ1HEOLaCzSEqyOAmbIy+M3Q5WP9cgOoWBUBqYEAVF7pDaIFb33z0bEunluqH3Pfhe8ERcP+0b12CRfTr+HyZgnrwhsFt/EJ6FFBufIPPhMbLHCK0bfuOqc0JsVB8GUe7TUlQrNrh613mW5nyoRz67fnsHTqbHZXTaXggt8lhwN92julxpSSvONVy2haj32beyeWK6otyam9kboZ6UIUdzzm0uBgFG5huETzjpNuh14jK2kw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 09 Feb 2022 11:25:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09.02.2022 12:00, dinhngoc.tu@xxxxxxx wrote:
> Previously, Xen used information from the BDA to detect the amount of
> available low memory. This does not work on some scenarios such as
> Coreboot, or when booting from Kexec on a UEFI system without CSM.
> 
> Use the information directly supplied by Multiboot boot information
> instead.
> ---
>  xen/arch/x86/boot/head.S | 30 ++++++------------------------
>  1 file changed, 6 insertions(+), 24 deletions(-)
> 
> diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
> index dd1bea0d10..31a0663e6d 100644
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -524,33 +524,15 @@ trampoline_bios_setup:
>          mov     %ecx,%fs
>          mov     %ecx,%gs
>  
> -        /* Set up trampoline segment 64k below EBDA */
> -        movzwl  0x40e,%ecx          /* EBDA segment */
> -        cmp     $0xa000,%ecx        /* sanity check (high) */
> -        jae     0f
> -        cmp     $0x4000,%ecx        /* sanity check (low) */
> -        jae     1f
> -0:
> -        movzwl  0x413,%ecx          /* use base memory size on failure */
> -        shl     $10-4,%ecx
> -1:
> -        /*
> -         * Compare the value in the BDA with the information from the
> -         * multiboot structure (if available) and use the smallest.
> -         */
> -        cmp     $0x100,%edx         /* is the multiboot value too small? */
> -        jb      2f                  /* if so, do not use it */

The comment here is a pretty clear indication that bad values may have
been observed, even if this was only in the distant past. But we have
to not regress even on very old boot loaders.

Is the kexec case recognizable by any means (including to distinguish
kexec properly communicating the value vs it not doing so, as iirc it
was said on irc that this didn't always work correctly there), such
that we could skip using the BDA value in that case?

Jan

> -        shl     $10-4,%edx
> -        cmp     %ecx,%edx           /* compare with BDA value */
> -        cmovb   %edx,%ecx           /* and use the smaller */
> +        /* Use lower memory size directly from Multiboot */
> +        mov     %edx,%ecx
> +        /* From arch/x86/smpboot.c: start_eip had better be page-aligned!
> */
> +        shr     $2,%ecx
>  
> -2:
>          /* Reserve memory for the trampoline and the low-memory stack. */
> -        sub     $((TRAMPOLINE_SPACE+TRAMPOLINE_STACK_SPACE)>>4),%ecx
> +        sub     $((TRAMPOLINE_SPACE+TRAMPOLINE_STACK_SPACE)>>12),%ecx
>  
> -        /* From arch/x86/smpboot.c: start_eip had better be page-aligned!
> */
> -        xor     %cl, %cl
> -        shl     $4, %ecx
> +        shl     $12,%ecx
>          mov     %ecx,sym_esi(trampoline_phys)
>  
>  trampoline_setup:




 


Rackspace

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