From patchwork Tue Nov 21 20:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13463532 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 DDE67C61D85 for ; Tue, 21 Nov 2023 20:16:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.638180.994509 (Exim 4.92) (envelope-from ) id 1r5XA6-0007CJ-F2; Tue, 21 Nov 2023 20:15:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 638180.994509; Tue, 21 Nov 2023 20:15:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r5XA6-0007CC-Bs; Tue, 21 Nov 2023 20:15:58 +0000 Received: by outflank-mailman (input) for mailman id 638180; Tue, 21 Nov 2023 20:15:57 +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 1r5XA5-0007Bx-BF for xen-devel@lists.xenproject.org; Tue, 21 Nov 2023 20:15:57 +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 c5e7804c-88aa-11ee-9b0e-b553b5be7939; Tue, 21 Nov 2023 21:15:55 +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: c5e7804c-88aa-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1700597755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SMthb4NtkNO2RAGaFUKKyekiWRpIMs0yeackPSSJ3Nc=; b=VfD5t2hsDMSClkAICzWKTQf08hWf3LOSUF/vVy0p7chzOJTqhf3iZ9RO 41yZWjkIkJ9MYsgj6Ns3bQQ9iLcvmjJuxlgkCDJnmsri4j/6VCxnbEY5l y6kZ3h026+VzlvetAG25Gl5430LIgHaIrOTEdOx9vScq7GPMcrxKSKkDV w=; X-CSE-ConnectionGUID: +GZ+UsK9SGatMSUbv7Cxvg== X-CSE-MsgGUID: eEvee9pQQCazgXO2Vt1ohA== Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 127464600 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:IFo2MKN8Rs/+wvfvrR1Dl8FynXyQoLVcMsEvi/4bfWQNrUpw0jxSm mMXXmiPO/beYGX8KthzOo2x/UoOsJ7RndYxTwto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CQ6jefQAOOkVIYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/7rRC9H5qyo42pB5AVmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0qVYMyJz7 t9JEx8EcjW4uuion5mrVOY506zPLOGzVG8eknRpzD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SyHhneQ6Kf3Fhie0lM/Xlp0sP0f2F mAvQzlw62p98i60xPY12jeq69bl7Lau5Z+Lf3JpMgJDz3mzj+pfYhlW7qP+AopqPyy8j8R4Z XxiiZlEcRvznvbOlivpxjg0RSI6kdm11bSjXGZnF7qqojBXzQ4B8BdwaJVGyGpo3YIjZVT0L 9v12ncjoFQDh/LgWDF78XIPisa3XackD4DlvIWhHoacaZ2Us4rkWRWlHklbavpVkrBmfwaOd grKt3A6/NfdlHfS3jYu21mx7WXNEgOIg== X-Talos-CUID: 9a23:2riqdmjCpUro7ISMMsq7mXSuKjJuMVLvj0rLAB6DJm91bYaoQ0HP07N6nJ87 X-Talos-MUID: 9a23:vLR/9guwDWOE0LzpB82niRx8Oco5+52XI0kfnqUh4feYbCtwEmLI X-IronPort-AV: E=Sophos;i="6.04,216,1695700800"; d="scan'208";a="127464600" 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 1/5] x86/setup: Clean up cmdline handling in create_dom0() Date: Tue, 21 Nov 2023 20:15:36 +0000 Message-ID: <20231121201540.1528161-2-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 There's a confusing mix of variables; a static dom0_cmdline[], and a cmdline pointer which points to image->string before being pointed at the static buffer in order to be passed into construct_dom0(). cmdline being a mutable pointer falls over -Wwrite-strings builds. Delete the cmdline pointer, and rename dom0_cmdline[] to cmdline extending it to have full function scope. 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: * New. This unravelled a bit, so I pulled it into a separate patch, but the end result is much clearer to follow IMO. --- xen/arch/x86/setup.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c41dfdb2bdf8..c0302c6bdd62 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -873,6 +873,8 @@ static struct domain *__init create_dom0(const module_t *image, module_t *initrd, const char *kextra, const char *loader) { + static char __initdata cmdline[MAX_GUEST_CMDLINE]; + struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, @@ -885,7 +887,6 @@ static struct domain *__init create_dom0(const module_t *image, }, }; struct domain *d; - char *cmdline; domid_t domid; if ( opt_dom0_pvh ) @@ -913,33 +914,30 @@ static struct domain *__init create_dom0(const module_t *image, panic("Error creating d%uv0\n", domid); /* Grab the DOM0 command line. */ - cmdline = image->string ? __va(image->string) : NULL; - if ( cmdline || kextra ) + if ( image->string || kextra ) { - static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; - - cmdline = cmdline_cook(cmdline, loader); - safe_strcpy(dom0_cmdline, cmdline); + if ( image->string ) + safe_strcpy(cmdline, cmdline_cook(__va(image->string), loader)); if ( kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(dom0_cmdline, kextra); + safe_strcat(cmdline, kextra); /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") ) - safe_strcat(dom0_cmdline, " noapic"); + if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) + safe_strcat(cmdline, " noapic"); + if ( (strlen(acpi_param) == 0) && acpi_disabled ) { printk("ACPI is disabled, notifying Domain 0 (acpi=off)\n"); safe_strcpy(acpi_param, "off"); } - if ( (strlen(acpi_param) != 0) && !strstr(dom0_cmdline, "acpi=") ) + + if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") ) { - safe_strcat(dom0_cmdline, " acpi="); - safe_strcat(dom0_cmdline, acpi_param); + safe_strcat(cmdline, " acpi="); + safe_strcat(cmdline, acpi_param); } - - cmdline = dom0_cmdline; } /*