Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43334C83F25 for ; Mon, 21 Jul 2025 23:43:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ue09h-00030H-4o; Mon, 21 Jul 2025 19:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ue09V-0002vF-PG for grub-devel@gnu.org; Mon, 21 Jul 2025 19:42:39 -0400 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ue09T-0002sF-CX for grub-devel@gnu.org; Mon, 21 Jul 2025 19:42:37 -0400 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3e2b2a6bb0fso876845ab.3 for ; Mon, 21 Jul 2025 16:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753141353; x=1753746153; darn=gnu.org; h=mime-version:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=bbzBddkfbZlvM6usOTYQ7UG7vXW17UW4hAxcHmWU3a4=; b=mYvR1i8JsQ6e6v+IwcdEE68Vf1KVqFmchDUuMDRqKB0maa95YetbqBfV1CKIb9aE9q yJRwJrXoLl4CvEPl0ldif24+/KgBOhkvxiPC+VyLh1tnG0Amto2t7ShCM0Qc70dvuHxp sEajAsrqM2famFtUauByR2lI0JuFxS8cuTHNsy6aBl2Bym0MWqlsUHDXFBTbMbTmHyCH ykYV331kHKOlCzwMdN4dgb9AP+ncU2KxwtvSsr4fvr35CxXimeJ9dMvIEaeacARqU+ye w8LoBUSY+hpu5mV0443tXRKhPNYDGOo1T0/SFNAj38xrNC4bhTeelFLba/SEMDQViztw umOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753141353; x=1753746153; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bbzBddkfbZlvM6usOTYQ7UG7vXW17UW4hAxcHmWU3a4=; b=aptlrqfkQdK0M9IoanYyvkamsbL0qbuY3C/KT9gDSg3QW7bjWP1K+LjPhBvAIYXwn5 /Q2KbFqfqHOKeU6EmpKsAH+h30pdgp466uwlHqtlgNnp4+93NdPjiGauq01I9RYez2a+ HRToo+eYG5oRknt/uDXEpR4thFu88I2C8ZbZo/Fck0U7N3TiQAv3xC8ctUJi3CWqf0uC xmr6oRl4JHUc7gWfcK+SKP3CHVGXZVJv5sAb6p+CLoYjiygNInPpC+YgREGVIkV2rNKQ xp49S10XP3xCLnH6iGWa8Wv4A5d4HE7Ts0l9oE8Otk26N5HWVkxVbxjjlbBPRK4SR0zJ XmOg== X-Gm-Message-State: AOJu0Yzk8jvAt/Ae6VGGXR6tEfejXiS3sAZGjzqyRneQAyWgEq2bIXtw gZJ9qe43hoRkYQtNEy61z2hQ5EPyEl0BeOAUvD7E3b9A40Zaih1Npgs2qnenrokt X-Gm-Gg: ASbGncun0CH/P/0E6s5JRxjmBbktWoj7vI8bniYGXeiNgHv32g0sqRFpGC0KcaN9oBt 0gUVMdCDp/gDP95kpjSZjMHBfqZP+A9QMCF2HyvqS5BFOhX+isHRpPU5yIATg/dTarsaemg6flc l8cTmyJZxnZQ4IPl/woVzNB7ZdtJMygsEvVp8JNtnhTj8/FzL/vP8mSEBdGqh3bB4/fZAeviHOg Fp5zaBON5uZvHPCex4lO/QT0Fjw5Yhzmo/agNODlJiLzeyLZsuHdnMMSMMEkjJPUK5qGGqc3NXP PuOp8vS0NjFWYOISY0PH+k6ivusHbnsFfFo8DlTuMVD98Sou+kJq3jveY89jzOti/dRkddp0YK+ 6HxyO1B0yXDrhwL4zrU3M X-Google-Smtp-Source: AGHT+IFabfYbh1TtbnnHh/DDe864sZMPBM6Y/O1jL7CYNGoEMjfWv++eRAhrqXyLxkV0tQUoVg2BjQ== X-Received: by 2002:a05:6e02:df3:b0:3dd:990b:83e3 with SMTP id e9e14a558f8ab-3e2821dc09bmr57645115ab.0.1753141352791; Mon, 21 Jul 2025 16:42:32 -0700 (PDT) Received: from kf-m2g5 ([2607:fb90:bf84:45ad:48e4:ec32:d2d1:cd6e]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-5084c787a7asm2083242173.14.2025.07.21.16.42.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 16:42:32 -0700 (PDT) Date: Mon, 21 Jul 2025 18:42:25 -0500 From: Aaron Rainbolt To: grub-devel@gnu.org Subject: [RESEND PATCH v3 0/1] kern/xen: Add Xen command line parsing Message-ID: <20250721184225.0fdd5913@kf-m2g5> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::129; envelope-from=arraybolt3@gmail.com; helo=mail-il1-x129.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Reply-To: The development of GNU GRUB Content-Type: multipart/mixed; boundary="===============3346557500265777128==" Errors-To: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org Sender: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org --===============3346557500265777128== Content-Type: multipart/signed; boundary="Sig_/XzK+Z+qYl1rN1wxqcFQB1vF"; protocol="application/pgp-signature"; micalg=pgp-sha512 --Sig_/XzK+Z+qYl1rN1wxqcFQB1vF Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable The purpose of this patch is to allow the Xen hypervisor to pass extra data to GRUB in the form of a kernel command line, allowing the host to customize the boot process of the guest. The command line from Xen is parsed, and any variables within that start with the string `xen_grub_env_` are exposed as environment variables. The grub.cfg script can then use those environment variables as it sees fit. The main reason for doing this is to allow implementing boot modes in Qubes OS while also using in-VM kernels. For more context on Qubes boot modes, see [1]. In order for this to work with in-VM kernels, it is necessary for dom0 to pass kernel parameters to the guest without modifying the guest's grub.cfg manually. This patch allows this to be done, by allowing dom0 to pass kernel parameters to GRUB, which then provides them to grub.cfg as an environment variable. The grub.cfg script within the VM can then append those variables to the kernel command line. The patch's code is unchanged from the last time I sent it [2], I've simply rebased it on top of the latest commit at the time of this writing (0e36779). I have not run it through the full test suite used previously, but I have ensured that both PV and PVH bootloaders build successfully and can boot an Arch Linux virtual machine on an Arch Linux host. Changes from the version 2 of the patch: * Added documentation for the future to the GRUB manual. * Fixed error checking when allocating memory. * Enhanced coding style, code efficiency, and comments based on Daniel Kiper's previous review and my own re-review. * Added an explicit null termination check on the Xen-provided kernel command line before parsing. * Fixed some memory management issues that could result in unnecessary memory consumption (one memory leak and a couple of places where an extra byte was allocated that didn't need to be). [1] https://github.com/QubesOS/qubes-linux-pvgrub2/pull/16 [2] https://lists.gnu.org/archive/html/grub-devel/2025-06/msg00011.html Aaron Rainbolt (1): kern/xen: Add Xen command line parsing docs/grub.texi | 50 +++++ grub-core/Makefile.core.def | 2 + grub-core/kern/i386/xen/pvh.c | 14 ++ grub-core/kern/main.c | 12 ++ grub-core/kern/xen/cmdline.c | 343 ++++++++++++++++++++++++++++++++++ include/grub/xen.h | 2 + 6 files changed, 423 insertions(+) create mode 100644 grub-core/kern/xen/cmdline.c --=20 2.50.1 --Sig_/XzK+Z+qYl1rN1wxqcFQB1vF Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEudh48PFXwyPDa0wGpwkWDXPHkQkFAmh+0GEACgkQpwkWDXPH kQnJ3RAAuHJZ1ku5cvRPB93rpTUa4cSwrmsujgOWXSOachTK+kUON8SQUoMy5yOH 4cEitwtomuIDdhkLuqXWlx139hWbWeNMsBIoHnQSsSwJxXPflJGVRlA+MhMdMVSM Jcm0c9CT5sdFCouW/apycSms0YorBkx04xA+UOs3yM8mkixT2uibNG6qk17RQRet 5n/VEAKCq8EHr+HgkUBVEd3I5TdlWSwSFShLjp436jfq++rJC12qDi70g0YGbD9Q rmLdENEMlO4g+GGbKSf3rZDHwrR5jgDKrHTY2W052/5HWbfEAz2vTRGRwBWBrV+e tYcWlRwJ9n0xbgMIBHM6YB3MkUkAre8566a+NUr9pyoVaDLZxcRL7UI5rYS6nD0c TPQ8CQh0Twwd7sed56zAjOzaHQHgLSIWqqDKB/FLWew8snkGkjxaoK2LaXYY+bnt ip+aPRq8ApobKY693m36GIZG07BjZAhz8DZc37HWgpHDkZ9zfX5Avw5WlenE9yjl eVKJDuCJtr8LUmqd22qltdg+P56pmiGq/gCWQhUmRYkwyWyLKYqisgFjk9g6XRrV 01+w+B/eS2Wl/mTjz5b7XiF98d0d1Q6gLdhsFQltFh0fPGfpPxwEiK/dbS5AWnTj c5Br3I6IiJRCXJokvPwbVUyIzLg8pYMUFEJGPHGd60Gc2eY/4Xg= =jM+1 -----END PGP SIGNATURE----- --Sig_/XzK+Z+qYl1rN1wxqcFQB1vF-- --===============3346557500265777128== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR3J1Yi1kZXZl bCBtYWlsaW5nIGxpc3QKR3J1Yi1kZXZlbEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t YWlsbWFuL2xpc3RpbmZvL2dydWItZGV2ZWwK --===============3346557500265777128==--