Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8BCB2820CD for ; Thu, 8 May 2025 15:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746716755; cv=none; b=cYkrFQYMSWhCeYcAb05nVcLYZDstz/MmY+XpRRVe6BnxrfxWbqJTeDEs0in3Fm6//jzbZcBBeSBEMYrgYAVoFraeNeHdEeWE4yJtwjuDT5u2i4+qauVkwlIvTORqZtqypeJ1mU8/XL8Jma8rMd6k48Kt6PJtGgILUSBYitMfd4k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746716755; c=relaxed/simple; bh=XOi7fATzB9FEw16qYRY7/+7a4/QX+FWXQsT471Ty9b0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LIhUbQQfr40QKLvcobfOZq4RRmJjp8CV2pWkvNg5S6XP8K0WoBfQXC60iWJY7aavJuEacxiHMYzo2zGSAjNwm8Zq2hFf6vYqPZibLAbSKI/jU47oFOw05faYLFVQsiMJYp2z+hJ1ItjoMXzbLv1ct3xdlR4SYKAVRDMfrLtHUtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QJ3bGGHC; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QJ3bGGHC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746716754; x=1778252754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XOi7fATzB9FEw16qYRY7/+7a4/QX+FWXQsT471Ty9b0=; b=QJ3bGGHCK/JqMq9obDRvm9P0G1r5CqGwos932EbENzNtAZBVdB8x8yw0 vKJaNG23dQxIbfdYOvHmtRh2klMzNGgeoy/WJECOqPa73bV0KfxTIGwD3 nBCkjR3f5rlyaQbJm4A+feSi7lGS/ve1a46VfDudc5DqFmLWN/DFteP5/ klEHJucfDtRo55fGDMUAZHGp1i1Yv99f+ASci4grsENSTWzMexEFuX0VU z7ed1V4bqecQoLIni2rhexMZA6YhKJn8D0YwXOBO6c2gzVwqaG8HfvUF1 S6BmtkOKKHo63+jG4U1Z192quucz40xuaJ6++ECg+D4kw23QQiRN0iMuW w==; X-CSE-ConnectionGUID: PkETycFoQwCi7yAuQczg3A== X-CSE-MsgGUID: hycLDI93TIiv6/ceqOmtog== X-IronPort-AV: E=McAfee;i="6700,10204,11427"; a="73888154" X-IronPort-AV: E=Sophos;i="6.15,272,1739865600"; d="scan'208";a="73888154" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2025 08:05:53 -0700 X-CSE-ConnectionGUID: FaHaoShITfmzR1ANeGiZew== X-CSE-MsgGUID: pjnWlw/uTW6shCrP/HPZRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,272,1739865600"; d="scan'208";a="141439941" Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by orviesa005.jf.intel.com with ESMTP; 08 May 2025 08:05:50 -0700 From: Xiaoyao Li To: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Cc: "Michael S. Tsirkin" , Markus Armbruster , Francesco Lavra , Marcelo Tosatti , kvm@vger.kernel.org, qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Rick Edgecombe , Xiaoyao Li Subject: [PATCH v9 19/55] i386/tdx: Don't initialize pc.rom for TDX VMs Date: Thu, 8 May 2025 10:59:25 -0400 Message-ID: <20250508150002.689633-20-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250508150002.689633-1-xiaoyao.li@intel.com> References: <20250508150002.689633-1-xiaoyao.li@intel.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit For TDX, the address below 1MB are entirely general RAM. No need to initialize pc.rom memory region for TDs. Signed-off-by: Xiaoyao Li Reviewed-by: Zhao Liu --- This is more as a workaround of the issue that for q35 machine type, the real memslot update (which requires memslot deletion )for pc.rom happens after tdx_init_memory_region. It leads to the private memory ADD'ed before get lost. I haven't work out a good solution to resolve the order issue. So just skip the pc.rom setup to avoid memslot deletion. --- hw/i386/pc.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 01d0581f62a3..bcbbea235645 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -43,6 +43,7 @@ #include "system/xen.h" #include "system/reset.h" #include "kvm/kvm_i386.h" +#include "kvm/tdx.h" #include "hw/xen/xen.h" #include "qobject/qlist.h" #include "qemu/error-report.h" @@ -972,21 +973,23 @@ void pc_memory_init(PCMachineState *pcms, /* Initialize PC system firmware */ pc_system_firmware_init(pcms, rom_memory); - option_rom_mr = g_malloc(sizeof(*option_rom_mr)); - if (machine_require_guest_memfd(machine)) { - memory_region_init_ram_guest_memfd(option_rom_mr, NULL, "pc.rom", - PC_ROM_SIZE, &error_fatal); - } else { - memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, - &error_fatal); - if (pcmc->pci_enabled) { - memory_region_set_readonly(option_rom_mr, true); + if (!is_tdx_vm()) { + option_rom_mr = g_malloc(sizeof(*option_rom_mr)); + if (machine_require_guest_memfd(machine)) { + memory_region_init_ram_guest_memfd(option_rom_mr, NULL, "pc.rom", + PC_ROM_SIZE, &error_fatal); + } else { + memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, + &error_fatal); + if (pcmc->pci_enabled) { + memory_region_set_readonly(option_rom_mr, true); + } } + memory_region_add_subregion_overlap(rom_memory, + PC_ROM_MIN_VGA, + option_rom_mr, + 1); } - memory_region_add_subregion_overlap(rom_memory, - PC_ROM_MIN_VGA, - option_rom_mr, - 1); fw_cfg = fw_cfg_arch_create(machine, x86ms->boot_cpus, x86ms->apic_id_limit); -- 2.43.0