Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nHOAp-0001aB-FT for mharc-grub-devel@gnu.org; Tue, 08 Feb 2022 05:56:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHOAn-0001WG-Pn for grub-devel@gnu.org; Tue, 08 Feb 2022 05:56:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33252) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHOAl-00034U-V3 for grub-devel@gnu.org; Tue, 08 Feb 2022 05:56:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644317794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3LVewSSUUwpdyLjrGYwoUjXi4Mq9FrkYKneeT/JfIow=; b=BiGruozY9H2SogCNachrvKx64G+lIU9PszSyHWk0H5lc+ftAn+Pml5EM3f3PSYAQxtQiCR 1oEEr6qLvjAqNIdoEg8uvV9IlCQVSGFBCRqB91tKLp7XOMWUUc93W7azr1OfbOwOpzfIPD t294q56SCrHANKQizzMrlzjAMn9yJQI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-BuebP597Pw6TPzSoLAQbpQ-1; Tue, 08 Feb 2022 05:56:33 -0500 X-MC-Unique: BuebP597Pw6TPzSoLAQbpQ-1 Received: by mail-wm1-f72.google.com with SMTP id f7-20020a1cc907000000b0034b63f314ccso391199wmb.6 for ; Tue, 08 Feb 2022 02:56:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3LVewSSUUwpdyLjrGYwoUjXi4Mq9FrkYKneeT/JfIow=; b=kbzc3mArwfDNb4MF5TVnXuWFrZ8Oirl1ispdBwhmaHGyHQZzYTzLC5fJVMvglg10ws T6vyRYrtIC4ADr7AAHrtpY45+40ASo/hCcqH26F5lBl0oQBiksmWLKVA0klQtWT3PYpa muKeBiJ6j0bFdUz6iH4qZ+ML6Gaj7tfdSA81OPluNFR9mvqgXGj/PS+RXDAD1+3UKjs0 qT3mpLR3NBR+C/FbaF1wTgCh8E3jMiuXvIlX8FxCAe1qO3EkopweLEM+JchSm4Rob4dp InTjOcg1CZy8iwSNLxir0LbufC4eArvJeun9x9B8OB28L06Gb4AqwKpVvk19w0lyxulJ gUlA== X-Gm-Message-State: AOAM530PRFmbLqMZRFOQV4Hn3lDwEW/gGoZ9VuSaqsmu+7sLnpmT652a 40s6m7fF3xgr7Uyc9f/d0783MVK0QStGL6L95vYLT90wy1laNCxxHzE7ETZs1k4rOAEdgjqy1AR 6OqaucLpd71Q/OpyjOFeAi+iTBkld87xk+ZY0hDoLMI7lyPAx5UvV4Qc+SH++Vmk= X-Received: by 2002:a05:600c:a0a:: with SMTP id z10mr622000wmp.124.1644317792465; Tue, 08 Feb 2022 02:56:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVqHdwmIphTFrWJL1kv2l2ydmg+tH4pNQcxXfztux5SCv2CNtsBQLcAa6FcDRs0gvfsXZHPg== X-Received: by 2002:a05:600c:a0a:: with SMTP id z10mr621981wmp.124.1644317792174; Tue, 08 Feb 2022 02:56:32 -0800 (PST) Received: from t590.redhat.com (82-64-217-13.subs.proxad.net. [82.64.217.13]) by smtp.gmail.com with ESMTPSA id e17sm14347064wrt.27.2022.02.08.02.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 02:56:31 -0800 (PST) From: =?UTF-8?q?Renaud=20M=C3=A9trich?= To: grub-devel@gnu.org Cc: =?UTF-8?q?Renaud=20M=C3=A9trich?= Subject: [PATCH v1] efi: make sure EFI disk controllers are connected when discovering devices Date: Tue, 8 Feb 2022 11:56:15 +0100 Message-Id: <20220208105615.97192-1-rmetrich@redhat.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rmetrich@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=rmetrich@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: Tue, 08 Feb 2022 10:56:38 -0000 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 --- 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); -- 2.34.1