kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Zixuan Wang <zxwang42@gmail.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, drjones@redhat.com,
	marcorr@google.com, erdemaktas@google.com, rientjes@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 2/7] x86 UEFI: Refactor set up process
Date: Fri, 5 Nov 2021 18:54:06 +0000	[thread overview]
Message-ID: <YYV9ztwl/7Z5LqyT@google.com> (raw)
In-Reply-To: <20211031055634.894263-3-zxwang42@gmail.com>

On Sat, Oct 30, 2021, Zixuan Wang wrote:
> +efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo)
>  {
> +	efi_status_t status;
> +
> +	status = setup_memory_allocator(efi_bootinfo);
> +	if (status != EFI_SUCCESS) {
> +		printf("Failed to set up memory allocator: ");
> +		switch (status) {
> +		case EFI_OUT_OF_RESOURCES:
> +			printf("No free memory region\n");
> +			break;
> +		default:
> +			printf("Unknown error\n");
> +			break;
> +		}
> +		return status;
> +	}
> +	
> +	status = setup_rsdp(efi_bootinfo);
> +	if (status != EFI_SUCCESS) {
> +		printf("Cannot find RSDP in EFI system table\n");
> +		return status;
> +	}
> +
> +	status = setup_amd_sev();
> +	if (status != EFI_SUCCESS) {
> +		switch (status) {
> +		case EFI_UNSUPPORTED:
> +			/* Continue if AMD SEV is not supported */
> +			break;
> +		default:
> +			printf("Set up AMD SEV failed\n");
> +			return status;
> +		}
> +	}

Looks like this is pre-existing behavior, but the switch is quite gratuituous,
and arguably does the wrong thing for EFI_UNSUPPORTED here as attempting to setup
SEV-ES without SEV is guaranteed to fail.  And it'd be really nice if the printf()
actually provided the error (below might be wrong, I don't know the type of
efi_status-t).

	status = setup_amd_sev();

	/* Continue on if AMD SEV isn't supported, but skip SEV-ES setup. */
	if (status == EFI_UNSUPPORTED)
		goto continue_setup;

	if (status != EFI_SUCCESS) {
		printf("AMD SEV setup failed, error = %d\n", status);
		return status;
	}

	/* Same as above, lack of SEV-ES is not a fatal error. */
	status = setup_amd_sev_es();
	if (status != EFI_SUCCESS && status != EFI_UNSUPPORTED) {
		printf("AMD SEV-ES setup failed, error = %d\n", status);
		return status;
	}

continue_setup:

> +
> +	status = setup_amd_sev_es();
> +	if (status != EFI_SUCCESS) {
> +		switch (status) {
> +		case EFI_UNSUPPORTED:
> +			/* Continue if AMD SEV-ES is not supported */
> +			break;
> +		default:
> +			printf("Set up AMD SEV-ES failed\n");
> +			return status;
> +		}
> +	}
> +
>  	reset_apic();
>  	setup_gdt_tss();
>  	setup_idt();
> @@ -343,9 +334,9 @@ void setup_efi(efi_bootinfo_t *efi_bootinfo)
>  	enable_apic();
>  	enable_x2apic();
>  	smp_init();
> -	phys_alloc_init(efi_bootinfo->free_mem_start, efi_bootinfo->free_mem_size);
> -	setup_efi_rsdp(efi_bootinfo->rsdp);
>  	setup_page_table();
> +
> +	return EFI_SUCCESS;
>  }
>  
>  #endif /* TARGET_EFI */
> -- 
> 2.33.0
> 

  reply	other threads:[~2021-11-05 18:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31  5:56 [kvm-unit-tests PATCH v1 0/7] x86_64 UEFI set up process refactor and scripts fixes Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 1/7] x86 UEFI: Remove mixed_mode Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 2/7] x86 UEFI: Refactor set up process Zixuan Wang
2021-11-05 18:54   ` Sean Christopherson [this message]
2021-11-09 17:16     ` Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 3/7] x86 UEFI: Convert x86 test cases to PIC Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 4/7] x86 UEFI: Set UEFI OVMF as readonly Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 5/7] x86 UEFI: Exit QEMU with return code Zixuan Wang
2021-10-31 10:01   ` Paolo Bonzini
2021-10-31 21:36     ` Zixuan Wang
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 6/7] scripts: Generalize EFI check Zixuan Wang
2021-10-31  7:13   ` Paolo Bonzini
2021-10-31 15:35     ` Marc Orr
2021-10-31  5:56 ` [kvm-unit-tests PATCH v1 7/7] x86 UEFI: Make run_tests.sh (mostly) work under UEFI Zixuan Wang
2021-10-31  7:28 ` [kvm-unit-tests PATCH v1 0/7] x86_64 UEFI set up process refactor and scripts fixes Paolo Bonzini
2021-10-31 16:14   ` Marc Orr
2021-10-31 21:54     ` Zixuan Wang
2021-11-01  7:11       ` Andrew Jones
2021-11-01 22:35         ` Zixuan Wang

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=YYV9ztwl/7Z5LqyT@google.com \
    --to=seanjc@google.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=drjones@redhat.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=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 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).