From mboxrd@z Thu Jan 1 00:00:00 1970 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 8007AD11704 for ; Tue, 2 Dec 2025 16:07:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vQStv-0008EI-SG; Tue, 02 Dec 2025 11:06:52 -0500 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 1vQStk-0007Ze-8Z; Tue, 02 Dec 2025 11:06:40 -0500 Received: from mgamail.intel.com ([192.198.163.7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vQSti-0007th-1Z; Tue, 02 Dec 2025 11:06:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764691598; x=1796227598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iIFkXAwDouZhjCj49/RtwlrDvBr56i+CVsV4TELuVn4=; b=leb+3Umq3FrvL9TxKy2DDGrNvajrBQFzUb73EAyj660BMdF7o5D9jFAr lPkjCp/WFrELh4JHVIIbKrjkm1Rv36ZY+m5I4GQgLP50deP0aWdo3KM+p iomGUJe8s5qfqSnNOBkGA1xRyMGUlBwBRXJfEDbaQk2/7Xf0ofBAEjYV5 nDxBI04bKBe6/GRg960VUJuMbTF8V60Yxzi3DlMiUD+zUolVH8g4IC2M1 fyYgmhQQ5tZYbm8nSWHLNQx+NrnqHno4Fqla68FLCMd+PfaoYKX6Q1sDW rlU5X9dHD2gtwlacz9swIFXSH4/0aP1EQh3yMc8bU7dn8+EmZfUqwr1Rq A==; X-CSE-ConnectionGUID: +CPiD+8MRP69lDVNIt0jxw== X-CSE-MsgGUID: khA0VgnCSgiNxmMJnznuzA== X-IronPort-AV: E=McAfee;i="6800,10657,11630"; a="92142741" X-IronPort-AV: E=Sophos;i="6.20,243,1758610800"; d="scan'208";a="92142741" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2025 08:06:23 -0800 X-CSE-ConnectionGUID: lVG5CcosQviNXv4AEgnBgA== X-CSE-MsgGUID: ZQar24nhT0KDs9MH5czLOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,243,1758610800"; d="scan'208";a="199537512" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa005.jf.intel.com with ESMTP; 02 Dec 2025 08:06:14 -0800 From: Zhao Liu To: Paolo Bonzini , "Michael S . Tsirkin" , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Thomas Huth Cc: qemu-devel@nongnu.org, devel@lists.libvirt.org, kvm@vger.kernel.org, qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Sergio Lopez , Gerd Hoffmann , Peter Maydell , Laurent Vivier , Jiaxun Yang , Yi Liu , Eduardo Habkost , Alistair Francis , Daniel Henrique Barboza , Marcelo Tosatti , Weiwei Li , Amit Shah , Xiaoyao Li , Yanan Wang , Helge Deller , Palmer Dabbelt , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Ani Sinha , Fabiano Rosas , Liu Zhiwei , =?UTF-8?q?Cl=C3=A9ment=20Mathieu--Drif?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Huacai Chen , Jason Wang , Mark Cave-Ayland , BALATON Zoltan , Peter Krempa , Jiri Denemark , Zhao Liu Subject: [PATCH v5 15/28] hw/i386: Assume fw_cfg DMA is always enabled Date: Wed, 3 Dec 2025 00:28:22 +0800 Message-Id: <20251202162835.3227894-16-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251202162835.3227894-1-zhao1.liu@intel.com> References: <20251202162835.3227894-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=192.198.163.7; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Philippe Mathieu-Daudé Now all calls of x86 machines to fw_cfg_init_io_dma() pass DMA arguments, so the FWCfgState (FWCfgIoState) created by x86 machines enables DMA by default. Although other callers of fw_cfg_init_io_dma() besides x86 also pass DMA arguments to create DMA-enabled FwCfgIoState, the "dma_enabled" property of FwCfgIoState cannot yet be removed, because Sun4u and Sun4v still create DMA-disabled FwCfgIoState (bypass fw_cfg_init_io_dma()) in sun4uv_init() (hw/sparc64/sun4u.c). Maybe reusing fw_cfg_init_io_dma() for them would be a better choice, or adding fw_cfg_init_io_nodma(). However, before that, first simplify the handling of FwCfgState in x86. Considering that FwCfgIoState in x86 enables DMA by default, remove the handling for DMA-disabled cases and replace DMA checks with assertions to ensure that the default DMA-enabled setting is not broken. Then 'linuxboot.bin' isn't used anymore, and it will be removed in the next commit. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Zhao Liu --- Changes since v4: * Keep "dma_enabled" property in fw_cfg_io_properties[]. * Replace DMA checks with assertions for x86 machines. --- hw/i386/fw_cfg.c | 16 ++++++++-------- hw/i386/x86-common.c | 6 ++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 5c0bcd5f8a9f..5670e8553eaa 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -215,18 +215,18 @@ void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg) #ifdef CONFIG_ACPI void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg) { + uint8_t io_size; + Aml *dev = aml_device("FWCF"); + Aml *crs = aml_resource_template(); + /* * when using port i/o, the 8-bit data register *always* overlaps * with half of the 16-bit control register. Hence, the total size - * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the - * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 + * of the i/o region used is FW_CFG_CTL_SIZE; And the DMA control + * register is located at FW_CFG_DMA_IO_BASE + 4 */ - Object *obj = OBJECT(fw_cfg); - uint8_t io_size = object_property_get_bool(obj, "dma_enabled", NULL) ? - ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : - FW_CFG_CTL_SIZE; - Aml *dev = aml_device("FWCF"); - Aml *crs = aml_resource_template(); + assert(fw_cfg_dma_enabled(fw_cfg)); + io_size = ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t); aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 1ee55382dab8..e8dc4d903bd6 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -1002,10 +1002,8 @@ void x86_load_linux(X86MachineState *x86ms, } option_rom[nb_option_roms].bootindex = 0; - option_rom[nb_option_roms].name = "linuxboot.bin"; - if (fw_cfg_dma_enabled(fw_cfg)) { - option_rom[nb_option_roms].name = "linuxboot_dma.bin"; - } + assert(fw_cfg_dma_enabled(fw_cfg)); + option_rom[nb_option_roms].name = "linuxboot_dma.bin"; nb_option_roms++; } -- 2.34.1