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 C46A6C369CB for ; Thu, 24 Apr 2025 02:47:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u7mbm-0006kC-R4; Wed, 23 Apr 2025 22:46:39 -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 1u7mbd-0006j2-Gc for grub-devel@gnu.org; Wed, 23 Apr 2025 22:46:31 -0400 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u7mbb-0007WJ-2E for grub-devel@gnu.org; Wed, 23 Apr 2025 22:46:28 -0400 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-3d90215ff34so205225ab.0 for ; Wed, 23 Apr 2025 19:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745462785; x=1746067585; darn=gnu.org; h=mime-version:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=K3UYpAobfU8CycQImfb9ZuPayhiVPBK6XDLgeWIPeJ0=; b=a/JityfcfPQ4mn1Jv0c64AX45aOpl3JfYz1pXdiMemRPiqChvSjlKA49S74mBqKxu6 4DHqV7P3D0fQdn3mjM6uNuHmK/ODcewno2vFx/OCzdb/BrbpLykRCHjZLP3EfFu14/yP YeC8CX150QnIc6j8hAqgYHG2LWudNJiJe4Vm8HXZVKfOj2+unr8uwz/IAcMReUya/ISO 9CNilLzSGK5OI/Ab8piN3VIGhvAJg1CS4hLI8aA4JwJFHgm38/w/YiUvCHQDER3XQVP2 FnEIBJki1ARBNC903xZf0bPXFbvdPc6Ufvr2hvKgwryL1z1HDNu6sIQXya8l+UuVFXNv m5LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745462785; x=1746067585; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=K3UYpAobfU8CycQImfb9ZuPayhiVPBK6XDLgeWIPeJ0=; b=TuIvuI5PQCr09xeJdUJjqUDh9XEl9nxS8gtPiHoTCuRg5P7HmKYZLdu/skmJqU8iYk lkdTx1LfVSny5/HevQx8PLuBGoQJ29ZGocPpDkZlYwVPT/lK3lkSZhHKlbB/qmnmFY0T 19TyH9rdICZC3cd3/HwYCDgn4Zhgq8/qM8pC0IE7byYRoIyedkJpDh1C82maYbrKf9fF lgpq74dI1lcxLHvXigqsccV+Auqz1cf9SwC26jbUiQD+GJgnexPoBeTGzR5o+P/iToUv /yDtOGqhrluABEUum5ySGzStPZkGvP7Dj6PY9MlpUZhtX9HHOpaYDOutHC3bozx6jWr5 YMrg== X-Gm-Message-State: AOJu0YxTNuBcpaXJs7DRtBidxWwCqXWdrVTI3X00rdUokOmHelhJ3zHv slMt1fYxd0HHt6YoiMxh13M49LTKGWuCs9TAd+pRFLO3buCy8q87zyZne8a5 X-Gm-Gg: ASbGnct1jfNGrqiqnmAyHFJyxrcBn9i2CaxVdprUYYVhc3PYXznICj1GsK29yFoc7ot UHj+0BjmlirVlqUBgQK1VLLTn3Q2Mos+ZX/u7PrF+xP60aL9OSm9zSg95iU/Ji3rX29wzBcyWkV IsBEy0cQ8zQgItNAGy9ufgKVjbWa25l+jvbEfMqJMlt6vcfWi4pLEINWO30RySGtK+gMtPCrtT4 EzYYq2rhzbuoUOT+1CyLexcgUuL7Gx8rxVww+5Pzit9Qo3vumXLruvzeLyNltWAtaMC5wN+5x8D PY7xOHxO8ws4mLgxJeMbsiin4R2spRBBdx62JZo= X-Google-Smtp-Source: AGHT+IFjr+cNf5C4L2z9LpMf4wn3y5TaMrx6cLtvIv1mNZGc56tUdwJAo7BxogyCbrdUJaW0g/9dNQ== X-Received: by 2002:a05:6e02:1523:b0:3d5:d743:808a with SMTP id e9e14a558f8ab-3d930466ecemr2311145ab.6.1745462785042; Wed, 23 Apr 2025 19:46:25 -0700 (PDT) Received: from kf-m2g5 ([2607:fb90:cf1d:8c21:c767:68fc:f6f5:fe2a]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4f824ba0f3bsm77352173.123.2025.04.23.19.46.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 19:46:24 -0700 (PDT) Date: Wed, 23 Apr 2025 21:46:15 -0500 From: Aaron Rainbolt To: grub-devel@gnu.org Subject: [PATCH 0/1] Add Xen command line parsing Message-ID: <20250423214615.23d46d47@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::132; envelope-from=arraybolt3@gmail.com; helo=mail-il1-x132.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="===============0912190771223656530==" Errors-To: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org Sender: grub-devel-bounces+grub-devel=archiver.kernel.org@gnu.org --===============0912190771223656530== Content-Type: multipart/signed; boundary="Sig_/Nj85HatSxrIkIVSLYxpUs3I"; protocol="application/pgp-signature"; micalg=pgp-sha512 --Sig_/Nj85HatSxrIkIVSLYxpUs3I 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. This is a significantly more robust version of the Xen command line parsing draft sent previously [2]. The patch has been tested with both PV and PVH virtual machines, using an otherwise unpatched GRUB source tree, building the patch on top of the tip of git master at the time of this writing (commit 4abac0a). My testing environment is a fully updated Arch Linux system with Xen built from the stable-4.20 branch. Some changes from the initial draft sent previously: * Only parameters starting with `xen_grub_env_` are exposed as environment variables. This solves two of the previous patch's issues - dom0 can no longer clobber arbitrary variables within grub.cfg (as it cannot define variables with names that don't start with `xen_grub_env`), and API breakage won't occur if in the future more features are added to GRUB that use the Xen-provided kernel command line. * Testing has been done as described above. [1] https://github.com/QubesOS/qubes-linux-pvgrub2/pull/16 [2] https://lists.gnu.org/archive/html/grub-devel/2025-04/msg00050.html Aaron Rainbolt (1): Add Xen command line parsing grub-core/Makefile.core.def | 2 + grub-core/kern/i386/xen/pvh.c | 16 ++ grub-core/kern/main.c | 12 ++ grub-core/kern/xen/cmdline.c | 270 ++++++++++++++++++++++++++++++++++ include/grub/xen.h | 2 + 5 files changed, 302 insertions(+) create mode 100644 grub-core/kern/xen/cmdline.c --=20 2.49.0 --Sig_/Nj85HatSxrIkIVSLYxpUs3I Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEudh48PFXwyPDa0wGpwkWDXPHkQkFAmgJpfcACgkQpwkWDXPH kQlSCA//eR3bTzTE8MDq0b6aAsCuxz9bObXieuME3NkXSSdhWdyZHWB6hAPageNb RyEmIH9U+/vCU75eu1YyxaTgjom/VxQHEGXwcHWBiKAxnM8XroDyNwdBO8r+ML29 m9xhrnuYFyA+LONxwPPZDKPqPMvnXW7ddhc9j/DdCdAuwNkNdLVt8Yl6RAu6mVZj k/NJsMO+bHQ1+XeJxkouXTwN/bshUmkFudcbTQZdzHXwBY+MUu829ZqnySmlsZf/ Z0LONxyckL+RDluYfiqorQ+ew1W+zq2rHaXIQiqIcNlyNxBXbjosUpk4LinBPsuv qyDH6z8IIaZqvxRWpxdYGB0rok6t54Lx1BWnVDFLmxUHYCEgnmiP7TlMtoAq9sI0 Auq+zsBCmhBfZRK9ueeDLk72GQEZL1NFaxvuu7G1Eu/bISjUSWllkKJB0mG3xay+ 97ZOnz2vPO+67nN9HHa26bu4rZECyOwfepa2+ladMRwnfkLqQXLl4l4RkJSWCRyt qjesvXhSgkIS90+ISJZZiwIhRlY+kV33m2u/omqhOUjyxT6wZgz2MhH3BltI7f0f ef4Oc8Fv8UEVi3umdet1hfEmIu+1KV/U7Do7kcn/juI9mAgPpSK8qvTrf8SZ3evr xqypMl0e4MP6SXwRsXP5AAMryaODwRpFi3TraUOkVKhRO8PBWUY= =S2/d -----END PGP SIGNATURE----- --Sig_/Nj85HatSxrIkIVSLYxpUs3I-- --===============0912190771223656530== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KR3J1Yi1kZXZl bCBtYWlsaW5nIGxpc3QKR3J1Yi1kZXZlbEBnbnUub3JnCmh0dHBzOi8vbGlzdHMuZ251Lm9yZy9t YWlsbWFuL2xpc3RpbmZvL2dydWItZGV2ZWwK --===============0912190771223656530==--