From patchwork Tue Nov 21 20:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13463533 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 54CF9C61D97 for ; Tue, 21 Nov 2023 20:16:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.638182.994529 (Exim 4.92) (envelope-from ) id 1r5XA9-0007hX-0Y; Tue, 21 Nov 2023 20:16:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 638182.994529; Tue, 21 Nov 2023 20:16:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5XA8-0007hK-Te; Tue, 21 Nov 2023 20:16:00 +0000 Received: by outflank-mailman (input) for mailman id 638182; Tue, 21 Nov 2023 20:15:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5XA7-0007Bx-1G for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 20:15:59 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c7a0f2a2-88aa-11ee-9b0e-b553b5be7939; Tue, 21 Nov 2023 21:15:57 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c7a0f2a2-88aa-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1700597757; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zhFqeBE6+dVJCflG9ZGRRYk/WpALPCbVG60q2etK4II=; b=BW7A2YyFmjWN24+UDkmP12zTh8dNbOAI6w/AEURezRjJ3e5dJ6PERoY9 jomYta76/Qt9kB15yUCaI8AtSVO/t2PA8ZgeXsX6lcLwtUzDmQ2ULzefs ++nSSYaArZczJ2w4WlrdEJzrwFhY+iFHIDrjhTrwfyIa7OMRx1MHATHVX I=; X-CSE-ConnectionGUID: +GZ+UsK9SGatMSUbv7Cxvg== X-CSE-MsgGUID: H2Ia19A2RQmFFwSxh4AdHQ== Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 127464601 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.159.70 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:/FnTPKuUYR9imAmGJy+qrLoIpufnVLBeMUV32f8akzHdYApBsoF/q tZmKW2GafuMMTfye94gbo+080sE7JXUm9RnHgZu/31mH3gS+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVaicfHg3HFc4IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4rKq5Fv0gnRkPaoQ5QaEziFPZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwax8/LS2YpLON77unb9JRjNp8B9n1M9ZK0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tZZmMmzUL/KiWAiIuNloI6BSqhTjt0b7iHx2Z2Rtbcz4n+8ZpzU H11yL4+4CquLWDygbR0m/V49BslNSJ8KoPOOW8zuYUNxDlgUKQZJ1sXr2EsHQOvemz9ExCqq iBnz4Qe+py9lbYdSWNuh3v1wP8uQxeokPK+Bu3gWbHqce8fSk9CMZKmMZ4f3LimgIdleA5/q JX+mqT86NNCxDNljm43tDUVnhR5wGJiEtnsekOi3dYFasyAYUh1rD2tCtuYeo99GiT0vFaLM BeSOfB+flSeVSZK1TQvmxqyNvEZB4OIis= X-Talos-CUID: 9a23:og0zG2mjVcoHell2OC0bblIbR6TXOT7y/jTtOGzpMklgVJiudFWOp4h0jcU7zg== X-Talos-MUID: 9a23:D141jAnqhRS0Xh9Kjj1adnpCbuZhuvWHUno0lLsopPKUNXBZNxek2WE= X-IronPort-AV: E=Sophos;i="6.04,216,1695700800"; d="scan'208";a="127464601" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Roberto Bagnara , Nicola Vetrini Subject: [PATCH v2 3/5] x86/efi: Simplify efi_arch_handle_cmdline() Date: Tue, 21 Nov 2023 20:15:38 +0000 Message-ID: <20231121201540.1528161-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231121201540.1528161-1-andrew.cooper3@citrix.com> References: <20231121201540.1528161-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 -Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but all this work is useless; it's making a memory allocation just to prepend the image name which cmdline_cook() intentionally strips back out. Simply forgo the work and identify EFI_LOADER as one of the loaders which doesn't prepend the image name. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Roberto Bagnara CC: Nicola Vetrini v2: * Brand new. I can't find anything which cares about the image name in the slightest. This logic is from bf6501a62e80 ("x86-64: EFI boot code") when EFI was introduced, at whcih point GRUB2 was the only excluded loader in cmdline_cook(). --- xen/arch/x86/efi/efi-boot.h | 10 +--------- xen/arch/x86/setup.c | 7 +++++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index eebc54180bf7..1a2a2dd83c9b 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -309,6 +309,7 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name, { union string name; + /* NB place_string() prepends, so call in reverse order. */ if ( cmdline_options ) { name.w = cmdline_options; @@ -317,15 +318,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name, } if ( cfgfile_options ) place_string(&mbi.cmdline, cfgfile_options); - /* Insert image name last, as it gets prefixed to the other options. */ - if ( image_name ) - { - name.w = image_name; - w2s(&name); - } - else - name.s = "xen"; - place_string(&mbi.cmdline, name.s); if ( mbi.cmdline ) mbi.flags |= MBI_CMDLINE; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b171a8f4cf84..200520392481 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -850,8 +850,11 @@ static const char *__init cmdline_cook(const char *p, const char *loader_name) while ( *p == ' ' ) p++; - /* GRUB2 and PVH don't not include image name as first item on command line. */ - if ( xen_guest || loader_is_grub2(loader_name) ) + /* + * PVH, our EFI loader, and GRUB2 don't not include image name as first + * item on command line. + */ + if ( xen_guest || efi_enabled(EFI_LOADER) || loader_is_grub2(loader_name) ) return p; /* Strip image name plus whitespace. */