Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oMDZh-0003wv-1u for mharc-grub-devel@gnu.org; Thu, 11 Aug 2022 15:10:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMDZf-0003rQ-7r for grub-devel@gnu.org; Thu, 11 Aug 2022 15:10:31 -0400 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]:47304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMDZd-0001Pq-8n for grub-devel@gnu.org; Thu, 11 Aug 2022 15:10:30 -0400 Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 701ED3FB99 for ; Thu, 11 Aug 2022 19:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1660245027; bh=hUhj4xVWV7i7kcWOSw9PKIOewcy2KLy7hUSFmlSeALs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JvfFDGvxb4Ky1UyLUiF1YIdF6mYNxCfwhk09hK6SY0yqMo+lOG0wljB0qxkLwTbCr kN5pKEOKE7+SX6uV8DBhdG9NHglkuaA2DbrJz+xvo7c/3Fc4NQKyvJRpsdo3zPj0HB wkG4yuiAg9c7FIbasgkYcycoIa2ZNQ8R2ftotSkAsetEQHqWBMRL7vDUhTvqXu1Uqc KZisrNZtloq1YoHnwOT3ugj91M43/isBjwETWksWupBWqUzCZd0V9cUF7rx/D7Eael +gGAVMSlKbDp2BIWdLS0EtyTh/GEj525rOvo9hJWysEmM7DSnmfoWbjlwlqsdia4F9 T/5S41C+PmIdQ== Received: by mail-ua1-f71.google.com with SMTP id d18-20020ab03192000000b0038785905f99so3799169uan.16 for ; Thu, 11 Aug 2022 12:10:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=hUhj4xVWV7i7kcWOSw9PKIOewcy2KLy7hUSFmlSeALs=; b=FVuzeUZ9FcRkWyRL4db+Pzzy/n9IZs1l2OJRiWKEiCj+TLqwKSVWJmYcUWmLSJ+iYK t0zO/cr2yu90O4MXBkPPPwEhgj7c+IamGrRHEunEv7qzphzJB+TMcGAVeZxERJf+nnyw wGqzER2jvhCzEvHRyjvMCwsRzQLb9TINlcpEaldcNdJ6b1jEDItvDvF1vT+bPWYQMaJY 8fmNK+oE169o5A0jZx9O5sW00eJS4XSAT4+ZKd2EqwJ1ELPE9rRiipwke/KEZfdcW69J 9oX+Mb5uC49H6bIH9hrSE2Af3Hr6KXc+ccaQ+p4/h7nrDn0+O4azapUf96v1t0V6PkEN BQmg== X-Gm-Message-State: ACgBeo1PGrop4ie8w6g2tXd9SB4w3ZU34sX3P+3NF1TAYjkfxV/WkDBN hIHEezDcGNZcyfxQYTGIuPlySeG0iuE4WH06DvgorOId/dXtlJAXfd42MrKPzangOHrL1vWuo6b u8kShNnGxjHoUM0aYuWSHuY1bgjpP X-Received: by 2002:a05:6102:35c:b0:381:5d05:4eed with SMTP id e28-20020a056102035c00b003815d054eedmr291717vsa.74.1660245026117; Thu, 11 Aug 2022 12:10:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR6fIp/rY8D97jEgLS//TfrCICxkbup/p/NhqJDS1P8SHF2f6jQwj5g6tmRAkZjERWUPn7iSzQ== X-Received: by 2002:a05:6102:35c:b0:381:5d05:4eed with SMTP id e28-20020a056102035c00b003815d054eedmr291705vsa.74.1660245025851; Thu, 11 Aug 2022 12:10:25 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:4e1:83a2:2ee9:2118:a2dc:3dd6]) by smtp.gmail.com with ESMTPSA id g7-20020a67ea07000000b00384b60a5160sm120094vso.12.2022.08.11.12.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 12:10:25 -0700 (PDT) From: Mauricio Faria de Oliveira To: xen-devel@lists.xenproject.org, grub-devel@gnu.org Cc: Daniel Kiper , =?UTF-8?q?Peter=20Gro=C3=9Fe?= Subject: [PATCH 1/2] templates/linux_xen: Properly load multiple initrd files Date: Thu, 11 Aug 2022 16:10:13 -0300 Message-Id: <20220811191014.139882-2-mfo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220811191014.139882-1-mfo@canonical.com> References: <20220811191014.139882-1-mfo@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=185.125.188.122; envelope-from=mfo@canonical.com; helo=smtp-relay-internal-0.canonical.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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: Thu, 11 Aug 2022 19:10:31 -0000 The linux_xen template can put multiple initrd files in the same multiboot[2] module[2] command, which is against specs. This causes ONLY the _first_ initrd file to be loaded; other files just have filenames in a "cmdline" string of the first initrd file and are NOT loaded. Fix this by inserting a module[2] command per initrd file. Before: # touch /boot/xen /boot/microcode.cpio # grub-mkconfig 2>/dev/null | grep -P '^\t(multiboot|module)' multiboot /boot/xen ... module /boot/vmlinuz-5.4.0-122-generic ... module --nounzip /boot/microcode.cpio /boot/initrd.img-5.4.0-122-generic After: # touch /boot/xen /boot/microcode.cpio # grub-mkconfig 2>/dev/null | grep -P '^\t(multiboot|module)' multiboot /boot/xen ... module /boot/vmlinuz-5.4.0-122-generic ... module --nounzip /boot/microcode.cpio module --nounzip /boot/initrd.img-5.4.0-122-generic Cause: The code was copied from the linux template, which is *apparently* equivalent.. but its initrd command grub_cmd_initrd() *supports* multiple files (see grub_initrd_init()), while module/module2 in grub_cmd_module() *does not* (see grub_multiboot[2]_add_module()). See commit e86f6aafb8de ("grub-mkconfig/20_linux_xen: Support multiple early initrd images"): 'This is basically a copy of a698240d "grub-mkconfig/10_linux: Support multiple early initrd images" ...' Specs: Both multiboot and multiboot2 specifications mention support for 'multiple boot modules' (struct/tag used for kernel/initrd files): "Boot loaders don’t have to support multiple boot modules, but they are strongly encouraged to" [1,2] However, there is a 1:1 relationship between boot modules and files, more or less clearly; note the usage of singular/plural "module(s)". (Multiboot2, clearly: "One tag appears per module".) Multiboot [1]: "the ‘mods’ fields indicate ... what boot modules were loaded ..., and where they can be found. ‘mods_count’ contains the number of modules loaded" "The first two fields contain the start and end addresses of the boot module itself." Multiboot2 [2]: "This tag indicates ... what boot module was loaded ..., and where it can be found." "The ‘mod_start’ and ‘mod_end’ contain the start and end physical addresses of the boot module itself." "One tag appears per module. This tag type may appear multiple times." And both clearly mention the 'string' field of a boot module, which is to be used by the operating system, not boot loader: "The ‘string’ field provides an arbitrary string to be associated with that particular boot module ... its exact use is specific to the operating system." Links: [1] https://www.gnu.org/software/grub/manual/multiboot/multiboot.html 3.3 Boot information format [2] https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html 3.6.6 Modules Fixes: e86f6aafb8de ("grub-mkconfig/20_linux_xen: Support multiple early initrd images") Signed-off-by: Mauricio Faria de Oliveira --- util/grub.d/20_linux_xen.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 4382303c17f0..50c62562b730 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -162,12 +162,12 @@ EOF message="$(gettext_printf "Loading initial ramdisk ...")" initrd_path= for i in ${initrd}; do - initrd_path="${initrd_path} ${rel_dirname}/${i}" - done - sed "s/^/$submenu_indentation/" << EOF + initrd_path="${rel_dirname}/${i}" + sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' ${module_loader} --nounzip $(echo $initrd_path) EOF + done fi if test -n "${xenpolicy}" ; then message="$(gettext_printf "Loading XSM policy ...")" -- 2.34.1