All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Zixuan Wang <zxwang42@gmail.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, marcorr@google.com,
	erdemaktas@google.com, rientjes@google.com, seanjc@google.com,
	brijesh.singh@amd.com, Thomas.Lendacky@amd.com,
	varad.gautam@suse.com, jroedel@suse.de, bp@suse.de
Subject: Re: [kvm-unit-tests PATCH v1 0/3] x86 UEFI: pass envs and args
Date: Mon, 21 Feb 2022 09:40:56 +0100	[thread overview]
Message-ID: <20220221084056.edgpsgqdm2xph4kv@gator> (raw)
In-Reply-To: <20220220224234.422499-1-zxwang42@gmail.com>

On Sun, Feb 20, 2022 at 02:42:31PM -0800, Zixuan Wang wrote:
> Hello,
> 
> This patch series enables kvm-unit-tests to get envs and args under
> UEFI. The host passes envs and args through files:
> 
> 1. The host stores envs into ENVS.TXT and args into ARGS.TXT

EFI already has support for an environment and EFI apps can accept args.
Why not find a way to convert kvm-unit-tests ENV and unit tests args
into the EFI system and then use that?

efi_setup_argv()[*] in my original PoC does that. It uses gnu-efi, but
it should be easy to strip away the gnu-efi stuff and go straight for
the underlining EFI functions.

[*] https://github.com/rhdrjones/kvm-unit-tests/commit/12a49a2e97b457e23af10bb25cd972362b379951#:~:text=static%20void%20efi_setup_argv(EFI_HANDLE%20Image%2C%20EFI_SYSTEM_TABLE%20*SysTab)

If you want to mimic efi_setup_argv(), then you'll also need 85baf398
("lib/argv: Allow environ to be primed") from that same branch.

EFI wrapper scripts for each unit test can be generated to pass the args
to the unit test EFI apps automatically. For the environment, the EFI
vars can be set as usual for the system. For QEMU, that means creating
a VARS.fd and then adding another flash device to the VM to exposes it.

Thanks,
drew


> 2. The guest boots up and reads data from these files through UEFI file
> operation services
> 3. The file data is passed to corresponding setup functions
> 
> As a result, several x86 test cases (e.g., kvmclock_test and vmexit)
> can now get envs/args from the host [1], thus do not report FAIL when
> running ./run-tests.sh.
> 
> An alternative approach for envs/args passing under UEFI is to use
> QEMU's -append/-initrd options. However, this approach requires EFI
> binaries to be passed through QEMU's -kernel option. While currently,
> EFI binaries are loaded from a disk image. Changing this bootup process
> may make kvm-unit-tests (under UEFI) unable to run on bare-metal [2].
> On the other hand, passing envs/args through files should work on
> bare-metal because UEFI's file operation services do not rely on QEMU's
> functionalities, thus working on bare-metal.
> 
> The summary of this patch series:
> 
> Patch #1 pulls Linux kernel's UEFI definitions for file operations.
> 
> Patch #2 implements file read functions and envs setup functions.
> 
> Patch #3 implements the args setup functions.
> 
> Best regards,
> Zixuan
> 
> [1] https://github.com/TheNetAdmin/KVM-Unit-Tests-dev-fork/issues/8
> [2] https://lore.kernel.org/kvm/CAEDJ5ZQLm1rz+0a7MPPz3wMAoeTq2oH9z92sd0ZhCxEjWMkOpg@mail.gmail.com
> 
> Zixuan Wang (3):
>   x86 UEFI: pull UEFI definitions for file operations
>   x86 UEFI: read envs from file
>   x86 UEFI: read args from file
> 
>  lib/efi.c       | 150 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/linux/efi.h |  82 +++++++++++++++++++++++++-
>  x86/efi/run     |  36 +++++++++++-
>  3 files changed, 265 insertions(+), 3 deletions(-)
> 
> -- 
> 2.35.1
> 


  parent reply	other threads:[~2022-02-21  8:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-20 22:42 [kvm-unit-tests PATCH v1 0/3] x86 UEFI: pass envs and args Zixuan Wang
2022-02-20 22:42 ` [kvm-unit-tests PATCH v1 1/3] x86 UEFI: pull UEFI definitions for file operations Zixuan Wang
2022-02-20 22:42 ` [kvm-unit-tests PATCH v1 2/3] x86 UEFI: read envs from file Zixuan Wang
2022-02-20 22:42 ` [kvm-unit-tests PATCH v1 3/3] x86 UEFI: read args " Zixuan Wang
2022-02-21  8:40 ` Andrew Jones [this message]
2022-02-21 15:25   ` [kvm-unit-tests PATCH v1 0/3] x86 UEFI: pass envs and args Andrew Jones
2022-02-21 18:47     ` Zixuan Wang
2022-02-22  6:11     ` Gerd Hoffmann

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=20220221084056.edgpsgqdm2xph4kv@gator \
    --to=drjones@redhat.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=erdemaktas@google.com \
    --cc=jroedel@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=varad.gautam@suse.com \
    --cc=zxwang42@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.