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

Re: [PATCH v3] x86: Prioritize low memory size from Multiboot


  • To: Tu Dinh Ngoc <dinhngoc.tu@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 10 Feb 2022 10:38:01 +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=m5q6dxP/k7rShSl19FkBcKcwKdpKKn40N5IXShciDLY=; b=EnGshvLDUeTX2UY2Dv8rt60HESmQI7MyY1uqYWOo2LoKDpp+hWq0ifq+oqaSB5dl4vojEm2d/dETMmJQKOxtjEE/QeXVwRjxfGVUlSZ1njydib6ls28U4nsCRu8+rb3wASGiMEm61qE3sv3rJZRyk/IArFa76AZ1FU3gO/vDku635Y4c0JH/XsV5OrIol48SMOBUZ8b8VMYWjFIVqAVww/BSyk0WrOqCCV0k3tcS/hXOBUYQ3uXbQ/PhRlhFMu5KIm0IhyOQKUW+SapP323hppp83mqGcsGbhl8Ri+1M0iI7DR5QwqbHe8DPyZb3MAVTTPF4BTMK924iW2p+lU+mpw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G7pVBWX9mXBzlqpTeBGTHWjikGptsKKgsJjVWa/zSRwgGiEOzmZScAGXpQruA/lmQv2u2tV9gkYmarkuOO0AY++9OTJwKLrRqIVfmBVrsiFrPAYCVHkqlOyWI7I2qKN0Hqdjhaf2QOqA8UgdStQhCg+fnKeJHy8SrnTXF6w3LW4P1Gjb1PXkySlfMNT0GIWdnMLxJFyXtWaRznWYCPi96EpU9bwhnZ2GF3rJGaKa98DZ5H8BsGVmivDjBJfK6NCFPkCoUPBzSO7YGhf8yYMdHgEyC3t1Y2l76Zs7XfcGEP3/rmCvKgjOlDfXB3nkpdMoEpneswJlMnqXTGxodjLnbA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 10 Feb 2022 09:38:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 10.02.2022 09:44, Tu Dinh Ngoc 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.
> 
> Prioritize the information supplied by Multiboot instead. If this is not
> available, fall back to the old BDA method.

You're still failing to provide information on why this would be a safe
thing to do. In the absence of such, prior behavior has to be retained,
and only the special case you're after wants adjusting for. This is
first and foremost (but not limited to) you moving to ...

> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -524,27 +524,41 @@ 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
> +        /* Check if Multiboot provides us with low memory size. */
> +        mov     %edx,%ecx
> +        test    %ecx,%ecx
> +        jz      1f

... checking for just zero, when originally ...

> +        /*
> +         * Old Kexec used to report memory sizes in bytes instead of 
> kilobytes
> +         * like it's supposed to.
> +         *
> +         * If Multiboot reports more than 640 KB of low memory, assume we 
> have
> +         * this problem.
> +         */
> +        cmp     $640,%ecx
> +        jbe     0f
> +        shr     $10,%ecx
>  0:
> -        movzwl  0x413,%ecx          /* use base memory size on failure */
> +        /* %ecx now contains the low memory size in kilobytes. */
>          shl     $10-4,%ecx
> +        jmp     3f
> +
>  1:
>          /*
> -         * Compare the value in the BDA with the information from the
> -         * multiboot structure (if available) and use the smallest.
> +         * Multiboot doesn't provide us with memory info. Set up trampoline
> +         * segment 64k below EBDA as fallback.
>           */
> -        cmp     $0x100,%edx         /* is the multiboot value too small? */
> -        jb      2f                  /* if so, do not use it */

... the boundary was 0x100.

It was for this reason why in reply to v1 I did ask "Is the kexec case
recognizable by any means (including [...]), such that we could skip
using the BDA value in that case?" If it wasn't clear, I did mean
_just_ in this case.

> -        shl     $10-4,%edx
> -        cmp     %ecx,%edx           /* compare with BDA value */
> -        cmovb   %edx,%ecx           /* and use the smaller */
> -
> +        movzwl  0x40e,%ecx          /* EBDA segment */
> +        cmp     $0xa000,%ecx        /* sanity check (high) */
> +        jae     2f
> +        cmp     $0x4000,%ecx        /* sanity check (low) */
> +        jae     3f
>  2:
> +        movzwl  0x413,%ecx          /* use base memory size on failure */
> +        shl     $10-4,%ecx

I don't see why this shift can't be folded with the other one, by
moving it ...

> +
> +3:

... below here (and removing the one further up).

Jan

>          /* Reserve memory for the trampoline and the low-memory stack. */
>          sub     $((TRAMPOLINE_SPACE+TRAMPOLINE_STACK_SPACE)>>4),%ecx
>  




 


Rackspace

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