All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paluri, PavanKumar" <papaluri@amd.com>
To: Michael Roth <michael.roth@amd.com>
Cc: kvm@vger.kernel.org, pbonzini@redhat.com, andrew.jones@linux.dev,
	nikos.nikoleris@arm.com, thomas.lendacky@amd.com,
	amit.shah@amd.com
Subject: Re: [kvm-unit-tests RFC PATCH 2/3] x86/efi: Retry call to efi exit boot services
Date: Tue, 26 Mar 2024 08:45:53 -0500	[thread overview]
Message-ID: <4c2c7598-2c07-0cd6-620c-1a603bcb1f0f@amd.com> (raw)
In-Reply-To: <20240326133801.p4eqegjor54mn3h5@amd.com>

Hi Mike,

On 3/26/2024 8:38 AM, Michael Roth wrote:
> On Mon, Mar 25, 2024 at 04:36:22PM -0500, Pavan Kumar Paluri wrote:
>> In some cases, KUT guest might fail to exit boot services due to a
>> possible memory map update that might have taken place between
>> efi_get_memory_map() and efi_exit_boot_services() calls. As per UEFI
>> spec 2.10 (Section 7.4.6 EFI_BOOT_SERVICES.ExitBootServices()), we need
>> to update the memory map and retry call to exit boot
>> services.
>>
>> Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
>> ---
>>  lib/efi.c | 23 ++++++++++++++++++-----
>>  1 file changed, 18 insertions(+), 5 deletions(-)
>>
>> diff --git a/lib/efi.c b/lib/efi.c
>> index 124e77685230..9d066bfad0b6 100644
>> --- a/lib/efi.c
>> +++ b/lib/efi.c
>> @@ -458,14 +458,27 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab)
>>  	}
>>  #endif
>>  
>> -	/* 
>> +	/*
>>  	 * Exit EFI boot services, let kvm-unit-tests take full control of the
>> -	 * guest
>> +	 * guest.
>>  	 */
>>  	status = efi_exit_boot_services(handle, &efi_bootinfo.mem_map);
>> -	if (status != EFI_SUCCESS) {
>> -		printf("Failed to exit boot services\n");
>> -		goto efi_main_error;
> 
> With this change, error codes other than EFI_INVALID_PARAMETER are only
> handled if the first failure is EFI_INVALID_PARAMETER. Need to to re-add
> the previous handling for when the first EBS failure is something other
> than EFI_INVALID_PARAMETER.
> 
But the status codes that could be returned from
efi_exit_boot_services() are only EFI_INVALID_PARAMETER/EFI_SUCCESS [1].

[1] UEFI 2.10 Section 7.4.6.

Thanks,
Pavan

> -Mike
> 
>> +
>> +	/*
>> +	 * There is a possibility that memory map might have changed
>> +	 * between efi_get_memory_map() and efi_exit_boot_services in
>> +	 * which case status is EFI_INVALID_PARAMETER. As per UEFI spec
>> +	 * 2.10, we need to get the updated memory map and try again.
>> +	 */
>> +	if (status == EFI_INVALID_PARAMETER) {
>> +		efi_get_memory_map(&efi_bootinfo.mem_map);
>> +
>> +		status = efi_exit_boot_services(handle,
>> +						&efi_bootinfo.mem_map);
>> +		if (status != EFI_SUCCESS) {
>> +			printf("Failed to exit boot services\n");
>> +			goto efi_main_error;
>> +		}
>>  	}
>>  
>>  	/* Set up arch-specific resources */
>> -- 
>> 2.34.1
>>

  reply	other threads:[~2024-03-26 13:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 21:36 [kvm-unit-tests RFC PATCH 1/3] x86 EFI: Bypass call to fdt_check_header() Pavan Kumar Paluri
2024-03-25 21:36 ` [kvm-unit-tests RFC PATCH 2/3] x86/efi: Retry call to efi exit boot services Pavan Kumar Paluri
2024-03-26  8:57   ` Andrew Jones
2024-03-26 13:29     ` Paluri, PavanKumar
2024-03-26 13:38   ` Michael Roth
2024-03-26 13:45     ` Paluri, PavanKumar [this message]
2024-03-26 13:58       ` Michael Roth
2024-03-25 21:36 ` [kvm-unit-tests RFC PATCH 3/3] x86 AMD SEV-ES: Setup a new page table and install level 1 PTEs Pavan Kumar Paluri
2024-03-26 14:01   ` Tom Lendacky
2024-03-26 15:35     ` Paluri, PavanKumar
2024-03-26  8:51 ` [kvm-unit-tests RFC PATCH 1/3] x86 EFI: Bypass call to fdt_check_header() Andrew Jones
2024-03-26 13:28   ` Paluri, PavanKumar
2024-03-26 15:30   ` Paluri, PavanKumar

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=4c2c7598-2c07-0cd6-620c-1a603bcb1f0f@amd.com \
    --to=papaluri@amd.com \
    --cc=amit.shah@amd.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=nikos.nikoleris@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=thomas.lendacky@amd.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.