Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oQsqo-0003ul-6D for mharc-grub-devel@gnu.org; Wed, 24 Aug 2022 12:03:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQsqj-0003q7-Ut for grub-devel@gnu.org; Wed, 24 Aug 2022 12:03:26 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:56278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQsqi-000453-BZ for grub-devel@gnu.org; Wed, 24 Aug 2022 12:03:25 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EF6B7208FA; Wed, 24 Aug 2022 16:03:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661357002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4eGC+SPQFh5G1U/nS4H0jW2Z//oQiRYMJMVlb4dm4fo=; b=DLgr4HTTx/5LYiLIW2i6setTZjy/tkRofERL6c16ZjM3CLcCD0KIa4vql/gXG2SeIC3IJ5 mOTDczlhpG4UUH+haOWvmn7F8f/5S48ummaJsWyXqP4OgA+0F8tNb3kOXELdgQ7zz3wJcc JhGKHK5AJEYpy9lLhyYLCEmj+yyvfW0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661357002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4eGC+SPQFh5G1U/nS4H0jW2Z//oQiRYMJMVlb4dm4fo=; b=bNa8fwiga/BLra+t40egpyFcbW6Ybv5DQdPrpW7ECwokACS6WbqaUy2KnEyvn5GMdKO8Kk +IJ/oJFOpYlL7uCw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D29D513780; Wed, 24 Aug 2022 16:03:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8E7aMMpLBmPdLQAAMHmgww (envelope-from ); Wed, 24 Aug 2022 16:03:22 +0000 From: Ismael Luceno To: grub-devel@gnu.org Cc: Ismael Luceno Subject: [PATCH 2/2] Ensure nvram is available and functional on IEEE1275 Date: Wed, 24 Aug 2022 18:03:11 +0200 Message-Id: <20220824160311.21160-3-iluceno@suse.de> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220824160311.21160-1-iluceno@suse.de> References: <20220824160311.21160-1-iluceno@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.29; envelope-from=iluceno@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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, 24 Aug 2022 16:03:26 -0000 Otherwise the installation will fail, and the system will be left in an unbootable state. On ppc64le, the boot process shows: Welcome to GRUB! error: ../../grub-core/kern/dl.c:380:symbol `grub_disk_get_size' not found. Entering rescue mode... grub rescue> Signed-off-by: Ismael Luceno --- grub-core/osdep/unix/platform.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c index a5bf064b7cf5..fd23176e58a0 100644 --- a/grub-core/osdep/unix/platform.c +++ b/grub-core/osdep/unix/platform.c @@ -192,12 +192,30 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, return ret; } +static void +linux_ensure_nvram (void) +{ + int fd; +#ifndef __linux__ + return 0; +#endif + if (linux_kmod_load("nvram")) + grub_util_error (_("%s: kernel module not found"), "nvram"); + fd = open ("/dev/nvram", O_RDWR); + if (fd == -1) + grub_util_error ("/dev/nvram: %s", strerror(errno)); + close (fd); +} + void grub_install_register_ieee1275 (int is_prep, const char *install_device, int partno, const char *relpath) { char *boot_device; + /* On Linux, ensure nvram is available and functional. */ + linux_ensure_nvram (); + if (grub_util_exec_redirect_null ((const char * []){ "ofpathname", "--version", NULL })) { /* TRANSLATORS: This message is shown when required executable `%s' -- 2.37.1