xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Anthony PERARD <anthony.perard@citrix.com>, xen-devel@lists.xen.org
Subject: Re: [RFC PATCH v2 07/16] hvmloader: Grab the hvmlite info page and parse the cmdline
Date: Wed, 4 Nov 2015 10:39:44 +0000	[thread overview]
Message-ID: <5639E070.4010503@citrix.com> (raw)
In-Reply-To: <1445875397-2846-8-git-send-email-anthony.perard@citrix.com>

On 26/10/15 16:03, Anthony PERARD wrote:
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
>  tools/firmware/hvmloader/hvmloader.c | 69 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 68 insertions(+), 1 deletion(-)

As part of using the DMLite infrastructure, hvmloader should gain
appropriate elfnotes.  This will avoid the need to duplicate the dmlite
codepath in libxc just for hvmloader.

>
> diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
> index 716d03c..9df12ac 100644
> --- a/tools/firmware/hvmloader/hvmloader.c
> +++ b/tools/firmware/hvmloader/hvmloader.c
> @@ -62,7 +62,7 @@ asm (
>      "    mov  %ax,%ss                \n"

mov %ebx, start_info

and have

static const struct hvm_start_info *hvmlite_start_info;

somewhere other than the main() stack.  However, I would avoid naming it
"hvmlite".

>      /* Initialise all 32-bit GPRs to zero. */
>      "    xor  %eax,%eax              \n"
> -    "    xor  %ebx,%ebx              \n"
> +    /* Keep ebx, for HVMLite start info */
>      "    xor  %ecx,%ecx              \n"
>      "    xor  %edx,%edx              \n"
>      "    xor  %esp,%esp              \n"
> @@ -249,15 +249,82 @@ static void acpi_enable_sci(void)
>      BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
>  }
>  
> +static const char *module_list_order = NULL;
> +void cmdline_parser(const char *the_cmdline)
> +{
> +    char cmdline[MAX_GUEST_CMDLINE];
> +    char *p, *q;
> +    char *optval;
> +
> +    strncpy(cmdline, the_cmdline, sizeof (cmdline));
> +    cmdline[MAX_GUEST_CMDLINE-1] = '\0';

Why do you need to copy the command line?  It is already in writable
hvmloader memory.

You also need to check for NULL, being the indication that no command
line has been provided.

~Andrew

> +
> +    for ( p = cmdline; p < (cmdline + MAX_GUEST_CMDLINE) && *p; p++ )
> +    {
> +        if ( *p == ' ' )
> +            continue;
> +
> +        /* search for the end of the parameter name */
> +        for ( q = p; *q && *q != '=' && *q != ' '; q++ )
> +            ;
> +
> +        /* search for the end of the optional paremeter value */
> +        if ( *q == '=' )
> +        {
> +            optval = q+1;
> +            if (*optval == '\0' || *optval == ' ') {
> +                optval = NULL;
> +            }
> +        } else
> +            optval = NULL;
> +        *q = '\0';
> +
> +        if ( optval )
> +        {
> +            for ( q = optval; *q && *q != ' '; q++ )
> +                ;
> +            *q = '\0';
> +        }
> +
> +        /* compare known parameters */
> +        if ( !strcmp(p, "modules") )
> +        {
> +            printf("  cmdline: found '%s', with val '%s'\n", p, optval);
> +            if ( optval )
> +            {
> +                unsigned size = strlen(optval) + 1;
> +                char *tmp = scratch_alloc(size, 0);
> +                strncpy(tmp, optval, size);
> +                module_list_order = tmp;
> +            }
> +        } else {
> +            printf("  Unknown cmdline option '%s'", p);
> +            if ( optval )
> +                printf(" with val '%s'\n", optval);
> +            else
> +                printf("\n");
> +        }
> +
> +        p = q;
> +    }
> +}
> +
>  int main(void)
>  {
>      const struct bios_config *bios;
>      int acpi_enabled;
> +    const struct hvm_start_info *hvmlite_start_info;
> +
> +    /* Load hvmlite start info pointer from ebx. */
> +    asm volatile ( "mov %%ebx,%0" : "=r" (hvmlite_start_info) );
>  
>      /* Initialise hypercall stubs with RET, rendering them no-ops. */
>      memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
>  
>      printf("HVM Loader\n");
> +    BUG_ON(hvmlite_start_info->magic != HVM_START_MAGIC_VALUE);
> +    printf("cmdline: %s\n", (char*)hvmlite_start_info->cmdline_paddr);
> +    cmdline_parser((char*)hvmlite_start_info->cmdline_paddr);
>  
>      init_hypercalls();
>  

  reply	other threads:[~2015-11-04 10:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 16:03 [RFC PATCH v2 00/16] Load BIOS via toolstack instead of been embedded in hvmloader Anthony PERARD
2015-10-26 16:03 ` [RFC PATCH v2 01/16] hvmloader: Fix scratch_alloc to avoid overlaps Anthony PERARD
2015-11-03 17:38   ` Ian Campbell
2015-11-10 16:29   ` Jan Beulich
2015-10-26 16:03 ` [RFC PATCH v2 02/16] libxc: Load BIOS and ACPI table into guest memory Anthony PERARD
2015-11-03 17:45   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 03/16] configure: #define SEABIOS_PATH and OVMF_PATH Anthony PERARD
2015-11-04 10:24   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 04/16] firmware/makefile: install BIOS and ACPI blob Anthony PERARD
2015-11-04 10:35   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 05/16] libxl: Load guest BIOS from file Anthony PERARD
2015-11-04 10:51   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 06/16] libxl: Load guest ACPI table " Anthony PERARD
2015-11-04 10:57   ` Ian Campbell
2015-12-18 14:43     ` Anthony PERARD
2015-10-26 16:03 ` [RFC PATCH v2 07/16] hvmloader: Grab the hvmlite info page and parse the cmdline Anthony PERARD
2015-11-04 10:39   ` Andrew Cooper [this message]
2015-11-04 11:02   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 08/16] hvmloader: Locate the BIOS blob Anthony PERARD
2015-11-04 11:05   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 09/16] hvmloader: Load SeaBIOS from hvm_start_info modules Anthony PERARD
2015-11-04 11:11   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 10/16] hvmloader: Load OVMF from modules Anthony PERARD
2015-11-04 11:15   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 11/16] hvmloader: No BIOS ROM image allowed to be compiled in Anthony PERARD
2015-11-04 11:17   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 12/16] hvmloader: Load ACPI tables from hvm_start_info module Anthony PERARD
2015-11-04 11:20   ` Ian Campbell
2015-10-26 16:03 ` [RFC PATCH v2 13/16] hvmloader/makefile: Compile out SeaBIOS and OVMF ROM blob Anthony PERARD
2015-10-26 16:03 ` [RFC PATCH v2 14/16] hvmloader: Always build-in SeaBIOS and OVMF loader Anthony PERARD
2015-10-26 16:03 ` [RFC PATCH v2 15/16] hvmloader: Compile out the qemu-xen ACPI tables Anthony PERARD
2015-10-26 16:03 ` [RFC PATCH v2 16/16] hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH Anthony PERARD
2015-11-03 17:30 ` [RFC PATCH v2 00/16] Load BIOS via toolstack instead of been embedded in hvmloader Ian Campbell
2015-11-03 17:50   ` Anthony PERARD
2015-11-04 10:18     ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5639E070.4010503@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).