Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nHmpP-0006lo-J8 for mharc-grub-devel@gnu.org; Wed, 09 Feb 2022 08:16:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHmpN-0006hO-V9 for grub-devel@gnu.org; Wed, 09 Feb 2022 08:16:09 -0500 Received: from mail.csgraf.de ([85.25.223.15]:35120 helo=zulu616.server4you.de) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHmpL-0001Io-K9 for grub-devel@gnu.org; Wed, 09 Feb 2022 08:16:09 -0500 Received: from [0.0.0.0] (ec2-3-122-114-9.eu-central-1.compute.amazonaws.com [3.122.114.9]) by csgraf.de (Postfix) with ESMTPSA id 7849E60806B1; Wed, 9 Feb 2022 14:16:05 +0100 (CET) Message-ID: <2be34079-a56d-0e9b-b406-608fb63e77ac@csgraf.de> Date: Wed, 9 Feb 2022 14:16:04 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v1] efi: make sure EFI disk controllers are connected when discovering devices To: The development of GNU GRUB , =?UTF-8?Q?Renaud_M=c3=a9trich?= References: <20220208105615.97192-1-rmetrich@redhat.com> Cc: Benjamin Herrenschmidt From: Alexander Graf In-Reply-To: <20220208105615.97192-1-rmetrich@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=85.25.223.15; envelope-from=agraf@csgraf.de; helo=zulu616.server4you.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Feb 2022 13:16:10 -0000 On 08.02.22 11:56, Renaud Métrich wrote: > When efi.quickboot is enabled on VMWare (which is the default for > hardware release 16 and later), it may happen that not all EFI devices > are connected. Due to this, browsing the devices in make_devices() just > fails to find devices, in particular partitions for a given disk. > This typically happens when network booting, then trying to chainload to > local disk (this is used in deployment tools such as Red Hat Satellite). > > This patch makes sure all controllers are connected before enumerating > the disks. It blindly calls the EFI ConnectController function with > recursive option and just ignores the result, which is 0 (EFI_SUCCESS) > or 14 (EFI_NOT_FOUND) when the handle is not a controller. > > Signed-off-by: Renaud Métrich Isn't this going to slow down most normal boots? Is there a way we can only try harder to find devices once the "fast path" is exhausted? This could be useful for other systems as well, where we could delay probing for floppy drives until such a point. I'm thinking of something akin to udev_settle. You typically search for devices by UUID. If you find the UUID, all is good. If you don't, invoke the "try to find additional devices" path. Alex > --- > grub-core/disk/efi/efidisk.c | 10 ++++++++++ > grub-core/kern/efi/efi.c | 13 +++++++++++++ > include/grub/efi/efi.h | 5 +++++ > 3 files changed, 28 insertions(+) > > diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c > index f077b5f55..0b16c3868 100644 > --- a/grub-core/disk/efi/efidisk.c > +++ b/grub-core/disk/efi/efidisk.c > @@ -387,6 +387,16 @@ static void > enumerate_disks (void) > { > struct grub_efidisk_data *devices; > + unsigned i; > + grub_efi_handle_t *handles; > + grub_efi_uintn_t num_handles; > + > + /* Prior to enumerating, make sure all EFI devices are connected */ > + > + handles = grub_efi_locate_handle (GRUB_EFI_ALL_HANDLES, > + NULL, NULL, &num_handles); > + for (i = 0; i < num_handles; i++) > + (void) grub_efi_connect_controller(handles[i], NULL, NULL, 1); > > devices = make_devices (); > if (! devices) > diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c > index 18858c327..bdfff3dd0 100644 > --- a/grub-core/kern/efi/efi.c > +++ b/grub-core/kern/efi/efi.c > @@ -95,6 +95,19 @@ grub_efi_locate_handle (grub_efi_locate_search_type_t search_type, > return buffer; > } > > +grub_efi_status_t > +grub_efi_connect_controller (grub_efi_handle_t controller_handle, > + grub_efi_handle_t *driver_image_handle, > + grub_efi_device_path_protocol_t *remaining_device_path, > + grub_efi_boolean_t recursive) > +{ > + grub_efi_boot_services_t *b; > + > + b = grub_efi_system_table->boot_services; > + return efi_call_4 (b->connect_controller, controller_handle, > + driver_image_handle, remaining_device_path, recursive); > +} > + > void * > grub_efi_open_protocol (grub_efi_handle_t handle, > grub_efi_guid_t *protocol, > diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h > index fc723962d..62dbd9788 100644 > --- a/include/grub/efi/efi.h > +++ b/include/grub/efi/efi.h > @@ -32,6 +32,11 @@ EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type, > grub_efi_guid_t *protocol, > void *search_key, > grub_efi_uintn_t *num_handles); > +grub_efi_status_t > +EXPORT_FUNC(grub_efi_connect_controller) (grub_efi_handle_t controller_handle, > + grub_efi_handle_t *driver_image_handle, > + grub_efi_device_path_protocol_t *remaining_device_path, > + grub_efi_boolean_t recursive); > void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle, > grub_efi_guid_t *protocol, > grub_efi_uint32_t attributes);