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

Re: [PATCH v3 1/3] multiboot2: parse vga= option when setting GOP mode


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 7 Jun 2023 11:41:24 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=VgiZ0t3JvhPPvFdp7H1rr5uqGPk/tLlbwEYKPq8KVdo=; b=LeGcxks24Lr3htX0jFIRHZxn1Sb11iKp+RCYvvJN/NClydzm6ofwFdM06ftVmhH757ipkhZQX0sjH5o4rIY2Cf7J7tSZzGzqN4u+mKh/bOfMCP2ilKGyXqynb4h5R9b0FujvP1aLfGQYeIg0qx6iBvVd6wNIlO29z2AT+9tf0JfFEqQYk8bs0ZPdHp9Ty3cDlaM/DUqLtaOMtx2fVWZhdwwjeo+9ECew7xQZWa+2k5JugZ/XG59iOg152xOvDmwWIYVMj/gHwAvIQ8PIpMRvXIIDLG7nGb6rvnva0M8nUFhysyEkyhCSxpxBbfAadFMENhYiT7efbvHU4IAUztL7kQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nRYOwSUlVPCP5tY1eOTIDNqe4KBjJTg4Rkv1+LO2fAB4BmaHOOmPFV4Zlw3k7nG9doXp4tUtml0HK0JfOflrgQq4K8HfUnmrmgaigfj/8Vk/PXBbvuj0YQirQZ8VcrmqBdh2duOxBRLuTcl2E3NFjGOBX6MN/0yiDWo2eYCp0KJOE6Uqz97DGv6bgLVmn8GSVOqd5Rgu0u5sKHcZa1GfPAtcBCBUT/bqdAGyHRPTtmlRjevMpqemCtdr/B3xGosHOldavEnjL0uPz2LjbUFZvBGErv1ZCFIkuemFkZ9FqlkCRfSVV+nVH5aZG6zi+fqX52TzYi0v119z96gBlcgsQA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 07 Jun 2023 09:41:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.06.2023 15:05, Roger Pau Monne wrote:
> --- a/xen/arch/x86/boot/head.S
> +++ b/xen/arch/x86/boot/head.S
> @@ -226,9 +226,10 @@ __efi64_mb2_start:
>          jmp     x86_32_switch
>  
>  .Lefi_multiboot2_proto:
> -        /* Zero EFI SystemTable and EFI ImageHandle addresses. */
> +        /* Zero EFI SystemTable, EFI ImageHandle addresses and cmdline. */
>          xor     %esi,%esi
>          xor     %edi,%edi
> +        xor     %edx,%edx

While perhaps better to leave this as you have it, ...

> @@ -266,6 +267,13 @@ __efi64_mb2_start:
>          cmove   MB2_efi64_ih(%rcx),%rdi
>          je      .Lefi_mb2_next_tag
>  
> +        /* Get command line from Multiboot2 information. */
> +        cmpl    $MULTIBOOT2_TAG_TYPE_CMDLINE,MB2_tag_type(%rcx)
> +        jne     .Lno_cmdline
> +        lea     MB2_tag_string(%rcx),%rdx
> +        jmp     .Lefi_mb2_next_tag
> +.Lno_cmdline:

... in new blocks of code I think it would be nice if commas were
followed by visually separating blanks.

> @@ -329,7 +337,8 @@ __efi64_mb2_start:
>  
>          /*
>           * efi_multiboot2() is called according to System V AMD64 ABI:
> -         *   - IN:  %rdi - EFI ImageHandle, %rsi - EFI SystemTable.
> +         *   - IN:  %rdi - EFI ImageHandle, %rsi - EFI SystemTable,
> +         *          %rdx - MB2 cmdline
>           */
>          call    efi_multiboot2

All you obtain is a pointer to the string, which is fine from what I
was able to establish, but that's not entirely obvious: The MBI
structure used has a size field, so it could have been that the
string isn't nul-terminated, and hence the size would also need
passing. May I ask that this be mentioned at least in the description?

> --- a/xen/arch/x86/efi/efi-boot.h
> +++ b/xen/arch/x86/efi/efi-boot.h
> @@ -786,7 +786,30 @@ static bool __init 
> efi_arch_use_config_file(EFI_SYSTEM_TABLE *SystemTable)
>  
>  static void __init efi_arch_flush_dcache_area(const void *vaddr, UINTN size) 
> { }
>  
> -void __init efi_multiboot2(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
> *SystemTable)
> +/* Return the first occurrence of opt in cmd. */
> +static const char __init *get_option(const char *cmd, const char *opt)
> +{
> +    const char *s = cmd, *o = NULL;
> +
> +    if ( !cmd || !opt )
> +        return NULL;
> +
> +    while ( (s = strstr(s, opt)) != NULL )
> +    {
> +        if ( s == cmd || *(s - 1) == ' ' )

Iirc I had asked before: Not allowing for at least tab? (See
cmdline.c:delim_chars_comma[] for what the non-EFI parsing permits,
which in turn might be going a little too far especially with
permitting comma as well.)

> +        {
> +            o = s + strlen(opt);

I don't think the comment ahead of the function describes this
behavior, i.e. in particular the adding of the length of the
option.

> @@ -807,7 +830,41 @@ void __init efi_multiboot2(EFI_HANDLE ImageHandle, 
> EFI_SYSTEM_TABLE *SystemTable
>  
>      if ( gop )
>      {
> -        gop_mode = efi_find_gop_mode(gop, 0, 0, 0);
> +        const char *last = cmdline;

Nit: Maybe better "cur" than "last"?

> +        unsigned int width = 0, height = 0, depth = 0;
> +        bool keep_current = false;
> +
> +        while ( (last = get_option(last, "vga=")) != NULL )
> +        {
> +            if ( !strncmp(last, "gfx-", 4) )
> +            {
> +                width = simple_strtoul(last + 4, &last, 10);
> +                if ( *last == 'x' )
> +                    height = simple_strtoul(last + 1, &last, 10);
> +                if ( *last == 'x' )
> +                    depth = simple_strtoul(last + 1, &last, 10);
> +                if ( *last != ' ' && *last != '\t' && *last != '\0' &&
> +                     *last != ',' )
> +                    width = height = depth = 0;
> +                keep_current = false;
> +            }
> +            else if ( !strncmp(last, "current", 7) )
> +                keep_current = true;
> +            else if ( !strncmp(last, "keep", 4) )
> +            {
> +                /* Ignore. */

Maybe "Ignore here, handled in ..."?

Jan



 


Rackspace

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